<!-- downloaded from http://www.whatwg.org/specs/web-apps/current-work/ on 2011-11-07 00:21:23 +0100 --> <!DOCTYPE html><html lang=en-US-x-hixie><title>HTML Standard</title><script> var loadTimer = new Date(); var current_revision = "r" + "$Revision: 6818 $".substr(11); current_revision = current_revision.substr(0, current_revision.length - 2); var last_known_revision = current_revision; function getCookie(name) { var params = location.search.substr(1).split("&"); for (var index = 0; index < params.length; index++) { if (params[index] == name) return "1"; var data = params[index].split("="); if (data[0] == name) return unescape(data[1]); } var cookies = document.cookie.split("; "); for (var index = 0; index < cookies.length; index++) { var data = cookies[index].split("="); if (data[0] == name) return unescape(data[1]); } return null; } var currentAlert; var currentAlertTimeout; function showAlert(s, href) { if (!currentAlert) { currentAlert = document.createElement('div'); currentAlert.id = 'alert'; var x = document.createElement('button'); x.textContent = '\u2573'; x.onclick = closeAlert2; currentAlert.appendChild(x); currentAlert.appendChild(document.createElement('span')); currentAlert.onmousemove = function () { clearTimeout(currentAlertTimeout); currentAlert.className = ''; currentAlertTimeout = setTimeout(closeAlert, 10000); } document.body.appendChild(currentAlert); } else { clearTimeout(currentAlertTimeout); currentAlert.className = ''; } currentAlert.lastChild.textContent = s + ' '; if (href) { var link = document.createElement('a'); link.href = href; link.textContent = href; currentAlert.lastChild.appendChild(link); } currentAlertTimeout = setTimeout(closeAlert, 10000); } function closeAlert() { clearTimeout(currentAlertTimeout); if (currentAlert) { currentAlert.className = 'closed'; currentAlertTimeout = setTimeout(closeAlert2, 3000); } } function closeAlert2() { clearTimeout(currentAlertTimeout); if (currentAlert) { currentAlert.parentNode.removeChild(currentAlert); currentAlert = null; } } window.addEventListener('keydown', function (event) { if (event.keyCode == 27) { if (currentAlert) closeAlert2(); } else { closeAlert(); } }, false); window.addEventListener('scroll', function (event) { closeAlert(); }, false); function load(script) { var e = document.createElement('script'); e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer)); document.body.appendChild(e); } </script><link href=/style/specification rel=stylesheet><link href=/images/icon rel=icon><style> .proposal { border: blue solid; padding: 1em; } .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; } #updatesStatus { display: none; } #updatesStatus.relevant { display: block; position: fixed; right: 1em; top: 1em; padding: 0.5em; font: bold small sans-serif; min-width: 25em; width: 30%; max-width: 40em; height: auto; border: ridge 4px gray; background: #EEEEEE; color: black; } div.head .logo { width: 11em; margin-bottom: 20em; } #configUI { position: absolute; z-index: 20; top: 10em; right: 0; width: 11em; padding: 0 0.5em 0 0.5em; font-size: small; background: gray; background: rgba(32,32,32,0.9); color: white; border-radius: 1em 0 0 1em; -moz-border-radius: 1em 0 0 1em; } #configUI p { margin: 0.75em 0; padding: 0.3em; } #configUI p label { display: block; } #configUI #updateUI, #configUI .loginUI { text-align: center; } #configUI input[type=button] { display: block; margin: auto; } #configUI :link, #configUI :visited { color: white; } #configUI :link:hover, #configUI :visited:hover { background: transparent; } #reviewer { position: fixed; bottom: 0; right: 0; padding: 0.15em 0.25em 0em 0.5em; white-space: nowrap; overflow: hidden; z-index: 30; background: gray; background: rgba(32,32,32,0.9); color: white; border-radius: 1em 0 0 0; -moz-border-radius: 1em 0 0 0; max-width: 90%; } #reviewer input { max-width: 50%; } #reviewer * { font-size: small; } #reviewer.off > :not(:first-child) { display: none; } #alert { position: fixed; top: 20%; left: 20%; right: 20%; font-size: 2em; padding: 0.5em; z-index: 40; background: gray; background: rgba(32,32,32,0.9); color: white; border-radius: 1em; -moz-border-radius: 1em; -webkit-transition: opacity 1s linear; } #alert.closed { opacity: 0; } #alert button { position: absolute; top: -1em; right: 2em; border-radius: 1em 1em 0 0; border: none; line-height: 0.9; color: white; background: rgb(64,64,64); font-size: 0.6em; font-weight: 900; cursor: pointer; } #alert :link, #alert :visited { color: white; } #alert :link:hover, #alert :visited:hover { background: transparent; } @media print { #configUI { display: none; } } .rfc2119 { font-variant: small-caps; text-shadow: 0 0 0.5em yellow; position: static; } .rfc2119::after { position: absolute; left: 0; width: 25px; text-align: center; color: yellow; text-shadow: 0.075em 0.075em 0.2em black; } .rfc2119.m\ust::after { content: '\2605'; } .rfc2119.s\hould::after { content: '\2606'; } [hidden] { display: none; } </style><style type=text/css> .applies thead th > * { display: block; } .applies thead code { display: block; } .applies tbody th { whitespace: nowrap; } .applies td { text-align: center; } .applies .yes { background: yellow; } .matrix, .matrix td { border: hidden; text-align: right; } .matrix { margin-left: 2em; } .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 * { font-family: "Essays1743", serif; line-height: 1.01em; } #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; } .details-example img { vertical-align: top; } #base64-table { white-space: nowrap; font-size: 0.6em; column-width: 6em; column-count: 5; column-gap: 1em; -moz-column-width: 6em; -moz-column-count: 5; -moz-column-gap: 1em; -webkit-column-width: 6em; -webkit-column-count: 5; -webkit-column-gap: 1em; } #base64-table thead { display: none; } #base64-table * { border: none; } #base64-table tbody td:first-child:after { content: ':'; } #base64-table tbody td:last-child { text-align: right; } #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; } @font-face { font-family: 'Essays1743'; src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf'); } @font-face { font-family: 'Essays1743'; font-weight: bold; src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf'); } @font-face { font-family: 'Essays1743'; font-style: italic; src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf'); } @font-face { font-family: 'Essays1743'; font-style: italic; font-weight: bold; src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf'); } </style><link href=status.css rel=stylesheet><script> var startedInit = 0; function init() { startedInit = 1; if (location.search == '?slow-browser') return; var configUI = document.createElement('div'); configUI.id = 'configUI'; document.body.appendChild(configUI); load('reviewer.js'); if (document.documentElement.className == "" || document.documentElement.className == "split index") load('toc.js'); load('updater.js'); load('dfn.js'); load('status.js'); if (getCookie('profile') == '1') document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms'; } if (document.documentElement.className == "") setTimeout(function () { if (!startedInit) showAlert("Too slow? Try reading the multipage copy of the spec instead:", "http://whatwg.org/html"); }, 6000); </script><body onload=init()> <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p> <hgroup><h1 class=allcaps>HTML</h1> <h2 class="no-num no-toc">Living Standard — Last Updated 4 November 2011</h2> </hgroup><dl><dt><strong>Web developer edition:</strong></dt> <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd> <dt>Multiple-page version:</dt> <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/>http://whatwg.org/html</a></dd> <dt>One-page version:</dt> <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/>http://whatwg.org/c</a></dd> <dt>Participate:</dt> <dd><a href=http://www.whatwg.org/mailing-list>whatwg@whatwg.org</a></dd> <dd><a href=http://forums.whatwg.org/>http://forums.whatwg.org/</a></dd> <dd><a href=http://wiki.whatwg.org/wiki/IRC>IRC: #whatwg on Freenode</a></dd> <dt>FAQ:</dt> <dd><a href=http://wiki.whatwg.org/wiki/FAQ>http://wiki.whatwg.org/wiki/FAQ</a></dd> <dt>Version history:</dt> <dd>Twitter updates: <a href=http://twitter.com/WHATWG>http://twitter.com/WHATWG</a></dd> <dd>Commit-Watchers mailing list: <a href=http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org>http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a></dd> <dd>Interactive Web interface: <a href=http://html5.org/tools/web-apps-tracker>http://html5.org/tools/web-apps-tracker</a></dd> <dd>Subversion interface: <a href=http://svn.whatwg.org/>http://svn.whatwg.org/</a></dd> <dt>Issues:</dt> <dd>To view the open bugs: <a href="http://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=ian%40hixie.ch&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">HTML bug list</a></dd> <dd>To file bugs, use the "submit review comments" feature at the bottom of the window</dd> <dd>To send feedback by e-mail: <a href=http://www.whatwg.org/mailing-list>whatwg@whatwg.org</a></dd> <dd>To view and vote on e-mail feedback: <a href=http://www.whatwg.org/issues/>http://www.whatwg.org/issues/</a></dd> <dt>Editor:</dt> <dd>Ian Hickson, Google, ian@hixie.ch</dd> </dl><p class=copyright>© Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA.</p> <p class=copyright>You are granted a license to use, reproduce and create derivative works of this document.</p> </header><hr><h2 class="no-num no-toc" id=contents>Table of contents</h2> <!--begin-toc--> <ol class=toc> <li><a href=#introduction><span class=secno>1 </span>Introduction</a> <ol> <li><a href=#abstract><span class=secno>1.1 </span>Where does this specification fit?</a></li> <li><a href=#is-this-html5?><span class=secno>1.2 </span>Is this HTML5?</a></li> <li><a href=#background><span class=secno>1.3 </span>Background</a></li> <li><a href=#audience><span class=secno>1.4 </span>Audience</a></li> <li><a href=#scope><span class=secno>1.5 </span>Scope</a></li> <li><a href=#history-1><span class=secno>1.6 </span>History</a></li> <li><a href=#design-notes><span class=secno>1.7 </span>Design notes</a> <ol> <li><a href=#serializability-of-script-execution><span class=secno>1.7.1 </span>Serializability of script execution</a></li> <li><a href=#compliance-with-other-specifications><span class=secno>1.7.2 </span>Compliance with other specifications</a></ol></li> <li><a href=#html-vs-xhtml><span class=secno>1.8 </span>HTML vs XHTML</a></li> <li><a href=#structure-of-this-specification><span class=secno>1.9 </span>Structure of this specification</a> <ol> <li><a href=#how-to-read-this-specification><span class=secno>1.9.1 </span>How to read this specification</a></li> <li><a href=#typographic-conventions><span class=secno>1.9.2 </span>Typographic conventions</a></ol></li> <li><a href=#a-quick-introduction-to-html><span class=secno>1.10 </span>A quick introduction to HTML</a> <ol> <li><a href=#writing-secure-applications-with-html><span class=secno>1.10.1 </span>Writing secure applications with HTML</a></li> <li><a href=#common-pitfalls-to-avoid-when-using-the-scripting-apis><span class=secno>1.10.2 </span>Common pitfalls to avoid when using the scripting APIs</a></ol></li> <li><a href=#conformance-requirements-for-authors><span class=secno>1.11 </span>Conformance requirements for authors</a> <ol> <li><a href=#presentational-markup><span class=secno>1.11.1 </span>Presentational markup</a></li> <li><a href=#syntax-errors><span class=secno>1.11.2 </span>Syntax errors</a></li> <li><a href=#restrictions-on-content-models-and-on-attribute-values><span class=secno>1.11.3 </span>Restrictions on content models and on attribute values</a></ol></li> <li><a href=#recommended-reading><span class=secno>1.12 </span>Recommended reading</a></ol></li> <li><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=#resources><span class=secno>2.1.1 </span>Resources</a></li> <li><a href=#xml><span class=secno>2.1.2 </span>XML</a></li> <li><a href=#dom-trees><span class=secno>2.1.3 </span>DOM trees</a></li> <li><a href=#scripting-0><span class=secno>2.1.4 </span>Scripting</a></li> <li><a href=#plugins><span class=secno>2.1.5 </span>Plugins</a></li> <li><a href=#character-encodings><span class=secno>2.1.6 </span>Character encodings</a></ol></li> <li><a href=#conformance-requirements><span class=secno>2.2 </span>Conformance requirements</a> <ol> <li><a href=#conformance-classes><span class=secno>2.2.1 </span>Conformance classes</a></li> <li><a href=#dependencies><span class=secno>2.2.2 </span>Dependencies</a></li> <li><a href=#extensibility><span class=secno>2.2.3 </span>Extensibility</a></ol></li> <li><a href=#case-sensitivity-and-string-comparison><span class=secno>2.3 </span>Case-sensitivity and string comparison</a></li> <li><a href=#utf-8><span class=secno>2.4 </span>UTF-8</a></li> <li><a href=#common-microsyntaxes><span class=secno>2.5 </span>Common microsyntaxes</a> <ol> <li><a href=#common-parser-idioms><span class=secno>2.5.1 </span>Common parser idioms</a></li> <li><a href=#boolean-attributes><span class=secno>2.5.2 </span>Boolean attributes</a></li> <li><a href=#keywords-and-enumerated-attributes><span class=secno>2.5.3 </span>Keywords and enumerated attributes</a></li> <li><a href=#numbers><span class=secno>2.5.4 </span>Numbers</a> <ol> <li><a href=#signed-integers><span class=secno>2.5.4.1 </span>Signed integers</a></li> <li><a href=#non-negative-integers><span class=secno>2.5.4.2 </span>Non-negative integers</a></li> <li><a href=#floating-point-numbers><span class=secno>2.5.4.3 </span>Floating-point numbers</a></li> <li><a href=#percentages-and-dimensions><span class=secno>2.5.4.4 </span>Percentages and lengths</a></li> <li><a href=#lists-of-integers><span class=secno>2.5.4.5 </span>Lists of integers</a></li> <li><a href=#lists-of-dimensions><span class=secno>2.5.4.6 </span>Lists of dimensions</a></ol></li> <li><a href=#dates-and-times><span class=secno>2.5.5 </span>Dates and times</a> <ol> <li><a href=#months><span class=secno>2.5.5.1 </span>Months</a></li> <li><a href=#dates><span class=secno>2.5.5.2 </span>Dates</a></li> <li><a href=#times><span class=secno>2.5.5.3 </span>Times</a></li> <li><a href=#local-dates-and-times><span class=secno>2.5.5.4 </span>Local dates and times</a></li> <li><a href=#global-dates-and-times><span class=secno>2.5.5.5 </span>Global dates and times</a></li> <li><a href=#weeks><span class=secno>2.5.5.6 </span>Weeks</a></li> <li><a href=#vaguer-moments-in-time><span class=secno>2.5.5.7 </span>Vaguer moments in time</a></ol></li> <li><a href=#colors><span class=secno>2.5.6 </span>Colors</a></li> <li><a href=#space-separated-tokens><span class=secno>2.5.7 </span>Space-separated tokens</a></li> <li><a href=#comma-separated-tokens><span class=secno>2.5.8 </span>Comma-separated tokens</a></li> <li><a href=#syntax-references><span class=secno>2.5.9 </span>References</a></li> <li><a href=#mq><span class=secno>2.5.10 </span>Media queries</a></ol></li> <li><a href=#urls><span class=secno>2.6 </span>URLs</a> <ol> <li><a href=#terminology-0><span class=secno>2.6.1 </span>Terminology</a></li> <li><a href=#parsing-urls><span class=secno>2.6.2 </span>Parsing URLs</a></li> <li><a href=#resolving-urls><span class=secno>2.6.3 </span>Resolving URLs</a></li> <li><a href=#url-manipulation-and-creation><span class=secno>2.6.4 </span>URL manipulation and creation</a></li> <li><a href=#dynamic-changes-to-base-urls><span class=secno>2.6.5 </span>Dynamic changes to base URLs</a></li> <li><a href=#interfaces-for-url-manipulation><span class=secno>2.6.6 </span>Interfaces for URL manipulation</a></ol></li> <li><a href=#fetching-resources><span class=secno>2.7 </span>Fetching resources</a> <ol> <li><a href=#concept-http-equivalent><span class=secno>2.7.1 </span>Protocol concepts</a></li> <li><a href=#encrypted-http-and-related-security-concerns><span class=secno>2.7.2 </span>Encrypted HTTP and related security concerns</a></li> <li><a href=#content-type-sniffing><span class=secno>2.7.3 </span>Determining the type of a resource</a></li> <li><a href=#extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code>meta</code> elements</a></li> <li><a href=#cors-settings-attributes><span class=secno>2.7.5 </span>CORS settings attributes</a></li> <li><a href=#cors-enabled-fetch><span class=secno>2.7.6 </span>CORS-enabled fetch</a></ol></li> <li><a href=#common-dom-interfaces><span class=secno>2.8 </span>Common DOM interfaces</a> <ol> <li><a href=#reflecting-content-attributes-in-idl-attributes><span class=secno>2.8.1 </span>Reflecting content attributes in IDL attributes</a></li> <li><a href=#collections-0><span class=secno>2.8.2 </span>Collections</a> <ol> <li><a href=#htmlallcollection-0><span class=secno>2.8.2.1 </span>HTMLAllCollection</a></li> <li><a href=#htmlformcontrolscollection-0><span class=secno>2.8.2.2 </span>HTMLFormControlsCollection</a></li> <li><a href=#htmloptionscollection-0><span class=secno>2.8.2.3 </span>HTMLOptionsCollection</a></li> <li><a href=#htmlpropertiescollection-0><span class=secno>2.8.2.4 </span>HTMLPropertiesCollection</a></ol></li> <li><a href=#domstringmap-0><span class=secno>2.8.3 </span>DOMStringMap</a></li> <li><a href=#domelementmap-0><span class=secno>2.8.4 </span>DOMElementMap</a></li> <li><a href=#transferable-objects><span class=secno>2.8.5 </span>Transferable objects</a></li> <li><a href=#safe-passing-of-structured-data><span class=secno>2.8.6 </span>Safe passing of structured data</a></li> <li><a href=#dom-feature-strings><span class=secno>2.8.7 </span>DOM feature strings</a></li> <li><a href=#garbage-collection><span class=secno>2.8.8 </span>Garbage collection</a></ol></li> <li><a href=#namespaces><span class=secno>2.9 </span>Namespaces</a></ol></li> <li><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=#documents-in-the-dom><span class=secno>3.1.1 </span>Documents in the DOM</a></li> <li><a href=#security-document><span class=secno>3.1.2 </span>Security</a></li> <li><a href=#resource-metadata-management><span class=secno>3.1.3 </span>Resource metadata management</a></li> <li><a href=#dom-tree-accessors><span class=secno>3.1.4 </span>DOM tree accessors</a></li> <li><a href=#loading-xml-documents><span class=secno>3.1.5 </span>Loading XML documents</a></ol></li> <li><a href=#elements><span class=secno>3.2 </span>Elements</a> <ol> <li><a href=#semantics-0><span class=secno>3.2.1 </span>Semantics</a></li> <li><a href=#elements-in-the-dom><span class=secno>3.2.2 </span>Elements in the DOM</a></li> <li><a href=#global-attributes><span class=secno>3.2.3 </span>Global attributes</a> <ol> <li><a href=#the-id-attribute><span class=secno>3.2.3.1 </span>The <code>id</code> attribute</a></li> <li><a href=#the-title-attribute><span class=secno>3.2.3.2 </span>The <code>title</code> attribute</a></li> <li><a href=#the-lang-and-xml:lang-attributes><span class=secno>3.2.3.3 </span>The <code title=attr-lang>lang</code> and <code title=attr-xml-lang>xml:lang</code> attributes</a></li> <li><a href=#the-xml:base-attribute-(xml-only)><span class=secno>3.2.3.4 </span>The <code>xml:base</code> attribute (XML only)</a></li> <li><a href=#the-dir-attribute><span class=secno>3.2.3.5 </span>The <code>dir</code> attribute</a></li> <li><a href=#classes><span class=secno>3.2.3.6 </span>The <code>class</code> attribute</a></li> <li><a href=#the-style-attribute><span class=secno>3.2.3.7 </span>The <code>style</code> attribute</a></li> <li><a href=#embedding-custom-non-visible-data-with-the-data-*-attributes><span class=secno>3.2.3.8 </span>Embedding custom non-visible data with the <code title=attr-data-*>data-*</code> attributes</a></ol></li> <li><a href=#element-definitions><span class=secno>3.2.4 </span>Element definitions</a> <ol> <li><a href=#attributes><span class=secno>3.2.4.1 </span>Attributes</a></ol></li> <li><a href=#content-models><span class=secno>3.2.5 </span>Content models</a> <ol> <li><a href=#kinds-of-content><span class=secno>3.2.5.1 </span>Kinds of content</a> <ol> <li><a href=#metadata-content-0><span class=secno>3.2.5.1.1 </span>Metadata content</a></li> <li><a href=#flow-content-0><span class=secno>3.2.5.1.2 </span>Flow content</a></li> <li><a href=#sectioning-content-0><span class=secno>3.2.5.1.3 </span>Sectioning content</a></li> <li><a href=#heading-content-0><span class=secno>3.2.5.1.4 </span>Heading content</a></li> <li><a href=#phrasing-content-0><span class=secno>3.2.5.1.5 </span>Phrasing content</a></li> <li><a href=#embedded-content-0><span class=secno>3.2.5.1.6 </span>Embedded content</a></li> <li><a href=#interactive-content-0><span class=secno>3.2.5.1.7 </span>Interactive content</a></li> <li><a href=#palpable-content-0><span class=secno>3.2.5.1.8 </span>Palpable content</a></ol></li> <li><a href=#transparent-content-models><span class=secno>3.2.5.2 </span>Transparent content models</a></li> <li><a href=#paragraphs><span class=secno>3.2.5.3 </span>Paragraphs</a></ol></li> <li><a href=#requirements-relating-to-bidirectional-algorithm-formatting-characters><span class=secno>3.2.6 </span>Requirements relating to bidirectional-algorithm formatting characters</a></li> <li><a href=#wai-aria><span class=secno>3.2.7 </span>WAI-ARIA</a></ol></li> <li><a href=#interactions-with-xpath-and-xslt><span class=secno>3.3 </span>Interactions with XPath and XSLT</a></li> <li><a href=#dynamic-markup-insertion><span class=secno>3.4 </span>Dynamic markup insertion</a> <ol> <li><a href=#opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input stream</a></li> <li><a href=#closing-the-input-stream><span class=secno>3.4.2 </span>Closing the input stream</a></li> <li><a href=#document.write()><span class=secno>3.4.3 </span><code title=dom-document-write>document.write()</code></a></li> <li><a href=#document.writeln()><span class=secno>3.4.4 </span><code title=dom-document-writeln>document.writeln()</code></a></ol></ol></li> <li><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 root element</a> <ol> <li><a href=#the-html-element><span class=secno>4.1.1 </span>The <code>html</code> element</a></ol></li> <li><a href=#document-metadata><span class=secno>4.2 </span>Document metadata</a> <ol> <li><a href=#the-head-element><span class=secno>4.2.1 </span>The <code>head</code> element</a></li> <li><a href=#the-title-element><span class=secno>4.2.2 </span>The <code>title</code> element</a></li> <li><a href=#the-base-element><span class=secno>4.2.3 </span>The <code>base</code> element</a></li> <li><a href=#the-link-element><span class=secno>4.2.4 </span>The <code>link</code> element</a></li> <li><a href=#the-meta-element><span class=secno>4.2.5 </span>The <code>meta</code> element</a> <ol> <li><a href=#standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</a></li> <li><a href=#other-metadata-names><span class=secno>4.2.5.2 </span>Other metadata names</a></li> <li><a href=#pragma-directives><span class=secno>4.2.5.3 </span>Pragma directives</a></li> <li><a href=#other-pragma-directives><span class=secno>4.2.5.4 </span>Other pragma directives</a></li> <li><a href=#charset><span class=secno>4.2.5.5 </span>Specifying the document's character encoding</a></ol></li> <li><a href=#the-style-element><span class=secno>4.2.6 </span>The <code>style</code> element</a></li> <li><a href=#styling><span class=secno>4.2.7 </span>Styling</a></ol></li> <li><a href=#scripting-1><span class=secno>4.3 </span>Scripting</a> <ol> <li><a href=#the-script-element><span class=secno>4.3.1 </span>The <code>script</code> element</a> <ol> <li><a href=#scriptingLanguages><span class=secno>4.3.1.1 </span>Scripting languages</a></li> <li><a href=#restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span>Restrictions for contents of <code>script</code> elements</a></li> <li><a href=#inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span>Inline documentation for external scripts</a></li> <li><a href=#scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code>script</code> elements and XSLT</a></ol></li> <li><a href=#the-noscript-element><span class=secno>4.3.2 </span>The <code>noscript</code> element</a></ol></li> <li><a href=#sections><span class=secno>4.4 </span>Sections</a> <ol> <li><a href=#the-body-element><span class=secno>4.4.1 </span>The <code>body</code> element</a></li> <li><a href=#the-section-element><span class=secno>4.4.2 </span>The <code>section</code> element</a></li> <li><a href=#the-nav-element><span class=secno>4.4.3 </span>The <code>nav</code> element</a></li> <li><a href=#the-article-element><span class=secno>4.4.4 </span>The <code>article</code> element</a></li> <li><a href=#the-aside-element><span class=secno>4.4.5 </span>The <code>aside</code> element</a></li> <li><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.6 </span>The <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code> elements</a></li> <li><a href=#the-hgroup-element><span class=secno>4.4.7 </span>The <code>hgroup</code> element</a></li> <li><a href=#the-header-element><span class=secno>4.4.8 </span>The <code>header</code> element</a></li> <li><a href=#the-footer-element><span class=secno>4.4.9 </span>The <code>footer</code> element</a></li> <li><a href=#the-address-element><span class=secno>4.4.10 </span>The <code>address</code> element</a></li> <li><a href=#headings-and-sections><span class=secno>4.4.11 </span>Headings and sections</a> <ol> <li><a href=#outlines><span class=secno>4.4.11.1 </span>Creating an outline</a></ol></ol></li> <li><a href=#grouping-content><span class=secno>4.5 </span>Grouping content</a> <ol> <li><a href=#the-p-element><span class=secno>4.5.1 </span>The <code>p</code> element</a></li> <li><a href=#the-hr-element><span class=secno>4.5.2 </span>The <code>hr</code> element</a></li> <li><a href=#the-pre-element><span class=secno>4.5.3 </span>The <code>pre</code> element</a></li> <li><a href=#the-blockquote-element><span class=secno>4.5.4 </span>The <code>blockquote</code> element</a></li> <li><a href=#the-ol-element><span class=secno>4.5.5 </span>The <code>ol</code> element</a></li> <li><a href=#the-ul-element><span class=secno>4.5.6 </span>The <code>ul</code> element</a></li> <li><a href=#the-li-element><span class=secno>4.5.7 </span>The <code>li</code> element</a></li> <li><a href=#the-dl-element><span class=secno>4.5.8 </span>The <code>dl</code> element</a></li> <li><a href=#the-dt-element><span class=secno>4.5.9 </span>The <code>dt</code> element</a></li> <li><a href=#the-dd-element><span class=secno>4.5.10 </span>The <code>dd</code> element</a></li> <li><a href=#the-figure-element><span class=secno>4.5.11 </span>The <code>figure</code> element</a></li> <li><a href=#the-figcaption-element><span class=secno>4.5.12 </span>The <code>figcaption</code> element</a></li> <li><a href=#the-div-element><span class=secno>4.5.13 </span>The <code>div</code> element</a></ol></li> <li><a href=#text-level-semantics><span class=secno>4.6 </span>Text-level semantics</a> <ol> <li><a href=#the-a-element><span class=secno>4.6.1 </span>The <code>a</code> element</a></li> <li><a href=#the-em-element><span class=secno>4.6.2 </span>The <code>em</code> element</a></li> <li><a href=#the-strong-element><span class=secno>4.6.3 </span>The <code>strong</code> element</a></li> <li><a href=#the-small-element><span class=secno>4.6.4 </span>The <code>small</code> element</a></li> <li><a href=#the-s-element><span class=secno>4.6.5 </span>The <code>s</code> element</a></li> <li><a href=#the-cite-element><span class=secno>4.6.6 </span>The <code>cite</code> element</a></li> <li><a href=#the-q-element><span class=secno>4.6.7 </span>The <code>q</code> element</a></li> <li><a href=#the-dfn-element><span class=secno>4.6.8 </span>The <code>dfn</code> element</a></li> <li><a href=#the-abbr-element><span class=secno>4.6.9 </span>The <code>abbr</code> element</a></li> <li><a href=#the-data-element><span class=secno>4.6.10 </span>The <code>data</code> element</a></li> <li><a href=#the-code-element><span class=secno>4.6.11 </span>The <code>code</code> element</a></li> <li><a href=#the-var-element><span class=secno>4.6.12 </span>The <code>var</code> element</a></li> <li><a href=#the-samp-element><span class=secno>4.6.13 </span>The <code>samp</code> element</a></li> <li><a href=#the-kbd-element><span class=secno>4.6.14 </span>The <code>kbd</code> element</a></li> <li><a href=#the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <code>sub</code> and <code>sup</code> elements</a></li> <li><a href=#the-i-element><span class=secno>4.6.16 </span>The <code>i</code> element</a></li> <li><a href=#the-b-element><span class=secno>4.6.17 </span>The <code>b</code> element</a></li> <li><a href=#the-u-element><span class=secno>4.6.18 </span>The <code>u</code> element</a></li> <li><a href=#the-mark-element><span class=secno>4.6.19 </span>The <code>mark</code> element</a></li> <li><a href=#the-ruby-element><span class=secno>4.6.20 </span>The <code>ruby</code> element</a></li> <li><a href=#the-rt-element><span class=secno>4.6.21 </span>The <code>rt</code> element</a></li> <li><a href=#the-rp-element><span class=secno>4.6.22 </span>The <code>rp</code> element</a></li> <li><a href=#the-bdi-element><span class=secno>4.6.23 </span>The <code>bdi</code> element</a></li> <li><a href=#the-bdo-element><span class=secno>4.6.24 </span>The <code>bdo</code> element</a></li> <li><a href=#the-span-element><span class=secno>4.6.25 </span>The <code>span</code> element</a></li> <li><a href=#the-br-element><span class=secno>4.6.26 </span>The <code>br</code> element</a></li> <li><a href=#the-wbr-element><span class=secno>4.6.27 </span>The <code>wbr</code> element</a></li> <li><a href=#usage-summary><span class=secno>4.6.28 </span>Usage summary</a></ol></li> <li><a href=#edits><span class=secno>4.7 </span>Edits</a> <ol> <li><a href=#the-ins-element><span class=secno>4.7.1 </span>The <code>ins</code> element</a></li> <li><a href=#the-del-element><span class=secno>4.7.2 </span>The <code>del</code> element</a></li> <li><a href=#attributes-common-to-ins-and-del-elements><span class=secno>4.7.3 </span>Attributes common to <code>ins</code> and <code>del</code> elements</a></li> <li><a href=#edits-and-paragraphs><span class=secno>4.7.4 </span>Edits and paragraphs</a></li> <li><a href=#edits-and-lists><span class=secno>4.7.5 </span>Edits and lists</a></li> <li><a href=#edits-and-tables><span class=secno>4.7.6 </span>Edits and tables</a></ol></li> <li><a href=#embedded-content-1><span class=secno>4.8 </span>Embedded content</a> <ol> <li><a href=#the-img-element><span class=secno>4.8.1 </span>The <code>img</code> element</a> <ol> <li><a href=#alt><span class=secno>4.8.1.1 </span>Requirements for providing text to act as an alternative for images</a> <ol> <li><a href=#general-guidelines><span class=secno>4.8.1.1.1 </span>General guidelines</a></li> <li><a href=#a-link-or-button-containing-nothing-but-the-image><span class=secno>4.8.1.1.2 </span>A link or button containing nothing but the image</a></li> <li><a href=#a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations><span class=secno>4.8.1.1.3 </span>A phrase or paragraph with an alternative graphical representation: charts, diagrams, graphs, maps, illustrations</a></li> <li><a href=#a-short-phrase-or-label-with-an-alternative-graphical-representation:-icons,-logos><span class=secno>4.8.1.1.4 </span>A short phrase or label with an alternative graphical representation: icons, logos</a></li> <li><a href=#text-that-has-been-rendered-to-a-graphic-for-typographical-effect><span class=secno>4.8.1.1.5 </span>Text that has been rendered to a graphic for typographical effect</a></li> <li><a href=#a-graphical-representation-of-some-of-the-surrounding-text><span class=secno>4.8.1.1.6 </span>A graphical representation of some of the surrounding text</a></li> <li><a href="#a-purely-decorative-image-that-doesn't-add-any-information"><span class=secno>4.8.1.1.7 </span>A purely decorative image that doesn't add any information</a></li> <li><a href=#a-group-of-images-that-form-a-single-larger-picture-with-no-links><span class=secno>4.8.1.1.8 </span>A group of images that form a single larger picture with no links</a></li> <li><a href=#a-group-of-images-that-form-a-single-larger-picture-with-links><span class=secno>4.8.1.1.9 </span>A group of images that form a single larger picture with links</a></li> <li><a href=#a-key-part-of-the-content><span class=secno>4.8.1.1.10 </span>A key part of the content</a></li> <li><a href=#an-image-not-intended-for-the-user><span class=secno>4.8.1.1.11 </span>An image not intended for the user</a></li> <li><a href=#an-image-in-an-e-mail-or-private-document-intended-for-a-specific-person-who-is-known-to-be-able-to-view-images><span class=secno>4.8.1.1.12 </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> <li><a href=#guidance-for-markup-generators><span class=secno>4.8.1.1.13 </span>Guidance for markup generators</a></li> <li><a href=#guidance-for-conformance-checkers><span class=secno>4.8.1.1.14 </span>Guidance for conformance checkers</a></ol></ol></li> <li><a href=#the-iframe-element><span class=secno>4.8.2 </span>The <code>iframe</code> element</a></li> <li><a href=#the-embed-element><span class=secno>4.8.3 </span>The <code>embed</code> element</a></li> <li><a href=#the-object-element><span class=secno>4.8.4 </span>The <code>object</code> element</a></li> <li><a href=#the-param-element><span class=secno>4.8.5 </span>The <code>param</code> element</a></li> <li><a href=#the-video-element><span class=secno>4.8.6 </span>The <code>video</code> element</a></li> <li><a href=#the-audio-element><span class=secno>4.8.7 </span>The <code>audio</code> element</a></li> <li><a href=#the-source-element><span class=secno>4.8.8 </span>The <code>source</code> element</a></li> <li><a href=#the-track-element><span class=secno>4.8.9 </span>The <code>track</code> element</a></li> <li><a href=#media-elements><span class=secno>4.8.10 </span>Media elements</a> <ol> <li><a href=#error-codes><span class=secno>4.8.10.1 </span>Error codes</a></li> <li><a href=#location-of-the-media-resource><span class=secno>4.8.10.2 </span>Location of the media resource</a></li> <li><a href=#mime-types><span class=secno>4.8.10.3 </span>MIME types</a></li> <li><a href=#network-states><span class=secno>4.8.10.4 </span>Network states</a></li> <li><a href=#loading-the-media-resource><span class=secno>4.8.10.5 </span>Loading the media resource</a></li> <li><a href=#offsets-into-the-media-resource><span class=secno>4.8.10.6 </span>Offsets into the media resource</a></li> <li><a href=#ready-states><span class=secno>4.8.10.7 </span>Ready states</a></li> <li><a href=#playing-the-media-resource><span class=secno>4.8.10.8 </span>Playing the media resource</a></li> <li><a href=#seeking><span class=secno>4.8.10.9 </span>Seeking</a></li> <li><a href=#media-resources-with-multiple-media-tracks><span class=secno>4.8.10.10 </span>Media resources with multiple media tracks</a> <ol> <li><a href=#audiotracklist-and-videotracklist-objects><span class=secno>4.8.10.10.1 </span><code>AudioTrackList</code> and <code>VideoTrackList</code> objects</a></li> <li><a href=#selecting-specific-audio-and-video-tracks-declaratively><span class=secno>4.8.10.10.2 </span>Selecting specific audio and video tracks declaratively</a></ol></li> <li><a href=#synchronising-multiple-media-elements><span class=secno>4.8.10.11 </span>Synchronising multiple media elements</a> <ol> <li><a href=#introduction-0><span class=secno>4.8.10.11.1 </span>Introduction</a></li> <li><a href=#media-controllers><span class=secno>4.8.10.11.2 </span>Media controllers</a></li> <li><a href=#assigning-a-media-controller-declaratively><span class=secno>4.8.10.11.3 </span>Assigning a media controller declaratively</a></ol></li> <li><a href=#timed-text-tracks><span class=secno>4.8.10.12 </span>Timed text tracks</a> <ol> <li><a href=#text-track-model><span class=secno>4.8.10.12.1 </span>Text track model</a></li> <li><a href=#sourcing-in-band-text-tracks><span class=secno>4.8.10.12.2 </span>Sourcing in-band text tracks</a></li> <li><a href=#sourcing-out-of-band-text-tracks><span class=secno>4.8.10.12.3 </span>Sourcing out-of-band text tracks</a></li> <li><a href=#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues><span class=secno>4.8.10.12.4 </span>Guidelines for exposing cues in various formats as text track cues</a></li> <li><a href=#text-track-api><span class=secno>4.8.10.12.5 </span>Text track API</a></li> <li><a href=#text-tracks-describing-chapters><span class=secno>4.8.10.12.6 </span>Text tracks describing chapters</a></li> <li><a href=#cue-events><span class=secno>4.8.10.12.7 </span>Event definitions</a></ol></li> <li><a href=#webvtt-0><span class=secno>4.8.10.13 </span>WebVTT</a> <ol> <li><a href=#introduction-1><span class=secno>4.8.10.13.1 </span>Introduction</a></li> <li><a href=#syntax-0><span class=secno>4.8.10.13.2 </span>Syntax</a></li> <li><a href=#parsing-0><span class=secno>4.8.10.13.3 </span>Parsing</a></li> <li><a href=#webvtt-cue-text-parsing-rules><span class=secno>4.8.10.13.4 </span>WebVTT cue text parsing rules</a></li> <li><a href=#webvtt-cue-text-dom-construction-rules><span class=secno>4.8.10.13.5 </span>WebVTT cue text DOM construction rules</a></ol></li> <li><a href=#user-interface><span class=secno>4.8.10.14 </span>User interface</a></li> <li><a href=#time-ranges><span class=secno>4.8.10.15 </span>Time ranges</a></li> <li><a href=#event-definitions><span class=secno>4.8.10.16 </span>Event definitions</a></li> <li><a href=#mediaevents><span class=secno>4.8.10.17 </span>Event summary</a></li> <li><a href=#security-and-privacy-considerations><span class=secno>4.8.10.18 </span>Security and privacy considerations</a></li> <li><a href=#best-practices-for-authors-using-media-elements><span class=secno>4.8.10.19 </span>Best practices for authors using media elements</a></li> <li><a href=#best-practices-for-implementors-of-media-elements><span class=secno>4.8.10.20 </span>Best practices for implementors of media elements</a></ol></li> <li><a href=#the-canvas-element><span class=secno>4.8.11 </span>The <code>canvas</code> element</a> <ol> <li><a href=#2dcontext><span class=secno>4.8.11.1 </span>The 2D context</a> <ol> <li><a href=#the-canvas-state><span class=secno>4.8.11.1.1 </span>The canvas state</a></li> <li><a href=#transformations><span class=secno>4.8.11.1.2 </span>Transformations</a></li> <li><a href=#compositing><span class=secno>4.8.11.1.3 </span>Compositing</a></li> <li><a href=#colors-and-styles><span class=secno>4.8.11.1.4 </span>Colors and styles</a></li> <li><a href=#line-styles><span class=secno>4.8.11.1.5 </span>Line styles</a></li> <li><a href=#shadows><span class=secno>4.8.11.1.6 </span>Shadows</a></li> <li><a href=#simple-shapes-(rectangles)><span class=secno>4.8.11.1.7 </span>Simple shapes (rectangles)</a></li> <li><a href=#complex-shapes-(paths)><span class=secno>4.8.11.1.8 </span>Complex shapes (paths)</a></li> <li><a href=#text-0><span class=secno>4.8.11.1.9 </span>Text</a></li> <li><a href=#images><span class=secno>4.8.11.1.10 </span>Images</a></li> <li><a href=#pixel-manipulation><span class=secno>4.8.11.1.11 </span>Pixel manipulation</a></li> <li><a href=#drawing-model><span class=secno>4.8.11.1.12 </span>Drawing model</a></li> <li><a href=#best-practices><span class=secno>4.8.11.1.13 </span>Best practices</a></li> <li><a href=#examples><span class=secno>4.8.11.1.14 </span>Examples</a></ol></li> <li><a href=#color-spaces-and-color-correction><span class=secno>4.8.11.2 </span>Color spaces and color correction</a></li> <li><a href=#security-with-canvas-elements><span class=secno>4.8.11.3 </span>Security with <code>canvas</code> elements</a></ol></li> <li><a href=#the-map-element><span class=secno>4.8.12 </span>The <code>map</code> element</a></li> <li><a href=#the-area-element><span class=secno>4.8.13 </span>The <code>area</code> element</a></li> <li><a href=#image-maps><span class=secno>4.8.14 </span>Image maps</a> <ol> <li><a href=#authoring><span class=secno>4.8.14.1 </span>Authoring</a></li> <li><a href=#processing-model><span class=secno>4.8.14.2 </span>Processing model</a></ol></li> <li><a href=#mathml><span class=secno>4.8.15 </span>MathML</a></li> <li><a href=#svg-0><span class=secno>4.8.16 </span>SVG</a></li> <li><a href=#dimension-attributes><span class=secno>4.8.17 </span>Dimension attributes</a></ol></li> <li><a href=#tabular-data><span class=secno>4.9 </span>Tabular data</a> <ol> <li><a href=#the-table-element><span class=secno>4.9.1 </span>The <code>table</code> element</a> <ol> <li><a href=#table-descriptions-techniques><span class=secno>4.9.1.1 </span>Techniques for describing tables</a></li> <li><a href=#table-layout-techniques><span class=secno>4.9.1.2 </span>Techniques for table layout</a></ol></li> <li><a href=#the-caption-element><span class=secno>4.9.2 </span>The <code>caption</code> element</a></li> <li><a href=#the-colgroup-element><span class=secno>4.9.3 </span>The <code>colgroup</code> element</a></li> <li><a href=#the-col-element><span class=secno>4.9.4 </span>The <code>col</code> element</a></li> <li><a href=#the-tbody-element><span class=secno>4.9.5 </span>The <code>tbody</code> element</a></li> <li><a href=#the-thead-element><span class=secno>4.9.6 </span>The <code>thead</code> element</a></li> <li><a href=#the-tfoot-element><span class=secno>4.9.7 </span>The <code>tfoot</code> element</a></li> <li><a href=#the-tr-element><span class=secno>4.9.8 </span>The <code>tr</code> element</a></li> <li><a href=#the-td-element><span class=secno>4.9.9 </span>The <code>td</code> element</a></li> <li><a href=#the-th-element><span class=secno>4.9.10 </span>The <code>th</code> element</a></li> <li><a href=#attributes-common-to-td-and-th-elements><span class=secno>4.9.11 </span>Attributes common to <code>td</code> and <code>th</code> elements</a></li> <li><a href=#processing-model-0><span class=secno>4.9.12 </span>Processing model</a> <ol> <li><a href=#forming-a-table><span class=secno>4.9.12.1 </span>Forming a table</a></li> <li><a href=#header-and-data-cell-semantics><span class=secno>4.9.12.2 </span>Forming relationships between data cells and header cells</a></ol></li> <li><a href=#examples-0><span class=secno>4.9.13 </span>Examples</a></ol></li> <li><a href=#forms><span class=secno>4.10 </span>Forms</a> <ol> <li><a href=#introduction-2><span class=secno>4.10.1 </span>Introduction</a> <ol> <li><a href="#writing-a-form's-user-interface"><span class=secno>4.10.1.1 </span>Writing a form's user interface</a></li> <li><a href=#implementing-the-server-side-processing-for-a-form><span class=secno>4.10.1.2 </span>Implementing the server-side processing for a form</a></li> <li><a href=#configuring-a-form-to-communicate-with-a-server><span class=secno>4.10.1.3 </span>Configuring a form to communicate with a server</a></li> <li><a href=#client-side-form-validation><span class=secno>4.10.1.4 </span>Client-side form validation</a></ol></li> <li><a href=#categories><span class=secno>4.10.2 </span>Categories</a></li> <li><a href=#the-form-element><span class=secno>4.10.3 </span>The <code>form</code> element</a></li> <li><a href=#the-fieldset-element><span class=secno>4.10.4 </span>The <code>fieldset</code> element</a></li> <li><a href=#the-legend-element><span class=secno>4.10.5 </span>The <code>legend</code> element</a></li> <li><a href=#the-label-element><span class=secno>4.10.6 </span>The <code>label</code> element</a></li> <li><a href=#the-input-element><span class=secno>4.10.7 </span>The <code>input</code> element</a> <ol> <li><a href=#states-of-the-type-attribute><span class=secno>4.10.7.1 </span>States of the <code title=attr-input-type>type</code> attribute</a> <ol> <li><a href=#hidden-state><span class=secno>4.10.7.1.1 </span>Hidden state</a></li> <li><a href=#text-state-and-search-state><span class=secno>4.10.7.1.2 </span>Text state and Search state</a></li> <li><a href=#telephone-state><span class=secno>4.10.7.1.3 </span>Telephone state</a></li> <li><a href=#url-state><span class=secno>4.10.7.1.4 </span>URL state</a></li> <li><a href=#e-mail-state><span class=secno>4.10.7.1.5 </span>E-mail state</a></li> <li><a href=#password-state><span class=secno>4.10.7.1.6 </span>Password state</a></li> <li><a href=#date-and-time-state><span class=secno>4.10.7.1.7 </span>Date and Time state</a></li> <li><a href=#date-state><span class=secno>4.10.7.1.8 </span>Date state</a></li> <li><a href=#month-state><span class=secno>4.10.7.1.9 </span>Month state</a></li> <li><a href=#week-state><span class=secno>4.10.7.1.10 </span>Week state</a></li> <li><a href=#time-state><span class=secno>4.10.7.1.11 </span>Time state</a></li> <li><a href=#local-date-and-time-state><span class=secno>4.10.7.1.12 </span>Local Date and Time state</a></li> <li><a href=#number-state><span class=secno>4.10.7.1.13 </span>Number state</a></li> <li><a href=#range-state><span class=secno>4.10.7.1.14 </span>Range state</a></li> <li><a href=#color-state><span class=secno>4.10.7.1.15 </span>Color state</a></li> <li><a href=#checkbox-state><span class=secno>4.10.7.1.16 </span>Checkbox state</a></li> <li><a href=#radio-button-state><span class=secno>4.10.7.1.17 </span>Radio Button state</a></li> <li><a href=#file-upload-state><span class=secno>4.10.7.1.18 </span>File Upload state</a></li> <li><a href=#submit-button-state><span class=secno>4.10.7.1.19 </span>Submit Button state</a></li> <li><a href=#image-button-state><span class=secno>4.10.7.1.20 </span>Image Button state</a></li> <li><a href=#reset-button-state><span class=secno>4.10.7.1.21 </span>Reset Button state</a></li> <li><a href=#button-state><span class=secno>4.10.7.1.22 </span>Button state</a></ol></li> <li><a href=#common-input-element-attributes><span class=secno>4.10.7.2 </span>Common <code>input</code> element attributes</a> <ol> <li><a href=#the-autocomplete-attribute><span class=secno>4.10.7.2.1 </span>The <code title=attr-input-autocomplete>autocomplete</code> attribute</a></li> <li><a href=#the-dirname-attribute><span class=secno>4.10.7.2.2 </span>The <code title=attr-input-dirname>dirname</code> attribute</a></li> <li><a href=#the-list-attribute><span class=secno>4.10.7.2.3 </span>The <code title=attr-input-list>list</code> attribute</a></li> <li><a href=#the-readonly-attribute><span class=secno>4.10.7.2.4 </span>The <code title=attr-input-readonly>readonly</code> attribute</a></li> <li><a href=#the-size-attribute><span class=secno>4.10.7.2.5 </span>The <code title=attr-input-size>size</code> attribute</a></li> <li><a href=#the-required-attribute><span class=secno>4.10.7.2.6 </span>The <code title=attr-input-required>required</code> attribute</a></li> <li><a href=#the-multiple-attribute><span class=secno>4.10.7.2.7 </span>The <code title=attr-input-multiple>multiple</code> attribute</a></li> <li><a href=#the-maxlength-attribute><span class=secno>4.10.7.2.8 </span>The <code title=attr-input-maxlength>maxlength</code> attribute</a></li> <li><a href=#the-pattern-attribute><span class=secno>4.10.7.2.9 </span>The <code title=attr-input-pattern>pattern</code> attribute</a></li> <li><a href=#the-min-and-max-attributes><span class=secno>4.10.7.2.10 </span>The <code title=attr-input-min>min</code> and <code title=attr-input-max>max</code> attributes</a></li> <li><a href=#the-step-attribute><span class=secno>4.10.7.2.11 </span>The <code title=attr-input-step>step</code> attribute</a></li> <li><a href=#the-placeholder-attribute><span class=secno>4.10.7.2.12 </span>The <code title=attr-input-placeholder>placeholder</code> attribute</a></ol></li> <li><a href=#common-input-element-apis><span class=secno>4.10.7.3 </span>Common <code>input</code> element APIs</a></li> <li><a href=#common-event-behaviors><span class=secno>4.10.7.4 </span>Common event behaviors</a></ol></li> <li><a href=#the-button-element><span class=secno>4.10.8 </span>The <code>button</code> element</a></li> <li><a href=#the-select-element><span class=secno>4.10.9 </span>The <code>select</code> element</a></li> <li><a href=#the-datalist-element><span class=secno>4.10.10 </span>The <code>datalist</code> element</a></li> <li><a href=#the-optgroup-element><span class=secno>4.10.11 </span>The <code>optgroup</code> element</a></li> <li><a href=#the-option-element><span class=secno>4.10.12 </span>The <code>option</code> element</a></li> <li><a href=#the-textarea-element><span class=secno>4.10.13 </span>The <code>textarea</code> element</a></li> <li><a href=#the-keygen-element><span class=secno>4.10.14 </span>The <code>keygen</code> element</a></li> <li><a href=#the-output-element><span class=secno>4.10.15 </span>The <code>output</code> element</a></li> <li><a href=#the-progress-element><span class=secno>4.10.16 </span>The <code>progress</code> element</a></li> <li><a href=#the-meter-element><span class=secno>4.10.17 </span>The <code>meter</code> element</a></li> <li><a href=#association-of-controls-and-forms><span class=secno>4.10.18 </span>Association of controls and forms</a></li> <li><a href=#attributes-common-to-form-controls><span class=secno>4.10.19 </span>Attributes common to form controls</a> <ol> <li><a href=#naming-form-controls><span class=secno>4.10.19.1 </span>Naming form controls</a></li> <li><a href=#enabling-and-disabling-form-controls><span class=secno>4.10.19.2 </span>Enabling and disabling form controls</a></li> <li><a href="#a-form-control's-value"><span class=secno>4.10.19.3 </span>A form control's value</a></li> <li><a href=#autofocusing-a-form-control><span class=secno>4.10.19.4 </span>Autofocusing a form control</a></li> <li><a href=#limiting-user-input-length><span class=secno>4.10.19.5 </span>Limiting user input length</a></li> <li><a href=#form-submission-0><span class=secno>4.10.19.6 </span>Form submission</a></li> <li><a href=#submitting-element-directionality><span class=secno>4.10.19.7 </span>Submitting element directionality</a></ol></li> <li><a href=#textFieldSelection><span class=secno>4.10.20 </span>APIs for the text field selections</a></li> <li><a href=#constraints><span class=secno>4.10.21 </span>Constraints</a> <ol> <li><a href=#definitions><span class=secno>4.10.21.1 </span>Definitions</a></li> <li><a href=#constraint-validation><span class=secno>4.10.21.2 </span>Constraint validation</a></li> <li><a href=#the-constraint-validation-api><span class=secno>4.10.21.3 </span>The constraint validation API</a></li> <li><a href=#security-forms><span class=secno>4.10.21.4 </span>Security</a></ol></li> <li><a href=#form-submission><span class=secno>4.10.22 </span>Form submission</a> <ol> <li><a href=#introduction-3><span class=secno>4.10.22.1 </span>Introduction</a></li> <li><a href=#implicit-submission><span class=secno>4.10.22.2 </span>Implicit submission</a></li> <li><a href=#form-submission-algorithm><span class=secno>4.10.22.3 </span>Form submission algorithm</a></li> <li><a href=#constructing-form-data-set><span class=secno>4.10.22.4 </span>Constructing the form data set</a></li> <li><a href=#url-encoded-form-data><span class=secno>4.10.22.5 </span>URL-encoded form data</a></li> <li><a href=#multipart-form-data><span class=secno>4.10.22.6 </span>Multipart form data</a></li> <li><a href=#plain-text-form-data><span class=secno>4.10.22.7 </span>Plain text form data</a></ol></li> <li><a href=#resetting-a-form><span class=secno>4.10.23 </span>Resetting a form</a></ol></li> <li><a href=#interactive-elements><span class=secno>4.11 </span>Interactive elements</a> <ol> <li><a href=#the-details-element><span class=secno>4.11.1 </span>The <code>details</code> element</a></li> <li><a href=#the-summary-element><span class=secno>4.11.2 </span>The <code>summary</code> element</a></li> <li><a href=#the-command-element><span class=secno>4.11.3 </span>The <code>command</code> element</a></li> <li><a href=#the-menu-element><span class=secno>4.11.4 </span>The <code>menu</code> element</a> <ol> <li><a href=#menus-intro><span class=secno>4.11.4.1 </span>Introduction</a></li> <li><a href=#building-menus-and-toolbars><span class=secno>4.11.4.2 </span>Building menus and toolbars</a></li> <li><a href=#context-menus><span class=secno>4.11.4.3 </span>Context menus</a></li> <li><a href=#toolbars><span class=secno>4.11.4.4 </span>Toolbars</a></ol></li> <li><a href=#commands><span class=secno>4.11.5 </span>Commands</a> <ol> <li><a href=#using-the-a-element-to-define-a-command><span class=secno>4.11.5.1 </span>Using the <code>a</code> element to define a command</a></li> <li><a href=#using-the-button-element-to-define-a-command><span class=secno>4.11.5.2 </span>Using the <code>button</code> element to define a command</a></li> <li><a href=#using-the-input-element-to-define-a-command><span class=secno>4.11.5.3 </span>Using the <code>input</code> element to define a command</a></li> <li><a href=#using-the-option-element-to-define-a-command><span class=secno>4.11.5.4 </span>Using the <code>option</code> element to define a command</a></li> <li><a href=#using-the-command-element-to-define-a-command><span class=secno>4.11.5.5 </span>Using the <code>command</code> element to define a command</a></li> <li><a href=#using-the-accesskey-attribute-on-a-label-element-to-define-a-command><span class=secno>4.11.5.6 </span>Using the <code title=attr-accesskey>accesskey</code> attribute on a <code>label</code> element to define a command</a></li> <li><a href=#using-the-accesskey-attribute-on-a-legend-element-to-define-a-command><span class=secno>4.11.5.7 </span>Using the <code title=attr-accesskey>accesskey</code> attribute on a <code>legend</code> element to define a command</a></li> <li><a href=#using-the-accesskey-attribute-to-define-a-command-on-other-elements><span class=secno>4.11.5.8 </span>Using the <code title=attr-accesskey>accesskey</code> attribute to define a command on other elements</a></ol></ol></li> <li><a href=#links><span class=secno>4.12 </span>Links</a> <ol> <li><a href=#introduction-4><span class=secno>4.12.1 </span>Introduction</a></li> <li><a href=#links-created-by-a-and-area-elements><span class=secno>4.12.2 </span>Links created by <code>a</code> and <code>area</code> elements</a></li> <li><a href=#following-hyperlinks-0><span class=secno>4.12.3 </span>Following hyperlinks</a></li> <li><a href=#downloading-resources><span class=secno>4.12.4 </span>Downloading resources</a> <ol> <li><a href=#hyperlink-auditing><span class=secno>4.12.4.1 </span>Hyperlink auditing</a></ol></li> <li><a href=#linkTypes><span class=secno>4.12.5 </span>Link types</a> <ol> <li><a href=#rel-alternate><span class=secno>4.12.5.1 </span>Link type "<code>alternate</code>"</a></li> <li><a href=#link-type-author><span class=secno>4.12.5.2 </span>Link type "<code>author</code>"</a></li> <li><a href=#link-type-bookmark><span class=secno>4.12.5.3 </span>Link type "<code>bookmark</code>"</a></li> <li><a href=#link-type-help><span class=secno>4.12.5.4 </span>Link type "<code>help</code>"</a></li> <li><a href=#rel-icon><span class=secno>4.12.5.5 </span>Link type "<code>icon</code>"</a></li> <li><a href=#link-type-license><span class=secno>4.12.5.6 </span>Link type "<code>license</code>"</a></li> <li><a href=#link-type-nofollow><span class=secno>4.12.5.7 </span>Link type "<code>nofollow</code>"</a></li> <li><a href=#link-type-noreferrer><span class=secno>4.12.5.8 </span>Link type "<code>noreferrer</code>"</a></li> <li><a href=#link-type-prefetch><span class=secno>4.12.5.9 </span>Link type "<code>prefetch</code>"</a></li> <li><a href=#link-type-search><span class=secno>4.12.5.10 </span>Link type "<code>search</code>"</a></li> <li><a href=#link-type-stylesheet><span class=secno>4.12.5.11 </span>Link type "<code>stylesheet</code>"</a></li> <li><a href=#link-type-tag><span class=secno>4.12.5.12 </span>Link type "<code>tag</code>"</a></li> <li><a href=#sequential-link-types><span class=secno>4.12.5.13 </span>Sequential link types</a> <ol> <li><a href=#link-type-next><span class=secno>4.12.5.13.1 </span>Link type "<code>next</code>"</a></li> <li><a href=#link-type-prev><span class=secno>4.12.5.13.2 </span>Link type "<code>prev</code>"</a></ol></li> <li><a href=#other-link-types><span class=secno>4.12.5.14 </span>Other link types</a></ol></ol></li> <li><a href=#common-idioms><span class=secno>4.13 </span>Common idioms without dedicated elements</a> <ol> <li><a href=#the-main-part-of-the-content><span class=secno>4.13.1 </span>The main part of the content</a></li> <li><a href=#rel-up><span class=secno>4.13.2 </span>Bread crumb navigation</a></li> <li><a href=#tag-clouds><span class=secno>4.13.3 </span>Tag clouds</a></li> <li><a href=#conversations><span class=secno>4.13.4 </span>Conversations</a></li> <li><a href=#footnotes><span class=secno>4.13.5 </span>Footnotes</a></ol></li> <li><a href=#selectors><span class=secno>4.14 </span>Matching HTML elements using selectors</a> <ol> <li><a href=#case-sensitivity><span class=secno>4.14.1 </span>Case-sensitivity</a></li> <li><a href=#pseudo-classes><span class=secno>4.14.2 </span>Pseudo-classes</a></ol></ol></li> <li><a href=#microdata><span class=secno>5 </span>Microdata</a> <ol> <li><a href=#introduction-5><span class=secno>5.1 </span>Introduction</a> <ol> <li><a href=#overview><span class=secno>5.1.1 </span>Overview</a></li> <li><a href=#the-basic-syntax><span class=secno>5.1.2 </span>The basic syntax</a></li> <li><a href=#typed-items><span class=secno>5.1.3 </span>Typed items</a></li> <li><a href=#global-identifiers-for-items><span class=secno>5.1.4 </span>Global identifiers for items</a></li> <li><a href=#selecting-names-when-defining-vocabularies><span class=secno>5.1.5 </span>Selecting names when defining vocabularies</a></li> <li><a href=#using-the-microdata-dom-api><span class=secno>5.1.6 </span>Using the microdata DOM API</a></ol></li> <li><a href=#encoding-microdata><span class=secno>5.2 </span>Encoding microdata</a> <ol> <li><a href=#the-microdata-model><span class=secno>5.2.1 </span>The microdata model</a></li> <li><a href=#items><span class=secno>5.2.2 </span>Items</a></li> <li><a href=#names:-the-itemprop-attribute><span class=secno>5.2.3 </span>Names: the <code>itemprop</code> attribute</a></li> <li><a href=#values><span class=secno>5.2.4 </span>Values</a></li> <li><a href=#associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</a></li> <li><a href=#microdata-and-other-namespaces><span class=secno>5.2.6 </span>Microdata and other namespaces</a></ol></li> <li><a href=#microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</a></li> <li><a href=#mdvocabs><span class=secno>5.4 </span>Microdata vocabularies</a> <ol> <li><a href=#vcard><span class=secno>5.4.1 </span>vCard</a> <ol> <li><a href=#conversion-to-vcard><span class=secno>5.4.1.1 </span>Conversion to vCard</a></li> <li><a href=#examples-1><span class=secno>5.4.1.2 </span>Examples</a></ol></li> <li><a href=#vevent><span class=secno>5.4.2 </span>vEvent</a> <ol> <li><a href=#conversion-to-icalendar><span class=secno>5.4.2.1 </span>Conversion to iCalendar</a></li> <li><a href=#examples-2><span class=secno>5.4.2.2 </span>Examples</a></ol></li> <li><a href=#licensing-works><span class=secno>5.4.3 </span>Licensing works</a> <ol> <li><a href=#examples-3><span class=secno>5.4.3.1 </span>Examples</a></ol></ol></li> <li><a href=#converting-html-to-other-formats><span class=secno>5.5 </span>Converting HTML to other formats</a> <ol> <li><a href=#json><span class=secno>5.5.1 </span>JSON</a></ol></ol></li> <li><a href=#browsers><span class=secno>6 </span>Loading Web pages</a> <ol> <li><a href=#windows><span class=secno>6.1 </span>Browsing contexts</a> <ol> <li><a href=#nested-browsing-contexts><span class=secno>6.1.1 </span>Nested browsing contexts</a> <ol> <li><a href=#navigating-nested-browsing-contexts-in-the-dom><span class=secno>6.1.1.1 </span>Navigating nested browsing contexts in the DOM</a></ol></li> <li><a href=#auxiliary-browsing-contexts><span class=secno>6.1.2 </span>Auxiliary browsing contexts</a> <ol> <li><a href=#navigating-auxiliary-browsing-contexts-in-the-dom><span class=secno>6.1.2.1 </span>Navigating auxiliary browsing contexts in the DOM</a></ol></li> <li><a href=#secondary-browsing-contexts><span class=secno>6.1.3 </span>Secondary browsing contexts</a></li> <li><a href=#security-nav><span class=secno>6.1.4 </span>Security</a></li> <li><a href=#groupings-of-browsing-contexts><span class=secno>6.1.5 </span>Groupings of browsing contexts</a></li> <li><a href=#browsing-context-names><span class=secno>6.1.6 </span>Browsing context names</a></ol></li> <li><a href=#the-window-object><span class=secno>6.2 </span>The <code>Window</code> object</a> <ol> <li><a href=#security-window><span class=secno>6.2.1 </span>Security</a></li> <li><a href=#apis-for-creating-and-navigating-browsing-contexts-by-name><span class=secno>6.2.2 </span>APIs for creating and navigating browsing contexts by name</a></li> <li><a href=#accessing-other-browsing-contexts><span class=secno>6.2.3 </span>Accessing other browsing contexts</a></li> <li><a href=#named-access-on-the-window-object><span class=secno>6.2.4 </span>Named access on the <code>Window</code> object</a></li> <li><a href=#garbage-collection-and-browsing-contexts><span class=secno>6.2.5 </span>Garbage collection and browsing contexts</a></li> <li><a href=#browser-interface-elements><span class=secno>6.2.6 </span>Browser interface elements</a></li> <li><a href=#the-windowproxy-object><span class=secno>6.2.7 </span>The <code>WindowProxy</code> object</a></ol></li> <li><a href=#origin-0><span class=secno>6.3 </span>Origin</a> <ol> <li><a href=#relaxing-the-same-origin-restriction><span class=secno>6.3.1 </span>Relaxing the same-origin restriction</a></ol></li> <li><a href=#history><span class=secno>6.4 </span>Session history and navigation</a> <ol> <li><a href=#the-session-history-of-browsing-contexts><span class=secno>6.4.1 </span>The session history of browsing contexts</a></li> <li><a href=#the-history-interface><span class=secno>6.4.2 </span>The <code>History</code> interface</a></li> <li><a href=#the-location-interface><span class=secno>6.4.3 </span>The <code>Location</code> interface</a> <ol> <li><a href=#security-location><span class=secno>6.4.3.1 </span>Security</a></ol></li> <li><a href=#history-notes><span class=secno>6.4.4 </span>Implementation notes for session history</a></ol></li> <li><a href=#browsing-the-web><span class=secno>6.5 </span>Browsing the Web</a> <ol> <li><a href=#navigating-across-documents><span class=secno>6.5.1 </span>Navigating across documents</a></li> <li><a href=#read-html><span class=secno>6.5.2 </span>Page load processing model for HTML files</a></li> <li><a href=#read-xml><span class=secno>6.5.3 </span>Page load processing model for XML files</a></li> <li><a href=#read-text><span class=secno>6.5.4 </span>Page load processing model for text files</a></li> <li><a href=#read-multipart-x-mixed-replace><span class=secno>6.5.5 </span>Page load processing model for <code>multipart/x-mixed-replace</code> resources</a></li> <li><a href=#read-media><span class=secno>6.5.6 </span>Page load processing model for media</a></li> <li><a href=#read-plugin><span class=secno>6.5.7 </span>Page load processing model for content that uses plugins</a></li> <li><a href=#read-ua-inline><span class=secno>6.5.8 </span>Page load processing model for inline content that doesn't have a DOM</a></li> <li><a href=#scroll-to-fragid><span class=secno>6.5.9 </span>Navigating to a fragment identifier</a></li> <li><a href=#history-traversal><span class=secno>6.5.10 </span>History traversal</a> <ol> <li><a href=#event-definitions-0><span class=secno>6.5.10.1 </span>Event definitions</a></ol></li> <li><a href=#unloading-documents><span class=secno>6.5.11 </span>Unloading documents</a> <ol> <li><a href=#event-definition><span class=secno>6.5.11.1 </span>Event definition</a></ol></li> <li><a href=#aborting-a-document-load><span class=secno>6.5.12 </span>Aborting a document load</a></ol></li> <li><a href=#offline><span class=secno>6.6 </span>Offline Web applications</a> <ol> <li><a href=#introduction-6><span class=secno>6.6.1 </span>Introduction</a> <ol> <li><a href=#appcacheevents><span class=secno>6.6.1.1 </span>Event summary</a></ol></li> <li><a href=#appcache><span class=secno>6.6.2 </span>Application caches</a></li> <li><a href=#manifests><span class=secno>6.6.3 </span>The cache manifest syntax</a> <ol> <li><a href=#some-sample-manifests><span class=secno>6.6.3.1 </span>Some sample manifests</a></li> <li><a href=#writing-cache-manifests><span class=secno>6.6.3.2 </span>Writing cache manifests</a></li> <li><a href=#parsing-cache-manifests><span class=secno>6.6.3.3 </span>Parsing cache manifests</a></ol></li> <li><a href=#downloading-or-updating-an-application-cache><span class=secno>6.6.4 </span>Downloading or updating an application cache</a></li> <li><a href=#the-application-cache-selection-algorithm><span class=secno>6.6.5 </span>The application cache selection algorithm</a></li> <li><a href=#changesToNetworkingModel><span class=secno>6.6.6 </span>Changes to the networking model</a></li> <li><a href=#expiring-application-caches><span class=secno>6.6.7 </span>Expiring application caches</a></li> <li><a href=#disk-space><span class=secno>6.6.8 </span>Disk space</a></li> <li><a href=#application-cache-api><span class=secno>6.6.9 </span>Application cache API</a></li> <li><a href=#browser-state><span class=secno>6.6.10 </span>Browser state</a></ol></ol></li> <li><a href=#webappapis><span class=secno>7 </span>Web application APIs</a> <ol> <li><a href=#scripting><span class=secno>7.1 </span>Scripting</a> <ol> <li><a href=#introduction-7><span class=secno>7.1.1 </span>Introduction</a></li> <li><a href=#enabling-and-disabling-scripting><span class=secno>7.1.2 </span>Enabling and disabling scripting</a></li> <li><a href=#processing-model-1><span class=secno>7.1.3 </span>Processing model</a> <ol> <li><a href=#definitions-0><span class=secno>7.1.3.1 </span>Definitions</a></li> <li><a href=#calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</a></li> <li><a href=#creating-scripts><span class=secno>7.1.3.3 </span>Creating scripts</a></li> <li><a href=#killing-scripts><span class=secno>7.1.3.4 </span>Killing scripts</a></li> <li><a href=#runtime-script-errors><span class=secno>7.1.3.5 </span>Runtime script errors</a> <ol> <li><a href=#runtime-script-errors-in-documents><span class=secno>7.1.3.5.1 </span>Runtime script errors in documents</a></ol></ol></li> <li><a href=#event-loops><span class=secno>7.1.4 </span>Event loops</a> <ol> <li><a href=#definitions-1><span class=secno>7.1.4.1 </span>Definitions</a></li> <li><a href=#processing-model-2><span class=secno>7.1.4.2 </span>Processing model</a></li> <li><a href=#generic-task-sources><span class=secno>7.1.4.3 </span>Generic task sources</a></ol></li> <li><a href=#javascript-protocol><span class=secno>7.1.5 </span>The <code title="">javascript:</code> URL scheme</a></li> <li><a href=#events><span class=secno>7.1.6 </span>Events</a> <ol> <li><a href=#event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers</a></li> <li><a href=#event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>7.1.6.2 </span>Event handlers on elements, <code>Document</code> objects, and <code>Window</code> objects</a></li> <li><a href=#event-firing><span class=secno>7.1.6.3 </span>Event firing</a></li> <li><a href=#events-and-the-window-object><span class=secno>7.1.6.4 </span>Events and the <code>Window</code> object</a></ol></ol></li> <li><a href=#atob><span class=secno>7.2 </span>Base64 utility methods</a></li> <li><a href=#timers><span class=secno>7.3 </span>Timers</a></li> <li><a href=#user-prompts><span class=secno>7.4 </span>User prompts</a> <ol> <li><a href=#simple-dialogs><span class=secno>7.4.1 </span>Simple dialogs</a></li> <li><a href=#printing><span class=secno>7.4.2 </span>Printing</a></li> <li><a href=#dialogs-implemented-using-separate-documents><span class=secno>7.4.3 </span>Dialogs implemented using separate documents</a></ol></li> <li><a href=#system-state-and-capabilities><span class=secno>7.5 </span>System state and capabilities</a> <ol> <li><a href=#the-navigator-object><span class=secno>7.5.1 </span>The <code>Navigator</code> object</a> <ol> <li><a href=#client-identification><span class=secno>7.5.1.1 </span>Client identification</a></li> <li><a href=#custom-handlers><span class=secno>7.5.1.2 </span>Custom scheme and content handlers</a></li> <li><a href=#security-and-privacy><span class=secno>7.5.1.3 </span>Security and privacy</a></li> <li><a href=#sample-handler-impl><span class=secno>7.5.1.4 </span>Sample user interface</a></li> <li><a href=#manually-releasing-the-storage-mutex><span class=secno>7.5.1.5 </span>Manually releasing the storage mutex</a></ol></li> <li><a href=#the-external-interface><span class=secno>7.5.2 </span>The <code>External</code> interface</a></ol></ol></li> <li><a href=#editing><span class=secno>8 </span>User interaction</a> <ol> <li><a href=#the-hidden-attribute><span class=secno>8.1 </span>The <code>hidden</code> attribute</a></li> <li><a href=#activation><span class=secno>8.2 </span>Activation</a></li> <li><a href=#focus><span class=secno>8.3 </span>Focus</a> <ol> <li><a href=#sequential-focus-navigation-and-the-tabindex-attribute><span class=secno>8.3.1 </span>Sequential focus navigation and the <code title=attr-tabindex>tabindex</code> attribute</a></li> <li><a href=#focus-management><span class=secno>8.3.2 </span>Focus management</a></li> <li><a href=#document-level-focus-apis><span class=secno>8.3.3 </span>Document-level focus APIs</a></li> <li><a href=#element-level-focus-apis><span class=secno>8.3.4 </span>Element-level focus APIs</a></ol></li> <li><a href=#assigning-keyboard-shortcuts><span class=secno>8.4 </span>Assigning keyboard shortcuts</a> <ol> <li><a href=#introduction-8><span class=secno>8.4.1 </span>Introduction</a></li> <li><a href=#the-accesskey-attribute><span class=secno>8.4.2 </span>The <code>accesskey</code> attribute</a></li> <li><a href=#processing-model-3><span class=secno>8.4.3 </span>Processing model</a></ol></li> <li><a href=#editing-0><span class=secno>8.5 </span>Editing</a> <ol> <li><a href=#contenteditable><span class=secno>8.5.1 </span>Making document regions editable: The <code title=attr-contenteditable>contenteditable</code> content attribute</a></li> <li><a href=#making-entire-documents-editable:-the-designmode-idl-attribute><span class=secno>8.5.2 </span>Making entire documents editable: The <code title=dom-document-designMode>designMode</code> IDL attribute</a></li> <li><a href=#best-practices-for-in-page-editors><span class=secno>8.5.3 </span>Best practices for in-page editors</a></li> <li><a href=#editing-apis><span class=secno>8.5.4 </span>Editing APIs</a></li> <li><a href=#spelling-and-grammar-checking><span class=secno>8.5.5 </span>Spelling and grammar checking</a></ol></li> <li><a href=#dnd><span class=secno>8.6 </span>Drag and drop</a> <ol> <li><a href=#introduction-9><span class=secno>8.6.1 </span>Introduction</a></li> <li><a href=#the-drag-data-store><span class=secno>8.6.2 </span>The drag data store</a></li> <li><a href=#the-datatransfer-interface><span class=secno>8.6.3 </span>The <code>DataTransfer</code> interface</a> <ol> <li><a href=#the-datatransferitemlist-interface><span class=secno>8.6.3.1 </span>The <code>DataTransferItemList</code> interface</a></li> <li><a href=#the-datatransferitem-interface><span class=secno>8.6.3.2 </span>The <code>DataTransferItem</code> interface</a></ol></li> <li><a href=#the-dragevent-interface><span class=secno>8.6.4 </span>The <code>DragEvent</code> interface</a></li> <li><a href=#drag-and-drop-processing-model><span class=secno>8.6.5 </span>Drag-and-drop processing model</a></li> <li><a href=#dndevents><span class=secno>8.6.6 </span>Events summary</a></li> <li><a href=#the-draggable-attribute><span class=secno>8.6.7 </span>The <code>draggable</code> attribute</a></li> <li><a href=#the-dropzone-attribute><span class=secno>8.6.8 </span>The <code>dropzone</code> attribute</a></li> <li><a href=#security-risks-in-the-drag-and-drop-model><span class=secno>8.6.9 </span>Security risks in the drag-and-drop model</a></ol></li> <li><a href=#text-search-apis><span class=secno>8.7 </span>Text search APIs</a></ol></li> <li><a href=#video-conferencing-and-peer-to-peer-communication><span class=secno>9 </span>Video conferencing and peer-to-peer communication</a> <ol> <li><a href=#introduction-10><span class=secno>9.1 </span>Introduction</a></li> <li><a href=#obtaining-local-multimedia-content><span class=secno>9.2 </span>Obtaining local multimedia content</a></li> <li><a href=#stream-api><span class=secno>9.3 </span>Stream API</a> <ol> <li><a href=#introduction-11><span class=secno>9.3.1 </span>Introduction</a></li> <li><a href=#interface-definitions><span class=secno>9.3.2 </span>Interface definitions</a></ol></li> <li><a href=#peer-to-peer-connections><span class=secno>9.4 </span>Peer-to-peer connections</a> <ol> <li><a href=#introduction-12><span class=secno>9.4.1 </span>Introduction</a></li> <li><a href=#interface-definitions-0><span class=secno>9.4.2 </span>Interface definitions</a></ol></li> <li><a href=#the-data-stream><span class=secno>9.5 </span>The data stream</a> <ol> <li><a href=#security-considerations><span class=secno>9.5.1 </span>Security considerations</a></ol></li> <li><a href=#garbage-collection-0><span class=secno>9.6 </span>Garbage collection</a></li> <li><a href=#event-definitions-1><span class=secno>9.7 </span>Event definitions</a></li> <li><a href=#mediastreamevents><span class=secno>9.8 </span>Event Summary</a></ol></li> <li><a href=#workers><span class=secno>10 </span>Web workers</a> <ol> <li><a href=#introduction-13><span class=secno>10.1 </span>Introduction</a> <ol> <li><a href=#scope-0><span class=secno>10.1.1 </span>Scope</a></li> <li><a href=#examples-4><span class=secno>10.1.2 </span>Examples</a> <ol> <li><a href=#a-background-number-crunching-worker><span class=secno>10.1.2.1 </span>A background number-crunching worker</a></li> <li><a href=#a-worker-for-updating-a-client-side-database><span class=secno>10.1.2.2 </span>A worker for updating a client-side database</a></li> <li><a href=#worker-used-for-background-i/o><span class=secno>10.1.2.3 </span>Worker used for background I/O</a></li> <li><a href=#shared-workers-introduction><span class=secno>10.1.2.4 </span>Shared workers introduction</a></li> <li><a href=#shared-state-using-a-shared-worker><span class=secno>10.1.2.5 </span>Shared state using a shared worker</a></li> <li><a href=#delegation><span class=secno>10.1.2.6 </span>Delegation</a></ol></li> <li><a href=#tutorials><span class=secno>10.1.3 </span>Tutorials</a> <ol> <li><a href=#creating-a-dedicated-worker><span class=secno>10.1.3.1 </span>Creating a dedicated worker</a></li> <li><a href=#communicating-with-a-dedicated-worker><span class=secno>10.1.3.2 </span>Communicating with a dedicated worker</a></li> <li><a href=#shared-workers><span class=secno>10.1.3.3 </span>Shared workers</a></ol></ol></li> <li><a href=#infrastructure-0><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-abstract-interface><span class=secno>10.2.1.1 </span>The <code>WorkerGlobalScope</code> abstract interface</a></li> <li><a href=#dedicated-workers-and-the-dedicatedworkerglobalscope-interface><span class=secno>10.2.1.2 </span>Dedicated workers and the <code>DedicatedWorkerGlobalScope</code> interface</a></li> <li><a href=#shared-workers-and-the-sharedworkerglobalscope-interface><span class=secno>10.2.1.3 </span>Shared workers and the <code>SharedWorkerGlobalScope</code> interface</a></ol></li> <li><a href=#origins-of-workers><span class=secno>10.2.2 </span>Origins of workers</a></li> <li><a href=#the-event-loop><span class=secno>10.2.3 </span>The event loop</a></li> <li><a href="#the-worker's-lifetime"><span class=secno>10.2.4 </span>The worker's lifetime</a></li> <li><a href=#processing-model-4><span class=secno>10.2.5 </span>Processing model</a></li> <li><a href=#runtime-script-errors-0><span class=secno>10.2.6 </span>Runtime script errors</a></li> <li><a href=#creating-workers><span class=secno>10.2.7 </span>Creating workers</a> <ol> <li><a href=#the-abstractworker-abstract-interface><span class=secno>10.2.7.1 </span>The <code>AbstractWorker</code> abstract interface</a></li> <li><a href=#dedicated-workers-and-the-worker-interface><span class=secno>10.2.7.2 </span>Dedicated workers and the <code>Worker</code> interface</a></li> <li><a href=#shared-workers-and-the-sharedworker-interface><span class=secno>10.2.7.3 </span>Shared workers and the <code>SharedWorker</code> interface</a></ol></ol></li> <li><a href=#apis-available-to-workers><span class=secno>10.3 </span>APIs available to workers</a> <ol> <li><a href=#importing-scripts-and-libraries><span class=secno>10.3.1 </span>Importing scripts and libraries</a></li> <li><a href=#the-workernavigator-object><span class=secno>10.3.2 </span>The <code>WorkerNavigator</code> object</a></li> <li><a href=#interface-objects-and-constructors><span class=secno>10.3.3 </span>Interface objects and constructors</a></li> <li><a href=#worker-locations><span class=secno>10.3.4 </span>Worker locations</a></ol></ol></li> <li><a href=#comms><span class=secno>11 </span>Communication</a> <ol> <li><a href=#event-definitions-2><span class=secno>11.1 </span>Event definitions</a></li> <li><a href=#server-sent-events><span class=secno>11.2 </span>Server-sent events</a> <ol> <li><a href=#server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</a></li> <li><a href=#the-eventsource-interface><span class=secno>11.2.2 </span>The <code>EventSource</code> interface</a></li> <li><a href=#processing-model-5><span class=secno>11.2.3 </span>Processing model</a></li> <li><a href=#parsing-an-event-stream><span class=secno>11.2.4 </span>Parsing an event stream</a></li> <li><a href=#event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting an event stream</a></li> <li><a href=#notes><span class=secno>11.2.6 </span>Notes</a></li> <li><a href=#eventsource-push><span class=secno>11.2.7 </span>Connectionless push and other features</a></li> <li><a href=#garbage-collection-1><span class=secno>11.2.8 </span>Garbage collection</a></li> <li><a href=#iana-considerations><span class=secno>11.2.9 </span>IANA considerations</a> <ol> <li><a href=#text/event-stream><span class=secno>11.2.9.1 </span><code>text/event-stream</code></a></li> <li><a href=#last-event-id><span class=secno>11.2.9.2 </span><code>Last-Event-ID</code></a></ol></ol></li> <li><a href=#network><span class=secno>11.3 </span>Web sockets</a> <ol> <li><a href=#network-intro><span class=secno>11.3.1 </span>Introduction</a></li> <li><a href=#the-websocket-interface><span class=secno>11.3.2 </span>The <code>WebSocket</code> interface</a></li> <li><a href=#feedback-from-the-protocol><span class=secno>11.3.3 </span>Feedback from the protocol</a></li> <li><a href=#ping-and-pong-frames><span class=secno>11.3.4 </span>Ping and Pong frames</a></li> <li><a href=#parsing-websocket-urls><span class=secno>11.3.5 </span>Parsing WebSocket URLs</a></li> <li><a href=#event-definitions-3><span class=secno>11.3.6 </span>Event definitions</a></li> <li><a href=#garbage-collection-2><span class=secno>11.3.7 </span>Garbage collection</a></ol></li> <li><a href=#web-messaging><span class=secno>11.4 </span>Cross-document messaging</a> <ol> <li><a href=#introduction-14><span class=secno>11.4.1 </span>Introduction</a></li> <li><a href=#security-postmsg><span class=secno>11.4.2 </span>Security</a> <ol> <li><a href=#authors><span class=secno>11.4.2.1 </span>Authors</a></li> <li><a href=#user-agents><span class=secno>11.4.2.2 </span>User agents</a></ol></li> <li><a href=#posting-messages><span class=secno>11.4.3 </span>Posting messages</a></ol></li> <li><a href=#channel-messaging><span class=secno>11.5 </span>Channel messaging</a> <ol> <li><a href=#introduction-15><span class=secno>11.5.1 </span>Introduction</a> <ol> <li><a href=#ports-as-the-basis-of-an-object-capability-model-on-the-web><span class=secno>11.5.1.1 </span>Ports as the basis of an object-capability model on the Web</a></li> <li><a href=#ports-as-the-basis-of-abstracting-out-service-implementations><span class=secno>11.5.1.2 </span>Ports as the basis of abstracting out service implementations</a></ol></li> <li><a href=#message-channels><span class=secno>11.5.2 </span>Message channels</a></li> <li><a href=#message-ports><span class=secno>11.5.3 </span>Message ports</a> <ol> <li><a href=#ports-and-garbage-collection><span class=secno>11.5.3.1 </span>Ports and garbage collection</a></ol></ol></ol></li> <li><a href=#webstorage><span class=secno>12 </span>Web storage</a> <ol> <li><a href=#introduction-16><span class=secno>12.1 </span>Introduction</a></li> <li><a href=#storage><span class=secno>12.2 </span>The API</a> <ol> <li><a href=#the-storage-interface><span class=secno>12.2.1 </span>The <code>Storage</code> interface</a></li> <li><a href=#the-sessionstorage-attribute><span class=secno>12.2.2 </span>The <code title=dom-sessionStorage>sessionStorage</code> attribute</a></li> <li><a href=#the-localstorage-attribute><span class=secno>12.2.3 </span>The <code title=dom-localStorage>localStorage</code> attribute</a> <ol> <li><a href=#security-localStorage><span class=secno>12.2.3.1 </span>Security</a></ol></li> <li><a href=#the-storage-event><span class=secno>12.2.4 </span>The <code title=event-storage>storage</code> event</a> <ol> <li><a href=#event-definition-0><span class=secno>12.2.4.1 </span>Event definition</a></ol></li> <li><a href=#threads><span class=secno>12.2.5 </span>Threads</a></ol></li> <li><a href=#disk-space-0><span class=secno>12.3 </span>Disk space</a></li> <li><a href=#privacy><span class=secno>12.4 </span>Privacy</a> <ol> <li><a href=#user-tracking><span class=secno>12.4.1 </span>User tracking</a></li> <li><a href=#sensitivity-of-data><span class=secno>12.4.2 </span>Sensitivity of data</a></ol></li> <li><a href=#security-storage><span class=secno>12.5 </span>Security</a> <ol> <li><a href=#dns-spoofing-attacks><span class=secno>12.5.1 </span>DNS spoofing attacks</a></li> <li><a href=#cross-directory-attacks><span class=secno>12.5.2 </span>Cross-directory attacks</a></li> <li><a href=#implementation-risks><span class=secno>12.5.3 </span>Implementation risks</a></ol></ol></li> <li><a href=#syntax><span class=secno>13 </span>The HTML syntax</a> <ol> <li><a href=#writing><span class=secno>13.1 </span>Writing HTML documents</a> <ol> <li><a href=#the-doctype><span class=secno>13.1.1 </span>The DOCTYPE</a></li> <li><a href=#elements-0><span class=secno>13.1.2 </span>Elements</a> <ol> <li><a href=#start-tags><span class=secno>13.1.2.1 </span>Start tags</a></li> <li><a href=#end-tags><span class=secno>13.1.2.2 </span>End tags</a></li> <li><a href=#attributes-0><span class=secno>13.1.2.3 </span>Attributes</a></li> <li><a href=#optional-tags><span class=secno>13.1.2.4 </span>Optional tags</a></li> <li><a href=#element-restrictions><span class=secno>13.1.2.5 </span>Restrictions on content models</a></li> <li><a href=#cdata-rcdata-restrictions><span class=secno>13.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</a></ol></li> <li><a href=#text-1><span class=secno>13.1.3 </span>Text</a> <ol> <li><a href=#newlines><span class=secno>13.1.3.1 </span>Newlines</a></ol></li> <li><a href=#character-references><span class=secno>13.1.4 </span>Character references</a></li> <li><a href=#cdata-sections><span class=secno>13.1.5 </span>CDATA sections</a></li> <li><a href=#comments><span class=secno>13.1.6 </span>Comments</a></ol></li> <li><a href=#parsing><span class=secno>13.2 </span>Parsing HTML documents</a> <ol> <li><a href=#overview-of-the-parsing-model><span class=secno>13.2.1 </span>Overview of the parsing model</a></li> <li><a href=#the-input-stream><span class=secno>13.2.2 </span>The input stream</a> <ol> <li><a href=#determining-the-character-encoding><span class=secno>13.2.2.1 </span>Determining the character encoding</a></li> <li><a href=#character-encodings-0><span class=secno>13.2.2.2 </span>Character encodings</a></li> <li><a href=#preprocessing-the-input-stream><span class=secno>13.2.2.3 </span>Preprocessing the input stream</a></li> <li><a href=#changing-the-encoding-while-parsing><span class=secno>13.2.2.4 </span>Changing the encoding while parsing</a></ol></li> <li><a href=#parse-state><span class=secno>13.2.3 </span>Parse state</a> <ol> <li><a href=#the-insertion-mode><span class=secno>13.2.3.1 </span>The insertion mode</a></li> <li><a href=#the-stack-of-open-elements><span class=secno>13.2.3.2 </span>The stack of open elements</a></li> <li><a href=#the-list-of-active-formatting-elements><span class=secno>13.2.3.3 </span>The list of active formatting elements</a></li> <li><a href=#the-element-pointers><span class=secno>13.2.3.4 </span>The element pointers</a></li> <li><a href=#other-parsing-state-flags><span class=secno>13.2.3.5 </span>Other parsing state flags</a></ol></li> <li><a href=#tokenization><span class=secno>13.2.4 </span>Tokenization</a> <ol> <li><a href=#data-state><span class=secno>13.2.4.1 </span>Data state</a></li> <li><a href=#character-reference-in-data-state><span class=secno>13.2.4.2 </span>Character reference in data state</a></li> <li><a href=#rcdata-state><span class=secno>13.2.4.3 </span>RCDATA state</a></li> <li><a href=#character-reference-in-rcdata-state><span class=secno>13.2.4.4 </span>Character reference in RCDATA state</a></li> <li><a href=#rawtext-state><span class=secno>13.2.4.5 </span>RAWTEXT state</a></li> <li><a href=#script-data-state><span class=secno>13.2.4.6 </span>Script data state</a></li> <li><a href=#plaintext-state><span class=secno>13.2.4.7 </span>PLAINTEXT state</a></li> <li><a href=#tag-open-state><span class=secno>13.2.4.8 </span>Tag open state</a></li> <li><a href=#end-tag-open-state><span class=secno>13.2.4.9 </span>End tag open state</a></li> <li><a href=#tag-name-state><span class=secno>13.2.4.10 </span>Tag name state</a></li> <li><a href=#rcdata-less-than-sign-state><span class=secno>13.2.4.11 </span>RCDATA less-than sign state</a></li> <li><a href=#rcdata-end-tag-open-state><span class=secno>13.2.4.12 </span>RCDATA end tag open state</a></li> <li><a href=#rcdata-end-tag-name-state><span class=secno>13.2.4.13 </span>RCDATA end tag name state</a></li> <li><a href=#rawtext-less-than-sign-state><span class=secno>13.2.4.14 </span>RAWTEXT less-than sign state</a></li> <li><a href=#rawtext-end-tag-open-state><span class=secno>13.2.4.15 </span>RAWTEXT end tag open state</a></li> <li><a href=#rawtext-end-tag-name-state><span class=secno>13.2.4.16 </span>RAWTEXT end tag name state</a></li> <li><a href=#script-data-less-than-sign-state><span class=secno>13.2.4.17 </span>Script data less-than sign state</a></li> <li><a href=#script-data-end-tag-open-state><span class=secno>13.2.4.18 </span>Script data end tag open state</a></li> <li><a href=#script-data-end-tag-name-state><span class=secno>13.2.4.19 </span>Script data end tag name state</a></li> <li><a href=#script-data-escape-start-state><span class=secno>13.2.4.20 </span>Script data escape start state</a></li> <li><a href=#script-data-escape-start-dash-state><span class=secno>13.2.4.21 </span>Script data escape start dash state</a></li> <li><a href=#script-data-escaped-state><span class=secno>13.2.4.22 </span>Script data escaped state</a></li> <li><a href=#script-data-escaped-dash-state><span class=secno>13.2.4.23 </span>Script data escaped dash state</a></li> <li><a href=#script-data-escaped-dash-dash-state><span class=secno>13.2.4.24 </span>Script data escaped dash dash state</a></li> <li><a href=#script-data-escaped-less-than-sign-state><span class=secno>13.2.4.25 </span>Script data escaped less-than sign state</a></li> <li><a href=#script-data-escaped-end-tag-open-state><span class=secno>13.2.4.26 </span>Script data escaped end tag open state</a></li> <li><a href=#script-data-escaped-end-tag-name-state><span class=secno>13.2.4.27 </span>Script data escaped end tag name state</a></li> <li><a href=#script-data-double-escape-start-state><span class=secno>13.2.4.28 </span>Script data double escape start state</a></li> <li><a href=#script-data-double-escaped-state><span class=secno>13.2.4.29 </span>Script data double escaped state</a></li> <li><a href=#script-data-double-escaped-dash-state><span class=secno>13.2.4.30 </span>Script data double escaped dash state</a></li> <li><a href=#script-data-double-escaped-dash-dash-state><span class=secno>13.2.4.31 </span>Script data double escaped dash dash state</a></li> <li><a href=#script-data-double-escaped-less-than-sign-state><span class=secno>13.2.4.32 </span>Script data double escaped less-than sign state</a></li> <li><a href=#script-data-double-escape-end-state><span class=secno>13.2.4.33 </span>Script data double escape end state</a></li> <li><a href=#before-attribute-name-state><span class=secno>13.2.4.34 </span>Before attribute name state</a></li> <li><a href=#attribute-name-state><span class=secno>13.2.4.35 </span>Attribute name state</a></li> <li><a href=#after-attribute-name-state><span class=secno>13.2.4.36 </span>After attribute name state</a></li> <li><a href=#before-attribute-value-state><span class=secno>13.2.4.37 </span>Before attribute value state</a></li> <li><a href=#attribute-value-(double-quoted)-state><span class=secno>13.2.4.38 </span>Attribute value (double-quoted) state</a></li> <li><a href=#attribute-value-(single-quoted)-state><span class=secno>13.2.4.39 </span>Attribute value (single-quoted) state</a></li> <li><a href=#attribute-value-(unquoted)-state><span class=secno>13.2.4.40 </span>Attribute value (unquoted) state</a></li> <li><a href=#character-reference-in-attribute-value-state><span class=secno>13.2.4.41 </span>Character reference in attribute value state</a></li> <li><a href=#after-attribute-value-(quoted)-state><span class=secno>13.2.4.42 </span>After attribute value (quoted) state</a></li> <li><a href=#self-closing-start-tag-state><span class=secno>13.2.4.43 </span>Self-closing start tag state</a></li> <li><a href=#bogus-comment-state><span class=secno>13.2.4.44 </span>Bogus comment state</a></li> <li><a href=#markup-declaration-open-state><span class=secno>13.2.4.45 </span>Markup declaration open state</a></li> <li><a href=#comment-start-state><span class=secno>13.2.4.46 </span>Comment start state</a></li> <li><a href=#comment-start-dash-state><span class=secno>13.2.4.47 </span>Comment start dash state</a></li> <li><a href=#comment-state><span class=secno>13.2.4.48 </span>Comment state</a></li> <li><a href=#comment-end-dash-state><span class=secno>13.2.4.49 </span>Comment end dash state</a></li> <li><a href=#comment-end-state><span class=secno>13.2.4.50 </span>Comment end state</a></li> <li><a href=#comment-end-bang-state><span class=secno>13.2.4.51 </span>Comment end bang state</a></li> <li><a href=#doctype-state><span class=secno>13.2.4.52 </span>DOCTYPE state</a></li> <li><a href=#before-doctype-name-state><span class=secno>13.2.4.53 </span>Before DOCTYPE name state</a></li> <li><a href=#doctype-name-state><span class=secno>13.2.4.54 </span>DOCTYPE name state</a></li> <li><a href=#after-doctype-name-state><span class=secno>13.2.4.55 </span>After DOCTYPE name state</a></li> <li><a href=#after-doctype-public-keyword-state><span class=secno>13.2.4.56 </span>After DOCTYPE public keyword state</a></li> <li><a href=#before-doctype-public-identifier-state><span class=secno>13.2.4.57 </span>Before DOCTYPE public identifier state</a></li> <li><a href=#doctype-public-identifier-(double-quoted)-state><span class=secno>13.2.4.58 </span>DOCTYPE public identifier (double-quoted) state</a></li> <li><a href=#doctype-public-identifier-(single-quoted)-state><span class=secno>13.2.4.59 </span>DOCTYPE public identifier (single-quoted) state</a></li> <li><a href=#after-doctype-public-identifier-state><span class=secno>13.2.4.60 </span>After DOCTYPE public identifier state</a></li> <li><a href=#between-doctype-public-and-system-identifiers-state><span class=secno>13.2.4.61 </span>Between DOCTYPE public and system identifiers state</a></li> <li><a href=#after-doctype-system-keyword-state><span class=secno>13.2.4.62 </span>After DOCTYPE system keyword state</a></li> <li><a href=#before-doctype-system-identifier-state><span class=secno>13.2.4.63 </span>Before DOCTYPE system identifier state</a></li> <li><a href=#doctype-system-identifier-(double-quoted)-state><span class=secno>13.2.4.64 </span>DOCTYPE system identifier (double-quoted) state</a></li> <li><a href=#doctype-system-identifier-(single-quoted)-state><span class=secno>13.2.4.65 </span>DOCTYPE system identifier (single-quoted) state</a></li> <li><a href=#after-doctype-system-identifier-state><span class=secno>13.2.4.66 </span>After DOCTYPE system identifier state</a></li> <li><a href=#bogus-doctype-state><span class=secno>13.2.4.67 </span>Bogus DOCTYPE state</a></li> <li><a href=#cdata-section-state><span class=secno>13.2.4.68 </span>CDATA section state</a></li> <li><a href=#tokenizing-character-references><span class=secno>13.2.4.69 </span>Tokenizing character references</a></ol></li> <li><a href=#tree-construction><span class=secno>13.2.5 </span>Tree construction</a> <ol> <li><a href=#creating-and-inserting-elements><span class=secno>13.2.5.1 </span>Creating and inserting elements</a></li> <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>13.2.5.2 </span>Closing elements that have implied end tags</a></li> <li><a href=#foster-parenting><span class=secno>13.2.5.3 </span>Foster parenting</a></li> <li><a href=#parsing-main-inhtml><span class=secno>13.2.5.4 </span>The rules for parsing tokens in HTML content</a> <ol> <li><a href=#the-initial-insertion-mode><span class=secno>13.2.5.4.1 </span>The "initial" insertion mode</a></li> <li><a href=#the-before-html-insertion-mode><span class=secno>13.2.5.4.2 </span>The "before html" insertion mode</a></li> <li><a href=#the-before-head-insertion-mode><span class=secno>13.2.5.4.3 </span>The "before head" insertion mode</a></li> <li><a href=#parsing-main-inhead><span class=secno>13.2.5.4.4 </span>The "in head" insertion mode</a></li> <li><a href=#parsing-main-inheadnoscript><span class=secno>13.2.5.4.5 </span>The "in head noscript" insertion mode</a></li> <li><a href=#the-after-head-insertion-mode><span class=secno>13.2.5.4.6 </span>The "after head" insertion mode</a></li> <li><a href=#parsing-main-inbody><span class=secno>13.2.5.4.7 </span>The "in body" insertion mode</a></li> <li><a href=#parsing-main-incdata><span class=secno>13.2.5.4.8 </span>The "text" insertion mode</a></li> <li><a href=#parsing-main-intable><span class=secno>13.2.5.4.9 </span>The "in table" insertion mode</a></li> <li><a href=#parsing-main-intabletext><span class=secno>13.2.5.4.10 </span>The "in table text" insertion mode</a></li> <li><a href=#parsing-main-incaption><span class=secno>13.2.5.4.11 </span>The "in caption" insertion mode</a></li> <li><a href=#parsing-main-incolgroup><span class=secno>13.2.5.4.12 </span>The "in column group" insertion mode</a></li> <li><a href=#parsing-main-intbody><span class=secno>13.2.5.4.13 </span>The "in table body" insertion mode</a></li> <li><a href=#parsing-main-intr><span class=secno>13.2.5.4.14 </span>The "in row" insertion mode</a></li> <li><a href=#parsing-main-intd><span class=secno>13.2.5.4.15 </span>The "in cell" insertion mode</a></li> <li><a href=#parsing-main-inselect><span class=secno>13.2.5.4.16 </span>The "in select" insertion mode</a></li> <li><a href=#parsing-main-inselectintable><span class=secno>13.2.5.4.17 </span>The "in select in table" insertion mode</a></li> <li><a href=#parsing-main-afterbody><span class=secno>13.2.5.4.18 </span>The "after body" insertion mode</a></li> <li><a href=#parsing-main-inframeset><span class=secno>13.2.5.4.19 </span>The "in frameset" insertion mode</a></li> <li><a href=#parsing-main-afterframeset><span class=secno>13.2.5.4.20 </span>The "after frameset" insertion mode</a></li> <li><a href=#the-after-after-body-insertion-mode><span class=secno>13.2.5.4.21 </span>The "after after body" insertion mode</a></li> <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>13.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li> <li><a href=#parsing-main-inforeign><span class=secno>13.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li> <li><a href=#the-end><span class=secno>13.2.6 </span>The end</a></li> <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>13.2.7 </span>Coercing an HTML DOM into an infoset</a></li> <li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>13.2.8 </span>An introduction to error handling and strange cases in the parser</a> <ol> <li><a href=#misnested-tags:-b-i-/b-/i><span class=secno>13.2.8.1 </span>Misnested tags: <b><i></b></i></a></li> <li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></a></li> <li><a href=#unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</a></li> <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li> <li><a href=#the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</a></li> <li><a href=#unclosed-formatting-elements><span class=secno>13.2.8.6 </span>Unclosed formatting elements</a></ol></ol></li> <li><a href=#serializing-html-fragments><span class=secno>13.3 </span>Serializing HTML fragments</a></li> <li><a href=#parsing-html-fragments><span class=secno>13.4 </span>Parsing HTML fragments</a></li> <li><a href=#named-character-references><span class=secno>13.5 </span>Named character references</a></ol></li> <li><a href=#the-xhtml-syntax><span class=secno>14 </span>The XHTML syntax</a> <ol> <li><a href=#writing-xhtml-documents><span class=secno>14.1 </span>Writing XHTML documents</a></li> <li><a href=#parsing-xhtml-documents><span class=secno>14.2 </span>Parsing XHTML documents</a></li> <li><a href=#serializing-xhtml-fragments><span class=secno>14.3 </span>Serializing XHTML fragments</a></li> <li><a href=#parsing-xhtml-fragments><span class=secno>14.4 </span>Parsing XHTML fragments</a></ol></li> <li><a href=#rendering><span class=secno>15 </span>Rendering</a> <ol> <li><a href=#introduction-17><span class=secno>15.1 </span>Introduction</a></li> <li><a href=#the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>15.2 </span>The CSS user agent style sheet and presentational hints</a></li> <li><a href=#non-replaced-elements><span class=secno>15.3 </span>Non-replaced elements</a> <ol> <li><a href=#hidden-elements><span class=secno>15.3.1 </span>Hidden elements</a></li> <li><a href=#the-page><span class=secno>15.3.2 </span>The page</a></li> <li><a href=#flow-content-1><span class=secno>15.3.3 </span>Flow content</a></li> <li><a href=#phrasing-content-1><span class=secno>15.3.4 </span>Phrasing content</a></li> <li><a href=#bidirectional-text><span class=secno>15.3.5 </span>Bidirectional text</a></li> <li><a href=#quotes><span class=secno>15.3.6 </span>Quotes</a></li> <li><a href=#sections-and-headings><span class=secno>15.3.7 </span>Sections and headings</a></li> <li><a href=#lists><span class=secno>15.3.8 </span>Lists</a></li> <li><a href=#tables><span class=secno>15.3.9 </span>Tables</a></li> <li><a href=#form-controls><span class=secno>15.3.10 </span>Form controls</a></li> <li><a href=#the-hr-element-0><span class=secno>15.3.11 </span>The <code>hr</code> element</a></li> <li><a href=#the-fieldset-element-0><span class=secno>15.3.12 </span>The <code>fieldset</code> element</a></ol></li> <li><a href=#replaced-elements><span class=secno>15.4 </span>Replaced elements</a> <ol> <li><a href=#embedded-content-2><span class=secno>15.4.1 </span>Embedded content</a></li> <li><a href=#timed-text-tracks-0><span class=secno>15.4.2 </span>Timed text tracks</a> <ol> <li><a href=#webvtt-cue-text-rendering-rules><span class=secno>15.4.2.1 </span>WebVTT cue text rendering rules</a></li> <li><a href=#applying-css-properties-to-webvtt-node-objects><span class=secno>15.4.2.2 </span>Applying CSS properties to WebVTT Node Objects</a></li> <li><a href=#css-extensions><span class=secno>15.4.2.3 </span>CSS extensions</a> <ol> <li><a href="#the-'::cue'-pseudo-element"><span class=secno>15.4.2.3.1 </span>The '::cue' pseudo-element</a></li> <li><a href="#the-':past'-and-':future'-pseudo-classes"><span class=secno>15.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</a></ol></ol></li> <li><a href=#images-0><span class=secno>15.4.3 </span>Images</a></li> <li><a href=#attributes-for-embedded-content-and-images><span class=secno>15.4.4 </span>Attributes for embedded content and images</a></li> <li><a href=#image-maps-0><span class=secno>15.4.5 </span>Image maps</a></li> <li><a href=#toolbars-0><span class=secno>15.4.6 </span>Toolbars</a></ol></li> <li><a href=#bindings><span class=secno>15.5 </span>Bindings</a> <ol> <li><a href=#introduction-18><span class=secno>15.5.1 </span>Introduction</a></li> <li><a href=#the-button-element-0><span class=secno>15.5.2 </span>The <code>button</code> element</a></li> <li><a href=#the-details-element-0><span class=secno>15.5.3 </span>The <code>details</code> element</a></li> <li><a href=#the-input-element-as-a-text-entry-widget><span class=secno>15.5.4 </span>The <code>input</code> element as a text entry widget</a></li> <li><a href=#the-input-element-as-domain-specific-widgets><span class=secno>15.5.5 </span>The <code>input</code> element as domain-specific widgets</a></li> <li><a href=#the-input-element-as-a-range-control><span class=secno>15.5.6 </span>The <code>input</code> element as a range control</a></li> <li><a href=#the-input-element-as-a-color-well><span class=secno>15.5.7 </span>The <code>input</code> element as a color well</a></li> <li><a href=#the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>15.5.8 </span>The <code>input</code> element as a checkbox and radio button widgets</a></li> <li><a href=#the-input-element-as-a-file-upload-control><span class=secno>15.5.9 </span>The <code>input</code> element as a file upload control</a></li> <li><a href=#the-input-element-as-a-button><span class=secno>15.5.10 </span>The <code>input</code> element as a button</a></li> <li><a href=#the-marquee-element-0><span class=secno>15.5.11 </span>The <code>marquee</code> element</a></li> <li><a href=#the-meter-element-0><span class=secno>15.5.12 </span>The <code>meter</code> element</a></li> <li><a href=#the-progress-element-0><span class=secno>15.5.13 </span>The <code>progress</code> element</a></li> <li><a href=#the-select-element-0><span class=secno>15.5.14 </span>The <code>select</code> element</a></li> <li><a href=#the-textarea-element-0><span class=secno>15.5.15 </span>The <code>textarea</code> element</a></li> <li><a href=#the-keygen-element-0><span class=secno>15.5.16 </span>The <code>keygen</code> element</a></ol></li> <li><a href=#frames-and-framesets><span class=secno>15.6 </span>Frames and framesets</a></li> <li><a href=#interactive-media><span class=secno>15.7 </span>Interactive media</a> <ol> <li><a href=#links,-forms,-and-navigation><span class=secno>15.7.1 </span>Links, forms, and navigation</a></li> <li><a href=#the-title-attribute-0><span class=secno>15.7.2 </span>The <code title=attr-title>title</code> attribute</a></li> <li><a href=#editing-hosts><span class=secno>15.7.3 </span>Editing hosts</a></li> <li><a href=#text-rendered-in-native-user-interfaces><span class=secno>15.7.4 </span>Text rendered in native user interfaces</a></ol></li> <li><a href=#print-media><span class=secno>15.8 </span>Print media</a></ol></li> <li><a href=#obsolete><span class=secno>16 </span>Obsolete features</a> <ol> <li><a href=#obsolete-but-conforming-features><span class=secno>16.1 </span>Obsolete but conforming features</a> <ol> <li><a href=#warnings-for-obsolete-but-conforming-features><span class=secno>16.1.1 </span>Warnings for obsolete but conforming features</a></ol></li> <li><a href=#non-conforming-features><span class=secno>16.2 </span>Non-conforming features</a></li> <li><a href=#requirements-for-implementations><span class=secno>16.3 </span>Requirements for implementations</a> <ol> <li><a href=#the-applet-element><span class=secno>16.3.1 </span>The <code>applet</code> element</a></li> <li><a href=#the-marquee-element><span class=secno>16.3.2 </span>The <code>marquee</code> element</a></li> <li><a href=#frames><span class=secno>16.3.3 </span>Frames</a></li> <li><a href=#other-elements,-attributes-and-apis><span class=secno>16.3.4 </span>Other elements, attributes and APIs</a></ol></ol></li> <li><a href=#iana><span class=secno>17 </span>IANA considerations</a> <ol> <li><a href=#text/html><span class=secno>17.1 </span><code>text/html</code></a></li> <li><a href=#multipart/x-mixed-replace><span class=secno>17.2 </span><code>multipart/x-mixed-replace</code></a></li> <li><a href=#application/xhtml+xml><span class=secno>17.3 </span><code>application/xhtml+xml</code></a></li> <li><a href=#application/x-www-form-urlencoded><span class=secno>17.4 </span><code>application/x-www-form-urlencoded</code></a></li> <li><a href=#text/cache-manifest><span class=secno>17.5 </span><code>text/cache-manifest</code></a></li> <li><a href=#text/ping><span class=secno>17.6 </span><code>text/ping</code></a></li> <li><a href=#text/vtt><span class=secno>17.7 </span><code>text/vtt</code></a></li> <li><a href=#application/microdata+json><span class=secno>17.8 </span><code>application/microdata+json</code></a></li> <li><a href=#application/html-peer-connection-data><span class=secno>17.9 </span><code>application/html-peer-connection-data</code></a></li> <li><a href=#ping-from><span class=secno>17.10 </span><code>Ping-From</code></a></li> <li><a href=#ping-to><span class=secno>17.11 </span><code>Ping-To</code></a></li> <li><a href=#web+-scheme-prefix><span class=secno>17.12 </span><code>web+</code> scheme prefix</a></ol></li> <li><a class=no-num href=#index>Index</a> <ol> <li><a class=no-num href=#elements-1>Elements</a></li> <li><a class=no-num href=#element-content-categories>Element content categories</a></li> <li><a class=no-num href=#attributes-1>Attributes</a></li> <li><a class=no-num href=#interfaces>Interfaces</a></ol></li> <li><a class=no-num href=#references>References</a></li> <li><a class=no-num href=#acknowledgements>Acknowledgements</a></ol> <!--end-toc--> <hr><!-- An advisory for those reading this source. --><!-- In this specification, there are a number of comments (like this one) that have three consecutive Xs. These indicate known problems that are expected to be resolved in the future. --><!-- There are also comments with the string "v2", "v3", "v4", or higher numbers. These indicate ideas for future versions of the specification that have not yet been included, usually because it's too early (one has to move slowly lest the browser vendors get overwhelmed with changes). --><!-- Finally, there may also be some known issues in this specification marked with the following punctuation: --><!--!--><!-- These are issues that are known to the editor but cannot be currently fixed because they were introduced by W3C decisions. In theory we could fork the WHATWG copy of the spec, but doing so would introduce normative differences between the W3C and WHATWG specs and these issues are not worth the hassle that this would cause. We'll probably be able to fix them some day, but for now we are living with them. --><h2 id=introduction><span class=secno>1 </span>Introduction</h2> <h3 id=abstract><span class=secno>1.1 </span>Where does this specification fit?</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> <p><img alt="It consists of everything else, above such core technologies as HTTP, URI/IRIs, DOM Core, XML, Unicode, and ECMAScript; below presentation-layer technologies like CSS, XBL, and the NPAPI; and to the side of technologies like Geolocation, SVG, MathML, and XHR." height=359 src=http://images.whatwg.org/abstract.png width=398></p> <h3 id=is-this-html5?><span class=secno>1.2 </span>Is this HTML5?</h3><!--VERSION--> <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, in some cases in conjunction with the W3C and IETF.</p> <p>The WHATWG work is all published in one specification (the one you are reading right now), parts of which are republished in a variety of other forms, including an edition optimized for Web developers (known as <a href=http://developers.whatwg.org/>HTML5</a>). <!-- and one which focuses mainly on the core HTML language --> <!-- (known as the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML Living Standard</a>). --> In addition, two subparts of the specification are republished as separate documents, for ease of reference: <a href=http://www.whatwg.org/specs/web-apps/current-work/webvtt.html>WebVTT</a> and <a href=http://www.whatwg.org/specs/web-apps/current-work/webrtc.html>WebRTC</a>. </p> <p>The W3C also publishes parts of this specification as separate documents. One of these parts is called "HTML5"; it is a subset of this specification (the HTML Living Standard). </p> <!-- <p>The WHATWG specification is a continuously maintained living standard, with maturity managed at a very granular per-section scale, indicated by markers in the left margin; this is intended to model the way in which specifications are approached in practice by implementors and authors alike. The W3C specifications follow a more traditional style, with versioned releases of the specification, and with maturity management being done only at the document level; this means that the W3C specifications have version numbers (e.g. "HTML5") and necessarily go through periods of "feature freeze" where new features are not added, so that the specifications can as a whole reach a more mature state.</p> --> <h6 class=no-toc id=how-do-the-whatwg-and-w3c-specifications-differ?><span class=secno>1.2.1 </span>How do the WHATWG and W3C specifications differ?</h6> <p>The features present in both the WHATWG and W3C specifications are specified using identical text, except for the following (mostly editorial) differences:</p><!--FORK--> <ul><!-- <li>Instead of this section, the W3C HTML specification has a different paragraph explaining the difference between the W3C and WHATWG versions of HTML.</li> --><!-- in the status section --><li>The W3C HTML specification refers to the technology as HTML5, rather than just HTML.</li><!--VERSION--> <li>Examples that use features from HTML5 are not present in the W3C specifications since the W3C specifications are published as HTML4 due to <a href="http://www.w3.org/2005/07/pubrules?uimode=filter&uri=#format">W3C publication policies</a>.</li><!--HTML4POLICE--> <li>The W3C HTML specification defines conformance for documents in a more traditional (version-orientated) way, because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Mar/0574.html>a working group decision from March 2011</a>. This specification, in part driven by its versionless development model, instead uses a conformance definition that more closely models how specifications are used in practice.</li><!--CONFORMANCE--> <li>The W3C HTML specification omits a paragraph of implementation advice because of <a href=http://lists.w3.org/Archives/Public/public-html/2010Jun/0001.html>a working group decision from June 2010</a>.</li> <li>The W3C HTML specification includes a paragraph of advice redundant with the ARIA specifications because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Mar/0244.html>a working group decision from March 2011</a>.</li> <li>The W3C HTML specification gives incomplete advice regarding the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute and instead references other documents on the matter because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Mar/0691.html>a working group decision from March 2011</a>.</li> <li>The W3C HTML specification includes a link to an incomplete document that contradicts this specification because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Feb/0407.html>a working group decision from February 2011</a>.</li><!--HPAAIG--> <li>The W3C HTML specification has different prose regarding the use of tables for layout purposes because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Mar/0245.html>a working group decision from March 2011</a>. In contrast, this specification unambiguously disallows the use of <code><a href=#the-table-element>table</a></code> elements for layout purposes.</li> <li>The W3C HTML specification requires authors who are writing HTML e-mails with images to people they know can see the images (e.g. a wife sending her husband photos of their child) to nonetheless include textual alternatives to those images, because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Apr/0451.html>a working group decision from April 2011</a>.</li> <li>The W3C HTML specification does not state that the <code><a href=#the-img-element>img</a></code> element's <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is its <a href=#fallback-content>fallback content</a>, because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Apr/0452.html>a working group decision from April 2011</a>.</li> <li>The W3C HTML specification is missing a clause that requires conformance checkers to discourage cargo-cult accessibility authoring because of <a href=http://lists.w3.org/Archives/Public/public-html/2011May/0018.html>a working group chair decision from May 2011</a>.</li><!--bug 11557--> <li>The W3C HTML specification is missing some conformance constraints that would make documents misusing <code><a href=#the-canvas-element>canvas</a></code> invalid, because of <a href=http://lists.w3.org/Archives/Public/public-html/2011Jun/0083.html>a working group chair decision from June 2011</a>.</li><!--bug 12906--> <li>The W3C 2D Context specification has a different API for handling focus and selection in the 2D canvas API, because of <a href=http://lists.w3.org/Archives/Public/public-html/2011May/0138.html>a working group chair decision from May 2011</a>.</li> </ul><p>The following sections are only published in the WHATWG specifications and are not currently available anywhere else:</p> <ul><li>The <code><a href=#peerconnection>PeerConnection</a></code> API and related video-conferencing features.</li> <!--PEERCONNECTION--> <li>New hyperlink features: the <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute to make download links and the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute for <a href=#hyperlink-auditing>hyperlink auditing</a>.</li> <!--DOWNLOAD--><!--PING--> <li>The <a href=#webvtt>WebVTT</a> format and some <a href=#text-track>text track</a> API features.</li> <!--TTVTT--> <li>Rules for <a href=#atom>converting HTML to Atom</a>.</li> <!--MD--> <li>The <code title=dom-document-cssElementMap><a href=#dom-document-csselementmap>cssElementMap</a></code> feature for defining <a href=#css-element-reference-identifier title="CSS element reference identifier">CSS element reference identifiers</a>.</li> <!--CSSREF--> <li>An experimental specification of the legacy <code title=dom-find><a href=#dom-find>window.find()</a></code> API.</li><!--FIND--> <li>Some predefined <a href=#mdvocabs>Microdata vocabularies</a>.</li> </ul><!-- <p>Features that are part of the WHATWG HTML Living Standard specification but that are currently published as separate specifications as well, and are not included in the W3C HTML5 specification, consist of:</p> <ul> <li><a href="#2dcontext">Canvas 2D Graphics Context</a>--><!--2DCONTEXT--><!-- <li><a href="#microdata">Microdata</a>--><!--MD--><!-- <li><a href="#crossDocumentMessages">Cross-document messaging</a> (also known as Communications)--><!--POSTMSG--><!-- <li><a href="#channel-messaging">Channel messaging</a> (also known as Communications)--><!--POSTMSG--><!-- </ul> --><!-- <h6 class="no-toc">What else is HTML5?</h6> <p>Features that are not currently published or maintained by the WHATWG but that are sometimes considered to be informally part of "HTML5" include:</p> <ul> <li><a href="http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol">WebSocket protocol</a> <li><a href="http://tools.ietf.org/html/draft-abarth-mime-sniff">Media Type Sniffing</a> <li><a href="http://tools.ietf.org/html/draft-abarth-origin">The Web Origin Concept</a> <li><a href="http://dev.w3.org/geo/api/spec-source.html">Geolocation API</a> <li><a href="http://www.w3.org/TR/SVG/">SVG</a> <li><a href="http://www.w3.org/TR/MathML/">MathML</a> <li><a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/">XMLHttpRequest</a> <li>Parts of <a href="http://www.w3.org/Style/CSS/current-work">CSS</a>.</li> </ul> --><!-- <p>The <a href="#forms">forms</a> part of this specification was previously published separately in a specification known as Web Forms 2. The <a href="#workers">Web Workers</a> section was also previously published as a separate document.</p> --><!-- <p>See also <a href="http://wiki.whatwg.org/wiki/FAQ#What_are_the_various_versions_of_the_spec.3F">the relevant FAQ entry</a>.</p> --><!--VERSION--><h3 id=background><span class=secno>1.3 </span>Background</h3> <p><i>This section is non-normative.</i></p> <p>The World Wide Web's markup language has always been HTML. HTML was primarily designed as a language for semantically describing scientific documents, although its general design and adaptations over the years have enabled it to be used to describe a number of other types of documents.</p> <p>The main area that has not been adequately addressed by HTML is a vague subject referred to as Web Applications. This specification attempts to rectify this, while at the same time updating the HTML specifications to address issues raised in the past few years.</p> <h3 id=audience><span class=secno>1.4 </span>Audience</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<span class=impl>, implementors 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</span>.</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 Core and DOM Events 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</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. For instance 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-1><span class=secno>1.6 </span>History</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. <!-- http://www.w3.org/MarkUp/future/#summary --> 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>Since then, both groups have been working together.</p> <p>A separate document has been published by the W3C HTML working group to document the differences between the HTML specified in this document and the language described in the HTML4 specification. <a href=#refsHTMLDIFF>[HTMLDIFF]</a></p> <h3 id=design-notes><span class=secno>1.7 </span>Design notes</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=serializability-of-script-execution><span class=secno>1.7.1 </span>Serializability of script execution</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 title=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 title="browsing context">browsing contexts</a>.</p> <p class=note>The <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method, in this model, is equivalent to allowing other scripts to run while the calling script is blocked.</p> <h4 id=compliance-with-other-specifications><span class=secno>1.7.2 </span>Compliance with other specifications</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> <h3 id=html-vs-xhtml><span class=secno>1.8 </span>HTML vs XHTML</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><a href=#text/html>text/html</a></code> <a href=#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". <!--VERSION--> </p> <p>The second concrete syntax is the XHTML syntax, which is an application of XML. When a document is transmitted with an <a href=#xml-mime-type>XML MIME type</a>, such as <code><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. This specification defines the latest XHTML syntax, known simply as "XHTML". <!--VERSION--> </p> <p>The DOM, the HTML syntax, and the XHTML 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 XHTML syntax. Similarly, documents that use the <code><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 XHTML syntax. Comments that contain the string "<code title="">--></code>" can only be represented in the DOM, not in the HTML and XHTML syntaxes.</p> <h3 id=structure-of-this-specification><span class=secno>1.9 </span>Structure of this specification</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=#infrastructure>Common infrastructure</a></dt> <dd>The conformance classes, algorithms, definitions, and the common underpinnings of the rest of the specification.</dd> <dt><a href=#dom>Semantics, structure, and APIs of HTML documents</a></dt> <dd>Documents are built from elements. These elements form a tree using the DOM. This section defines the features of this DOM, as well as introducing the features common to all elements, and the concepts used in defining elements.</dd> <dt><a href=#semantics>The elements of HTML</a></dt> <dd>Each element has a predefined meaning, which is explained in this section. Rules for authors on how to use the element<span class=impl>, along with user agent requirements for how to handle each element,</span> are also given.</dd> <!--MD--> <dt><a href=#microdata>Microdata</a></dt> <dd>This specification introduces a mechanism for adding machine-readable annotations to documents, so that tools can extract trees of name-value pairs from the document. This section describes this mechanism<span class=impl> and some algorithms that can be used to convert HTML documents into other formats</span>. This section also defines some Microdata vocabularies for contact information, calendar events, and licensing works. </dd> <!--MD--> <dt><a href=#browsers>Loading Web pages</a></dt> <dd>HTML documents do not exist in a vacuum — this section defines many of the features that affect environments that deal with multiple pages.</dd> <dt><a href=#webappapis>Web application APIs</a></dt> <dd>This section introduces basic features for scripting of applications in HTML.</dd> <dt><a href=#editing>User interaction</a></dt> <dd>HTML documents can provide a number of mechanisms for users to interact with and modify content, which are described in this section.</dd> <dt><a href=#workers>Web workers</a></dt> <dd>This specification defines an API for background threads in JavaScript.</dd> <dt><a href=#webstorage>Web storage</a></dt> <dd>This specification defines a client-side storage mechanism based on name-value pairs.</dd> <!--POSTMSG--> <dt><a href=#comms>The communication APIs</a></dt> <dd>This section describes some mechanisms that applications written in HTML can use to communicate with other applications from different domains running on the same client. It also introduces a server-push event stream mechanism, and a two-way full-duplex socket protocol for scripts. </dd> <!--POSTMSG--> <dt><a href=#syntax>The HTML syntax</a></dt> <dt><a href=#xhtml>The XHTML syntax</a></dt> <dd>All of these features would be for naught if they couldn't be represented in a serialized form and sent to other people, and so these sections define the syntaxes of HTML and XHTML, along with rules for how to parse content using those syntaxes.</dd> </dl><p>There are also some appendices, defining <a href=#rendering>rendering rules</a> for Web browsers and listing <a href=#obsolete>obsolete features</a> and <a href=#iana>IANA considerations</a>.</p> <h4 id=how-to-read-this-specification><span class=secno>1.9.1 </span>How to read this specification</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 title="">foo</code> attribute's value must be a <a href=#valid-integer>valid integer</a>" is a requirement on producers, as it lays out the allowed values; in contrast, the requirement "the <code title="">foo</code> attribute's value must be parsed using the <a href=#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>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</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="idl extract">interface <dfn title="">Example</dfn> { // this is an IDL definition };</pre> <dl class=domintro><dt><var title="">variable</var> = <var title="">object</var> . <code title="">method</code>( [ <var title="">optionalArgument</var> ] )</dt> <dd> <p>This is a note to authors describing the usage of an interface.</p> </dd> </dl><pre class=css>/* this is a CSS fragment */</pre> <p>The defining instance of a term is marked up like <dfn id=x-this title=x-this>this</dfn>. Uses of that term are marked up like <a href=#x-this title=x-this>this</a> or like <i title=x-this><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 title=x-that><code>this</code></dfn>. References to that element, attribute, or API are marked up like <code title=x-that><a href=#x-that>this</a></code>.</p> <p>Other code fragments are marked up <code title="">like this</code>.</p> <p>Variables are marked up like <var title="">this</var>.</p> <p class=impl>This is an implementation requirement.</p> <h3 id=a-quick-introduction-to-html><span class=secno>1.10 </span>A quick introduction to HTML</h3> <p><i>This section is non-normative.</i></p> <p>A basic HTML document looks like this:</p> <pre id=intro-early-example><!DOCTYPE html> <html> <head> <title>Sample page</title> </head> <body> <h1>Sample page</h1> <p>This is a <a href="demo.html">simple</a> sample.</p> <!-- this is a comment --> </body> </html></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 title=syntax-start-tag>start tag</a>, such as "<code title=""><body></code>", and an <a href=#syntax-end-tag title=syntax-end-tag>end tag</a>, such as "<code title=""></body></code>". (Certain start tags and end tags can in certain cases be <a href=#syntax-tag-omission title=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><p>This is <em>very <strong>wrong</em>!</strong></p></pre> <pre><p>This <em>is <strong>correct</strong>.</em></p></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>hyperlink</a>, formed using the <code><a href=#the-a-element>a</a></code> element and its <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute:</p> <pre><a href="demo.html">simple</a></pre> <p><a href=#syntax-attributes title=syntax-attributes>Attributes</a> are placed inside the start tag, and consist of a <a href=#syntax-attribute-name title=syntax-attribute-name>name</a> and a <a href=#syntax-attribute-value title=syntax-attribute-value>value</a>, separated by an "<code title="">=</code>" character. The attribute value can remain <a href=#unquoted>unquoted</a> if it doesn't contain <a href=#space-character title="space character">space characters</a> or any of <code title="">"</code> <code title="">'</code> <code title="">`</code> <code title="">=</code> <code title=""><</code> or <code title="">></code>. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "<code title="">=</code>" character, can be omitted altogether if the value is the empty string.</p> <pre><!-- empty attributes --> <input name=address disabled> <input name=address disabled=""> <!-- attributes with a value --> <input name=address maxlength=200> <input name=address maxlength='200'> <input name=address maxlength="200"></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 DOCTYPE node, elements, text nodes, and comment 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 title="">html</code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-title-element>title</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣</span><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code><ul><li class=t3><code>#text</code>: <span title="">Sample page</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">This is a <!--grammar-check-override--></span><li class=t1><code><a href=#the-a-element>a</a></code> <span class=t2 title=""><code class="attribute name">href</code>="<code class="attribute value">demo.html</code>"</span><ul><li class=t3><code>#text</code>: <span title="">simple</span></ul><li class=t3><code>#text</code>: <span title=""> sample.</span></ul><li class=t3><code>#text</code>: <span title="">⏎␣␣</span><li class=t8><code>#comment</code>: <span title=""> this is a comment </span><li class=t3><code>#text</code>: <span title="">⏎␣⏎</span></ul></ul></ul><p>The <a href=#root-element>root element</a> of this tree is the <code><a href=#the-html-element>html</a></code> element, which is the element always found at the root of HTML documents. It contains two elements, <code><a href=#the-head-element>head</a></code> and <code><a href=#the-body-element>body</a></code>, as well as a text node between them.</p> <p>There are many more text 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 text 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><a href=#the-head-element>head</a></code> start tag ends up being dropped silently, and all the whitespace after the <code><a href=#the-body-element>body</a></code> end tag ends up placed at the end of the <code><a href=#the-body-element>body</a></code>.</p> <p>The <code><a href=#the-head-element>head</a></code> element contains a <code><a href=#the-title-element>title</a></code> element, which itself contains a text node with the text "Sample page". Similarly, the <code><a href=#the-body-element>body</a></code> element contains an <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element, a <code><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><a href=#the-script-element>script</a></code> element or using <a href=#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><a href=#the-output-element>output</a></code> element to say "Hello World":</p> <pre><<a href=#the-form-element>form</a> <a href=#attr-form-name title=attr-form-name>name</a>="main"> Result: <<a href=#the-output-element>output</a> <a href=#attr-fe-name title=attr-fe-name>name</a>="result"></output> <<a href=#the-script-element>script</a>> <a href=#document title=Document>document</a>.<a href=#dom-document-forms title=dom-document-forms>forms</a>.main.<a href=#dom-form-elements title=dom-form-elements>elements</a>.result.<a href=#dom-output-value title=dom-output-value>value</a> = 'Hello World'; </script> </form></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><a href=#the-a-element>a</a></code> element in the tree above) can have its "<code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>" attribute changed in several ways:</p> <pre>var a = <a href=#document title=Document>document</a>.<a href=#dom-document-links title=dom-document-links>links</a>[0]; // obtain the first link in the document a.<a href=#dom-a-href title=dom-a-href>href</a> = 'sample.html'; // change the destination URL of the link a.<a href=#dom-uda-protocol title=dom-uda-protocol>protocol</a> = 'https'; // change just the scheme part of the URL a.setAttribute('href', 'http://example.com/'); // change the content attribute directly</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><!DOCTYPE html> <html> <head> <title>Sample styled page</title> <style> body { background: navy; color: yellow; } </style> </head> <body> <h1>Sample styled page</h1> <p>This page is just a demo.</p> </body> </html></pre> <p>For more details on how to use HTML, authors are encouraged to consult tutorials and guides. Some of the examples included in this specification might also be of use, but the novice author is cautioned that this specification, by necessity, defines the language with a level of detail that might be difficult to understand at first.</p> <h4 id=writing-secure-applications-with-html><span class=secno>1.10.1 </span>Writing secure applications with HTML</h4> <p><i>This section is non-normative.</i></p> <p>When HTML is used to create interactive sites, care needs to be taken to avoid introducing vulnerabilities through which attackers can compromise the integrity of the site itself or of the site's users.</p> <p>A comprehensive study of this matter is beyond the scope of this document, and authors are strongly encouraged to study the matter in more detail. However, this section attempts to provide a quick introduction to some common pitfalls in HTML application development.</p> <p>The security model of the Web is based on the concept of "origins", and correspondingly many of the potential attacks on the Web involve cross-origin actions. <a href=#refsORIGIN>[ORIGIN]</a></p> <dl><dt>Not validating user input</dt> <dt>Cross-site scripting (XSS)</dt> <dt>SQL injection</dt> <dd> <p>When accepting untrusted input, e.g. user-generated content such as text comments, values in URL parameters, messages from third-party sites, etc, it is imperative that the data be validated before use, and properly escaped when displayed. Failing to do this can allow a hostile user to perform a variety of attacks, ranging from the potentially benign, such as providing bogus user information like a negative age, to the serious, such as running scripts every time a user looks at a page that includes the information, potentially propagating the attack in the process, to the catastrophic, such as deleting all data in the server.</p> <p>When writing filters to validate user input, it is imperative that filters always be whitelist-based, allowing known-safe constructs and disallowing all other input. Blacklist-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><ul> <li><a href="message.cgi?say=Hello">Say Hello</a> <li><a href="message.cgi?say=Welcome">Say Welcome</a> <li><a href="message.cgi?say=Kittens">Say Kittens</a> </ul></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>http://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> </dd> <dt>Cross-site request forgery (CSRF)</dt> <dd> <p>If a site allows a user to make form submissions with user-specific side-effects, for example posting messages on a forum under the user's name, making purchases, or applying for a passport, it is important to verify that the request was made by the user intentionally, rather than by another site tricking the user into making the request unknowingly.</p> <p>This problem exists because HTML forms can be submitted to other origins.</p> <p>Sites can prevent such attacks by populating forms with user-specific hidden tokens, or by checking <code title=http-origin>Origin</code> headers on all requests.</p> </dd> <dt>Clickjacking</dt> <dd> <p>A page that provides users with an interface to perform actions that the user might not wish to perform needs to be designed so as to avoid the possibility that users can be tricked into activating the interface.</p> <p>One way that a user could be so tricked is if a hostile site places the victim site in a small <code><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 title=dom-window><a href=#dom-window>window</a></code> object to the value of the <code title=dom-top><a href=#dom-top>top</a></code> attribute).</p> </dd> </dl><h4 id=common-pitfalls-to-avoid-when-using-the-scripting-apis><span class=secno>1.10.2 </span>Common pitfalls to avoid when using the scripting APIs</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 asynchronously and 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>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><a href=#the-img-element>img</a></code> elements and the <code title=event-load>load</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 title=handler-onload><a href=#handler-onload>onload</a></code> handler on an <code><a href=#the-img-element>img</a></code> element to catch the <code title=event-load>load</code> event:</p> <pre><img src="games.png" alt="Games" onload="gamesLogoHasLoaded(event)"></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><script> var img = new Image(); img.src = 'games.png'; img.alt = 'Games'; img.onload = gamesLogoHasLoaded; // img.addEventListener('load', gamesLogoHasLoaded, false); // would work also </script></pre> <p>However, if the author first created the <code><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 title=event-load>load</code> event would be fired in between, leading it to be missed:</p> <pre class=bad><!-- Do not use this style, it has a race condition! --> <img id="games" src="games.png" alt="Games"> <!-- the 'load' event might fire here while the parser is taking a break, in which case you will not see it! --> <script> var img = document.getElementById('games'); img.onload = gamesLogoHasLoaded; // might never fire! </script></pre> </div> <h3 id=conformance-requirements-for-authors><span class=secno>1.11 </span>Conformance requirements for authors</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> <!-- This has led to some questioning the purpose of conformance criteria: if there is no ambiguity in how something will be processed, why disallow it? --> <p>However, even though the processing of invalid content is in most cases well-defined, conformance requirements for documents are still important: in practice, interoperability (the situation in which all implementations process particular content in a reliable and identical or equivalent way) is not the only goal of document conformance requirements. This section details some of the more common reasons for still distinguishing between a conforming document and one with errors.</p> <h4 id=presentational-markup><span class=secno>1.11.1 </span>Presentational markup</h4> <p><i>This section is non-normative.</i></p> <p>The majority of presentational features from previous versions of HTML are no longer allowed. Presentational markup in general has been found to have a number of problems:</p> <dl><dt>The use of presentational elements leads to poorer accessibility</dt> <dd> <p>While it is possible to use presentational markup in a way that provides users of assistive technologies (ATs) with an acceptable experience (e.g. using ARIA), doing so is significantly more difficult than doing so when using semantically-appropriate markup. Furthermore, even using such techniques doesn't help make pages accessible for non-AT non-graphical users, such as users of text-mode browsers.</p> <p>Using media-independent markup, on the other hand, provides an easy way for documents to be authored in such a way that they work for more users (e.g. text browsers).</p> </dd> <dt>Higher cost of maintenance</dt> <dd> <p>It is significantly easier to maintain a site written in such a way that the markup is style-independent. For example, changing the color of a site that uses <code><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> </dd> <dt>Larger document sizes</dt> <dd> <p>Presentational markup tends to be much more redundant, and thus results in larger document sizes.</p> </dd> </dl><p>For those reasons, presentational markup has been removed from HTML in this version. This change should not come as a surprise; HTML4 deprecated presentational markup many years ago and provided a mode (HTML4 Transitional) to help authors move away from presentational markup; later, XHTML 1.1 went further and obsoleted those features altogether.</p> <p>The only remaining presentational markup features in HTML are the <code title=attr-style><a href=#the-style-attribute>style</a></code> attribute and the <code><a href=#the-style-element>style</a></code> element. Use of the <code title=attr-style><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><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><a href=#the-b-element>b</a></code>, <code><a href=#the-i-element>i</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-s-element>s</a></code>, <code><a href=#the-small-element>small</a></code>, and <code><a href=#the-u-element>u</a></code>.</p> <h4 id=syntax-errors><span class=secno>1.11.2 </span>Syntax errors</h4> <p><i>This section is non-normative.</i></p> <p>The syntax of HTML is constrained to avoid a wide variety of problems.</p> <dl><dt>Unintuitive error-handling behavior</dt> <dd> <p>Certain invalid syntax constructs, when parsed, result in DOM trees that are highly unintuitive.</p> <div class=example> <p>For example, the following markup fragment results in a DOM with an <code><a href=#the-hr-element>hr</a></code> element that is an <em>earlier</em> sibling of the corresponding <code><a href=#the-table-element>table</a></code> element:</p> <pre class=bad><table><hr>...</pre> </div> </dd> <dt>Errors with optional error recovery</dt> <dd> <p>To allow user agents to be used in controlled environments without having to implement the more bizarre and convoluted error handling rules, user agents are permitted to fail whenever encountering a <a href=#parse-error>parse error</a>.</p> </dd> <dt>Errors where the error-handling behavior is not compatible with streaming user agents</dt> <dd> <p>Some error-handling behavior, such as the behavior for the <code title=""><table><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> </dd> <dt>Errors that can result in infoset coercion</dt> <dd> <p>When a user agent based on XML is connected to an HTML parser, it is possible that certain invariants that XML enforces, such as comments never containing two consecutive hyphens, 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.</p> </dd> <dt>Errors that result in disproportionally poor performance</dt> <dd> <p>Certain syntax constructs can result in disproportionally 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><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><p><i>He dreamt. <p><i>He dreamt that he ate breakfast. <p><i>Then lunch. <p><i>And finally dinner.</pre> <p>The resulting DOM for this fragment would be:</p> <ul class=domTree><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">He dreamt.</span></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">He dreamt that he ate breakfast.</span></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">Then lunch.</span></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">And finally dinner.</span></ul></ul></ul></ul></ul></ul></div> </dd> <dt>Errors involving fragile syntax constructs</dt> <dd> <p>There are syntax constructs that, for historical reasons, are relatively fragile. To help reduce the number of users who accidentally run into such problems, they are made non-conforming.</p> <div class=example> <p>For example, the parsing of certain named character references in attributes happens even with the closing semicolon being omitted. It is safe to include an ampersand followed by letters that do not form a named character reference, but if the letters are changed to a string that <em>does</em> form a named character reference, they will be interpreted as that character instead.</p> <p>In this fragment, the attribute's value is "<code title="">?bill&ted</code>":</p> <pre class=bad><a href="?bill&ted">Bill and Ted</a></pre> <p>In the following fragment, however, the attribute's value is actually "<code title="">?art©</code>", <em>not</em> the intended "<code title="">?art&copy</code>", because even without the final semicolon, "<code title="">&copy</code>" is handled the same as "<code title="">&copy;</code>" and thus gets interpreted as "<code title="">©</code>":</p> <pre class=bad><a href="?art&copy">Art and Copy</a></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><a href="?bill&ted">Bill and Ted</a> <!-- &ted is ok, since it's not a named character reference --></pre> <pre><a href="?art&amp;copy">Art and Copy</a> <!-- the & has to be escaped, since &copy <em>is</em> a named character reference --></pre> </div> </dd> <dt>Errors involving known interoperability problems in legacy user agents</dt> <dd> <p>Certain syntax constructs are known to cause especially subtle or serious problems in legacy user agents, and are therefore marked as non-conforming to help authors avoid them.</p> <div class=example> <p>For example, this is why the U+0060 GRAVE ACCENT character (`) is not allowed in unquoted attributes. In certain legacy user agents, <!-- namely IE --> 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 href=#no-quirks-mode>no-quirks mode</a>, because the behavior of legacy user agents in <a href=#quirks-mode>quirks mode</a> is often largely undocumented.</p> </div> </dd> <dt>Errors that risk exposing authors to security attacks</dt> <dd> <p>Certain restrictions exist purely to avoid known security problems.</p> <div class=example> <p>For example, the restriction on using UTF-7 exists purely to avoid authors falling prey to a known cross-site-scripting attack using UTF-7.</p> </div> </dd> <dt>Cases where the author's intent is unclear</dt> <dd> <p>Markup where the author's intent is very unclear is often made non-conforming. Correcting these errors early makes later maintenance easier.</p> <div class=example> <p>For example, it is unclear whether the author intended the following to be an <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> heading or an <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> heading:</p> <pre class=bad><h1>Contact details</h2></pre> </div> </dd> <dt>Cases that are likely to be typos</dt> <dd> <p>When a user makes a simple typo, it is helpful if the error can be caught early, as this can save the author a lot of debugging time. This specification therefore usually considers it an error to use element names, attribute names, and so forth, that do not match the names defined in this specification.</p> <div class=example> <p>For example, if the author typed <code><capton></code> instead of <code><caption></code>, this would be flagged as an error and the author could correct the typo immediately.</p> </div> </dd> <dt>Errors that could interfere with new syntax in the future</dt> <dd> <p>In order to allow the language syntax to be extended in the future, certain otherwise harmless features are disallowed.</p> <div class=example> <p>For example, "attributes" in end tags are ignored currently, but they are invalid, in case a future change to the language makes use of that syntax feature without conflicting with already-deployed (and valid!) content.</p> </div> </dd> </dl><p>Some authors find it helpful to be in the practice of always quoting all attributes and always including all optional tags, preferring the consistency derived from such custom over the minor benefits of terseness afforded by making use of the flexibility of the HTML syntax. To aid such authors, conformance checkers can provide modes of operation wherein such conventions are enforced.</p> <h4 id=restrictions-on-content-models-and-on-attribute-values><span class=secno>1.11.3 </span>Restrictions on content models and on attribute values</h4> <p><i>This section is non-normative.</i></p> <p>Beyond the syntax of the language, this specification also places restrictions on how elements and attributes can be specified. These restrictions are present for similar reasons:</p> <dl><dt>Errors involving content with dubious semantics</dt> <dd> <p>To avoid misuse of elements with defined meanings, content models are defined that restrict how elements can be nested when such nestings would be of dubious value.</p> <p class=example>For example, this specification disallows nesting a <code><a href=#the-section-element>section</a></code> element inside a <code><a href=#the-kbd-element>kbd</a></code> element, since it is highly unlikely for an author to indicate that an entire section should be keyed in.</p> </dd> <dt>Errors that involve a conflict in expressed semantics</dt> <dd> <p>Similarly, to draw the author's attention to mistakes in the use of elements, clear contradictions in the semantics expressed are also considered conformance errors.</p> <div class=example> <p>In the fragments below, for example, the semantics are nonsensical: a separator cannot simultaneously be a cell, nor can a radio button be a progress bar.</p> <pre class=bad><hr role="cell"></pre> <pre class=bad><input type=radio role=progressbar></pre> </div> <p class=example>Another example is the restrictions on the content models of the <code><a href=#the-ul-element>ul</a></code> element, which only allows <code><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><a href=#the-ul-element>ul</a></code> element contains something other than an <code><a href=#the-li-element>li</a></code> element, it's not clear what was meant.</p> </dd> <dt>Cases where the default styles are likely to lead to confusion</dt> <dd> <p>Certain elements have default styles or behaviors that make certain combinations likely to lead to confusion. Where these have equivalent alternatives without this problem, the confusing combinations are disallowed.</p> <p class=example>For example, <code><a href=#the-div-element>div</a></code> elements are rendered as block boxes, and <code><a href=#the-span-element>span</a></code> elements as inline boxes. Putting a block box in an inline box is unnecessarily confusing; since either nesting just <code><a href=#the-div-element>div</a></code> elements, or nesting just <code><a href=#the-span-element>span</a></code> elements, or nesting <code><a href=#the-span-element>span</a></code> elements inside <code><a href=#the-div-element>div</a></code> elements all serve the same purpose as nesting a <code><a href=#the-div-element>div</a></code> element in a <code><a href=#the-span-element>span</a></code> element, but only the latter involves a block box in an inline box, the latter combination is disallowed.</p> <p class=example>Another example would be the way <a href=#interactive-content>interactive content</a> cannot be nested. For example, a <code><a href=#the-button-element>button</a></code> element cannot contain a <code><a href=#the-textarea-element>textarea</a></code> element. This is because the default behavior of such nesting interactive elements would be highly confusing to users. Instead of nesting these elements, they can be placed side by side.</p> </dd> <dt>Errors that indicate a likely misunderstanding of the specification</dt> <dd> <p>Sometimes, something is disallowed because allowing it would likely cause author confusion.</p> <p class=example>For example, setting the <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> attribute to the value "<code title="">false</code>" is disallowed, because despite the appearance of meaning that the element is enabled, it in fact means that the element is <em>disabled</em> (what matters for implementations is the presence of the attribute, not its value).</p> </dd> <dt>Errors involving limits that have been imposed merely to simplify the language</dt> <dd> <p>Some conformance errors simplify the language that authors need to learn.</p> <p class=example>For example, the <code><a href=#the-area-element>area</a></code> element's <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute, despite accepting both <code title=attr-area-shape-keyword-circ><a href=#attr-area-shape-keyword-circ>circ</a></code> and <code title=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 title=attr-area-shape-keyword-circ><a href=#attr-area-shape-keyword-circ>circ</a></code> value, so as to simplify tutorials and other learning aids. There would be no benefit to allowing both, but it would cause extra confusion when teaching the language.</p> </dd> <dt>Errors that involve peculiarities of the parser</dt> <dd> <p>Certain elements are parsed in somewhat eccentric ways (typically for historical reasons), and their content model restrictions are intended to avoid exposing the author to these issues.</p> <div class=example> <p>For example, a <code><a href=#the-form-element>form</a></code> element isn't allowed inside <a href=#phrasing-content>phrasing content</a>, because when parsed as HTML, a <code><a href=#the-form-element>form</a></code> element's start tag will imply a <code><a href=#the-p-element>p</a></code> element's end tag. Thus, the following markup results in two <a href=#paragraph title=paragraph>paragraphs</a>, not one:</p> <pre><p>Welcome. <form><label>Name:</label> <input></form></pre> <p>It is parsed exactly like the following:</p> <pre><p>Welcome. </p><form><label>Name:</label> <input></form></pre> </div> </dd> <dt>Errors that would likely result in scripts failing in hard-to-debug ways</dt> <dd> <p>Some errors are intended to help prevent script problems that would be hard to debug.</p> <p class=example>This is why, for instance, it is non-conforming to have two <code title=attr-id><a href=#the-id-attribute>id</a></code> attributes with the same value. Duplicate IDs lead to the wrong element being selected, with sometimes disastrous effects whose cause is hard to determine.</p> </dd> <dt>Errors that waste authoring time</dt> <dd> <p>Some constructs are disallowed because historically they have been the cause of a lot of wasted authoring time, and by encouraging authors to avoid making them, authors can save time in future efforts.</p> <p class=example>For example, a <code><a href=#the-script-element>script</a></code> element's <code title=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><a href=#the-script-element>script</a></code> element when the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is present. This means that authors who are validating their documents are less likely to waste time with this kind of mistake.</p> </dd> <dt>Errors that involve areas that affect authors migrating to and from XHTML</dt> <dd> <p>Some authors like to write files that can be interpreted as both XML and HTML with similar results. Though this practice is discouraged in general due to the myriad of subtle complications involved (especially when involving scripting, styling, or any kind of automated serialization), this specification has a few restrictions intended to at least somewhat mitigate the difficulties. This makes it easier for authors to use this as a transitionary step when migrating between HTML and XHTML.</p> <p class=example>For example, there are somewhat complicated rules surrounding the <code title=attr-lang><a href=#attr-lang>lang</a></code> and <code title=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 title="">xmlns</code> attributes in the HTML serialization, which are intended to ensure that elements in conforming documents end up in the same namespaces whether processed as HTML or XML.</p> </dd> <dt>Errors that involve areas reserved for future expansion</dt> <dd> <p>As with the restrictions on the syntax intended to allow for new syntax in future revisions of the language, some restrictions on the content models of elements and values of attributes are intended to allow for future expansion of the HTML vocabulary.</p> <p class=example>For example, limiting the values of the <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute that start with an U+005F LOW LINE character (_) to only specific predefined values allows new predefined values to be introduced at a future time without conflicting with author-defined values.</p> </dd> <dt>Errors that indicate a mis-use of other specifications</dt> <dd> <p>Certain restrictions are intended to support the restrictions made by other specifications.</p> <p class=example>For example, requiring that attributes that take media queries use only <em>valid</em> media queries reinforces the importance of following the conformance rules of that specification.</p> </dd> </dl><h3 id=recommended-reading><span class=secno>1.12 </span>Recommended reading</h3> <p><i>This section is non-normative.</i></p> <p>The following documents might be of interest to readers of this specification.</p> <dl><dt><cite>Character Model for the World Wide Web 1.0: Fundamentals</cite> <a href=#refsCHARMOD>[CHARMOD]</a></dt> <dd><blockquote><p>This Architectural Specification provides authors of specifications, software developers, and content developers with a common reference for interoperable text manipulation on the World Wide Web, building on the Universal Character Set, defined jointly by the Unicode Standard and ISO/IEC 10646. Topics addressed include use of the terms 'character', 'encoding' and 'string', a reference processing model, choice and identification of character encodings, character escaping, and string indexing.</blockquote></dd> <dt><cite>Unicode Security Considerations</cite> <a href=#refsUTR36>[UTR36]</a></dt> <dd><blockquote><p>Because Unicode contains such a large number of characters and incorporates the varied writing systems of the world, incorrect usage can expose programs or systems to possible security attacks. This is especially important as more and more products are internationalized. This document describes some of the security considerations that programmers, system analysts, standards developers, and users should take into account, and provides specific recommendations to reduce the risk of problems.</blockquote></dd> <dt><cite>Web Content Accessibility Guidelines (WCAG) 2.0</cite> <a href=#refsWCAG>[WCAG]</a></dt> <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></dd> <dt class=impl><cite>Authoring Tool Accessibility Guidelines (ATAG) 2.0</cite> <a href=#refsATAG>[ATAG]</a></dt> <dd class=impl><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></dd> <dt class=impl><cite>User Agent Accessibility Guidelines (UAAG) 2.0</cite> <a href=#refsUAAG>[UAAG]</a></dt> <dd class=impl><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></dd> <dt><cite>Polyglot Markup: HTML-Compatible XHTML Documents</cite> <a href=#refsPOLYGLOT>[POLYGLOT]</a></dt> <dd><blockquote><p>A document that uses polyglot markup is a document that is a stream of bytes that parses into identical document trees (with the exception of the xmlns attribute on the root element) when processed as HTML and when processed as XML. Polyglot markup that meets a well defined set of constraints is interpreted as compatible, regardless of whether they are processed as HTML or as XHTML, per the HTML5 specification. Polyglot markup uses a specific DOCTYPE, namespace declarations, and a specific case — normally lower case but occasionally camel case — for element and attribute names. Polyglot markup uses lower case for certain attribute values. Further constraints include those on empty elements, named entity references, and the use of scripts and style.</blockquote></dd> <!--(the following is not included in the WHATWG spec for quality reasons)--> </dl><h2 id=infrastructure><span class=secno>2 </span>Common infrastructure</h2> <h3 id=terminology><span class=secno>2.1 </span>Terminology</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 title="">content attributes</dfn> for HTML and XML attributes, and <dfn title="">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 title="">object properties</dfn> and <dfn title="">CSS properties</dfn> respectively.</p> <p>Generally, when the specification states that a feature applies to <a href=#syntax>the HTML syntax</a> or <a href=#the-xhtml-syntax>the XHTML 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 XHTML)".</p> <p>This specification uses the term <dfn title="">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><a href=#document>Document</a></code> objects and their descendant DOM trees, and to serialized byte streams using the <a href=#syntax title="the HTML syntax">HTML syntax</a> or <a href=#the-xhtml-syntax title="the XHTML syntax">XHTML syntax</a>, depending on context.</p> <p>In the context of the DOM structures, the terms <a href=#html-documents title="HTML documents">HTML document</a> and <a href=#xml-documents title="XML documents">XML document</a> are used as defined in the DOM Core specification, and refer specifically to two different modes that <code><a href=#document>Document</a></code> objects can find themselves in. <a href=#refsDOMCORE>[DOMCORE]</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><a href=#text/html>text/html</a></code>, and the term XML document refers to resources labeled with an <a href=#xml-mime-type>XML MIME type</a>.</p> <p>The term <dfn id=xhtml-document>XHTML document</dfn> is used to refer to both <code><a href=#document>Document</a></code>s in the <a href=#xml-documents title="XML documents">XML document</a> mode that contains element nodes in the <a href=#html-namespace-0>HTML namespace</a>, and byte streams labeled with an <a href=#xml-mime-type>XML MIME type</a> that contain elements from the <a href=#html-namespace-0>HTML namespace</a>, depending on context.</p> <hr><p>For simplicity, terms such as <dfn title="">shown</dfn>, <dfn title="">displayed</dfn>, and <dfn title="">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> <div class=impl> <p>When an algorithm B says to return to another algorithm A, it implies that A called B. Upon returning to A, the implementation must continue from where it left off in calling B.</p> </div> <!-- should find somewhere more appropriate to put this --> <p>The term "transparent black" refers to the color with red, green, blue, and alpha channels all set to zero.</p> <h4 id=resources><span class=secno>2.1.1 </span>Resources</h4> <p>The specification uses the term <dfn title="">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>A MPEG4 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 and URI specifications, refer to as a <i>representation</i> is referred to in this specification as a <dfn title="">resource</dfn>. <a href=#refsHTTP>[HTTP]</a> <a href=#refsRFC3986>[RFC3986]</a></p> <p>The term <dfn id=mime-type>MIME type</dfn> is used to refer to what is sometimes called an <i>Internet media type</i> in protocol literature. The term <i>media type</i> in this specification is used to refer to the type of media intended for presentation, as used by the CSS specifications. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsMQ>[MQ]</a></p> <p>A string is a <dfn id=valid-mime-type>valid MIME type</dfn> if it matches the <code title="">media-type</code> rule defined in section 3.7 "Media Types" of RFC 2616. In particular, a <a href=#valid-mime-type>valid MIME type</a> may include MIME type parameters. <a href=#refsHTTP>[HTTP]</a></p> <p>A string is a <dfn id=valid-mime-type-with-no-parameters>valid MIME type with no parameters</dfn> if it matches the <code title="">media-type</code> rule defined in section 3.7 "Media Types" of RFC 2616, but does not contain any U+003B SEMICOLON characters (;). In other words, if it consists only of a type and subtype, with no MIME Type parameters. <a href=#refsHTTP>[HTTP]</a></p> <p>The term <dfn id=html-mime-type>HTML MIME type</dfn> is used to refer to the <a href=#mime-type>MIME type</a> <code><a href=#text/html>text/html</a></code>.</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. For CSS resources, only <code title="">@import</code> rules introduce <a href=#critical-subresources>critical subresources</a>; other resources, e.g. fonts or backgrounds, are not.</p> <p>The term <dfn id=data-protocol title="data protocol"><code title="">data:</code> URL</dfn> refers to <a href=#url title=URL>URLs</a> that use the <code title="">data:</code> scheme. <a href=#refsRFC2397>[RFC2397]</a></p> <h4 id=xml><span class=secno>2.1.2 </span>XML</h4> <p id=html-namespace>To ease migration from HTML to XHTML, UAs conforming to this specification will place elements in HTML in the <code>http://www.w3.org/1999/xhtml</code> namespace, at least for the purposes of the DOM and CSS. The term "<dfn id=html-elements>HTML elements</dfn>", when used in this specification, refers to any element in that namespace, and thus refers to both HTML and XHTML elements.</p> <p>Except where otherwise stated, all elements defined or mentioned in this specification are in the <a href=#html-namespace-0>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 class of elements have a given local name and namespace. For example, <code><a href=#the-button-element>button</a></code> elements are elements with the element type <code><a href=#the-button-element>button</a></code>, meaning they have the local name "<code title="">button</code>" and (implicitly as defined above) the <a href=#html-namespace-0>HTML namespace</a>.</p> <p>Attribute names are said to be <dfn id=xml-compatible>XML-compatible</dfn> if they match the <a href=http://www.w3.org/TR/REC-xml/#NT-Name><code title="">Name</code></a> production defined in XML, they contain no U+003A COLON characters (:), and their first three characters are not an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">xml</code>". <a href=#refsXML>[XML]</a></p> <p>The term <dfn id=xml-mime-type>XML MIME type</dfn> is used to refer to the <a href=#mime-type title="MIME type">MIME types</a> <code title="">text/xml</code>, <code title="">application/xml</code>, and any <a href=#mime-type>MIME type</a> whose subtype ends with the four characters "<code title="">+xml</code>". <a href=#refsRFC3023>[RFC3023]</a></p> <h4 id=dom-trees><span class=secno>2.1.3 </span>DOM trees</h4> <p>The <dfn id=root-element-of-a-document-object>root element of a <code>Document</code> object</dfn> is that <code><a href=#document>Document</a></code>'s first element child, if any. If it does not have one then the <code><a href=#document>Document</a></code> has no root element.</p> <p>The term <dfn id=root-element>root element</dfn>, when not referring to a <code><a href=#document>Document</a></code> object's root element, means the furthest ancestor element node of whatever node is being discussed, or the node itself if it has no ancestors. When the node is a part of the document, then the node's <a href=#root-element>root element</a> is indeed the document's root element; however, if the node is not currently part of the document tree, the root element will be an orphaned node.</p> <p>When an element's <a href=#root-element>root element</a> is the <a href=#root-element-of-a-document-object>root element of a <code>Document</code> object</a>, it is said to be <dfn id=in-a-document>in a <code>Document</code></dfn>. An element is said to have been <dfn id=insert-an-element-into-a-document title="insert an element into a document">inserted into a document</dfn> when its <a href=#root-element>root element</a> changes and is now the document's <a href=#root-element>root element</a>. Analogously, an element is said to have been <dfn id=remove-an-element-from-a-document title="remove an element from a document">removed from a document</dfn> when its <a href=#root-element>root element</a> changes from being the document's <a href=#root-element>root element</a> to being another element.</p> <p>A node's <dfn id=home-subtree>home subtree</dfn> is the subtree rooted at that node's <a href=#root-element>root element</a>. When a node is <a href=#in-a-document>in a <code>Document</code></a>, its <a href=#home-subtree>home subtree</a> is that <code><a href=#document>Document</a></code>'s tree.</p> <p>The <code><a href=#document>Document</a></code> of a <code><a href=#node>Node</a></code> (such as an element) is the <code><a href=#document>Document</a></code> that the <code><a href=#node>Node</a></code>'s <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> IDL attribute returns. When a <code><a href=#node>Node</a></code> is <a href=#in-a-document>in a <code>Document</code></a> then that <code><a href=#document>Document</a></code> is always the <code><a href=#node>Node</a></code>'s <code><a href=#document>Document</a></code>, and the <code><a href=#node>Node</a></code>'s <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> IDL attribute thus always returns that <code><a href=#document>Document</a></code>.</p> <p>The <code><a href=#document>Document</a></code> of a content attribute is the <code><a href=#document>Document</a></code> of the attribute's element.</p> <p>The term <dfn id=tree-order>tree order</dfn> means a pre-order, depth-first traversal of DOM nodes involved (through the <code title=dom-Node-parentNode><a href=#dom-node-parentnode>parentNode</a></code>/<code title=dom-Node-childNodes><a href=#dom-node-childnodes>childNodes</a></code> relationship).</p> <p>When it is stated that some element or attribute is <dfn id=ignore title=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. <span class=impl>A user agent must not mutate the DOM in such situations.</span></p> <p>The term <dfn id=text-node>text node</dfn> refers to any <code><a href=#text>Text</a></code> node, including <code><a href=#cdatasection>CDATASection</a></code> nodes; specifically, any <code><a href=#node>Node</a></code> with node type <code title="">TEXT_NODE</code> (3) or <code title="">CDATA_SECTION_NODE</code> (4). <a href=#refsDOMCORE>[DOMCORE]</a></p> <p>A content attribute is said to <dfn title="">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 title="">empty</dfn>, when used of an attribute value, text node, or string, means that the length of the text is zero (i.e. not even containing spaces or control characters).</p> <h4 id=scripting-0><span class=secno>2.1.4 </span>Scripting</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 title="">getting</dfn> when its value is being retrieved (e.g. by author script), and is said to be <dfn title="">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 <span class=impl>must</span> operate on the actual underlying data, not a snapshot of the data.</p> <p>In the contexts of events, the terms <dfn title="">fire</dfn> and <dfn id=concept-event-dispatch title=concept-event-dispatch>dispatch</dfn> are used as defined in the DOM Core specification: firing an event means to create and dispatch it, and dispatching an event means to follow the steps that propagate the event through the tree. The term <dfn id=concept-events-trusted title=concept-events-trusted>trusted event</dfn> is used to refer to events whose <code title=dom-event-isTrusted><a href=#dom-event-istrusted>isTrusted</a></code> attribute is initialized to true. <a href=#refsDOMCORE>[DOMCORE]</a></p> <h4 id=plugins><span class=secno>2.1.5 </span>Plugins</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><a href=#document>Document</a></code> object, but that neither act as <a href=#child-browsing-context title="child browsing context">child browsing contexts</a> of the <code><a href=#document>Document</a></code> nor introduce any <code><a href=#node>Node</a></code> objects to the <code><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> <div class=impl> <p>A user agent must not consider the types <code>text/plain</code> and <code>application/octet-stream</code> as having a registered <a href=#plugin>plugin</a>.</p> <!-- because of the way <object> handles those types, if nothing else (it also doesn't make any sense to have a plugin registered for those types, of course) --> </div> <p class=example>One example of a plugin would be a PDF viewer that is instantiated in a <a href=#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 title=concept-plugin-secure>secured</dfn> if it honors the semantics of the <code title=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><a href=#the-iframe-element>iframe</a></code>.</p> <div class=impl> <p class=warning>Browsers should take extreme care when interacting with external content intended for <a href=#plugin title=plugin>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> </div> <h4 id=character-encodings><span class=secno>2.1.6 </span>Character encodings</h4> <p>The <dfn id=preferred-mime-name>preferred MIME name</dfn> of a character encoding is the name or alias labeled as "preferred MIME name" in the IANA <cite>Character Sets</cite> registry, if there is one, or the encoding's name, if none of the aliases are so labeled. <a href=#refsIANACHARSET>[IANACHARSET]</a></p> <p>An <dfn id=ascii-compatible-character-encoding>ASCII-compatible character encoding</dfn> is a single-byte or variable-length encoding in which the bytes 0x09, 0x0A, 0x0C, 0x0D, 0x20 - 0x22, 0x26, 0x27, 0x2C - 0x3F, 0x41 - 0x5A, and 0x61 - 0x7A<!-- is that list ok? do any character sets we want to support do things outside that range? -->, ignoring bytes that are the second and later bytes of multibyte sequences, all correspond to single-byte sequences that map to the same Unicode characters as those bytes in ANSI_X3.4-1968 (US-ASCII). <a href=#refsRFC1345>[RFC1345]</a></p> <p class=note>This includes such encodings as Shift_JIS, HZ-GB-2312, and variants of ISO-2022, even though it is possible in these encodings for bytes like 0x70 to be part of longer sequences that are unrelated to their interpretation as ASCII. It excludes such encodings as UTF-7, UTF-16, GSM03.38, and EBCDIC variants.</p> <!-- We'll have to change that if anyone comes up with a way to have a document that is valid as two different encodings at once, with different <meta charset> elements applying in each case. --> <p>The term <dfn id=a-utf-16-encoding>a UTF-16 encoding</dfn> refers to any variant of UTF-16: self-describing UTF-16 with a BOM, ambiguous UTF-16 without a BOM, raw UTF-16LE, and raw UTF-16BE. <a href=#refsRFC2781>[RFC2781]</a></p> <p>The term <dfn id=code-unit>code unit</dfn> is used as defined in the Web IDL specification: a 16 bit unsigned integer, the smallest atomic component of a <code>DOMString</code>. (This is a narrower definition than the one used in Unicode.) <a href=#refsWEBIDL>[WEBIDL]</a></p> <p>The term <dfn id=unicode-code-point>Unicode code point</dfn> means a <i title="">Unicode scalar value</i> where possible, and an isolated surrogate code point when not. When a conformance requirement is defined in terms of characters or Unicode code points, a pair of <a href=#code-unit title="code unit">code units</a> consisting of a high surrogate followed by a low surrogate must be treated as the single code point represented by the surrogate pair, but isolated surrogates must each be treated as the single code point with the value of the surrogate. <a href=#refsUNICODE>[UNICODE]</a></p> <p>In this specification, the term <dfn id=character>character</dfn>, when not qualified as <em>Unicode</em> character, is synonymous with the term <a href=#unicode-code-point>Unicode code point</a>.</p> <p>The term <dfn id=unicode-character>Unicode character</dfn> is used to mean a <i title="">Unicode scalar value</i> (i.e. any Unicode code point that is not a surrogate code point). <a href=#refsUNICODE>[UNICODE]</a></p> <p>The <dfn id=code-point-length>code-point length</dfn> of a string is the number of <a href=#code-unit title="code unit">code units</a> in that string.</p> <p class=note>This complexity results from the historical decision to define the DOM API in terms of 16 bit (UTF-16) <a href=#code-unit title="code unit">code units</a>, rather than in terms of <a href=#unicode-character title="Unicode character">Unicode characters</a>.</p> <h3 id=conformance-requirements><span class=secno>2.2 </span>Conformance requirements</h3> <p>All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.</p> <p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. <a href=#refsRFC2119>[RFC2119]</a></p> <div class=impl> <p>Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p> <div class=example> <p>For example, were the spec to say:</p> <pre>To eat a kiwi, the user must: 1. Peel the kiwi. 2. Eat the kiwi flesh.</pre> <p>...it would be equivalent to the following:</p> <pre>To eat a kiwi: 1. The user must peel the kiwi. 2. The user must eat the kiwi flesh.</pre> <p>Here the key word is "must".</p> <p>The former (imperative) style is generally preferred in this specification for stylistic reasons.</p> </div> <p>Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)</p> </div> <div class=impl> <h4 id=conformance-classes><span class=secno>2.2.1 </span>Conformance classes</h4> <p>This specification describes the conformance criteria for <span class=impl>user agents (relevant to implementors) and</span> documents<span class=impl> (relevant to authors and authoring tool implementors)</span>.</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 title="">foobar</code> element", it would imply that documents are not allowed to contain elements named <code title="">foobar</code>.</p> <p class="note impl">There is no implied relationship between document conformance requirements and implementation conformance requirements. User agents are not free to handle non-conformant documents as they please; the processing model described in this specification applies to implementations regardless of the conformity of the input documents.</p> <p>User agents fall into several (overlapping) categories with different conformance requirements.</p> <dl><dt id=interactive>Web browsers and other interactive user agents</dt> <dd> <p>Web browsers that support <a href=#the-xhtml-syntax>the XHTML syntax</a> must process elements and attributes from the <a href=#html-namespace-0>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 XHTML processor would, upon finding an XHTML <code><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><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>the HTML syntax</a> must process documents labeled with an <a href=#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><a href=#the-script-element>script</a></code> element in the example above would still implement the <code><a href=#htmlscriptelement>HTMLScriptElement</a></code> interface.</p> </dd> <dt id=non-interactive>Non-interactive presentation user agents</dt> <dd> <p>User agents that process HTML and XHTML documents purely to render non-interactive versions of them must comply to the same conformance criteria as Web browsers, except that they are exempt from requirements regarding user interaction.</p> <p class=note>Typical examples of non-interactive presentation user agents are printers (static UAs) and overhead displays (dynamic UAs). It is expected that most static non-interactive presentation user agents will also opt to <a href=#non-scripted>lack scripting support</a>.</p> <p class=example>A non-interactive but dynamic presentation UA would still execute scripts, allowing forms to be dynamically submitted, and so forth. However, since the concept of "focus" is irrelevant when the user cannot interact with the document, the UA would not need to support any of the focus-related DOM APIs.</p> </dd> <dt id=renderingUA>Visual user agents that support the suggested default rendering</dt> <dd> <p>User agents, whether interactive or not, may be designated (possibly as a user option) as supporting the suggested default rendering defined by this specification.</p> <p>This is not required. In particular, even user agents that do implement the suggested default rendering are encouraged to offer settings that override this default to improve the experience for the user, e.g. changing the color contrast, using different focus styles, or otherwise making the experience more accessible and usable to the user.</p> <p>User agents that are designated as supporting the suggested default rendering must, while so designated, implement the rules in <a href=#rendering>the rendering section</a> that that section defines as the behavior that user agents are <em>expected</em> to implement.</p> </dd> <dt id=non-scripted>User agents with no scripting support</dt> <dd> <p>Implementations that do not support scripting (or which have their scripting features disabled entirely) are exempt from supporting the events and DOM interfaces mentioned in this specification. For the parts of this specification that are defined in terms of an events model or in terms of the DOM, such user agents must still act as if events and the DOM were supported.</p> <p class=note>Scripting can form an integral part of an application. Web browsers that do not support scripting, or that have scripting disabled, might be unable to fully convey the author's intent.</p> </dd> <dt>Conformance checkers</dt> <dd id=conformance-checkers> <p>Conformance checkers must verify that a document conforms to the applicable conformance criteria described in this specification. Automated conformance checkers are exempt from detecting errors that require interpretation of the author's intent (for example, while a document is non-conforming if the content of a <code><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><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=#browsing-context>browsing context</a> (meaning that no scripts are run, and that the parser's <a href=#scripting-flag>scripting flag</a> is disabled), and should also check that the input document conforms when parsed with a <a href=#browsing-context>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> <!--VERSION--> <div class=note> <p>XML DTDs cannot express all the conformance requirements of this specification. Therefore, a validating XML processor and a DTD cannot constitute a conformance checker. Also, since neither of the two authoring formats defined in this specification are applications of SGML, a validating SGML system cannot constitute a conformance checker either.</p> <p>To put it another way, there are three types of conformance criteria:</p> <ol><li>Criteria that can be expressed in a DTD.</li> <li>Criteria that cannot be expressed by a DTD, but can still be checked by a machine.</li> <li>Criteria that can only be checked by a human.</li> </ol><p>A conformance checker must check for the first two. A simple DTD-based validator only checks for the first class of errors and is therefore not a conforming conformance checker according to this specification.</p> </div> </dd> <dt>Data mining tools</dt> <dd id=data-mining> <p>Applications and tools that process HTML and XHTML 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 title=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> </dd> <dt id=editors>Authoring tools and markup generators</dt> <dd> <p>Authoring tools and markup generators must generate <a href=#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><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 the author of the document or section. 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><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 a section, 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><a href=#the-div-element>div</a></code>, <code><a href=#the-b-element>b</a></code>, <code><a href=#the-i-element>i</a></code>, and <code><a href=#the-span-element>span</a></code> and making liberal use of the <code title=attr-style><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> </dd> </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.</p> <p>For compatibility with existing content and prior specifications, this specification describes two authoring formats: one based on XML (referred to as <a href=#the-xhtml-syntax>the XHTML syntax</a>), and one using a <a href=#writing>custom format</a> inspired by SGML (referred to as <a href=#syntax>the HTML syntax</a>). Implementations must support at least one of these two formats, although supporting both is encouraged.</p> <!--(DOM Core doesn't have entity references <p id="entity-references">The language in this specification assumes that the user agent expands all entity references, and therefore does not include entity reference nodes in the DOM. If user agents do include entity reference nodes in the DOM, then user agents must handle them as if they were fully expanded when implementing this specification. For example, if a requirement talks about an element's child text nodes, then any text nodes that are children of an entity reference that is a child of that element would be used as well. Entity references to unknown entities must be treated as if they contained just an empty text node for the purposes of the algorithms defined in this specification.</p> --><!--ENTITY--> <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> </div> <div class=impl> <h4 id=dependencies><span class=secno>2.2.2 </span>Dependencies</h4> <p>This specification relies on several other underlying specifications.</p> <dl><dt>XML</dt> <dd> <p>Implementations that support <a href=#the-xhtml-syntax>the XHTML syntax</a> 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> </dd> <dt>DOM</dt> <dd> <p>The Document Object Model (DOM) is a representation — a model — of a document and its content. The DOM is not just an API; the conformance criteria of HTML implementations are defined, in this specification, in terms of operations on the DOM. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p>Implementations must support DOM Core and the events defined in DOM Events, because this specification is defined in terms of the DOM, and some of the features are defined as extensions to the DOM Core interfaces. <a href=#refsDOMCORE>[DOMCORE]</a> <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> <p>In particular, the following features are defined in the DOM Core specification: <a href=#refsDOMCORE>[DOMCORE]</a></p> <ul class=brief><li><dfn id=attr><code>Attr</code></dfn> interface</li> <li><dfn id=cdatasection><code>CDATASection</code></dfn> interface</li> <li><dfn id=comment-0><code>Comment</code></dfn> interface</li> <li><dfn id=domimplementation><code>DOMImplementation</code></dfn> interface</li> <li><dfn id=document><code>Document</code></dfn> interface</li> <li><dfn id=documentfragment><code>DocumentFragment</code></dfn> interface</li> <li><dfn id=documenttype><code>DocumentType</code></dfn> interface</li> <li><dfn id=domexception><code>DOMException</code></dfn> interface</li> <li><dfn id=element><code>Element</code></dfn> interface</li> <li><dfn id=node><code>Node</code></dfn> interface</li> <li><dfn id=nodelist><code>NodeList</code></dfn> interface</li> <li><dfn id=processinginstruction><code>ProcessingInstruction</code></dfn> interface</li> <li><dfn id=text><code>Text</code></dfn> interface</li> <li><dfn id=htmlcollection><code>HTMLCollection</code></dfn> interface, and the terms <dfn id=collections>collections</dfn> and <dfn id=represented-by-the-collection>represented by the collection</dfn></li> <li><dfn id=domstringlist><code>DOMStringList</code></dfn> interface</li> <li><dfn id=domtokenlist><code>DOMTokenList</code></dfn> interface</li> <li><dfn id=domsettabletokenlist><code>DOMSettableTokenList</code></dfn> interface</li> <li><dfn id=dom-domimplementation-createdocument title=dom-DOMImplementation-createDocument><code>createDocument()</code></dfn> method</li> <li><dfn id=dom-domimplementation-createhtmldocument title=dom-DOMImplementation-createHTMLDocument><code>createHTMLDocument()</code></dfn> method</li> <li><dfn id=dom-document-createelement title=dom-Document-createElement><code>createElement()</code></dfn> method</li> <li><dfn id=dom-document-createelementns title=dom-Document-createElementNS><code>createElementNS()</code></dfn> method</li> <li><dfn id=dom-document-getelementbyid title=dom-Document-getElementById><code>getElementById()</code></dfn> method</li> <li><dfn id=dom-node-insertbefore title=dom-Node-insertBefore><code>insertBefore()</code></dfn> method</li> <li><dfn id=dom-node-ownerdocument title=dom-Node-ownerDocument><code>ownerDocument</code></dfn> attribute</li> <li><dfn id=dom-node-childnodes title=dom-Node-childNodes><code>childNodes</code></dfn> attribute</li> <li><dfn id=dom-node-localname title=dom-Node-localName><code>localName</code></dfn> attribute</li> <li><dfn id=dom-node-parentnode title=dom-Node-parentNode><code>parentNode</code></dfn> attribute</li> <li><dfn id=dom-node-namespaceuri title=dom-Node-namespaceURI><code>namespaceURI</code></dfn> attribute</li> <li><dfn id=dom-element-tagname title=dom-Element-tagName><code>tagName</code></dfn> attribute</li> <li><dfn id=dom-element-id title=dom-Element-id><code>id</code></dfn> attribute</li> <li><dfn id=textcontent><code>textContent</code></dfn> attribute</li> <li><dfn id=event><code>Event</code></dfn> interface</li> <li><dfn id=eventtarget><code>EventTarget</code></dfn> interface</li> <li><dfn id=eventinit><code>EventInit</code></dfn> dictionary type</li> <li><dfn id=dom-event-target title=dom-Event-target><code>target</code></dfn> attribute</li> <li><dfn id=dom-event-istrusted title=dom-Event-isTrusted><code>isTrusted</code></dfn> attribute</li> <li>The <dfn id=concept-event-type title=concept-event-type>type</dfn> of an event</li> <li>The concept of an <dfn id=concept-event-listener title=concept-event-listener>event listener</dfn> and the <a href=#concept-event-listener title=concept-event-listener>event listeners</a> associated with an <code><a href=#eventtarget>EventTarget</a></code></li> <li>The <dfn id="document's-character-encoding" title="document's character encoding">character encoding</dfn> and <dfn id=concept-document-media-type title=concept-document-media-type>media type</dfn> of a <code><a href=#document>Document</a></code></li> <li>The distinction between <dfn id=xml-documents>XML documents</dfn> and <dfn id=html-documents>HTML documents</dfn></li> <li>The terms <dfn id=quirks-mode>quirks mode</dfn>, <dfn id=limited-quirks-mode>limited-quirks mode</dfn>, and <dfn id=no-quirks-mode>no-quirks mode</dfn></li> <li>The algorithm to <dfn id=concept-node-clone title=concept-node-clone>clone</dfn> a <code><a href=#node>Node</a></code>, and the concept of <dfn id=concept-node-clone-ext title=concept-node-clone-ext>cloning steps</dfn> used by tat algorithm</li> <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> <li>The concept of an element's <dfn id=concept-id title=concept-id>unique identifier (ID)</dfn>.</li> </ul><p>The term <dfn id=throw>throw</dfn> in this specification is used as defined in the DOM Core specification. The following <code><a href=#domexception>DOMException</a></code> types are defined in the DOM Core specification: <a href=#refsDOMCORE>[DOMCORE]</a></p> <ol class=brief><li value=1><dfn id=indexsizeerror><code>IndexSizeError</code></dfn></li> <li value=3><dfn id=hierarchyrequesterror><code>HierarchyRequestError</code></dfn></li> <li value=4><dfn id=wrongdocumenterror><code>WrongDocumentError</code></dfn></li> <li value=5><dfn id=invalidcharactererror><code>InvalidCharacterError</code></dfn></li> <li value=7><dfn id=nomodificationallowederror><code>NoModificationAllowedError</code></dfn></li> <li value=8><dfn id=notfounderror><code>NotFoundError</code></dfn></li> <li value=9><dfn id=notsupportederror><code>NotSupportedError</code></dfn></li> <li value=11><dfn id=invalidstateerror><code>InvalidStateError</code></dfn></li> <li value=12><dfn id=syntaxerror><code>SyntaxError</code></dfn></li> <li value=13><dfn id=invalidmodificationerror><code>InvalidModificationError</code></dfn></li> <li value=14><dfn id=namespaceerror><code>NamespaceError</code></dfn></li> <li value=15><dfn id=invalidaccesserror><code>InvalidAccessError</code></dfn></li> <li value=17><dfn id=typemismatcherror><code>TypeMismatchError</code></dfn></li> <li value=18><dfn id=securityerror><code>SecurityError</code></dfn></li> <li value=19><dfn id=networkerror><code>NetworkError</code></dfn></li> <li value=20><dfn id=aborterror><code>AbortError</code></dfn></li> <li value=21><dfn id=urlmismatcherror><code>URLMismatchError</code></dfn></li> <li value=22><dfn id=quotaexceedederror><code>QuotaExceededError</code></dfn></li> <li value=23><dfn id=timeouterror><code>TimeoutError</code></dfn></li> <li value=24><dfn id=invalidnodetypeerror><code>InvalidNodeTypeError</code></dfn></li> <li value=25><dfn id=datacloneerror><code>DataCloneError</code></dfn></li> </ol><p class=example>For example, to <i>throw a <code><a href=#timeouterror>TimeoutError</a></code> exception</i>, a user agent would construct a <code><a href=#domexception>DOMException</a></code> object whose type was the string "<code title="">TimeoutError</code>" (and whose code was the number 23, for legacy reasons) and actually throw that object as an exception.</p> <p>The following features are defined in the DOM Events specification: <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> <ul class=brief><li><dfn id=uievent><code>UIEvent</code></dfn> interface</li> <li><dfn id=mouseevent><code>MouseEvent</code></dfn> interface</li> <li><dfn id=mouseeventinit><code>MouseEventInit</code></dfn> dictionary type</li> <li><dfn id=event-click title=event-click><code>click</code></dfn> event</li> </ul><p>In addition, user agents must implement the features defined in the DOM Range, DOM Parsing and Serialization specification, HTML Editing APIs, and UndoManager and DOM Transaction specifications that apply to their conformance class. <a href=#refsDOMRANGE>[DOMRANGE]</a> <a href=#refsDOMPARSING>[DOMPARSING]</a> <a href=#refsEDITING>[EDITING]</a> <a href=#refsUNDO>[UNDO]</a> </p> <!-- <p>The following features are defined in the DOM Range specification: <a href="#refsDOMRANGE">[DOMRANGE]</a></p> <ul class="brief"> <li><dfn><code>Range</code></dfn> interface</li> <li><dfn title="dom-Range-deleteContents"><code>deleteContents()</code></dfn> method </li> <li><dfn title="dom-Range-selectNodeContents"><code>selectNodeContents()</code></dfn> method </li> <li><dfn title="dom-Range-setEnd"><code>setEnd()</code></dfn> method </li> <li><dfn title="dom-Range-setStart"><code>setStart()</code></dfn> method </li> <li><dfn title="dom-Range-collapsed"><code>collapsed</code></dfn> attribute </li> <li><dfn title="dom-Range-endContainer"><code>endContainer</code></dfn> attribute </li> <li><dfn title="dom-Range-endOffset"><code>endOffset</code></dfn> attribute </li> <li><dfn title="dom-Range-startContainer"><code>startContainer</code></dfn> attribute </li> <li><dfn title="dom-Range-startOffset"><code>startOffset</code></dfn> attribute </li> </ul> --> <p>The following features are defined in the DOM Parsing and Serialization specification: <a href=#refsDOMPARSING>[DOMPARSING]</a></p> <ul class=brief><li><dfn id=dom-innerhtml title=dom-innerHTML>innerHTML</dfn></li> <li><dfn id=dom-outerhtml title=dom-outerHTML>outerHTML</dfn></li> </ul></dd> <dt>File API</dt> <dd> <p>This specification uses the following interfaces defined in the File API specification: <a href=#refsFILEAPI>[FILEAPI]</a></p> <ul class=brief><li><dfn id=blob><code>Blob</code></dfn></li> <li><dfn id=file><code>File</code></dfn></li> <li><dfn id=filelist><code>FileList</code></dfn></li> </ul></dd> <dt>Web IDL</dt> <dd> <p>The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. <a href=#refsWEBIDL>[WEBIDL]</a></p> <p>The terms <dfn id=supported-property-indices>supported property indices</dfn>, <dfn id=supported-property-names>supported property names</dfn>, <dfn id=determine-the-value-of-an-indexed-property>determine the value of an indexed property</dfn>, <dfn id=determine-the-value-of-a-named-property>determine the value of a named property</dfn>, <dfn id=platform-array-objects>platform array objects</dfn>, and <dfn id=dfn-read-only-array title=dfn-read-only-array>read only</dfn> (when applied to arrays) are used as defined in the WebIDL specification.</p> <p id=float-nan>Except where otherwise specified, if an IDL attribute that is a floating point number type (<code title="">double</code>) is assigned an Infinity or Not-a-Number (NaN) value, a <code><a href=#notsupportederror>NotSupportedError</a></code> exception must be raised.</p> <p>Except where otherwise specified, if a method with an argument that is a floating point number type (<code title="">double</code>) is passed an Infinity or Not-a-Number (NaN) value, a <code><a href=#notsupportederror>NotSupportedError</a></code> exception must be raised.</p> </dd> <dt>Typed Arrays</dt> <dd> <p>The <dfn id=arraybuffer>ArrayBuffer</dfn> interface and underlying concepts from the Typed Array Specification are used for several features in this specification. The <dfn id=uint8clampedarray>Uint8ClampedArray</dfn> interface type is specifically used in the definition of the <code><a href=#the-canvas-element>canvas</a></code> element's 2D API. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p> </dd> <dt>JavaScript</dt> <dd> <p>Some parts of the language described by this specification only support JavaScript as the underlying scripting language. <a href=#refsECMA262>[ECMA262]</a></p> <p class=note>The term "JavaScript" is used to refer to ECMA262, rather than the official term ECMAScript, since the term JavaScript is more widely known. Similarly, the <a href=#mime-type>MIME type</a> used to refer to JavaScript in this specification is <code title="">text/javascript</code>, since that is the most commonly used type, <a href=#willful-violation title="willful violation">despite it being an officially obsoleted type</a> according to RFC 4329. <a href=#refsRFC4329>[RFC4329]</a></p> </dd> <dt>Media Queries</dt> <dd> <p>Implementations must support the Media Queries language. <a href=#refsMQ>[MQ]</a></p> </dd> <dt>URIs, IRIs, IDNA</dt> <dd> <p>Implementations must support the semantics of <a href=#url title=URL>URLs</a> defined in the URI and IRI specifications, as well as the semantics of IDNA domain names defined in the <cite>Internationalizing Domain Names in Applications (IDNA)</cite> specification. <a href=#refsRFC3986>[RFC3986]</a> <a href=#refsRFC3987>[RFC3987]</a> <a href=#refsRFC3490>[RFC3490]</a> </dd> <dt>Cookies</dt> <dd> <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> </ul></dd> <dt>CORS</dt> <dd> <p>The following terms are defined in the CORS specification: <a href=#refsCORS>[CORS]</a></p> <ul class=brief><li><dfn id=cross-origin-request>cross-origin request</dfn> <li><dfn id=cross-origin-request-status>cross-origin request status</dfn> <li><dfn id=custom-request-headers>custom request headers</dfn> <li><dfn id=simple-cross-origin-request>simple cross-origin request</dfn> <li><dfn id=redirect-steps>redirect steps</dfn> <li><dfn id=credential-flag>credential flag</dfn> <li><dfn id=resource-sharing-check>resource sharing check</dfn> </ul></dd> <dt>CSS modules</dt> <dd> <p>While support for CSS as a whole is not required of implementations of this specification (though it is encouraged, at least for Web browsers), some features are defined in terms of specific CSS requirements.</p> <p>In particular, some features require that a string be <dfn id=parsed-as-a-css-color-value>parsed as a CSS <color> value</dfn>. When parsing a CSS value, user agents are required by the CSS specifications to apply some error handling rules. These apply to this specification also. <a href=#refsCSSCOLOR>[CSSCOLOR]</a> <a href=#refsCSS>[CSS]</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 title="">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 title="">rgb(0,0,</code>" (with both a missing parenthesis and a missing "blue" value) cannot be parsed, as closing the open construct does not result in a viable value.</p> <p>The term <dfn id=css-element-reference-identifier>CSS element reference identifier</dfn> is used as defined in the <cite>CSS Image Values and Replaced Content</cite> specification to define the API that declares identifiers for use with the CSS 'element()' function. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p> <p>Similarly, the term <dfn id=provides-a-paint-source>provides a paint source</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>Support for the CSS Object Model is required for implementations that support scripting. 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=linkstyle><code>LinkStyle</code></dfn></li> <li><dfn id=cssstyledeclaration><code>CSSStyleDeclaration</code></dfn></li> <li><dfn id=stylesheet><code>StyleSheet</code></dfn></li> <li><dfn id=dom-linkstyle-sheet title=dom-linkstyle-sheet><code>sheet</code></dfn></li> <li><dfn id=dom-stylesheet-disabled title=dom-stylesheet-disabled><code>disabled</code></dfn></li> <li><dfn id=alternative-style-sheet-sets>Alternative style sheet sets</dfn> and the <dfn id=preferred-style-sheet-set>preferred style sheet set</dfn></li> <li><dfn id=serializing-a-css-value>Serializing a CSS value</dfn></li> <li><dfn id=scroll-an-element-into-view>Scroll an element into view</dfn></li> </ul></dd> <dt>The WebSocket protocol</dt> <dd> <div data-component="WebSocket API (editor: Ian Hickson)"><!--websocket-api--> <p>The following terms are defined in the WebSocket protocol specification: <a href=#refsWSP>[WSP]</a></p> <ul class=brief><li><dfn id=establish-a-websocket-connection>establish a WebSocket connection</dfn> <li><dfn id=the-websocket-connection-is-established>the WebSocket connection is established</dfn> <li><dfn id="validate-the-server's-response">validate the server's response</dfn> <li><dfn id=extensions-in-use>extensions in use</dfn> <li><dfn id=subprotocol-in-use>subprotocol in use</dfn> <li><dfn id=headers-to-send-appropriate-cookies>headers to send appropriate cookies</dfn> <li><dfn id="cookies-set-during-the-server's-opening-handshake">cookies set during the server's opening handshake</dfn> <li><dfn id=a-websocket-message-has-been-received>a WebSocket message has been received</dfn> <li><dfn id=fail-the-websocket-connection>fail the WebSocket connection</dfn> <li><dfn id=close-the-websocket-connection>close the WebSocket connection</dfn> <li><dfn id=start-the-websocket-closing-handshake>start the WebSocket closing handshake</dfn> <li><dfn id=the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</dfn> <li><dfn id=the-websocket-connection-is-closed>the WebSocket connection is closed</dfn> (possibly <i title="">cleanly</i>) <li><dfn id=the-websocket-connection-close-code>the WebSocket connection close code</dfn> <li><dfn id=the-websocket-connection-close-reason>the WebSocket connection close reason</dfn> </ul></div><!--data-component--> </dd> </dl><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 described 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 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><span class=secno>2.2.3 </span>Extensibility</h4> <p>HTML has a wide number of extensibility mechanisms that can be used for adding semantics in a safe manner:</p> <ul><li>Authors can use the <code title=attr-class><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> <li>Authors can include data for inline client-side scripts or server-side site-wide scripts to process using the <code title=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> <li>Authors can use the <code title=meta><a href=#the-meta-element><meta name="" content=""></a></code> mechanism to include page-wide metadata by registering <a href=#concept-meta-extensions title=concept-meta-extensions>extensions to the predefined set of metadata names</a>.</li> <li>Authors can use the <code title=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 title=concept-rel-extensions>extensions to the predefined set of link types</a>. This is also used by microformats.</li> <li>Authors can embed raw data using the <code title=script><a href=#the-script-element><script type=""></a></code> mechanism with a custom type, for further handling by inline or server-side scripts.</li> <li>Authors can create <a href=#plugin title=plugin>plugins</a> and invoke them using the <code><a href=#the-embed-element>embed</a></code> element. This is how Flash works.</li> <li>Authors can extend APIs using the JavaScript prototyping mechanism. This is widely used by script libraries, for instance.</li> <!--MD--> <li>Authors can use the microdata feature (the <code title=attr-itemscope><a href=#attr-itemscope>itemscope=""</a></code> and <code title=attr-itemprop><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.</li> <!--MD--> </ul><div class=impl> <hr><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>If such extensions are nonetheless needed, e.g. for experimental purposes, then vendors are strongly urged to use one of the following extension mechanisms:</p> <p>For markup-level features that can be limited to the XML serialization and need not be supported in the HTML serialization, vendors should use the namespace mechanism to define custom namespaces in which the non-standard elements and attributes are supported.</p> <p>For markup-level features that are intended for use with <a href=#syntax>the HTML syntax</a>, extensions should be limited to new attributes of the form "<code title="">x-<var title="">vendor</var>-<var title="">feature</var></code>", where <var title="">vendor</var> is a short string that identifies the vendor responsible for the extension, and <var title="">feature</var> is the name of the feature. New element names should not be created. Using attributes for such extensions exclusively allows extensions from multiple vendors to co-exist on the same element, which would not be possible with elements. Using the "<code title="">x-<var title="">vendor</var>-<var title="">feature</var></code>" form allows extensions to be made without risk of conflicting with future additions to the specification.</p> <div class=example> <p>For instance, a browser named "FerretBrowser" could use "ferret" as a vendor prefix, while a browser named "Mellblom Browser" could use "mb". If both of these browsers invented extensions that turned elements into scratch-and-sniff areas, an author experimenting with these features could write:</p> <pre><p>This smells of lemons! <span x-ferret-smellovision x-ferret-smellcode="LEM01" x-mb-outputsmell x-mb-smell="lemon juice"></span></p></pre> </div> <p>Attribute names beginning with the two characters "<code title="">x-</code>" are reserved for user agent use and are guaranteed to never be formally added to the HTML language. For flexibility, attributes names containing underscores (the U+005F LOW LINE character) are also reserved for experimental purposes and are guaranteed to never be formally added to the HTML language.</p> <p class=note>Pages that use such attributes are by definition non-conforming.</p> <p>For DOM extensions, e.g. new methods and IDL attributes, the new members should be prefixed by vendor-specific strings to prevent clashes with future versions of this specification.</p> <p>For events, experimental event names should be prefixed with vendor-specific strings.</p> <div class=example> <p>For example, if a user agent called "Pleas<!--e h-->old" were to add an event to indicate when the user is going up in an elevator, it could use the prefix "<code title="">pleasold</code>" and thus name the event "<code title="">pleasoldgoingup</code>", possibly with an event handler attribute named "<code title="">onpleasoldgoingup</code>".</p> </div> <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> <!-- thanks to QA Framework --> <div class=example> <p>For example, while strongly discouraged from doing so, an implementation "Foo Browser" could add a new IDL attribute "<code title="">fooTypeTime</code>" to a control's DOM interface 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 title=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 title=dom-form-elements><a href=#dom-form-elements>elements</a></code> given in this specification.</p> </div> <p>When adding new <a href=#reflect title=reflect>reflecting</a> IDL attributes corresponding to content attributes of the form "<code title="">x-<var title="">vendor</var>-<var title="">feature</var></code>", the IDL attribute should be named "<code title=""><var title="">vendor</var><var title="">Feature</var></code>" (i.e. the "<code title="">x</code>" is dropped from the IDL attribute's name).</p> <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 <!--CONFORMANCE--><!--FORK--> <dfn id=other-applicable-specifications title="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> </div> <h3 id=case-sensitivity-and-string-comparison><span class=secno>2.3 </span>Case-sensitivity and string comparison</h3> <p>Comparing two strings in a <dfn id=case-sensitive>case-sensitive</dfn> manner means comparing them exactly, code point for code point.</p> <p>Comparing two strings in an <dfn id=ascii-case-insensitive>ASCII case-insensitive</dfn> manner means comparing them exactly, code point for code point, except that the characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also match.</p> <p>Comparing two strings in a <dfn id=compatibility-caseless>compatibility caseless</dfn> manner means using the Unicode <i>compatibility caseless match</i> operation to compare the two strings. <a href=#refsUNICODE>[UNICODE]</a></p> <p>Except where otherwise stated, string comparisons must be performed in a <a href=#case-sensitive>case-sensitive</a> manner.</p> <div class=impl> <p><dfn id=converted-to-ascii-uppercase title="converted to ASCII uppercase">Converting a string to ASCII uppercase</dfn> means replacing all characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) with the corresponding characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).</p> <p><dfn id=converted-to-ascii-lowercase title="converted to ASCII lowercase">Converting a string to ASCII lowercase</dfn> means replacing all characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) with the corresponding characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z).</p> </div> <p>A string <var title="">pattern</var> is a <dfn id=prefix-match>prefix match</dfn> for a string <var title="">s</var> when <var title="">pattern</var> is not longer than <var title="">s</var> and truncating <var title="">s</var> to <var title="">pattern</var>'s length leaves the two strings as matches of each other.</p> <div class=impl> <h3 id=utf-8><span class=secno>2.4 </span>UTF-8</h3> <p>When a user agent is required to <dfn id=decoded-as-utf-8,-with-error-handling title="decoded as UTF-8, with error handling">decode a byte string as UTF-8, with error handling</dfn>, it means that the byte stream must be converted to a Unicode string by interpreting it as UTF-8, except that any errors must be handled as described in the following list. Bytes in the following list are represented in hexadecimal. <a href=#refsRFC3629>[RFC3629]</a> <dl class=switch><dt>One byte in the range FE to FF</dt> <dt><a href=#overlong-form title="overlong form">Overlong forms</a> (e.g. F0 80 80 A0)</dt> <dt>One byte in the range C0 to C1, followed by one byte in the range 80 to BF</dt> <!-- overlong ASCII (redundant with the previous line, really, but worth calling out separately as it's especially dangerous to miss this case) --> <dt>One byte in the range F0 to F4, followed by three bytes in the range 80 to BF that represent a code point above U+10FFFF</dt> <dt>One byte in the range F5 to F7, followed by three bytes in the range 80 to BF</dt> <!-- above U+10FFFF --> <dt>One byte in the range F8 to FB, followed by four bytes in the range 80 to BF</dt> <!-- above U+10FFFF --> <dt>One byte in the range FC to FD, followed by five bytes in the range 80 to BF</dt> <!-- above U+10FFFF --> <dt>One byte in the range C0 to FD that is not followed by a byte in the range 80 to BF</dt> <!-- too short --> <dt>One byte in the range E0 to FD, followed by a byte in the range 80 to BF that is not followed by a byte in the range 80 to BF</dt> <!-- too short --> <dt>One byte in the range F0 to FD, followed by two bytes in the range 80 to BF, the last of which is not followed by a byte in the range 80 to BF</dt> <!-- too short --> <dt>One byte in the range F8 to FD, followed by three bytes in the range 80 to BF, the last of which is not followed by a byte in the range 80 to BF</dt> <!-- too short --> <dt>One byte in the range FC to FD, followed by four bytes in the range 80 to BF, the last of which is not followed by a byte in the range 80 to BF</dt> <!-- too short --> <dt>Any byte sequence that represents a code point in the range U+D800 to U+DFFF</dt> <!-- surrogate halves --> <dd>The whole matched sequence must be replaced by a single U+FFFD REPLACEMENT CHARACTER.</dd> <dt>One byte in the range 80 to BF not preceded by a byte in the range 80 to FD</dt> <dt>One byte in the range 80 to BF preceded by a byte that is part of a complete UTF-8 sequence that does not include this byte</dt> <dt>One byte in the range 80 to BF preceded by a byte that is part of a sequence that has been replaced by a U+FFFD REPLACEMENT CHARACTER, either alone or as part of a sequence</dt> <dd>Each such byte must be replaced with a U+FFFD REPLACEMENT CHARACTER.</dd> </dl><p>For the purposes of the above requirements, an <dfn id=overlong-form>overlong form</dfn> in UTF-8 is a sequence that encodes a code point using more bytes than the minimum needed to encode that code point in UTF-8.</p> <p class=example>For example, the byte string "41 98 BA 42 E2 98 43 E2 98 BA E2 98" would be converted to the string "A��B�C☺�".</p> </div> <h3 id=common-microsyntaxes><span class=secno>2.5 </span>Common microsyntaxes</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> <div class=impl> <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> </div> <div class=impl> <h4 id=common-parser-idioms><span class=secno>2.5.1 </span>Common parser idioms</h4> </div> <p>The <dfn id=space-character title="space character">space characters</dfn>, for the purposes of this specification, are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and U+000D CARRIAGE RETURN (CR).</p> <p>The <dfn id=white_space title=White_Space>White_Space characters</dfn> are those that have the Unicode property "White_Space" in the Unicode <code title="">PropList.txt</code> data file. <a href=#refsUNICODE>[UNICODE]</a></p> <p class=note>This should not be confused with the "White_Space" value (abbreviated "WS") of the "Bidi_Class" property in the <code title="">Unicode.txt</code> data file.</p> <div class=impl> <p>The <dfn id=alphanumeric-ascii-characters>alphanumeric ASCII characters</dfn> are those in the ranges U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z.</p> <p>Some of the micro-parsers described below follow the pattern of having an <var title="">input</var> variable that holds the string being parsed, and having a <var title="">position</var> variable pointing at the next character to parse in <var title="">input</var>.</p> <p>For parsers based on this pattern, a step that requires the user agent to <dfn id=collect-a-sequence-of-characters>collect a sequence of characters</dfn> means that the following algorithm must be run, with <var title="">characters</var> being the set of characters that can be collected:</p> <ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same name in the algorithm that invoked these steps.</li> <li><p>Let <var title="">result</var> be the empty string.</li> <li><p>While <var title="">position</var> doesn't point past the end of <var title="">input</var> and the character at <var title="">position</var> is one of the <var title="">characters</var>, append that character to the end of <var title="">result</var> and advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>Return <var title="">result</var>.</li> </ol><p>The step <dfn id=skip-whitespace>skip whitespace</dfn> means that the user agent must <a href=#collect-a-sequence-of-characters>collect a sequence of characters</a> that are <a href=#space-character title="space character">space characters</a>. The step <dfn id=skip-white_space-characters>skip White_Space characters</dfn> means that the user agent must <a href=#collect-a-sequence-of-characters>collect a sequence of characters</a> that are <a href=#white_space>White_Space</a> characters. In both cases, the collected characters are not used. <a href=#refsUNICODE>[UNICODE]</a></p> <p>When a user agent is to <dfn id=strip-line-breaks>strip line breaks</dfn> from a string, the user agent must remove any U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters from that string.</p> <p>When a user agent is to <dfn id=strip-leading-and-trailing-whitespace>strip leading and trailing whitespace</dfn> from a string, the user agent must remove all <a href=#space-character title="space character">space characters</a> that are at the start or end of the string.</p> <p>When a user agent has to <dfn id=strictly-split-a-string>strictly split a string</dfn> on a particular delimiter character <var title="">delimiter</var>, it must use the following algorithm:</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">tokens</var> be a list of tokens, initially empty.</li> <li><p>While <var title="">position</var> is not past the end of <var title="">input</var>:</p> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not the <var title="">delimiter</var> character.</li> <li><p>Add the string collected in the previous step to <var title="">tokens</var>.</li> <li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <!-- skips past the delimiter --> </ol></li> <li><p>Return <var title="">tokens</var>.</li> </ol><p class=note>For the special cases of splitting a string <a href=#split-a-string-on-spaces title="split a string on spaces">on spaces</a> and <a href=#split-a-string-on-spaces title="split a string on spaces">on commas</a>, this algorithm does not apply (those algorithms also perform <a href=#strip-leading-and-trailing-whitespace title="strip leading and trailing whitespace">whitespace trimming</a>).</p> </div> <h4 id=boolean-attributes><span class=secno>2.5.2 </span>Boolean attributes</h4> <p>A number of attributes are <dfn id=boolean-attribute title="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 href=#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 title=attr-input-checked><a href=#attr-input-checked>checked</a></code> and <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> attributes are the boolean attributes.</p> <pre><label><input type=checkbox checked name=cheese disabled> Cheese</label></pre> <p>This could be equivalently written as this: <pre><label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label></pre> <p>You can also mix styles; the following is still equivalent:</p> <pre><label><input type='checkbox' checked name=cheese disabled=""> Cheese</label></pre> </div> <h4 id=keywords-and-enumerated-attributes><span class=secno>2.5.3 </span>Keywords and enumerated attributes</h4> <p>Some attributes are defined as taking one of a finite set of keywords. Such attributes are called <dfn id=enumerated-attribute title="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 <i>invalid value default</i>, the second is the <i>missing value default</i>.</p> <p>If an enumerated attribute is specified, the attribute's value must be an <a href=#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 href=#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>invalid value default</i>, then the attribute represents that state. Otherwise, if the attribute value matches none of the keywords but there is a <i>missing value default</i> state defined, then <em>that</em> is the state represented by the attribute. Otherwise, there is no default, and invalid values must be ignored.</p> <p>When the attribute is <em>not</em> specified, if there is a <i>missing value default</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.5.4 </span>Numbers</h4> <h5 id=signed-integers><span class=secno>2.5.4.1 </span>Signed integers</h5> <p>A string is a <dfn id=valid-integer>valid integer</dfn> if it consists of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), optionally prefixed with a U+002D HYPHEN-MINUS character (-).</p> <p>A <a href=#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>valid integer</a> <em>with</em> a U+002D HYPHEN-MINUS (-) prefix represents the number represented in base ten by the string of digits that follows the U+002D HYPHEN-MINUS, subtracted from zero.</p> <div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">sign</var> have the value "positive".</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> <li> <p>If the character indicated by <var title="">position</var> (the first character) is a U+002D HYPHEN-MINUS character (-):</p> <ol><li>Let <var title="">sign</var> be "negative".</li> <li>Advance <var title="">position</var> to the next character.</li> <li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> </ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS SIGN character (+):</p> <ol><li>Advance <var title="">position</var> to the next character. (The "<code title="">+</code>" is ignored, but it is not conforming.)</li> <li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> </ol></li> <li><p>If the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then return an error.</li> <!-- Ok. At this point we know we have a number. It might have trailing garbage which we'll ignore, but it's a number, and we won't return an error. --> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the resulting sequence as a base-ten integer. Let <var title="">value</var> be that integer.</li> <li><p>If <var title="">sign</var> is "positive", return <var title="">value</var>, otherwise return the result of subtracting <var title="">value</var> from zero.</li> </ol></div> <h5 id=non-negative-integers><span class=secno>2.5.4.2 </span>Non-negative integers</h5> <p>A string is a <dfn id=valid-non-negative-integer>valid non-negative integer</dfn> if it consists of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p> <p>A <a href=#valid-non-negative-integer>valid non-negative integer</a> represents the number that is represented in base ten by that string of digits.</p> <div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">value</var> be the result of parsing <var title="">input</var> using the <a href=#rules-for-parsing-integers>rules for parsing integers</a>.</li> <li><p>If <var title="">value</var> is an error, return an error.</li> <li><p>If <var title="">value</var> is less than zero, return an error.</li> <li><p>Return <var title="">value</var>.</li> </ol><!-- Implications: A leading + is ignored. A leading - is ignored if the value is zero. --></div> <h5 id=floating-point-numbers><span class=secno>2.5.4.3 </span>Floating-point numbers</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> <li>One or both of the following, in the given order: <ol><li>A series of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li> <ol><li>A single U+002E FULL STOP character (.).</li> <li>A series of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol></li> </ol></li> <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> <li>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character (+).</li> <li>A series of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol></li> </ol><p>A <a href=#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 title="valid floating point number">valid floating point numbers</a>.</p> <div class=impl> <p>The <dfn id=best-representation-of-the-number-as-a-floating-point-number title="best representation of the number as a floating point number">best representation of the number <var title="">n</var> as a floating point number</dfn> is the string obtained from applying the JavaScript operator ToString to <var title="">n</var>. The JavaScript operator ToString is not uniquely determined. When there are multiple possible strings that could be obtained from the JavaScript operator ToString 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>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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">value</var> have the value 1.</li> <li><p>Let <var title="">divisor</var> have the value 1.</li> <li><p>Let <var title="">exponent</var> have the value 1.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> <li> <p>If the character indicated by <var title="">position</var> is a U+002D HYPHEN-MINUS character (-):</p> <ol><li>Change <var title="">value</var> and <var title="">divisor</var> to −1.</li> <li>Advance <var title="">position</var> to the next character.</li> <li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> </ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS SIGN character (+):</p> <ol><li>Advance <var title="">position</var> to the next character. (The "<code title="">+</code>" is ignored, but it is not conforming.)</li> <li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> </ol></li> <li><p>If the character indicated by <var title="">position</var> is a U+002E FULL STOP (.), and that is not the last character in <var title="">input</var>, and the character after the character indicated by <var title="">position</var> is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then set <var title="">value</var> to zero and jump to the step labeled <i>fraction</i>.</p> <!-- we have to check there's a number so that ".e1" fails to parse but ".0" does not --> <li><p>If the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then return an error.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the resulting sequence as a base-ten integer. Multiply <var title="">value</var> by that integer.</li> <li>If <var title="">position</var> is past the end of <var title="">input</var>, jump to the step labeled <i>conversion</i>.</li> <li><p><i>Fraction</i>: If the character indicated by <var title="">position</var> is a U+002E FULL STOP (.), run these substeps:</p> <ol><li><p>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), 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> <li><p>If the character indicated by <var title="">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 title="">divisor</var> by ten.</li> <li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9) and divided by <var title="">divisor</var>, to <var title="">value</var>.</li> <li><p>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>conversion</i>.</li> <li><p>If the character indicated by <var title="">position</var> is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), jump back to the step labeled <i>fraction loop</i> in these substeps.</li> </ol></li> <li><p>If the character indicated by <var title="">position</var> is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), run these substeps:</p> <ol><li><p>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>conversion</i>.</li> <li> <p>If the character indicated by <var title="">position</var> is a U+002D HYPHEN-MINUS character (-):</p> <ol><li>Change <var title="">exponent</var> to −1.</li> <li>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>conversion</i>.</li> </ol><p>Otherwise, if the character indicated by <var title="">position</var> is a U+002B PLUS SIGN character (+):</p> <ol><li>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>conversion</i>.</li> </ol></li> <li><p>If the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled <i>conversion</i>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the resulting sequence as a base-ten integer. Multiply <var title="">exponent</var> by that integer.</li> <li><p>Multiply <var title="">value</var> by ten raised to the <var title="">exponent</var>th power.</li> </ol></li> <li><p><i>Conversion</i>: Let <var title="">S</var> be the set of finite IEEE 754 double-precision floating point values except −0, but with two special values added: 2<sup title="">1024</sup> and −2<sup title="">1024</sup>.</li> <li><p>Let <var title="">rounded-value</var> be the number in <var title="">S</var> that is closest to <var title="">value</var>, selecting the number with an even significand if there are two equally close values. (The two special values 2<sup title="">1024</sup> and −2<sup title="">1024</sup> are considered to have even significands for this purpose.)</li> <li><p>If <var title="">rounded-value</var> is 2<sup title="">1024</sup> or −2<sup title="">1024</sup>, return an error.</li> <li><p>Return <var title="">rounded-value</var>.</li> </ol></div> <div class=impl> <h5 id=percentages-and-dimensions><span class=secno>2.5.4.4 </span>Percentages and lengths</h5> <!--(percentages are not used in valid html anymore) <p>A string is a <dfn>valid dimension value</dfn> if it consists of a character in the range U+0031 DIGIT ONE (1) to U+0039 DIGIT NINE (9), optionally followed by zero of more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), optionally followed by a U+002E FULL STOP character (.) and one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and optionally suffixed by a U+0025 PERCENT SIGN character (%).</p> <p>A <span>valid dimension value</span> represents the number that is represented in base ten by that string of digits, optionally with a fractional component. If the U+0025 PERCENT SIGN is present, then the dimension is a percentage; otherwise, it is a length.</p> <p class="note">For historical reasons, percentanges and lengths less than 1.0 cannot be represented as <span title="valid dimension value">valid dimension values</span>.</p> --> <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 1.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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> <li><p>If the character indicated by <var title="">position</var> is a U+002B PLUS SIGN character (+), advance <var title="">position</var> to the next character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are U+0030 DIGIT ZERO (0) characters, and discard them.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li> <li><p>If the character indicated by <var title="">position</var> is not one of U+0031 DIGIT ONE (1) to U+0039 DIGIT NINE (9), then return an error.</li> <!-- Ok. At this point we know we have a number. It might have trailing garbage which we'll ignore, but it's a number, and we won't return an error. --> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the resulting sequence as a base-ten integer. Let <var title="">value</var> be that number.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a length.</li> <li> <p>If the character indicated by <var title="">position</var> is a U+002E FULL STOP character (.):</p> <ol><li><p>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then return <var title="">value</var> as a length.</li> <li><p>Let <var title="">divisor</var> have the value 1.</li> <li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var> by ten.</li> <li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9) and divided by <var title="">divisor</var>, to <var title="">value</var>.</li> <li><p>Advance <var title="">position</var> to the next character.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return <var title="">value</var> as a length.</li> <li><p>If the character indicated by <var title="">position</var> is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return to the step labeled <i>fraction loop</i> in these substeps.</li> </ol></li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a length.</li> <li><p>If the character indicated by <var title="">position</var> is a U+0025 PERCENT SIGN character (%), return <var title="">value</var> as a percentage.</li> <li><p>Return <var title="">value</var> as a length.</li> </ol></div> <h5 id=lists-of-integers><span class=secno>2.5.4.5 </span>Lists of integers</h5> <p>A <dfn id=valid-list-of-integers>valid list of integers</dfn> is a number of <a href=#valid-integer title="valid integer">valid integers</a> separated by U+002C COMMA characters, with no other characters (e.g. no <a href=#space-character title="space character">space characters</a>). In addition, there might be restrictions on the number of integers that can be given, or on the range of values allowed.</p> <div class=impl> <p>The <dfn id=rules-for-parsing-a-list-of-integers>rules for parsing a list of integers</dfn> are as follows:</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">numbers</var> be an initially empty list of integers. This list will be the result of this algorithm.</li> <li><p>If there is a character in the string <var title="">input</var> at position <var title="">position</var>, and it is either a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON character, then advance <var title="">position</var> to the next character in <var title="">input</var>, or to beyond the end of the string if there are no more characters.</li> <li><p>If <var title="">position</var> points to beyond the end of <var title="">input</var>, return <var title="">numbers</var> and abort.</li> <li><p>If the character in the string <var title="">input</var> at position <var title="">position</var> is a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON character, then return to step 4.</li> <li><p>Let <var title="">negated</var> be false.</li> <li><p>Let <var title="">value</var> be 0.</li> <li><p>Let <var title="">started</var> be false. This variable is set to true when the parser sees a number or a U+002D HYPHEN-MINUS character (-).</li> <li><p>Let <var title="">got number</var> be false. This variable is set to true when the parser sees a number.</li> <li><p>Let <var title="">finished</var> be false. This variable is set to true to switch parser into a mode where it ignores characters until the next separator.</li> <li><p>Let <var title="">bogus</var> be false.</li> <li><p><i>Parser</i>: If the character in the string <var title="">input</var> at position <var title="">position</var> is:</p> <dl class=switch><dt>A U+002D HYPHEN-MINUS character</dt> <dd> <p>Follow these substeps:</p> <ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li> <li>If <var title="">finished</var> is true, skip to the next step in the overall set of steps.</li> <li>If <var title="">started</var> is true, let <var title="">negated</var> be false.</li> <li>Otherwise, if <var title="">started</var> is false and if <var title="">bogus</var> is false, let <var title="">negated</var> be true.</li> <li>Let <var title="">started</var> be true.</li> </ol></dd> <dt>A character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9)</dt> <dd> <p>Follow these substeps:</p> <ol><li>If <var title="">finished</var> is true, skip to the next step in the overall set of steps.</li> <li>Multiply <var title="">value</var> by ten.</li> <li>Add the value of the digit, interpreted in base ten, to <var title="">value</var>.</li> <li>Let <var title="">started</var> be true.</li> <li>Let <var title="">got number</var> be true.</li> </ol></dd> <dt>A U+0020 SPACE character</dt> <dt>A U+002C COMMA character</dt> <dt>A U+003B SEMICOLON character</dt> <dd> <p>Follow these substeps:</p> <ol><li>If <var title="">got number</var> is false, return the <var title="">numbers</var> list and abort. This happens if an entry in the list has no digits, as in "<code title="">1,2,x,4</code>".</li> <li>If <var title="">negated</var> is true, then negate <var title="">value</var>.</li> <li>Append <var title="">value</var> to the <var title="">numbers</var> list.</li> <li>Jump to step 4 in the overall set of steps.</li> </ol></dd> <!-- <dt>A U+002E FULL STOP character</dt> --> <dt>A character in the range U+0001 to U+001F, <!-- space --> U+0021 to U+002B, <!-- comma --> U+002D to U+002F, <!-- digits --> U+003A, <!-- semicolon --> U+003C to U+0040, <!-- a-z --> U+005B to U+0060, <!-- A-Z --> U+007b to U+007F (i.e. any other non-alphabetic ASCII character)</dt> <!-- Test: http://www.hixie.ch/tests/adhoc/html/flow/image-maps/004-demo.html IE6 on Wine treats the following characters like this also: U+1-U+1f, U+21-U+2b, U+2d-U+2f, U+3a, U+3c-U+40, U+5b-U+60, U+7b-U+82, U+84-U+89, U+8b, U+8d, U+8f-U+99, U+9b, U+9d, U+a0-U+bf, U+d7, U+f7, U+1f6-U+1f9, U+218-U+24f, U+2a9-U+385, U+387, U+38b, U+38d, U+3a2, U+3cf, U+3d7-U+3d9, U+3db, U+3dd, U+3df, U+3e1, U+3f4-U+400, U+40d, U+450, U+45d, U+482-U+48f, U+4c5-U+4c6, U+4c9-U+4ca, U+4cd-U+4cf, U+4ec-U+4ed, U+4f6-U+4f7, U+4fa-U+530, U+557-U+560, U+588-U+5cf, U+5eb-U+5ef, U+5f3-U+620, U+63b-U+640, U+64b-U+670, U+6b8-U+6b9, U+6bf, U+6cf, U+6d4, U+6d6-U+904, U+93a-U+957, U+962-U+984, U+98d-U+98e, U+991-U+992, U+9a9, U+9b1, U+9b3-U+9b5, U+9ba-U+9db, U+9de, U+9e2-U+9ef, U+9f2-U+a04, U+a0b-U+a0e, U+a11-U+a12, U+a29, U+a31, U+a34, U+a37, U+a3a-U+a58, U+a5d, U+a5f-U+a84, U+a8c, U+a8e, U+a92, U+aa9, U+ab1, U+ab4, U+aba-U+adf, U+ae1-U+b04, U+b0d-U+b0e, U+b11-U+b12, U+b29, U+b31, U+b34-U+b35, U+b3a-U+b5b, U+b5e, U+b62-U+b84, U+b8b-U+b8d, U+b91, U+b96-U+b98, U+b9b, U+b9d, U+ba0-U+ba2, U+ba5-U+ba7, U+bab-U+bad, U+bb6, U+bba-U+c04, U+c0d, U+c11, U+c29, U+c34, U+c3a-U+c5f, U+c62-U+c84, U+c8d, U+c91, U+ca9, U+cb4, U+cba-U+cdd, U+cdf, U+ce2-U+d04, U+d0d, U+d11, U+d29, U+d3a-U+d5f, U+d62-U+e00, U+e2f, U+e31, U+e34-U+e3f, U+e46-U+e80, U+e83, U+e85-U+e86, U+e89, U+e8b-U+e8c, U+e8e-U+e93, U+e98, U+ea0, U+ea4, U+ea6, U+ea8-U+ea9, U+eac, U+eaf-U+edb, U+ede-U+109f, U+10c6-U+10cf, U+10f7-U+10ff, U+115a-U+115e, U+11a3-U+11a7, U+11fa-U+1dff, U+1e9b-U+1e9f, U+1efa-U+1eff, U+1f16-U+1f17, U+1f1e-U+1f1f, U+1f46-U+1f47, U+1f4e-U+1f4f, U+1f58, U+1f5a, U+1f5c, U+1f5e, U+1f7e-U+1f7f, U+1fb5, U+1fbd-U+1fc1, U+1fc5, U+1fcd-U+1fcf, U+1fd4-U+1fd5, U+1fdc-U+1fdf, U+1fed-U+1ff1, U+1ff5, U+1ffd-U+249b, U+24ea-U+3004, U+3006-U+3040, U+3095-U+309a, U+309f-U+30a0, U+30fb, U+30ff-U+3104, U+312d-U+3130, U+318f-U+4dff, U+9fa6-U+abff, U+d7a4-U+d7ff, U+e000-U+f8ff, U+fa2e-U+faff, U+fb07-U+fb12, U+fb18-U+fb1e, U+fb37, U+fb3d, U+fb3f, U+fb42, U+fb45, U+fbb2-U+fbd2, U+fbe9, U+fce1, U+fd3e-U+fd4f, U+fd90-U+fd91, U+fdc8-U+fdef, U+fdfc-U+fe7f, U+fefd-U+ff20, U+ff3b-U+ff40, U+ff5b-U+ff65, U+ffa0, U+ffbf-U+ffc1, U+ffc8-U+ffc9, U+ffd0-U+ffd1, U+ffd8-U+ffd9, U+ffdd-U+ffff IE7 on Win2003 treats the following characters like this also instead: U+1-U+1f, U+21-U+2b, U+2d-U+2f, U+3a, U+3c-U+40, U+5b-U+60, U+7b-U+82, U+84-U+89, U+8b, U+8d, U+8f-U+99, U+9b, U+9d, U+a0-U+a9, U+ab-U+b4, U+b6-U+b9, U+bb-U+bf, U+d7, U+f7, U+220-U+221, U+234-U+24f, U+2ae-U+2af, U+2b9-U+2ba, U+2c2-U+2df, U+2e5-U+2ed, U+2ef-U+344, U+346-U+379, U+37b-U+385, U+387, U+38b, U+38d, U+3a2, U+3cf, U+3d8-U+3d9, U+3f4-U+3ff, U+482-U+48b, U+4c5-U+4c6, U+4c9-U+4ca, U+4cd-U+4cf, U+4f6-U+4f7, U+4fa-U+530, U+557-U+558, U+55a-U+560, U+588-U+5cf, U+5eb-U+5ef, U+5f3-U+620, U+63b-U+640, U+656-U+66f, U+6d4, U+6dd-U+6e0, U+6e9-U+6ec, U+6ee-U+6f9, U+6fd-U+70f, U+72d-U+72f, U+740-U+77f, U+7b1-U+900, U+904, U+93a-U+93c, U+94d - U+94f, U+951-U+957, U+964-U+980, U+984, U+98d-U+98e, U+991-U+992, U+9a9, U+9b1, U+9b3-U+9b5, U+9ba-U+9bd, U+9c5-U+9c6, U+9c9-U+9ca, U+9cd-U+9d6, U+9d8-U+9db, U+9de, U+9e4-U+9ef, U+9f2-U+a01, U+a03-U+a04, U+a0b-U+a0e, U+a11-U+a12, U+a29, U+a31, U+a34, U+a37, U+a3a-U+a3d, U+a43-U+a46, U+a49-U+a4a, U+a4d-U+a58, U+a5d, U+a5f-U+a6f, U+a75-U+a80, U+a84, U+a8c, U+a8e, U+a92, U+aa9, U+ab1, U+ab4, U+aba-U+abc, U+ac6, U+aca, U+acd-U+acf, U+ad1-U+adf, U+ae1-U+b00, U+b04, U+b0d-U+b0e, U+b11-U+b12, U+b29, U+b31, U+b34-U+b35, U+b3a-U+b3c, U+b44-U+b46, U+b49 - U+b4a, U+b4d-U+b55, U+b58-U+b5b, U+b5e, U+b62-U+b81, U+b84, U+b8b-U+b8d, U+b91, U+b96-U+b98, U+b9b, U+b9d, U+ba0 - U+ba2, U+ba5-U+ba7, U+bab-U+bad, U+bb6, U+bba-U+bbd, U+bc3-U+bc5, U+bc9, U+bcd-U+bd6, U+bd8-U+c00, U+c04, U+c0d, U+c11, U+c29, U+c34, U+c3a-U+c3d, U+c45, U+c49, U+c4d-U+c54, U+c57-U+c5f, U+c62-U+c81, U+c84, U+c8d, U+c91, U+ca9, U+cb4, U+cba-U+cbd, U+cc5, U+cc9, U+ccd-U+cd4, U+cd7-U+cdd, U+cdf, U+ce2-U+d01, U+d04, U+d0d, U+d11, U+d29, U+d3a-U+d3d, U+d44-U+d45, U+d49, U+d4d-U+d56, U+d58-U+d5f, U+d62-U+d81, U+d84, U+d97-U+d99, U+db2, U+dbc, U+dbe - U+dbf, U+dc7-U+dce, U+dd5, U+dd7, U+de0-U+df1, U+df4-U+e00, U+e3b-U+e3f, U+e4f-U+e80, U+e83, U+e85-U+e86, U+e89, U+e8b-U+e8c, U+e8e-U+e93, U+e98, U+ea0, U+ea4, U+ea6, U+ea8-U+ea9, U+eac, U+eba, U+ebe-U+ebf, U+ec5-U+ecc, U+ece-U+edb, U+ede-U+eff, U+f01-U+f3f, U+f48, U+f6b-U+f70, U+f82-U+f87, U+f8c-U+f8f, U+f98, U+fbd-U+fff, U+1022, U+1028, U+102b, U+1033-U+1035, U+1037, U+1039-U+104f, U+105a-U+109f, U+10c6-U+10cf, U+10f7-U+10ff, U+115a - U+115e, U+11a3-U+11a7, U+11fa-U+11ff, U+1207, U+1247, U+1249, U+124e-U+124f, U+1257, U+1259, U+125e-U+125f, U+1287, U+1289, U+128e-U+128f, U+12af, U+12b1, U+12b6-U+12b7, U+12bf, U+12c1, U+12c6-U+12c7, U+12cf, U+12d7, U+12ef, U+130f, U+1311, U+1316-U+1317, U+131f, U+1347, U+135b-U+139f, U+13f5-U+1400, U+166d-U+166e, U+1677-U+1680, U+169b - U+169f, U+16eb-U+177f, U+17c9-U+181f, U+1843, U+1878-U+187f, U+18aa-U+1dff, U+1e9c-U+1e9f, U+1efa-U+1eff, U+1f16-U+1f17, U+1f1e-U+1f1f, U+1f46-U+1f47, U+1f4e-U+1f4f, U+1f58, U+1f5a, U+1f5c, U+1f5e, U+1f7e-U+1f7f, U+1fb5, U+1fbd, U+1fbf-U+1fc1, U+1fc5, U+1fcd-U+1fcf, U+1fd4-U+1fd5, U+1fdc-U+1fdf, U+1fed-U+1ff1, U+1ff5, U+1ffd-U+207e, U+2080-U+2101, U+2103-U+2106, U+2108-U+2109, U+2114, U+2116-U+2118, U+211e-U+2123, U+2125, U+2127, U+2129, U+212e, U+2132, U+213a-U+215f, U+2184-U+3005, U+3008-U+3020, U+302a-U+3037, U+303b-U+3104, U+312d-U+3130, U+318f - U+319f, U+31b8-U+33ff, U+4db6-U+4dff, U+9fa6-U+9fff, U+a48d-U+abff, U+d7a4-U+d7ff, U+e000-U+f8ff, U+fa2e-U+faff, U+fb07-U+fb12, U+fb18-U+fb1c, U+fb1e, U+fb29, U+fb37, U+fb3d, U+fb3f, U+fb42, U+fb45, U+fbb2-U+fbd2, U+fd3e-U+fd4f, U+fd90-U+fd91, U+fdc8-U+fdef, U+fdfc-U+fe6f, U+fe73, U+fe75, U+fefd-U+ff20, U+ff3b-U+ff40, U+ff5b-U+ff9f, U+ffbf-U+ffc1, U+ffc8-U+ffc9, U+ffd0-U+ffd1, U+ffd8-U+ffd9, U+ffdd-U+ffff --> <dd> <p>Follow these substeps:</p> <ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li> <li>If <var title="">finished</var> is true, skip to the next step in the overall set of steps.</li> <li>Let <var title="">negated</var> be false.</li> </ol></dd> <dt>Any other character</dt> <!-- alphabetic a-z A-Z, and non-ASCII --> <dd> <p>Follow these substeps:</p> <ol><li>If <var title="">finished</var> is true, skip to the next step in the overall set of steps.</li> <li>Let <var title="">negated</var> be false.</li> <li>Let <var title="">bogus</var> be true.</li> <li>If <var title="">started</var> is true, then return the <var title="">numbers</var> list, and abort. (The value in <var title="">value</var> is not appended to the list first; it is dropped.)</li> </ol></dd> </dl></li> <li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>, or to beyond the end of the string if there are no more characters.</li> <li><p>If <var title="">position</var> points to a character (and not to beyond the end of <var title="">input</var>), jump to the big <i>Parser</i> step above.</li> <li><p>If <var title="">negated</var> is true, then negate <var title="">value</var>.</li> <li><p>If <var title="">got number</var> is true, then append <var title="">value</var> to the <var title="">numbers</var> list.</li> <li><p>Return the <var title="">numbers</var> list and abort.</li> </ol></div> <div class=impl> <h5 id=lists-of-dimensions><span class=secno>2.5.4.6 </span>Lists of dimensions</h5> <!-- no definition of a type since no conforming feature uses this syntax (it's only used in cols="" and rows="" on <frameset> --> <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 title="">raw input</var> be the string being parsed.</li> <li><p>If the last character in <var title="">raw input</var> is a U+002C COMMA character (,), then remove that character from <var title="">raw input</var>.</li> <li><p><a href=#split-a-string-on-commas title="split a string on commas">Split the string <var title="">raw input</var> on commas</a>. Let <var title="">raw tokens</var> be the resulting list of tokens.</li> <li><p>Let <var title="">result</var> be an empty list of number/unit pairs.</li> <li> <p>For each token in <var title="">raw tokens</var>, run the following substeps:</p> <ol><li><p>Let <var title="">input</var> be the token.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">value</var> be the number 0.</li> <li><p>Let <var title="">unit</var> be <i>absolute</i>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, set <var title="">unit</var> to <i>relative</i> and jump to the last substep.</li> <li><p>If the character at <var title="">position</var> is a character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), <a href=#collect-a-sequence-of-characters>collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), interpret the resulting sequence as an integer in base ten, and increment <var title="">value</var> by that integer.</li> <li> <p>If the character at <var title="">position</var> is a U+002E FULL STOP character (.), run these substeps:</p> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> consisting of <a href=#space-character title="space character">space characters</a> and characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). Let <var title="">s</var> be the resulting sequence.</li> <li><p>Remove all <a href=#space-character title="space character">space characters</a> in <var title="">s</var>.</li> <li> <p>If <var title="">s</var> is not the empty string, run these subsubsteps:</p> <ol><li><p>Let <var title="">length</var> be the number of characters in <var title="">s</var> (after the spaces were removed).</li> <li><p>Let <var title="">fraction</var> be the result of interpreting <var title="">s</var> as a base-ten integer, and then dividing that number by <span title="">10<sup title=""><var title="">length</var></sup></span>.</li> <li><p>Increment <var title="">value</var> by <var title="">fraction</var>.</li> </ol></li> </ol></li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li> <p>If the character at <var title="">position</var> is a U+0025 PERCENT SIGN character (%), then set <var title="">unit</var> to <i>percentage</i>.</p> <p>Otherwise, if the character at <var title="">position</var> is a U+002A ASTERISK character (*), then set <var title="">unit</var> to <i>relative</i>.</p> </li> <!-- the remaining characters in /input/ are ignored --> <li><p>Add an entry to <var title="">result</var> consisting of the number given by <var title="">value</var> and the unit given by <var title="">unit</var>.</li> </ol></li> <li><p>Return the list <var title="">result</var>.</li> </ol></div> <h4 id=dates-and-times><span class=secno>2.5.5 </span>Dates and times</h4> <p>In the algorithms below, the <dfn id=number-of-days-in-month-month-of-year-year>number of days in month <var title="">month</var> of year <var title="">year</var></dfn> is: <em>31</em> if <var title="">month</var> is 1, 3, 5, 7, 8, 10, or 12; <em>30</em> if <var title="">month</var> is 4, 6, 9, or 11; <em>29</em> if <var title="">month</var> is 2 and <var title="">year</var> is a number divisible by 400, or if <var title="">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>The <dfn id=concept-datetime-digit title=concept-datetime-digit>digits</dfn> in the date and time syntaxes defined in this section must be characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), used to express numbers in base ten.</p> <div class=impl> <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> </div> <h5 id=months><span class=secno>2.5.5.1 </span>Months</h5> <p>A <dfn id=concept-month title=concept-month>month</dfn> consists of a specific proleptic Gregorian date 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 title="">year</var> and month <var title="">month</var> if it consists of the following components in the given order:</p> <ol><li>Four or more <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing <var title="">year</var>, where <var title="">year</var> > 0</li> <li>A U+002D HYPHEN-MINUS character (-)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the month <var title="">month</var>, in the range 1 ≤ <var title="">month</var> ≤ 12</li> </ol><div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-a-month-component>Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Return <var title="">year</var> and <var title="">month</var>.</li> </ol><p>The rules to <dfn id=parse-a-month-component>parse a month component</dfn>, given an <var title="">input</var> string and a <var title="">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 href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">year</var>.</li> <li><p>If <var title="">year</var> is not a number greater than zero, then fail.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character, then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">month</var>.</li> <li><p>If <var title="">month</var> is not a number in the range 1 ≤ <var title="">month</var> ≤ 12, then fail.</li> <li><p>Return <var title="">year</var> and <var title="">month</var>.</li> </ol></div> <h5 id=dates><span class=secno>2.5.5.2 </span>Dates</h5> <p>A <dfn id=concept-date title=concept-date>date</dfn> consists of a specific proleptic Gregorian date 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 title="">year</var>, month <var title="">month</var>, and day <var title="">day</var> if it consists of the following components in the given order:</p> <ol><li>A <a href=#valid-month-string>valid month string</a>, representing <var title="">year</var> and <var title="">month</var></li> <li>A U+002D HYPHEN-MINUS character (-)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing <var title="">day</var>, in the range 1 ≤ <var title="">day</var> ≤ <var title="">maxday</var> where <var title="">maxday</var> is the <a href=#number-of-days-in-month-month-of-year-year title="number of days in month month of year year">number of days in the month <var title="">month</var> and year <var title="">year</var></a></li> </ol><div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-a-date-component>Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</li> <li><p>Return <var title="">date</var>.</li> </ol><p>The rules to <dfn id=parse-a-date-component>parse a date component</dfn>, given an <var title="">input</var> string and a <var title="">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>Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns nothing, then fail.</li> <li><p>Let <var title="">maxday</var> be the <a href=#number-of-days-in-month-month-of-year-year>number of days in month <var title="">month</var> of year <var title="">year</var></a>.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character, then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">day</var>.</li> <li><p>If <var title="">day</var> is not a number in the range 1 ≤ <var title="">day</var> ≤ <var title="">maxday</var>, then fail.</li> <li><p>Return <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>.</li> </ol></div> <h5 id=times><span class=secno>2.5.5.3 </span>Times</h5> <p>A <dfn id=concept-time title=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 title="">hour</var>, a minute <var title="">minute</var>, and a second <var title="">second</var> if it consists of the following components in the given order:</p> <ol><li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing <var title="">hour</var>, in the range 0 ≤ <var title="">hour</var> ≤ 23</li> <li>A U+003A COLON character (:)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing <var title="">minute</var>, in the range 0 ≤ <var title="">minute</var> ≤ 59</li> <li>Optionally (required if <var title="">second</var> is non-zero): <ol><li>A U+003A COLON character (:)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the integer part of <var title="">second</var>, in the range 0 ≤ <var title="">s</var> ≤ 59</li> <li>Optionally (required if <var title="">second</var> is not an integer): <ol><li>A 002E FULL STOP character (.)</li> <li>One or more <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the fractional part of <var title="">second</var></li> </ol></li> </ol></li> </ol><p class=note>The <var title="">second</var> component cannot be 60 or 61; leap seconds cannot be represented.</p> <div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-a-time-component>Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second <var title="">second</var>.</li> <li><p>Return <var title="">time</var>.</li> </ol><p>The rules to <dfn id=parse-a-time-component>parse a time component</dfn>, given an <var title="">input</var> string and a <var title="">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 href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">hour</var>.</li> <li>If <var title="">hour</var> is not a number in the range 0 ≤ <var title="">hour</var> ≤ 23, then fail.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">minute</var>.</li> <li>If <var title="">minute</var> is not a number in the range 0 ≤ <var title="">minute</var> ≤ 59, then fail.</li> <li><p>Let <var title="">second</var> be a string with the value "0".</li> <li> <p>If <var title="">position</var> is not beyond the end of <var title="">input</var> and the character at <var title="">position</var> is a U+003A COLON, then run these substeps:</p> <ol><li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, or at the last character in <var title="">input</var>, or if the next <em>two</em> characters in <var title="">input</var> starting at <var title="">position</var> are not two characters both in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then fail.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are either characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) or U+002E FULL STOP characters. 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, let the collected string be <var title="">second</var> instead of its previous value.</li> </ol></li> <li><p>Interpret <var title="">second</var> as a base-ten number (possibly with a fractional part). Let <var title="">second</var> be that number instead of the string version.</li> <li><p>If <var title="">second</var> is not a number in the range 0 ≤ <var title="">second</var> < 60, then fail.</li> <li><p>Return <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>.</li> </ol></div> <h5 id=local-dates-and-times><span class=secno>2.5.5.4 </span>Local dates and times</h5> <p>A <dfn id=concept-datetime-local title=concept-datetime-local>local date and time</dfn> consists of a specific proleptic Gregorian date, 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>valid date string</a> representing the date.</li> <li>A U+0054 LATIN CAPITAL LETTER T character (T).</li> <li>A <a href=#valid-time-string>valid time string</a> representing the time.</li> </ol><div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-a-date-component>Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#parse-a-time-component>Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</li> <li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second <var title="">second</var>.</li> <li><p>Return <var title="">date</var> and <var title="">time</var>.</li> </ol></div> <h5 id=global-dates-and-times><span class=secno>2.5.5.5 </span>Global dates and times</h5> <p>A <dfn id=concept-datetime title=concept-datetime>global date and time</dfn> consists of a specific proleptic Gregorian date, 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>valid date string</a> representing the date</li> <li>A U+0054 LATIN CAPITAL LETTER T character (T)</li> <li>A <a href=#valid-time-string>valid time string</a> representing the time</li> <li>Either: <ul><li>A U+005A LATIN CAPITAL LETTER Z character (Z), allowed only if the time zone is UTC</li> <li>Or: <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> <!-- the -00:00 offset is disallowed because RFC3339 gives it a special semantic --> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the hours component <var title="">hour</var> of the time-zone offset, in the range 0 ≤ <var title="">hour</var> ≤ 23</li> <li>A U+003A COLON character (:)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the minutes component <var title="">minute</var> of the time-zone offset, in the range 0 ≤ <var title="">minute</var> ≤ 59</li> </ol></li> </ul></li> </ol><p class=note>This format allows for time-zone offsets from -23:59 to +23:59. In practice, however, 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.</p> <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 interpeted 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 title="valid global date and time string">valid global date and time strings</a>.</p> <dl><dt>"<code>0037-12-13T00:00Z</code>"</dt> <dd>Midnight in areas using London time on the birthday of Nero (the Roman Emperor). See below for further discussion on which date this actually corresponds to.</dd> <dt>"<code>1979-10-14T12:00:00.001-04:00</code>"</dt> <dd>One millisecond after noon on October 14th 1979, in the time zone in use on the east coast of the USA during daylight saving time.</dd> <dt>"<code>8592-01-01T02:09+02:09</code>"</dt> <dd>Midnight UTC on the 1st of January, 8592. The time zone associated with that time is two hours and nine minutes ahead of UTC, which is not currently a real time zone, but is nonetheless allowed.</dd> </dl><p>Several things are notable about these dates:</p> <ul><li>Years with fewer than four digits have to be zero-padded. The date "37-12-13" would not be a valid date.</li> <li>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 proleptic Gregorian Calendar.</li> <!-- This might not be true. I can't find a reference that gives his birthday with an explicit statement about the calendar being used. However, it seems unlikely that it would be given in the Gregorian calendar, so I assume sites use the Julian one. --> <li>The time and time-zone offset components are not optional.</li> <li>Dates before the year one can't be represented as a datetime in this version of HTML.</li> <li>Times of specific events in ancient times are, at best, approximations, since time was not well coordinated or measured until relatively recent decades.</li> <li>Time-zone offsets differ based on daylight savings time.</li> </ul></div> <p>A string is a <dfn id=valid-forced-utc-global-date-and-time-string>valid forced-UTC 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>valid date string</a> representing the date converted to the UTC time zone</li> <li>A U+0054 LATIN CAPITAL LETTER T character (T)</li> <li>A <a href=#valid-time-string>valid time string</a> representing the time converted to the UTC time zone and expressed as the shortest possible string for the given time (e.g. omitting the seconds component entirely if the given time is zero seconds past the minute)</li> <li>A U+005A LATIN CAPITAL LETTER Z character (Z)</li> </ol><div class=impl> <p>The <dfn id=best-representation-of-the-global-date-and-time-string>best representation of the global date and time string</dfn> <var title="">datetime</var> is the <a href=#valid-global-date-and-time-string>valid global date and time string</a> representing <var title="">datetime</var>, with the <a href=#valid-time-string>valid time string</a> component being given in its shortest possible form, with the last character of the string not being a U+005A LATIN CAPITAL LETTER Z character (Z), even if the time zone is UTC, and with a U+002B PLUS SIGN character (+) representing the sign of the time-zone offset when the time zone is UTC.</p> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-a-date-component>Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#parse-a-time-component>Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</li> <li><p><a href=#parse-a-time-zone-offset-component>Parse a time-zone offset component</a> to obtain <var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns nothing, then fail.</p> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Let <var title="">time</var> be the moment in time at year <var title="">year</var>, month <var title="">month</var>, day <var title="">day</var>, hours <var title="">hour</var>, minute <var title="">minute</var>, second <var title="">second</var>, subtracting <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes. That moment in time is a moment in the UTC time zone.</li> <li><p>Let <var title="">timezone</var> be <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes from UTC.</li> <li><p>Return <var title="">time</var> and <var title="">timezone</var>.</li> </ol><p>The rules to <dfn id=parse-a-time-zone-offset-component>parse a time-zone offset component</dfn>, given an <var title="">input</var> string and a <var title="">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 title="">position</var> is a U+005A LATIN CAPITAL LETTER Z character (Z), then:</p> <ol><li><p>Let <var title="">timezone<sub title="">hours</sub></var> be 0.</li> <li><p>Let <var title="">timezone<sub title="">minutes</sub></var> be 0.</li> <li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> </ol><p>Otherwise, if the character at <var title="">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 title="">position</var> is a U+002B PLUS SIGN (+), let <var title="">sign</var> be "positive". Otherwise, it's a U+002D HYPHEN-MINUS (-); let <var title="">sign</var> be "negative".</li> <li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">timezone<sub title="">hours</sub></var>.</li> <li>If <var title="">timezone<sub title="">hours</sub></var> is not a number in the range 0 ≤ <var title="">timezone<sub title="">hours</sub></var> ≤ 23, then fail.</li> <li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">hours</sub></var>.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">timezone<sub title="">minutes</sub></var>.</li> <li>If <var title="">timezone<sub title="">minutes</sub></var> is not a number in the range 0 ≤ <var title="">timezone<sub title="">minutes</sub></var> ≤ 59, then fail.</li> <li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">minutes</sub></var>.</li> </ol><p>Otherwise, fail.</p> </li> <li><p>Return <var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>.</li> </ol></div> <h5 id=weeks><span class=secno>2.5.5.6 </span>Weeks</h5> <p>A <dfn id=concept-week title=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 title="">year</var> has 53 weeks if it corresponds to either a year <var title="">year</var> in the proleptic Gregorian calendar that has a Thursday as its first day (January 1st), or a year <var title="">year</var> in the proleptic Gregorian calendar that has a Wednesday as its first day (January 1st) and where <var title="">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 proleptic Gregorian calendar. The first week in a week-year <var title="">y</var> is the week that contains the first Thursday of the Gregorian year <var title="">y</var>.</p> <p>A string is a <dfn id=valid-week-string>valid week string</dfn> representing a week-year <var title="">year</var> and week <var title="">week</var> if it consists of the following components in the given order:</p> <ol><li>Four or more <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing <var title="">year</var>, where <var title="">year</var> > 0</li> <li>A U+002D HYPHEN-MINUS character (-)</li> <li>A U+0057 LATIN CAPITAL LETTER W character (W)</li> <li>Two <a href=#concept-datetime-digit title=concept-datetime-digit>digits</a>, representing the week <var title="">week</var>, in the range 1 ≤ <var title="">week</var> ≤ <var title="">maxweek</var>, where <var title="">maxweek</var> is the <a href=#week-number-of-the-last-day>week number of the last day</a> of week-year <var title="">year</var></li> </ol><div class=impl> <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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">year</var>.</li> <li><p>If <var title="">year</var> is not a number greater than zero, then fail.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character, then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0057 LATIN CAPITAL LETTER W character (W), then fail. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). 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 title="">week</var>.</li> <li><p>Let <var title="">maxweek</var> be the <a href=#week-number-of-the-last-day>week number of the last day</a> of year <var title="">year</var>.</li> <li><p>If <var title="">week</var> is not a number in the range 1 ≤ <var title="">week</var> ≤ <var title="">maxweek</var>, then fail.</li> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li><p>Return the week-year number <var title="">year</var> and the week number <var title="">week</var>.</li> </ol></div> <h5 id=vaguer-moments-in-time><span class=secno>2.5.5.7 </span>Vaguer moments in time</h5> <p>A string is a <dfn id=valid-date-or-time-string>valid date or time string</dfn> if it is also one of the following:</p> <ul><li>A <a href=#valid-date-string>valid date string</a>.</li> <li>A <a href=#valid-time-string>valid time string</a>.</li> <li>A <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</li> </ul><p>A string is a <dfn id=valid-date-or-time-string-in-content>valid date or time string in content</dfn> if it consists of zero or more <a href=#white_space>White_Space</a> characters, followed by a <a href=#valid-date-or-time-string>valid date or time string</a>, followed by zero or more further <a href=#white_space>White_Space</a> characters.</p> <hr><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>valid date string</a>.</li> <li>A <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</li> </ul><p>A string is a <dfn id=valid-date-string-in-content-with-optional-time>valid date string in content with optional time</dfn> if it consists of zero or more <a href=#white_space>White_Space</a> characters, followed by a <a href=#valid-date-string-with-optional-time>valid date string with optional time</a>, followed by zero or more further <a href=#white_space>White_Space</a> characters.</p> <div class=impl> <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 is invoked with a flag indicating if the <i>in attribute</i> variant or the <i>in content</i> variant is to be used. The algorithm will return either a <a href=#concept-date title=concept-date>date</a>, a <a href=#concept-time title=concept-time>time</a>, a <a href=#concept-datetime title=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 title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>For the <i>in content</i> variant: <a href=#skip-white_space-characters>skip White_Space characters</a>.</li> <li><p>Set <var title="">start position</var> to the same position as <var title="">position</var>.</li> <li><p>Set the <var title="">date present</var> and <var title="">time present</var> flags to true.</li> <li><p><a href=#parse-a-date-component>Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this fails, then set the <var title="">date present</var> flag to false.</p> <li> <p>If <var title="">date present</var> is true, and <var title="">position</var> is not beyond the end of <var title="">input</var>, and the character at <var title="">position</var> is a U+0054 LATIN CAPITAL LETTER T character (T), then advance <var title="">position</var> to the next character in <var title="">input</var>.</p> <p>Otherwise, if <var title="">date present</var> is true, and either <var title="">position</var> is beyond the end of <var title="">input</var> or the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T character (T), then set <var title="">time present</var> to false.</p> <p>Otherwise, if <var title="">date present</var> is false, set <var title="">position</var> back to the same position as <var title="">start position</var>.</p> </li> <li><p>If the <var title="">time present</var> flag is true, then <a href=#parse-a-time-component>parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</li> <li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, but <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</li> <li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, <a href=#parse-a-time-zone-offset-component>parse a time-zone offset component</a> to obtain <var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns nothing, then fail.</p> <li><p>For the <i>in content</i> variant: <a href=#skip-white_space-characters>skip White_Space characters</a>.</li> <li><p>If <var title="">position</var> is <em>not</em> beyond the end of <var title="">input</var>, then fail.</li> <li> <p>If the <var title="">date present</var> flag is true and the <var title="">time present</var> flag is false, then let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>, and return <var title="">date</var>.</p> <p>Otherwise, if the <var title="">time present</var> flag is true and the <var title="">date present</var> flag is false, then let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second <var title="">second</var>, and return <var title="">time</var>.</p> <p>Otherwise, let <var title="">time</var> be the moment in time at year <var title="">year</var>, month <var title="">month</var>, day <var title="">day</var>, hours <var title="">hour</var>, minute <var title="">minute</var>, second <var title="">second</var>, subtracting <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes, that moment in time being a moment in the UTC time zone; let <var title="">timezone</var> be <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes from UTC; and return <var title="">time</var> and <var title="">timezone</var>.</p> </li> </ol></div> <h4 id=colors><span class=secno>2.5.6 </span>Colors</h4> <p>A <dfn id=simple-color>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-color>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 in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, 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-color>valid lowercase simple color</dfn> if it is a <a href=#valid-simple-color>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> <div class=impl> <p>The <dfn id=rules-for-parsing-simple-color-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-color>simple color</a> or an error.</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>If <var title="">input</var> is not exactly seven characters long, then return an error.</li> <li><p>If the first character in <var title="">input</var> is not a U+0023 NUMBER SIGN character (#), then return an error.</li> <li><p>If the last six characters of <var title="">input</var> are not all in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, then return an error.</li> <li><p>Let <var title="">result</var> be a <a href=#simple-color>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 title="">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 title="">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 title="">result</var>.</p> <li><p>Return <var title="">result</var>.</p> </ol><p>The <dfn id=rules-for-serializing-simple-color-values>rules for serializing simple color values</dfn> given a <a href=#simple-color>simple color</a> are as given in the following algorithm:</p> <ol><li><p>Let <var title="">result</var> be a string consisting of a single U+0023 NUMBER SIGN character (#).</li> <li><p>Convert the red, green, and blue components in turn to two-digit hexadecimal numbers using the digits U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) and U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, zero-padding if necessary, and append these numbers to <var title="">result</var>, in the order red, green, blue.</p> <li><p>Return <var title="">result</var>, which will be a <a href=#valid-lowercase-simple-color>valid lowercase simple color</a>.</li> </ol><hr><p>Some obsolete legacy attributes parse colors in a more complicated manner, using the <dfn id=rules-for-parsing-a-legacy-color-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-color>simple color</a> or an error.</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>If <var title="">input</var> is the empty string, then return an error.</li> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">input</var>.</li> <li><p>If <var title="">input</var> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">transparent</code>", then return an error.</li> <li> <p>If <var title="">input</var> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for one of the keywords listed in the <a href=http://www.w3.org/TR/css3-color/#svg-color>SVG color keywords</a> <!-- or <a href="http://www.w3.org/TR/css3-color/#css2-system">CSS2 System Colors</a> --> section<!--s--> of the CSS3 Color specification, then return the <a href=#simple-color>simple color</a> corresponding to that keyword. <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p> <p class=note><a href=http://www.w3.org/TR/css3-color/#css2-system>CSS2 System Colors</a> are not recognised.</p> </li> <li> <p>If <var title="">input</var> is four characters long, and the first character in <var title="">input</var> is a U+0023 NUMBER SIGN character (#), and the last three characters of <var title="">input</var> are all in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, then run these substeps:</p> <ol><li><p>Let <var title="">result</var> be a <a href=#simple-color>simple color</a>.</p> <li><p>Interpret the second character of <var title="">input</var> as a hexadecimal digit; let the red component of <var title="">result</var> be the resulting number multiplied by 17.</p> <li><p>Interpret the third character of <var title="">input</var> as a hexadecimal digit; let the green component of <var title="">result</var> be the resulting number multiplied by 17.</p> <li><p>Interpret the fourth character of <var title="">input</var> as a hexadecimal digit; let the blue component of <var title="">result</var> be the resulting number multiplied by 17.</p> <li><p>Return <var title="">result</var>.</p> </ol></li> <li><p>Replace any characters in <var title="">input</var> that have a Unicode code point greater than U+FFFF (i.e. any characters that are not in the basic multilingual plane) with the two-character string "<code title="">00</code>".</li> <li><p>If <var title="">input</var> is longer than 128 characters, truncate <var title="">input</var>, leaving only the first 128 characters.</li> <li><p>If the first character in <var title="">input</var> is a U+0023 NUMBER SIGN character (#), remove it.</li> <li><p>Replace any character in <var title="">input</var> that is not in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F with the character U+0030 DIGIT ZERO (0).</li> <li><p>While <var title="">input</var>'s length is zero or not a multiple of three, append a U+0030 DIGIT ZERO (0) character to <var title="">input</var>.</li> <li><p>Split <var title="">input</var> into three strings of equal length, to obtain three components. Let <var title="">length</var> be the length of those components (one third the length of <var title="">input</var>).</li> <li><p>If <var title="">length</var> is greater than 8, then remove the leading <span title=""><var title="">length</var>-8</span> characters in each component, and let <var title="">length</var> be 8.</li> <li><p>While <var title="">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 title="">length</var> by one.</li> <li><p>If <var title="">length</var> is <em>still</em> greater than two, truncate each component, leaving only the first two characters in each.</li> <li><p>Let <var title="">result</var> be a <a href=#simple-color>simple color</a>.</p> <li><p>Interpret the first component as a hexadecimal number; let the red component of <var title="">result</var> be the resulting number.</li> <li><p>Interpret the second component as a hexadecimal number; let the green component of <var title="">result</var> be the resulting number.</li> <li><p>Interpret the third component as a hexadecimal number; let the blue component of <var title="">result</var> be the resulting number.</li> <li><p>Return <var title="">result</var>.</p> </ol></div> <hr><!--2DCANVAS--><p class=note>The <a href=#canvas-context-2d title=canvas-context-2d>2D graphics context</a> has a separate color syntax that also handles opacity.</p> <!--2DCANVAS--> <h4 id=space-separated-tokens><span class=secno>2.5.7 </span>Space-separated tokens</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 href=#space-character title="space character">space characters</a>, where words consist of any string of one or more characters, none of which are <a href=#space-character title="space character">space characters</a>.</p> <p>A string containing a <a href=#set-of-space-separated-tokens>set of space-separated tokens</a> may have leading or trailing <a href=#space-character title="space character">space characters</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>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>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 title="set of space-separated tokens">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>set of space-separated tokens</a> are to be compared (e.g. case-sensitively or not) is defined on a per-set basis.</p> <div class=impl> <p>When a user agent has to <dfn id=split-a-string-on-spaces>split a string on spaces</dfn>, it must use the following algorithm:</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">tokens</var> be a list of tokens, initially empty.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a></li> <li><p>While <var title="">position</var> is not past the end of <var title="">input</var>:</p> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not <a href=#space-character title="space character">space characters</a>.</li> <li><p>Add the string collected in the previous step to <var title="">tokens</var>.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a></li> </ol></li> <li><p>Return <var title="">tokens</var>.</li> </ol><p>When a user agent has to <dfn id=remove-a-token-from-a-string>remove a token from a string</dfn>, it must use the following algorithm:</p> <ol><li><p>Let <var title="">input</var> be the string being modified.</li> <li><p>Let <var title="">token</var> be the token being removed. It will not contain any <a href=#space-character title="space character">space characters</a>.</li> <li><p>Let <var title="">output</var> be the output string, initially empty.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><i>Loop</i>: If <var title="">position</var> is beyond the end of <var title="">input</var>, abort these steps.</li> <li><p>If the character at <var title="">position</var> is a <a href=#space-character>space character</a>:</p> <ol><li><p>Append the character at <var title="">position</var> to the end of <var title="">output</var>.</li> <li><p>Advance <var title="">position</var> so it points at the next character in <var title="">input</var>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> </ol></li> <li><p>Otherwise, the character at <var title="">position</var> is the first character of a token. <a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not <a href=#space-character title="space character">space characters</a>, and let that be <var title="">s</var>.</li> <li><p>If <var title="">s</var> is exactly equal to <var title="">token</var> (this is a <a href=#case-sensitive>case-sensitive</a> comparison), then:</p> <ol><li><p><a href=#skip-whitespace>Skip whitespace</a> (in <var title="">input</var>).</li> <li><p>Remove any <a href=#space-character title="space character">space characters</a> currently at the end of <var title="">output</var>.</li> <li><p>If <var title="">position</var> is not past the end of <var title="">input</var>, and <var title="">output</var> is not the empty string, append a single U+0020 SPACE character at the end of <var title="">output</var>.</li> </ol></li> <li><p>Otherwise, append <var title="">s</var> to the end of <var title="">output</var>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> </ol><p class=note>This causes any occurrences of the token to be removed from the string, and any spaces that were surrounding the token to be collapsed to a single space, except at the start and end of the string, where such spaces are removed.</p> </div> <h4 id=comma-separated-tokens><span class=secno>2.5.8 </span>Comma-separated tokens</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 href=#space-character title="space character">space characters</a>, nor containing any U+002C COMMA characters (,), and optionally surrounded by <a href=#space-character title="space character">space characters</a>.</p> <p class=example>For instance, the string "<code title=""> 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 title="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> <div class=impl> <p>When a user agent has to <dfn id=split-a-string-on-commas>split a string on commas</dfn>, it must use the following algorithm:</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">tokens</var> be a list of tokens, initially empty.</li> <li><p><i>Token</i>: If <var title="">position</var> is past the end of <var title="">input</var>, jump to the last step.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not U+002C COMMA characters (,). Let <var title="">s</var> be the resulting sequence (which might be the empty string).</li> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">s</var>.</li> <li><p>Add <var title="">s</var> to <var title="">tokens</var>.</li> <li><p>If <var title="">position</var> is not past the end of <var title="">input</var>, then the character at <var title="">position</var> is a U+002C COMMA character (,); advance <var title="">position</var> past that character.</li> <li><p>Jump back to the step labeled <i>token</i>.</li> <li><p>Return <var title="">tokens</var>.</li> </ol></div> <h4 id=syntax-references><span class=secno>2.5.9 </span>References</h4> <p>A <dfn id=valid-hash-name-reference>valid hash-name reference</dfn> to an element of type <var title="">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 title="">name</code> attribute of an element with type <var title="">type</var> in the document.</p> <div class=impl> <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 title="">type</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 and abort these steps.</li> <li><p>Let <var title="">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> <li><p>Return the first element of type <var title="">type</var> that has an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute whose value is a <a href=#case-sensitive>case-sensitive</a> match for <var title="">s</var> or a <code title="">name</code> attribute whose value is a <a href=#compatibility-caseless>compatibility caseless</a> match for <var title="">s</var>.</li> <!-- IE is also doing case-insensitive id="" matching. Tests: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cmap%20name%3D%22T%26eacute%3B%26%23x01F1%3B%26%23x2075%3B%22%3E%3Carea%20href%3D%22%2F%22%20shape%3Drect%20coords%3D0%2C0%2C200%2C200%3E%3C%2Fmap%3E%0A%3Cimg%20usemap%3D%22%23t%26Eacute%3BDZ5%22%20src%3Dimage%3E ...except that doesn't explain why this fails: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cmap%20name%3D%22T%26eacute%3B%26%23x01F1%3B%26%23x2075%3B%26%23xFB01%3B%22%3E%3Carea%20href%3D%22%2F%22%20shape%3Drect%20coords%3D0%2C0%2C200%2C200%3E%3C%2Fmap%3E%0A%3Cimg%20usemap%3D%22%23t%26Eacute%3BDZ5F%26%23x0131%3B%26%23x0307%3B%22%20src%3Dimage%3E maybe they just don't know about combining dot above? --> </ol></div> <h4 id=mq><span class=secno>2.5.10 </span>Media queries</h4> <p>A string is a <dfn id=valid-media-query>valid media query</dfn> if it matches the <code title="">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 href=#space-character title="space character">space characters</a>, or is a media query 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.6 </span>URLs</h3> <p>This specification defines the term <a href=#url>URL</a>, and defines various algorithms for dealing with URLs, because for historical reasons the rules defined by the URI and IRI specifications are not a complete description of what HTML user agents need to implement to be compatible with Web content.</p> <p class=note>The term "URL" in this specification is used in a manner distinct from the precise technical meaning it is given in RFC 3986. Readers familiar with that RFC will find it easier to read <em>this</em> specification if they pretend the term "URL" as used herein is really called something else altogether. This is a <a href=#willful-violation>willful violation</a> of RFC 3986. <a href=#refsRFC3986>[RFC3986]</a></p> <h4 id=terminology-0><span class=secno>2.6.1 </span>Terminology</h4> <p>A <dfn id=url>URL</dfn> is a string used to identify a resource.</p> <p>A <a href=#url>URL</a> is a <dfn id=valid-url>valid URL</dfn> if at least one of the following conditions holds:</p> <ul><li><p>The <a href=#url>URL</a> is a valid URI reference <a href=#refsRFC3986>[RFC3986]</a>.</li> <li><p>The <a href=#url>URL</a> is a valid IRI reference and it has no query component. <a href=#refsRFC3987>[RFC3987]</a></li> <li><p>The <a href=#url>URL</a> is a valid IRI reference and its query component contains no unescaped non-ASCII characters. <a href=#refsRFC3987>[RFC3987]</a></li> <li><p>The <a href=#url>URL</a> is a valid IRI reference and the <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> of the URL's <code><a href=#document>Document</a></code> is UTF-8 or <a href=#a-utf-16-encoding>a UTF-16 encoding</a>. <a href=#refsRFC3987>[RFC3987]</a></li> </ul><p>A string is a <dfn id=valid-non-empty-url>valid non-empty URL</dfn> if it is a <a href=#valid-url>valid URL</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=#strip-leading-and-trailing-whitespace title="strip leading and trailing whitespace">stripping leading and trailing whitespace</a> from it, it is a <a href=#valid-url>valid URL</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=#strip-leading-and-trailing-whitespace title="strip leading and trailing whitespace">stripping leading and trailing whitespace</a> from it, it is a <a href=#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 title="">about:</code> URI, for use in <a href=#syntax-doctype title=syntax-doctype>DOCTYPE</a>s in <a href=#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:srcdoc><code>about:srcdoc</code></dfn> as a reserved, though unresolvable, <code title="">about:</code> URI, that is used as <a href="#the-document's-address">the document's address</a> of <a href=#an-iframe-srcdoc-document title="an iframe srcdoc document"><code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> documents</a>. <a href=#refsABOUT>[ABOUT]</a></p> <div class=impl> <h4 id=parsing-urls><span class=secno>2.6.2 </span>Parsing URLs</h4> <p>To <dfn id=parse-a-url>parse a URL</dfn> <var title="">url</var> into its component parts, the user agent must use the following steps:</p> <ol><li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">url</var>.</li> <li> <p>Parse <var title="">url</var> in the manner defined by RFC 3986, with the following exceptions:</p> <ul><li>Add all characters with code points less than or equal to U+0020 or greater than or equal to U+007F to the <unreserved> production.</li> <li>Add the characters U+0022, U+003C, U+003E, U+005B .. U+005E, U+0060, and U+007B .. U+007D to the <unreserved> production. <!-- 0022 QUOTATION MARK 003C LESS-THAN SIGN 003E GREATER-THAN SIGN 005B LEFT SQUARE BRACKET 005C REVERSE SOLIDUS 005D RIGHT SQUARE BRACKET 005E CIRCUMFLEX ACCENT 0060 GRAVE ACCENT 007B LEFT CURLY BRACKET 007C VERTICAL LINE 007D RIGHT CURLY BRACKET --> </li> <li>Add a single U+0025 PERCENT SIGN character as a second alternative way of matching the <pct-encoded> production, except when the <pct-encoded> is used in the <reg-name> production.</li> <li>Add the U+0023 NUMBER SIGN character to the characters allowed in the <fragment> production.</li> <!-- some browsers also have other differences, e.g. Mozilla seems to treat ";" as if it was not in sub-delims, if the scheem is "ftp". --> </ul></li> <li> <p>If <var title="">url</var> doesn't match the <URI-reference> production, even after the above changes are made to the ABNF definitions, then parsing the URL fails with an error. <a href=#refsRFC3986>[RFC3986]</a></p> <p>Otherwise, parsing <var title="">url</var> was successful; the components of the URL are substrings of <var title="">url</var> defined as follows:</p> <dl><dt><dfn id=url-scheme title=url-scheme><scheme></dfn></dt> <dd><p>The substring matched by the <scheme> production, if any.</dd> <dt><dfn id=url-host title=url-host><host></dfn></dt> <dd><p>The substring matched by the <host> production, if any.</dd> <dt><dfn id=url-port title=url-port><port></dfn></dt> <dd><p>The substring matched by the <port> production, if any.</dd> <dt><dfn id=url-hostport title=url-hostport><hostport></dfn></dt> <dd><p>If there is a <scheme> component and a <port> component and the port given by the <port> component is different than the default port defined for the protocol given by the <scheme> component, then <hostport> is the substring that starts with the substring matched by the <host> production and ends with the substring matched by the <port> production, and includes the colon in between the two. Otherwise, it is the same as the <host> component.</p> <dt><dfn id=url-path title=url-path><path></dfn></dt> <dd> <p>The substring matched by one of the following productions, if one of them was matched:</p> <ul class=brief><li><path-abempty></li> <li><path-absolute></li> <li><path-noscheme></li> <li><path-rootless></li> <li><path-empty></li> </ul></dd> <dt><dfn id=url-query title=url-query><query></dfn></dt> <dd><p>The substring matched by the <query> production, if any.</dd> <dt><dfn id=url-fragment title=url-fragment><fragment></dfn></dt> <dd><p>The substring matched by the <fragment> production, if any.</dd> <dt><dfn id=url-host-specific title=url-host-specific><host-specific></dfn></dt> <dd><p>The substring that <em>follows</em> the substring matched by the <authority> production, or the whole string if the <authority> production wasn't matched.</dd> </dl></li> </ol><p class=note>These parsing rules are a <a href=#willful-violation>willful violation</a> of RFC 3986 and RFC 3987 (which do not define error handling), motivated by a desire to handle legacy content. <a href=#refsRFC3986>[RFC3986]</a> <a href=#refsRFC3987>[RFC3987]</a></p> </div> <h4 id=resolving-urls><span class=secno>2.6.3 </span>Resolving URLs</h4> <p>Resolving a URL is the process of taking a relative URL and obtaining the absolute URL that it implies.</p> <div class=impl> <p>To <dfn id=resolve-a-url>resolve a URL</dfn> to an <a href=#absolute-url>absolute URL</a> relative to either another <a href=#absolute-url>absolute URL</a> or an element, the user agent must use the following steps. Resolving a URL can result in an error, in which case the URL is not resolvable.</p> <ol><li><p>Let <var title="">url</var> be the <a href=#url>URL</a> being resolved.</li> <li> <p>Let <var title="">encoding</var> be determined as follows:</p> <dl class=switch><dt>If the URL had a character encoding defined when the URL was created or defined</dt> <dd>The URL character encoding is as defined.</dd> <dt>If the URL came from a script (e.g. as an argument to a method)</dt> <dd>The URL character encoding is the <a href="#script's-url-character-encoding">script's URL character encoding</a>.</dd> <dt>If the URL came from a DOM node (e.g. from an element)</dt> <dd>The node has a <code><a href=#document>Document</a></code>, and the URL character encoding is the <a href="#document's-character-encoding">document's character encoding</a>.</dd> </dl></li> <li><p>If <var title="">encoding</var> is <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, then change the value of <var title="">encoding</var> to UTF-8.</li> <li> <p>If the algorithm was invoked with an <a href=#absolute-url>absolute URL</a> to use as the base URL, let <var title="">base</var> be that <a href=#absolute-url>absolute URL</a>.</p> <p>Otherwise, let <var title="">base</var> be the <i>base URI of the element</i>, as defined by the XML Base specification, with <i>the base URI of the document entity</i> being defined as the <a href=#document-base-url>document base URL</a> of the <code><a href=#document>Document</a></code> that owns the element. <a href=#refsXMLBASE>[XMLBASE]</a></p> <p>For the purposes of the XML Base specification, user agents must act as if all <code><a href=#document>Document</a></code> objects represented XML documents.</p> <p class=note>It is possible for <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attributes to be present even in HTML fragments, as such attributes can be added dynamically using script. (Such scripts would not be conforming, however, as <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attributes are not allowed in <a href=#html-documents>HTML documents</a>.)</p> <p>The <dfn id=document-base-url>document base URL</dfn> of a <code><a href=#document>Document</a></code> object is the <a href=#absolute-url>absolute URL</a> obtained by running these substeps:</p> <ol><li><p>Let <var title="">fallback base url</var> be <a href="#the-document's-address">the document's address</a>.</li> <li> <!-- http://www.hixie.ch/tests/adhoc/html/navigation/javascript-url/ --> <!-- this should be tested in the case of a browsing context that was navigated to about:blank after having been elsewhere, as opposed to the about:blank used at the time of the browsing context's creation. --> <p>If <var title="">fallback base url</var> is <code><a href=#about:blank>about:blank</a></code>, and the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> has a <a href=#creator-browsing-context>creator browsing context</a>, then let <var title="">fallback base url</var> be the <a href=#document-base-url>document base URL</a> of the <a href=#creator-document>creator <code>Document</code></a> instead.</p> </li> <li><p>If the <code><a href=#document>Document</a></code> is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, then let <var title="">fallback base url</var> be the <a href=#document-base-url>document base URL</a> of the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-container>browsing context container</a>'s <code><a href=#document>Document</a></code> instead.</li> <li><p>If there is no <code><a href=#the-base-element>base</a></code> element that has an <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute, then the <a href=#document-base-url>document base URL</a> is <var title="">fallback base url</var>; abort these steps. Otherwise, let <var title="">url</var> be the value of the <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute of the first such element.</li> <li><p><a href=#resolve-a-url title="resolve a URL">Resolve</a> <var title="">url</var> relative to <var title="">fallback base url</var> (thus, the <code><a href=#the-base-element>base</a></code> <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute isn't affected by <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attributes).</li> <li><p>The <a href=#document-base-url>document base URL</a> is the result of the previous step if it was successful; otherwise it is <var title="">fallback base url</var>.</li> </ol></li> <li><p><a href=#parse-a-url title="parse a URL">Parse</a> <var title="">url</var> into its component parts.</li> <li> <p>If parsing <var title="">url</var> resulted in a <a href=#url-host title=url-host><host></a> component, then replace the matching substring of <var title="">url</var> with the string that results from expanding any sequences of percent-encoded octets in that component that are valid UTF-8 sequences into Unicode characters as defined by UTF-8.</p> <p>If any percent-encoded octets in that component are not valid UTF-8 sequences (e.g. sequences of percent-encoded octets that expand to surrogate code points), then return an error and abort these steps.</p> <p>Apply the IDNA ToASCII algorithm to the matching substring, with both the AllowUnassigned and UseSTD3ASCIIRules flags set. Replace the matching substring with the result of the ToASCII algorithm.</p> <p>If ToASCII fails to convert one of the components of the string, e.g. because it is too long or because it contains invalid characters, then return an error and abort these steps. <a href=#refsRFC3490>[RFC3490]</a></p> </li> <li> <p>If parsing <var title="">url</var> resulted in a <a href=#url-path title=url-path><path></a> component, then replace the matching substring of <var title="">url</var> with the string that results from applying the following steps to each character other than U+0025 PERCENT SIGN (%) that doesn't match the original <path> production defined in RFC 3986:</p> <ol><li>Encode the character into a sequence of octets as defined by UTF-8.</li> <li>Replace the character with the percent-encoded form of those octets. <a href=#refsRFC3986>[RFC3986]</a></li> </ol><div class=example> <p>For instance if <var title="">url</var> was "<code title="">//example.com/a^b☺c%FFd%z/?e</code>", then the <a href=#url-path title=url-path><path></a> component's substring would be "<code title="">/a^b☺c%FFd%z/</code>" and the two characters that would have to be escaped would be "<code title="">^</code>" and "<code title="">☺</code>". The result after this step was applied would therefore be that <var title="">url</var> now had the value "<code title="">//example.com/a%5Eb%E2%98%BAc%FFd%z/?e</code>".</p> </div> </li> <li> <p>If parsing <var title="">url</var> resulted in a <a href=#url-query title=url-query><query></a> component, then replace the matching substring of <var title="">url</var> with the string that results from applying the following steps to each character other than U+0025 PERCENT SIGN (%) that doesn't match the original <query> production defined in RFC 3986:</p> <ol><li>If the character in question cannot be expressed in the encoding <var title="">encoding</var>, then replace it with a single 0x3F octet (an ASCII question mark) and skip the remaining substeps for this character.</li> <li>Encode the character into a sequence of octets as defined by the encoding <var title="">encoding</var>.</li> <li>Replace the character with the percent-encoded form of those octets. <a href=#refsRFC3986>[RFC3986]</a></li> </ol></li> <li><p>Apply the algorithm described in RFC 3986 section 5.2 Relative Resolution, using <var title="">url</var> as the potentially relative URI reference (<var title="">R</var>), and <var title="">base</var> as the base URI (<var title="">Base</var>). <a href=#refsRFC3986>[RFC3986]</a></li> <li> <p>Apply any relevant conformance criteria of RFC 3986 and RFC 3987, returning an error and aborting these steps if appropriate. <a href=#refsRFC3986>[RFC3986]</a> <a href=#refsRFC3987>[RFC3987]</a></p> <p class=example>For instance, if an absolute URI that would be returned by the above algorithm violates the restrictions specific to its scheme, e.g. a <code title="">data:</code> URI using the "<code title="">//</code>" server-based naming authority syntax, then user agents are to treat this as an error instead.<!-- RFC 3986, 3.1 Scheme --></p> </li> <li><p>Let <var title="">result</var> be the target URI (<var title="">T</var>) returned by the Relative Resolution algorithm.</li> <li><p>If <var title="">result</var> uses a scheme with a server-based naming authority, replace all U+005C REVERSE SOLIDUS (\) characters in <var title="">result</var> with U+002F SOLIDUS (/) characters.</li> <li><p>Return <var title="">result</var>.</li> </ol><p class=note>Some of the steps in these rules, for example the processing of U+005C REVERSE SOLIDUS (\) characters, are a <a href=#willful-violation>willful violation</a> of RFC 3986 and RFC 3987, motivated by a desire to handle legacy content. <a href=#refsRFC3986>[RFC3986]</a> <a href=#refsRFC3987>[RFC3987]</a></p> </div> <p>A <a href=#url>URL</a> is an <dfn id=absolute-url>absolute URL</dfn> if <a href=#resolve-a-url title="resolve a url">resolving</a> it results in the same output regardless of what it is resolved relative to, and that output is not a failure.</p> <p>An <a href=#absolute-url>absolute URL</a> is a <dfn id=hierarchical-url>hierarchical URL</dfn> if, when <a href=#resolve-a-url title="resolve a url">resolved</a> and then <a href=#parse-a-url title="parse a url">parsed</a>, there is a character immediately after the <a href=#url-scheme title=url-scheme><scheme></a> component and it is a U+002F SOLIDUS character (/).</p> <p>An <a href=#absolute-url>absolute URL</a> is an <dfn id=authority-based-url>authority-based URL</dfn> if, when <a href=#resolve-a-url title="resolve a url">resolved</a> and then <a href=#parse-a-url title="parse a url">parsed</a>, there are two characters immediately after the <a href=#url-scheme title=url-scheme><scheme></a> component and they are both U+002F SOLIDUS characters (//).</p> <div class=impl> <h4 id=url-manipulation-and-creation><span class=secno>2.6.4 </span>URL manipulation and creation</h4> <p>To <dfn id=fragment-escaped title=fragment-escaped>fragment-escape</dfn> a string <var title="">input</var>, a user agent must run the following steps:</p> <ol><li><p>Let <var title="">input</var> be the string to be escaped.</li> <li><p>Let <var title="">position</var> point at the first character of <var title="">input</var>.</li> <li><p>Let <var title="">output</var> be an empty string.</li> <li><p><i>Loop</i>: If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>end</i>.</li> <li> <p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is in the range U+0000 to U+0020 or is one of the following characters:</p> <ul class=brief><li>U+0022 QUOTATION MARK character (") <li>U+0023 NUMBER SIGN character (#) <li>U+0025 PERCENT SIGN character (%) <li>U+003C LESS-THAN SIGN character (<) <li>U+003E GREATER-THAN SIGN character (>) <li>U+005B LEFT SQUARE BRACKET character ([) <li>U+005C REVERSE SOLIDUS character (\) <li>U+005D RIGHT SQUARE BRACKET character (]) <li>U+005E CIRCUMFLEX ACCENT character (^) <li>U+007B LEFT CURLY BRACKET character ({) <li>U+007C VERTICAL LINE character (|) <li>U+007D RIGHT CURLY BRACKET character (}) </ul><p>...then append the percent-encoded form of the character to <var title="">output</var>. <a href=#refsRFC3986>[RFC3986]</a></p> <!-- this is the same phrasing that's used elsewhere in the spec, but we really should define 'percent-encoded' or at least ensure we consistently say whether it's upper-case or lower-case. --> <p>Otherwise, append the character itself to <var title="">output</var>.</p> <p class=note>This escapes any ASCII characters that are not valid in the URI <fragment> production without being escaped.</p> </li> <li><p>Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> <li><p><i>End</i>: Return <var title="">output</var>.</li> </ol></div> <div class=impl> <h4 id=dynamic-changes-to-base-urls><span class=secno>2.6.5 </span>Dynamic changes to base URLs</h4> <p>When an <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attribute changes, the attribute's element, and all descendant elements, are <a href=#affected-by-a-base-url-change>affected by a base URL change</a>.</p> <p>When a document's <a href=#document-base-url>document base URL</a> changes, all elements in that document are <a href=#affected-by-a-base-url-change>affected by a base URL change</a>.</p> <p>The following are <a href=#base-url-change-steps>base URL change steps</a>, which run when an element is <a href=#affected-by-a-base-url-change>affected by a base URL change</a> (as defined by the DOM Core specification):</p> <dl class=switch><dt>If the element creates a <a href=#hyperlink>hyperlink</a></dt> <dd> <p>If the <a href=#absolute-url>absolute URL</a> identified by the hyperlink is being shown to the user, or if any data derived from that URL is affecting the display, then the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute should be <a href=#resolve-a-url title="resolve a url">re-resolved</a> relative to the element and the UI updated appropriately.</p> <p class=example>For example, the CSS <code title=selector-link><a href=#selector-link>:link</a></code>/<code title=selector-visited><a href=#selector-visited>:visited</a></code> pseudo-classes might have been affected.</p> <!--PING--> <p>If the hyperlink has a <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute and its <a href=#absolute-url title="absolute URL">absolute URL(s)</a> are being shown to the user, then the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute's tokens should be <a href=#resolve-a-url title="resolve a url">re-resolved</a> relative to the element and the UI updated appropriately.</p> <!--PING--> </dd> <dt>If the element is a <code><a href=#the-q-element>q</a></code>, <code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#the-ins-element>ins</a></code>, or <code><a href=#the-del-element>del</a></code> element with a <code title="">cite</code> attribute</dt> <dd> <p>If the <a href=#absolute-url>absolute URL</a> identified by the <code title="">cite</code> attribute is being shown to the user, or if any data derived from that URL is affecting the display, then the <a href=#url>URL</a> should be <a href=#resolve-a-url title="resolve a url">re-resolved</a> relative to the element and the UI updated appropriately.</p> </dd> <dt>Otherwise</dt> <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><a href=#the-img-element>img</a></code> elements, although subsequent accesses of the <code title=dom-img-src><a href=#dom-img-src>src</a></code> IDL attribute from script will return a new <a href=#absolute-url>absolute URL</a> that might no longer correspond to the image being shown.</p> </dd> </dl></div> <h4 id=interfaces-for-url-manipulation><span class=secno>2.6.6 </span>Interfaces for URL manipulation</h4> <p>An interface that has a complement of <dfn id=url-decomposition-idl-attributes>URL decomposition IDL attributes</dfn> has seven attributes with the following definitions:</p> <pre class="idl extract"> attribute DOMString <a href=#dom-uda-protocol title=dom-uda-protocol>protocol</a>; attribute DOMString <a href=#dom-uda-host title=dom-uda-host>host</a>; attribute DOMString <a href=#dom-uda-hostname title=dom-uda-hostname>hostname</a>; attribute DOMString <a href=#dom-uda-port title=dom-uda-port>port</a>; attribute DOMString <a href=#dom-uda-pathname title=dom-uda-pathname>pathname</a>; attribute DOMString <a href=#dom-uda-search title=dom-uda-search>search</a>; attribute DOMString <a href=#dom-uda-hash title=dom-uda-hash>hash</a>;</pre> <dl class=domintro><dt><var title="">o</var> . <code title=dom-uda-protocol><a href=#dom-uda-protocol>protocol</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current scheme of the underlying URL.</p> <p>Can be set, to change the underlying URL's scheme.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-host><a href=#dom-uda-host>host</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current host and port (if it's not the default port) in the underlying URL.</p> <p>Can be set, to change the underlying URL's host and port.</p> <p>The host and the port are separated by a colon. The port part, if omitted, will be assumed to be the current scheme's default port.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-hostname><a href=#dom-uda-hostname>hostname</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current host in the underlying URL.</p> <p>Can be set, to change the underlying URL's host.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-port><a href=#dom-uda-port>port</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current port in the underlying URL.</p> <p>Can be set, to change the underlying URL's port.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-pathname><a href=#dom-uda-pathname>pathname</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current path in the underlying URL.</p> <p>Can be set, to change the underlying URL's path.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-search><a href=#dom-uda-search>search</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current query component in the underlying URL.</p> <p>Can be set, to change the underlying URL's query component.</p> </dd> <dt><var title="">o</var> . <code title=dom-uda-hash><a href=#dom-uda-hash>hash</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current fragment identifier in the underlying URL.</p> <p>Can be set, to change the underlying URL's fragment identifier.</p> </dd> </dl><div class=impl> <hr><p>The attributes defined to be <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> must act as described for the attributes with the same corresponding names in this section.</p> <p>In addition, an interface with a complement of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> defines an <dfn id=concept-uda-input title=concept-uda-input>input</dfn>, which is a <a href=#url>URL</a> that the attributes act on, and a <dfn id=concept-uda-setter title=concept-uda-setter>common setter action</dfn>, which is a set of steps invoked when any of the attributes' setters are invoked.</p> <p>The seven <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> have similar requirements.</p> <p>On getting, if the <a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#absolute-url>absolute URL</a> that fulfills the condition given in the "getter condition" column corresponding to the attribute in the table below, the user agent must return the part of the <a href=#concept-uda-input title=concept-uda-input>input</a> URL given in the "component" column, with any prefixes specified in the "prefix" column appropriately added to the start of the string and any suffixes specified in the "suffix" column appropriately added to the end of the string. Otherwise, the attribute must return the empty string.</p> <p>On setting, the new value must first be mutated as described by the "setter preprocessor" column, then mutated by %-escaping any characters in the new value that are not valid in the relevant component as given by the "component" column. Then, if the <a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#absolute-url>absolute URL</a> and the resulting new value fulfills the condition given in the "setter condition" column, the user agent must make a new string <var title="">output</var> by replacing the component of the URL given by the "component" column in the <a href=#concept-uda-input title=concept-uda-input>input</a> URL with the new value; otherwise, the user agent must let <var title="">output</var> be equal to the <a href=#concept-uda-input title=concept-uda-input>input</a>. Finally, the user agent must invoke the <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> with the value of <var title="">output</var>.</p> <p>When replacing a component in the URL, if the component is part of an optional group in the URL syntax consisting of a character followed by the component, the component (including its prefix character) must be included even if the new value is the empty string.</p> <p class=note>The previous paragraph applies in particular to the "<code title="">:</code>" before a <port> component, the "<code title="">?</code>" before a <query> component, and the "<code title="">#</code>" before a <fragment> component.</p> <p>For the purposes of the above definitions, URLs must be parsed using the <a href=#parse-a-url title="parse a URL">URL parsing rules</a> defined in this specification.</p> <table id=table-uda><thead><tr><th>Attribute <th>Component <th>Getter Condition <th>Prefix <th>Suffix <th>Setter Preprocessor <th>Setter Condition <tbody><tr><td><dfn id=dom-uda-protocol title=dom-uda-protocol><code>protocol</code></dfn> <td><a href=#url-scheme title=url-scheme><scheme></a> <td>— <td>— <td>U+003A COLON (:) <td>Remove all trailing U+003A COLON characters (:) <td>The new value is not the empty string <tr><td><dfn id=dom-uda-host title=dom-uda-host><code>host</code></dfn> <td><a href=#url-hostport title=url-hostport><hostport></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a> <td>— <td>— <td>— <td>The new value is not the empty string and <a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a> <tr><td><dfn id=dom-uda-hostname title=dom-uda-hostname><code>hostname</code></dfn> <td><a href=#url-host title=url-host><host></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a> <td>— <td>— <td>Remove all leading U+002F SOLIDUS characters (/) <td>The new value is not the empty string and <a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a> <tr><td><dfn id=dom-uda-port title=dom-uda-port><code>port</code></dfn> <td><a href=#url-port title=url-port><port></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a>, and contained a <a href=#url-port title=url-port><port></a> component (possibly an empty one) <td>— <td>— <td>Remove all characters in the new value from the first that is not in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), if any. Remove any leading U+0030 DIGIT ZERO characters (0) in the new value. If the resulting string is empty, set it to a single U+0030 DIGIT ZERO character (0). <td><a href=#concept-uda-input title=concept-uda-input>input</a> is an <a href=#authority-based-url>authority-based URL</a>, and the new value, when interpreted as a base-ten integer, is less than or equal to 65535 <tr><td><dfn id=dom-uda-pathname title=dom-uda-pathname><code>pathname</code></dfn> <td><a href=#url-path title=url-path><path></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> is a <a href=#hierarchical-url>hierarchical URL</a> <td>— <td>— <td>If it has no leading U+002F SOLIDUS character (/), prepend a U+002F SOLIDUS character (/) to the new value <td><a href=#concept-uda-input title=concept-uda-input>input</a> is hierarchical <tr><td><dfn id=dom-uda-search title=dom-uda-search><code>search</code></dfn> <td><a href=#url-query title=url-query><query></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> is a <a href=#hierarchical-url>hierarchical URL</a>, and contained a <a href=#url-query title=url-query><query></a> component (possibly an empty one) <td>U+003F QUESTION MARK (?) <td>— <td>Remove one leading U+003F QUESTION MARK character (?), if any <td><a href=#concept-uda-input title=concept-uda-input>input</a> is a <a href=#hierarchical-url>hierarchical URL</a> <tr><td><dfn id=dom-uda-hash title=dom-uda-hash><code>hash</code></dfn> <td><a href=#url-fragment title=url-fragment><fragment></a> <td><a href=#concept-uda-input title=concept-uda-input>input</a> contained a non-empty <a href=#url-fragment title=url-fragment><fragment></a> component <td>U+0023 NUMBER SIGN (#) <td>— <td>Remove one leading U+0023 NUMBER SIGN character (#), if any <td>— </table><!-- http://www.hixie.ch/tests/adhoc/dom/level0/location/components/ http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsLocation.cpp http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ref_h-l.htm#84722 --></div> <div class=example> <p>The table below demonstrates how the getter <span class=impl>condition</span> for <code title=dom-uda-search><a href=#dom-uda-search>search</a></code> results in different results depending on the exact original syntax of the URL:</p> <table id=table-uda-examples><thead><tr><th> Input URL <th> <code title=dom-uda-search><a href=#dom-uda-search>search</a></code> value <th> Explanation <tbody><tr><td> <code title="">http://example.com/</code> <td> <i>empty string</i> <td> No <a href=#url-query title=url-query><query></a> component in input URL. <tr><td> <code title="">http://example.com/?</code> <td> <code title="">?</code> <td> There is a <a href=#url-query title=url-query><query></a> component, but it is empty. <span class=impl>The question mark in the resulting value is the prefix.</span> <tr><td> <code title="">http://example.com/?test</code> <td> <code title="">?test</code> <td> The <a href=#url-query title=url-query><query></a> component has the value "<code title="">test</code>". <tr><td> <code title="">http://example.com/?test#</code> <td> <code title="">?test</code> <td> The (empty) <a href=#url-fragment title=url-fragment><fragment></a> component is not part of the <a href=#url-query title=url-query><query></a> component. </table></div> <div class=example> <p>The following table is similar; it provides a list of what each of the <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> returns for a given <var title="">input</var> URL.</p> <table><thead><tr><th>Input <th><code title=dom-uda-protocol><a href=#dom-uda-protocol>protocol</a></code> <th><code title=dom-uda-host><a href=#dom-uda-host>host</a></code> <th><code title=dom-uda-hostname><a href=#dom-uda-hostname>hostname</a></code> <th><code title=dom-uda-port><a href=#dom-uda-port>port</a></code> <th><code title=dom-uda-pathname><a href=#dom-uda-pathname>pathname</a></code> <th><code title=dom-uda-search><a href=#dom-uda-search>search</a></code> <th><code title=dom-uda-hash><a href=#dom-uda-hash>hash</a></code> <tbody><tr><td><code title="">http://example.com/carrot#question%3f</code> <td><code title="">http:</code> <td><code title="">example.com</code> <td><code title="">example.com</code> <td>(empty string) <td><code title="">/carrot</code> <td>(empty string) <td><code title="">#question%3f</code> <tr><td><code title="">https://www.example.com:4443?</code> <td><code title="">https:</code> <td><code title="">www.example.com:4443</code> <td><code title="">www.example.com</code> <td><code title="">4443</code> <td><code title="">/</code> <td><code title="">?</code> <td>(empty string) </table></div> <div class=impl> <h3 id=fetching-resources><span class=secno>2.7 </span>Fetching resources</h3> <p>When a user agent is to <dfn id=fetch>fetch</dfn> a resource or <a href=#url>URL</a>, optionally from an origin <i title="">origin</i>, and optionally with a <i>synchronous flag</i>, a <i>manual redirect flag</i>, a <i>force same-origin flag</i>, and/or a <i>block cookies flag</i>, the following steps must be run. (When a <em>URL</em> is to be fetched, the URL identifies a resource to be obtained.)</p> <!-- if invoked with the synchronous flag, make sure to release the storage mutex first --> <!-- synchronous flag is only to be used in algorithms that are themselves asynchronous! Only sync-XHR is allowed to make the mistake of screwing that up. :-P --> <!-- the force same-origin flag is for use in places where we'll be moving to CORS one day; when used, the algorithm must be invoked with a URL (not something else, like a POST request) whose origin is the same as the /origin/, which must also be present, and the algorithm must not be invoked with the manual redirect flag. --> <!-- "block cookies" is currently only used by XHR --> <ol><li> <p>Let <var title="">document</var> be the appropriate <code><a href=#document>Document</a></code> as given by the following list:</p> <dl class=switch><dt>When <a href=#navigate title=navigate>navigating</a></dt> <dd>The <a href=#active-document>active document</a> of the <a href=#source-browsing-context>source browsing context</a>.</dd> <dt>When fetching resources for an element</dt> <dd>The element's <code><a href=#document>Document</a></code>.</dd> <dt>When fetching resources in response to a call to an API</dt> <dd>The <a href=#entry-script>entry script</a>'s <a href="#script's-document" title="script's document">document</a>.</dd> </dl></li> <li> <p>While <var title="">document</var> is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, let <var title="">document</var> be <var title="">document</var>'s <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-container>browsing context container</a>'s <code><a href=#document>Document</a></code> instead.</p> </li> <li> <p>Generate the <i>address of the resource from which Request-URIs are obtained</i> as required by HTTP for the <code title=http-referer>Referer</code> (sic) header from <a href="#the-document's-current-address">the document's current address</a> of <var title="">document</var>. <a href=#refsHTTP>[HTTP]</a></p> <p>Remove any <a href=#url-fragment title=url-fragment><fragment></a> component from the generated <i>address of the resource from which Request-URIs are obtained</i>.</p> <!-- RFC2616 says "The URI MUST NOT include a fragment." (section 14.36) --> <p>If the <a href=#origin>origin</a> of the appropriate <code><a href=#document>Document</a></code> is not a scheme/host/port tuple, then the <code title=http-referer>Referer</code> (sic) header must be omitted, regardless of its value.</p> </li> <li><p>If the algorithm was not invoked with the <i>synchronous flag</i>, perform the remaining steps asynchronously.</li> <li> <p>This is the <i>main step</i>.</p> <p>If the resource is identified by an <a href=#absolute-url>absolute URL</a>, and the resource is to be obtained using an idempotent action (such as an HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>), and it is already being downloaded for other reasons (e.g. another invocation of this algorithm), and this request would be identical to the previous one (e.g. same <code title=http-accept>Accept</code> and <code title=http-origin>Origin</code> headers), and the user agent is configured such that it is to reuse the data from the existing download instead of initiating a new one, then use the results of the existing download instead of starting a new one.</p> <p>Otherwise, if the resource is identified by an <a href=#absolute-url>absolute URL</a> with a scheme that does not define a mechanism to obtain the resource (e.g. it is a <code title="">mailto:</code> URL) or that the user agent does not support, then act as if the resource was an HTTP 204 No Content response with no other metadata.</p> <p>Otherwise, if the resource is identified by the <a href=#url>URL</a> <dfn id=about:blank><code>about:blank</code></dfn>, then the resource is immediately available and consists of the empty string, with no metadata.</p> <p>Otherwise, at a time convenient to the user and the user agent, download (or otherwise obtain) the resource, applying the semantics of the relevant specifications (e.g. performing an HTTP GET or POST operation, or reading the file from disk, <a href=#concept-js-deref title=concept-js-deref>dereferencing <span title="javascript protocol"><code title="">javascript:</code> URLs</span></a>, etc).</p> <p>For the purposes of the <code title=http-referer>Referer</code> (sic) header, use the <i>address of the resource from which Request-URIs are obtained</i> generated in the earlier step.</p> <p>For the purposes of the <code title=http-origin>Origin</code> header, if the <a href=#fetch title=fetch>fetching algorithm</a> was explicitly initiated from an <i title="">origin</i>, then <i title="">the origin that initiated the HTTP request</i> is <i title="">origin</i>. Otherwise, this is <i title="">a request from a "privacy-sensitive" context</i>. <a href=#refsORIGIN>[ORIGIN]</a></p> </li> <li> <p>If the algorithm was not invoked with the <i>block cookies flag</i>, and there are cookies to be set, then the user agent must run the following substeps:</p> <ol><li><p>Wait until ownership of the <a href=#storage-mutex>storage mutex</a> can be taken by this instance of the <a href=#fetch title=fetch>fetching</a> algorithm.</li> <li><p>Take ownership of the <a href=#storage-mutex>storage mutex</a>.</li> <li><p>Update the cookies. <a href=#refsCOOKIES>[COOKIES]</a></li> <li><p>Release the <a href=#storage-mutex>storage mutex</a> so that it is once again free.</li> </ol></li> <li> <p>If the fetched resource is an HTTP redirect <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, then:</p> <dl class=switch><dt>If the <i>force same-origin flag</i> is set and the <a href=#url>URL</a> of the target of the redirect does not have the <a href=#same-origin>same origin</a> as the <a href=#url>URL</a> for which the <a href=#fetch>fetch</a> algorithm was invoked</dt> <dd> <p>Abort these steps and return failure from this algorithm, as if the remote host could not be contacted.</p> </dd> <dt>If the <i>manual redirect flag</i> is set</dt> <dd> <p>Continue, using the fetched resource (the redirect) as the result of the algorithm. If the calling algorithm subsequently requires the user agent to <dfn id=transparently-follow-the-redirect>transparently follow the redirect</dfn>, then the user agent must resume this algorithm from the <i>main step</i>, but using the target of the redirect as the resource to fetch, rather than the original resource.</p> </dd> <dt>Otherwise</dt> <dd> <p>First, apply any relevant requirements for redirects (such as showing any appropriate prompts). Then, redo <i>main step</i>, but using the target of the redirect as the resource to fetch, rather than the original resource.</p> <p class=note>The HTTP specification requires that 301, 302, and 307 redirects, when applied to methods other than the safe methods, not be followed without user confirmation. That would be an appropriate prompt for the purposes of the requirement in the paragraph above. <a href=#refsHTTP>[HTTP]</a></p> </dd> </dl></li> <li> <p>If the algorithm was not invoked with the <i>synchronous flag</i>: When the resource is available, or if there is an error of some description, <a href=#queue-a-task>queue a task</a> that uses the resource as appropriate. If the resource can be processed incrementally, as, for instance, with a progressively interlaced JPEG or an HTML file, additional tasks may be queued to process the data as it is downloaded. The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#networking-task-source>networking task source</a>.</p> <p>Otherwise, return the resource or error information to the calling algorithm.</p> </li> </ol><p>If the user agent can determine the actual length of the resource being <a href=#fetch title=fetch>fetched</a> for an instance of this algorithm, and if that length is finite, then that length is the file's <dfn id=concept-fetch-total title=concept-fetch-total>size</dfn>. Otherwise, the subject of the algorithm (that is, the resource being fetched) has no known <a href=#concept-fetch-total title=concept-fetch-total>size</a>. (For example, the HTTP <code title=http-content-length>Content-Length</code> header might provide this information.)</p> <p>The user agent must also keep track of the <dfn id=concept-fetch-loaded title=concept-fetch-loaded>number of bytes downloaded</dfn> for each instance of this algorithm. This number must exclude any out-of-band metadata, such as HTTP headers.</p> <p class=note>The <a href=#application-cache>application cache</a> processing model introduces some <a href=#changesToNetworkingModel>changes to the networking model</a> to handle the returning of cached resources.</p> <p class=note>The <a href=#navigate title=navigate>navigation</a> processing model handles redirects itself, overriding the redirection handling that would be done by the fetching algorithm.</p> <p class=note>Whether the <a href=#content-type-sniffing>type sniffing rules</a> apply to the fetched resource depends on the algorithm that invokes the rules — they are not always applicable.</p> <h4 id=concept-http-equivalent><span class=secno>2.7.1 </span>Protocol concepts</h4> <p>User agents can implement a variety of transfer protocols, but this specification mostly defines behavior in terms of HTTP. <a href=#refsHTTP>[HTTP]</a></p> <p>The <dfn id=concept-http-equivalent-get title=concept-http-equivalent-get>HTTP GET method</dfn> is equivalent to the default retrieval action of the protocol. For example, RETR in FTP. Such actions are idempotent and safe, in HTTP terms.</p> <p>The <dfn id=concept-http-equivalent-codes title=concept-http-equivalent-codes>HTTP response codes</dfn> are equivalent to statuses in other protocols that have the same basic meanings. For example, a "file not found" error is equivalent to a 404 code, a server error is equivalent to a 5xx code, and so on.</p> <p>The <dfn id=concept-http-equivalent-headers title=concept-http-equivalent-headers>HTTP headers</dfn> are equivalent to fields in other protocols that have the same basic meaning. For example, the HTTP authentication headers are equivalent to the authentication aspects of the FTP protocol.</p> <h4 id=encrypted-http-and-related-security-concerns><span class=secno>2.7.2 </span>Encrypted HTTP and related security concerns</h4> <p>Anything in this specification that refers to HTTP also applies to HTTP-over-TLS, as represented by <a href=#url title=url>URLs</a> representing the <code title="">https</code> scheme.</p> <p class=warning>User agents should report certificate errors to the user and must either refuse to download resources sent with erroneous certificates or must act as if such resources were in fact served with no encryption.</p> <p>User agents should warn the user that there is a potential problem whenever the user visits a page that the user has previously visited, if the page uses less secure encryption on the second visit.</p> <p>Not doing so can result in users not noticing man-in-the-middle attacks.</p> <div class=example> <p>If a user connects to a server with a self-signed certificate, the user agent could allow the connection but just act as if there had been no encryption. If the user agent instead allowed the user to override the problem and then displayed the page as if it was fully and safely encrypted, the user could be easily tricked into accepting man-in-the-middle connections.</p> <p>If a user connects to a server with full encryption, but the page then refers to an external resource that has an expired certificate, then the user agent will act as if the resource was unavailable, possibly also reporting the problem to the user. If the user agent instead allowed the resource to be used, then an attacker could just look for "secure" sites that used resources from a different host and only apply man-in-the-middle attacks to that host, for example taking over scripts in the page.</p> <p>If a user bookmarks a site that uses a CA-signed certificate, and then later revisits that site directly but the site has started using a self-signed certificate, the user agent could warn the user that a man-in-the-middle attack is likely underway, instead of simply acting as if the page was not encrypted.</p> </div> <h4 id=content-type-sniffing><span class=secno>2.7.3 </span>Determining the type of a resource</h4> <p>The <dfn id=content-type title=Content-Type>Content-Type metadata</dfn> of a resource must be obtained and interpreted in a manner consistent with the requirements of the Media Type Sniffing specification. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p> <p>The <dfn id=content-type-sniffing-0 title="Content-Type sniffing">sniffed type of a resource</dfn> must be found in a manner consistent with the requirements given in the Media Type Sniffing specification for finding the <i>sniffed-type</i> of the relevant sequence of octets. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p> <p>The <dfn id=content-type-sniffing:-image title="Content-Type sniffing: image">rules for sniffing images specifically</dfn> and the <dfn id=content-type-sniffing:-text-or-binary title="Content-Type sniffing: text or binary">rules for distinguishing if a resource is text or binary</dfn> are also defined in the Media Type Sniffing specification. Both sets of rules return a <a href=#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 Media Type Sniffing specification 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 Media Type Sniffing specification. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p> <h4 id=extracting-encodings-from-meta-elements><span class=secno>2.7.4 </span>Extracting encodings from <code><a href=#the-meta-element>meta</a></code> elements</h4> <p>The <dfn id=algorithm-for-extracting-an-encoding-from-a-meta-element>algorithm for extracting an encoding from a <code>meta</code> element</dfn>, given a string <var title="">s</var>, is as follows. It either returns an encoding or nothing.</p> <ol><!-- http://www.hixie.ch/tests/adhoc/html/parsing/encoding/all.html --><li><p>Let <var title="">position</var> be a pointer into <var title="">s</var>, initially pointing at the start of the string.</li> <li><p><i>Loop</i>: Find the first seven characters in <var title="">s</var> after <var title="">position</var> that are an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the word "<code title="">charset</code>". If no such match is found, return nothing and abort these steps.</li> <li><p>Skip any U+0009, U+000A, U+000C, U+000D, or U+0020 characters that immediately follow the word "<code title="">charset</code>" (there might not be any).</li> <li><p>If the next character is not a U+003D EQUALS SIGN ('='), then move <var title="">position</var> to point just before that next character, and jump back to the step labeled <i>loop</i>.</li> <li><p>Skip any U+0009, U+000A, U+000C, U+000D, or U+0020 characters that immediately follow the equals sign (there might not be any).</li> <li> <p>Process the next character as follows:</p> <dl class=switch><dt>If it is a U+0022 QUOTATION MARK ('"') and there is a later U+0022 QUOTATION MARK ('"') in <var title="">s</var></dt> <dt>If it is a U+0027 APOSTROPHE ("'") and there is a later U+0027 APOSTROPHE ("'") in <var title="">s</var></dt> <dd>Return the encoding corresponding to the string between this character and the next earliest occurrence of this character.</dd> <dt>If it is an unmatched U+0022 QUOTATION MARK ('"')</dt> <dt>If it is an unmatched U+0027 APOSTROPHE ("'")</dt> <dt>If there is no next character</dt> <dd>Return nothing.</dd> <dt>Otherwise</dt> <dd>Return the encoding corresponding to the string from this character to the first U+0009, U+000A, U+000C, U+000D, U+0020, or U+003B character or the end of <var title="">s</var>, whichever comes first.</dd> </dl></li> </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<!-- not to mention not having any rules for error-handling, which is of course why we're having to define it ourselves -->). 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> </div> <h4 id=cors-settings-attributes><span class=secno>2.7.5 </span>CORS settings attributes</h4> <p>A <dfn id=cors-settings-attribute>CORS settings attribute</dfn> is an <a href=#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 title=attr-crossorigin-anonymous-keyword><code>anonymous</code></dfn> <td><dfn id=attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</dfn> <td>Cross-origin CORS requests for the element will not have the <i>credentials flag</i> set. <tr><td><dfn id=attr-crossorigin-use-credentials-keyword title=attr-crossorigin-use-credentials-keyword><code>use-credentials</code></dfn> <td><dfn id=attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</dfn> <td>Cross-origin CORS requests for the element will have the <i>credentials flag</i> set. </table><p>The empty string is also a valid keyword, and maps to the <a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a> state. The attribute's <i>invalid value default</i> is the <a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a> state. The <i>missing value default</i>, used when the attribute is omitted, is the <dfn id=attr-crossorigin-none title=attr-crossorigin-none>No CORS</dfn> state.</p> <div class=impl> <h4 id=cors-enabled-fetch><span class=secno>2.7.6 </span>CORS-enabled fetch</h4> <p>When the user agent is required to perform a <dfn id=potentially-cors-enabled-fetch>potentially CORS-enabled fetch</dfn> of an <a href=#absolute-url>absolute URL</a> <var title="">URL</var>, with a mode <var title="">mode</var> that is either "<a href=#attr-crossorigin-none title=attr-crossorigin-none>No CORS</a>", "<a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a>", or "<a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</a>", an <a href=#origin>origin</a> <var title="">origin</var>, and a default origin behaviour <var title="">default</var> which is either "<i>taint</i>" or "<i>fail</i>", it must run the first applicable set of steps from the following list. The default origin behaviour is only used if <var title="">mode</var> is "<a href=#attr-crossorigin-none title=attr-crossorigin-none>No CORS</a>". This algorithm wraps the <a href=#fetch>fetch</a> algorithm above, and labels the obtained resource as either <dfn id=cors-same-origin>CORS-same-origin</dfn> or <dfn id=cors-cross-origin>CORS-cross-origin</dfn>, or blocks the resource entirely.</p> <dl class=switch><dt>If <var title="">mode</var> is "<a href=#attr-crossorigin-none title=attr-crossorigin-none>No CORS</a>"</dt> <dd> <p>Run these substeps:</p> <ol><li><p>Let <var title="">result</var> have no value.</li> <li><p><a href=#fetch>Fetch</a> <var title="">URL</var>, with the <i>manual redirect flag</i> set.</li> <!-- http-origin privacy sensitive --> <li><p><i>Loop</i>: Wait for the <a href=#fetch>fetch</a> algorithm to know if the result is a redirect or not.</li> <li> <p>If the result of the <a href=#fetch>fetch</a> is a redirect, and <var title="">result</var> still has no value, then apply the CORS <a href=#redirect-steps>redirect steps</a>, with the CORS <a href=#credential-flag>credential flag</a> set to true and the <i>request rules</i> being that the user agent continue to follow these steps. If this resumes the <a href=#fetch>fetch</a> algorithm, then return to the <i>loop</i> step. If it failed due to a failure of the CORS <a href=#resource-sharing-check>resource sharing check</a>, then: if <var title="">default</var> is <i>fail</i>, then set <var title="">result</var> to <i>fail</i> and jump to the step labeled <i>end</i>; if <var title="">default</var> is <i>taint</i>, then set <var title="">result</var> to <i>taint</i>, <a href=#transparently-follow-the-redirect>transparently follow the redirect</a> but with the <i>manual redirect flag</i> no longer set, and jump to the step labeled <i>end</i> below.</p> <p>Otherwise, if the resource is not available (e.g. there is a network error) then set <var title="">result</var> to the same value as <var title="">default</var>, and jump to the step labeled <i>end</i> below.</p> <p>Otherwise, perform a <a href=#resource-sharing-check>resource sharing check</a>, with the CORS <a href=#credential-flag>credential flag</a> set to true. If it returns fail, then set <var title="">result</var> to the same value as <var title="">default</var>; otherwise, set <var title="">result</var> to <i>success</i>. Then, jump to the step labeled <i>end</i> below.</p> </li> <li> <p><i>End</i>: Jump to the appropriate step from the following list:</p> <dl class=switch><dt>If <var title="">result</var> is <i>fail</i></dt> <dd> <p>Discard all fetched data and prevent any <a href=#concept-task title=concept-task>tasks</a> from the <a href=#fetch>fetch</a> algorithm from being <a href=#queue-a-task title="queue a task">queued</a>. For the purposes of the calling algorithm, the user agent must act as if there was a fatal network error and no resource was obtained. The user agent may report a cross-origin resource access failure to the user (e.g. in a debugging console).</p> </dd> <dt>If <var title="">result</var> is <i>taint</i></dt> <dd> <p>The <a href=#concept-task title=concept-task>tasks</a> from the <a href=#fetch>fetch</a> algorithm are <a href=#queue-a-task title="queue a task">queued</a> normally, but for the purposes of the calling algorithm, the obtained resource is <a href=#cors-cross-origin>CORS-cross-origin</a>. The user agent may report a cross-origin resource access failure to the user (e.g. in a debugging console).</p> </dd> <dt>If <var title="">result</var> is <i>success</i></dt> <dd> <p>The <a href=#concept-task title=concept-task>tasks</a> from the <a href=#fetch>fetch</a> algorithm are <a href=#queue-a-task title="queue a task">queued</a> normally, and for the purposes of the calling algorithm, the obtained resource is <a href=#cors-same-origin>CORS-same-origin</a>.</p> </dd> </dl></li> </ol></dd> <dt>If <var title="">mode</var> is "<a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a>" or "<a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</a>"</dt> <dd> <p>Run these steps:</p> <ol><li><p>Perform a <a href=#cross-origin-request>cross-origin request</a> with the <i>request URL</i> set to <var title="">URL</var>, the <i>source origin</i> set to <var title="">origin</var>, and the <i>credentials flag</i> set to true if <var title="">mode</var> is "<a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</a>" and set to false otherwise. <a href=#refsCORS>[CORS]</a></li> <li><p>Wait for the CORS <a href=#cross-origin-request-status>cross-origin request status</a> to have a value.</li> <li> <p>Jump to the appropriate step from the following list:</p> <dl class=switch><dt>If the CORS <a href=#cross-origin-request-status>cross-origin request status</a> is not <i>success</i></dt> <dd> <p>Discard all fetched data and prevent any <a href=#concept-task title=concept-task>tasks</a> from the <a href=#fetch>fetch</a> algorithm from being <a href=#queue-a-task title="queue a task">queued</a>. For the purposes of the calling algorithm, the user agent must act as if there was a fatal network error and no resource was obtained. If a CORS <a href=#resource-sharing-check>resource sharing check</a> failed, the user agent may report a cross-origin resource access failure to the user (e.g. in a debugging console).</p> </dd> <dt>If the CORS <a href=#cross-origin-request-status>cross-origin request status</a> is <i>success</i></dt> <dd> <p>The <a href=#concept-task title=concept-task>tasks</a> from the <a href=#fetch>fetch</a> algorithm are <a href=#queue-a-task title="queue a task">queued</a> normally, and for the purposes of the calling algorithm, the obtained resource is <a href=#cors-same-origin>CORS-same-origin</a>.</p> </dd> </dl></li> </ol></dd> </dl></div> <h3 id=common-dom-interfaces><span class=secno>2.8 </span>Common DOM interfaces</h3> <h4 id=reflecting-content-attributes-in-idl-attributes><span class=secno>2.8.1 </span>Reflecting content attributes in IDL attributes</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> <!-- v2 for completeness: (also search for REFLECTIDL) <p class="note">A list of <span>reflecting IDL attributes</span> and their corresponding content attributes is given in the index.</p> --> <div class=impl> <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>DOMString</code> attribute whose content attribute is defined to contain a <a href=#url>URL</a>, then on getting, the IDL attribute must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of the content attribute relative to the element and return the resulting <a href=#absolute-url>absolute URL</a> if that was successful, or the empty string otherwise; and on setting, must set the content attribute to the specified literal value. If the content attribute is absent, the IDL attribute must return the default value, if the content attribute has one, or else the empty string.</p> <p>If a reflecting IDL attribute is a <code>DOMString</code> attribute whose content attribute is defined to contain one or more <a href=#url title=URL>URLs</a>, then on getting, the IDL attribute must <a href=#split-a-string-on-spaces title="split a string on spaces">split the content attribute on spaces</a> and return the concatenation of <a href=#resolve-a-url title="resolve a URL">resolving</a> each token URL to an <a href=#absolute-url>absolute URL</a> relative to the element, with a single U+0020 SPACE character between each URL, ignoring any tokens that did not resolve successfully. If the content attribute is absent, the IDL attribute must return the default value, if the content attribute has one, or else the empty string. On setting, the IDL attribute must set the content attribute to the specified literal value.</p> <p>If a reflecting IDL attribute is a <code>DOMString</code> attribute whose content attribute is an <a href=#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), or the empty string if the attribute is in a state that has no associated keyword value; and on setting, the content attribute must be set to the specified new value.</p> <p>If a reflecting IDL attribute is a <code>DOMString</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 title="">boolean</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 title="boolean attribute">boolean content attributes</a>.)</p> <p>If a reflecting IDL attribute has a signed integer type (<code>long</code>) then, on getting, the content attribute must be parsed according to the <a href=#rules-for-parsing-integers title="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>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>long</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>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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. Otherwise, the given value must be converted to the shortest possible string representing the number as a <a href=#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>unsigned long</code>) then, on getting, the content attribute must be parsed according to the <a href=#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 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, the given value must be converted to the shortest possible string representing the number as a <a href=#valid-non-negative-integer>valid non-negative integer</a> and then that string must be used as the new content attribute value.</p> <!-- see http://www.w3.org/Bugs/Public/show_bug.cgi?id=10352 and https://bugzilla.mozilla.org/show_bug.cgi?id=586118 for why the range is clamped to 2147483647 rather the normal unsigned long maximum value of 4294967295 --> <p>If a reflecting IDL attribute has an unsigned integer type (<code>unsigned long</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>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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. Otherwise, the given value must be converted to the shortest possible string representing the number as a <a href=#valid-non-negative-integer>valid non-negative integer</a> and then that string must be used as the new content attribute value.</p> <!-- see previous paragraph for note about the range --> <p>If a reflecting IDL attribute has a floating point number type (<code>double</code>), then, on getting, the content attribute must be parsed according to the <a href=#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>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>double</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>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>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 <a href=#float-nan>defined earlier</a>.</p> <p>If a reflecting IDL attribute has the type <code><a href=#domtokenlist>DOMTokenList</a></code> or <code><a href=#domsettabletokenlist>DOMSettableTokenList</a></code>, then on getting it must return a <code><a href=#domtokenlist>DOMTokenList</a></code> or <code><a href=#domsettabletokenlist>DOMSettableTokenList</a></code> object (as appropriate) whose underlying string is the element's corresponding content attribute. When the object mutates its underlying string, the content attribute must itself be immediately mutated. When the attribute is absent, then the string represented by the object is the empty string; when the object mutates this empty string, the user agent must add the corresponding content attribute, with its value set to the value it would have been set to after mutating the empty string. The same <code><a href=#domtokenlist>DOMTokenList</a></code> or <code><a href=#domsettabletokenlist>DOMSettableTokenList</a></code> object must be returned every time for each attribute.</p> <div class=example> <p>If an element with no attributes has its <code title=dom-tokenlist-remove>element.classList.remove()</code> method invoked, the underlying string won't be changed, since the result of removing any token from the empty string is still the empty string. However, if the <code title=dom-tokenlist-add>element.classList.add()</code> method is then invoked, a <code title=attr-class><a href=#classes>class</a></code> attribute will be added to the element with the value of the token to be added.</p> </div> <p>If a reflecting IDL attribute has the type <code><a href=#htmlelement>HTMLElement</a></code>, or an interface that descends from <code><a href=#htmlelement>HTMLElement</a></code>, then, on getting, it must run the following algorithm (stopping at the first point where a value is returned):</p> <ol><li>If the corresponding content attribute is absent, then the IDL attribute must return null.</li> <li>Let <var title="">candidate</var> be the element that the <code title=dom-Document-getElementById><a href=#dom-document-getelementbyid>document.getElementById()</a></code> method would find when called on the content attribute's document if it were passed as its argument the current value of the corresponding content attribute.</li> <li>If <var title="">candidate</var> is null, or if it is not type-compatible with the IDL attribute, then the IDL attribute must return null.</li> <li>Otherwise, it must return <var title="">candidate</var>.</li> </ol><p>On setting, if the given element has an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute, and has the same <a href=#home-subtree>home subtree</a> as the element of the attribute being set, and the given element is the first element in that <a href=#home-subtree>home subtree</a> whose <a href=#concept-id title=concept-ID>ID</a> is the value of that <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute, then the content attribute must be set to the value of that <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute. Otherwise, the content attribute must be set to the empty string.</p> </div> <h4 id=collections-0><span class=secno>2.8.2 </span>Collections</h4> <p>The <code><a href=#htmlallcollection>HTMLAllCollection</a></code>, <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code>, <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code>, <!--MD--> and <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> <!--MD--> interfaces are <a href=#collections>collections</a> derived from the <code><a href=#htmlcollection>HTMLCollection</a></code> interface.</p> <h5 id=htmlallcollection-0><span class=secno>2.8.2.1 </span>HTMLAllCollection</h5> <p>The <code><a href=#htmlallcollection>HTMLAllCollection</a></code> interface represents a generic <a href=#collections title=collections>collection</a> of elements just like <code><a href=#htmlcollection>HTMLCollection</a></code>, with the exception that its <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem()</a></code> method returns an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object when there are multiple matching elements.</p> <pre class=idl>interface <dfn id=htmlallcollection>HTMLAllCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> { // inherits <span title=dom-HTMLCollection-length>length</span> and <span title=dom-HTMLCollection-item>item</span>() legacycaller getter object? <a href=#dom-htmlallcollection-nameditem title=dom-HTMLAllCollection-namedItem>namedItem</a>(DOMString name); // overrides inherited namedItem() <a href=#htmlallcollection>HTMLAllCollection</a> <a href=#dom-htmlallcollection-tags title=dom-HTMLAllCollection-tags>tags</a>(DOMString tagName); };</pre> <dl class=domintro><dt><var title="">collection</var> . <code title=dom-HTMLCollection-length>length</code></dt> <dd> <p>Returns the number of elements in the collection.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLCollection-item>item</code>(<var title="">index</var>)</dt> <dt><var title="">collection</var>[<var title="">index</var>]</dt> <dt><var title="">collection</var>(<var title="">index</var>)</dt> <dd> <p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href=#tree-order>tree order</a>.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">collection</var> = <var title="">collection</var> . <code title=dom-HTMLAllCollection-namedItem><a href=#dom-htmlallcollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">collection</var>[<var title="">name</var>]</dt> <dt><var title="">collection</var>(<var title="">name</var>)</dt> <dd> <p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or name <var title="">name</var> from the collection.</p> <p>If there are multiple matching items, then an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object containing all those elements is returned.</p> <p>Only <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, and <code><a href=#the-object-element>object</a></code> elements can have a name for the purpose of this method; their name is given by the value of their <code title="">name</code> attribute.</p> </dd> <dt><var title="">collection</var> = <var title="">collection</var> . <code title=dom-HTMLAllCollection-tags><a href=#dom-htmlallcollection-tags>tags</a></code>(<var title="">tagName</var>)</dt> <dd> <p>Returns a collection that is a filtered view of the current collection, containing only elements with the given tag name.</p> </dd> </dl><div class=impl> <p>The object's <a href=#supported-property-indices>supported property indices</a> and <a href=#supported-property-names>supported property names</a> are as defined for <code><a href=#htmlcollection>HTMLCollection</a></code> objects.</p> <p>The <dfn id=dom-htmlallcollection-nameditem title=dom-HTMLAllCollection-namedItem><code>namedItem(<var title="">key</var>)</code></dfn> method must act according to the following algorithm:</p> <ol><li> <p>Let <var title="">collection</var> be an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object rooted at the same node as the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked, whose filter matches only elements that already match the filter of the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked and that are either:</p> <ul><li><code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <code><a href=#the-object-element>object</a></code> elements with a <code title="">name</code> attribute equal to <var title="">key</var>, or,</li> <li>elements with an <a href=#concept-id title=concept-id>ID</a> equal to <var title="">key</var>.</li> </ul></li> <li>If, at the time the method is called, there is exactly one node in <var title="">collection</var>, then return that node and stop the algorithm.</li> <li>Otherwise, if, at the time the method is called, <var title="">collection</var> is empty, return null and stop the algorithm.</li> <li>Otherwise, return <var title="">collection</var>.</li> </ol><p>The <dfn id=dom-htmlallcollection-tags title=dom-HTMLAllCollection-tags><code>tags(<var title="">tagName</var>)</code></dfn> method must return an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> rooted at the same node as the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked, whose filter matches only <a href=#html-elements>HTML elements</a> whose local name is the <var title="">tagName</var> argument and that already match the filter of the <code><a href=#htmlallcollection>HTMLAllCollection</a></code> object on which the method was invoked. In <a href=#html-documents>HTML documents</a>, the argument must first be <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</p> <!--if legacycaller is removed: <p>In addition to the above, <code>HTMLAllCollection</code> objects, in JavaScript, must be callable. Calling such an object must implicitly invoke the index getter with the same arguments.</p> --> </div> <h5 id=htmlformcontrolscollection-0><span class=secno>2.8.2.2 </span>HTMLFormControlsCollection</h5> <p>The <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code> interface represents a <a href=#collections title=collections>collection</a> of <a href=#category-listed title=category-listed>listed elements</a> in <code><a href=#the-form-element>form</a></code> and <code><a href=#the-fieldset-element>fieldset</a></code> elements.</p> <pre class=idl>interface <dfn id=htmlformcontrolscollection>HTMLFormControlsCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> { // inherits <span title=dom-HTMLCollection-length>length</span> and <span title=dom-HTMLCollection-item>item</span>() legacycaller getter object? <a href=#dom-htmlformcontrolscollection-nameditem title=dom-HTMLFormControlsCollection-namedItem>namedItem</a>(DOMString name); // overrides inherited namedItem() }; interface <dfn id=radionodelist>RadioNodeList</dfn> : <a href=#nodelist>NodeList</a> { attribute DOMString <a href=#dom-radionodelist-value title=dom-RadioNodeList-value>value</a>; };</pre> <dl class=domintro><dt><var title="">collection</var> . <code title=dom-HTMLCollection-length>length</code></dt> <dd> <p>Returns the number of elements in the collection.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLCollection-item>item</code>(<var title="">index</var>)</dt> <dt><var title="">collection</var>[<var title="">index</var>]</dt> <dt><var title="">collection</var>(<var title="">index</var>)</dt> <dd> <p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href=#tree-order>tree order</a>.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLFormControlsCollection-namedItem><a href=#dom-htmlformcontrolscollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">radioNodeList</var> = <var title="">collection</var> . <code title=dom-HTMLFormControlsCollection-namedItem><a href=#dom-htmlformcontrolscollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">collection</var>[<var title="">name</var>]</dt> <dt><var title="">collection</var>(<var title="">name</var>)</dt> <dd> <p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> <var title="">name</var> from the collection.</p> <p>If there are multiple matching items, then a <code><a href=#radionodelist>RadioNodeList</a></code> object containing all those elements is returned.</p> </dd> <dt><var title="">radioNodeList</var> . <var title="">value</var> [ = <var title="">value</var> ]</dt> <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> </dd> </dl><div class=impl> <p>The object's <a href=#supported-property-indices>supported property indices</a> are as defined for <code><a href=#htmlcollection>HTMLCollection</a></code> objects.</p> <p>The <a href=#supported-property-names>supported property names</a> consist of the values of all the <code title=attr-id><a href=#the-id-attribute>id</a></code> and <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attributes of all the elements <a href=#represented-by-the-collection>represented by the collection</a>.</p> <p>The <dfn id=dom-htmlformcontrolscollection-nameditem title=dom-HTMLFormControlsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the following algorithm:</p> <ol><li>If, at the time the method is called, there is exactly one node in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>, then return that node and stop the algorithm.</li> <li>Otherwise, if there are no nodes in the collection that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li> <li>Otherwise, create a new <code><a href=#radionodelist>RadioNodeList</a></code> object representing a <a href=#live>live</a> view of the <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code> object, further filtered so that the only nodes in the <code><a href=#radionodelist>RadioNodeList</a></code> object are those that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href=#radionodelist>RadioNodeList</a></code> object must be sorted in <a href=#tree-order>tree order</a>.</li> <li>Return that <code><a href=#radionodelist>RadioNodeList</a></code> object.</li> </ol><hr><p>Members of the <code><a href=#radionodelist>RadioNodeList</a></code> interface inherited from the <code><a href=#nodelist>NodeList</a></code> interface must behave as they would on a <code><a href=#nodelist>NodeList</a></code> object.</p> <p>The <dfn id=dom-radionodelist-value title=dom-RadioNodeList-value><code>value</code></dfn> IDL attribute on the <code><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 title="">element</var> be the first element in <a href=#tree-order>tree order</a> represented by the <code><a href=#radionodelist>RadioNodeList</a></code> object that is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state and whose <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is true. Otherwise, let it be null.</li> <li><p>If <var title="">element</var> is null, or if it is an element with no <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, return the empty string.</li> <li><p>Otherwise, return the value of <var title="">element</var>'s <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute.</li> </ol><p>On setting, the <code title=dom-RadioNodeList-value><a href=#dom-radionodelist-value>value</a></code> IDL attribute must run the following steps:</p> <ol><li><p>Let <var title="">element</var> be the first element in <a href=#tree-order>tree order</a> represented by the <code><a href=#radionodelist>RadioNodeList</a></code> object that is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state and whose <code title=attr-input-value><a href=#attr-input-value>value</a></code> content attribute is present and equal to the new value, if any. Otherwise, let it be null.</li> <li><p>If <var title="">element</var> is not null, then set its <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> to true.</p> </ol><!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E...%0A%3Cform%20name%3D%22a%22%3E%3Cinput%20id%3D%22x%22%20name%3D%22y%22%3E%3Cinput%20name%3D%22x%22%20id%3D%22y%22%3E%3C/form%3E%0A%3Cscript%3E%0A%20%20var%20x%3B%0A%20%20w%28x%20%3D%20document.forms%5B%27a%27%5D%5B%27x%27%5D%29%3B%0A%20%20w%28x.length%29%3B%0A%20%20x%5B0%5D.parentNode.removeChild%28x%5B0%5D%29%3B%0A%20%20w%28x.length%29%3B%0A%20%20w%28x%20%3D%3D%20document.forms%5B%27a%27%5D%5B%27x%27%5D%29%3B%0A%3C/script%3E%0A --></div> <h5 id=htmloptionscollection-0><span class=secno>2.8.2.3 </span>HTMLOptionsCollection</h5> <p>The <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> interface represents a list of <code><a href=#the-option-element>option</a></code> elements. It is always rooted on a <code><a href=#the-select-element>select</a></code> element and has attributes and methods that manipulate that element's descendants.</p> <pre class=idl>interface <dfn id=htmloptionscollection>HTMLOptionsCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> { // inherits <span title=dom-HTMLCollection-item>item</span>() attribute unsigned long <a href=#dom-htmloptionscollection-length title=dom-HTMLOptionsCollection-length>length</a>; // overrides inherited length legacycaller getter object? <a href=#dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem>namedItem</a>(DOMString name); // overrides inherited namedItem() <a href=#dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>setter creator</a> void (unsigned long index, <a href=#htmloptionelement>HTMLOptionElement</a> option); void <a href=#dom-htmloptionscollection-add title=dom-HTMLOptionsCollection-add>add</a>(<a href=#htmloptionelement>HTMLOptionElement</a> element, optional <a href=#htmlelement>HTMLElement</a>? before); void <a href=#dom-htmloptionscollection-add title=dom-HTMLOptionsCollection-add>add</a>(<a href=#htmloptgroupelement>HTMLOptGroupElement</a> element, optional <a href=#htmlelement>HTMLElement</a>? before); void <a href=#dom-htmloptionscollection-add title=dom-HTMLOptionsCollection-add>add</a>(<a href=#htmloptionelement>HTMLOptionElement</a> element, long before); void <a href=#dom-htmloptionscollection-add title=dom-HTMLOptionsCollection-add>add</a>(<a href=#htmloptgroupelement>HTMLOptGroupElement</a> element, long before); void <a href=#dom-htmloptionscollection-remove title=dom-HTMLOptionsCollection-remove>remove</a>(long index); attribute long <a href=#dom-htmloptionscollection-selectedindex title=dom-HTMLOptionsCollection-selectedIndex>selectedIndex</a>; };</pre> <dl class=domintro><dt><var title="">collection</var> . <code title=dom-HTMLOptionsCollection-length><a href=#dom-htmloptionscollection-length>length</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the number of elements in the collection.</p> <p>When set to a smaller number, truncates the number of <code><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><a href=#the-option-element>option</a></code> elements to that container.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLCollection-item>item</code>(<var title="">index</var>)</dt> <dt><var title="">collection</var>[<var title="">index</var>]</dt> <dt><var title="">collection</var>(<var title="">index</var>)</dt> <dd> <p>Returns the item with index <var title="">index</var> from the collection. The items are sorted in <a href=#tree-order>tree order</a>.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLOptionsCollection-namedItem><a href=#dom-htmloptionscollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">nodeList</var> = <var title="">collection</var> . <code title=dom-HTMLOptionsCollection-namedItem><a href=#dom-htmloptionscollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">collection</var>[<var title="">name</var>]</dt> <dt><var title="">collection</var>(<var title="">name</var>)</dt> <dd> <p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or <code title=attr-option-name><a href=#attr-option-name>name</a></code> <var title="">name</var> from the collection.</p> <p>If there are multiple matching items, then a <code><a href=#nodelist>NodeList</a></code> object containing all those elements is returned.</p> </dd> <dt><var title="">collection</var> . <code title=dom-HTMLOptionsCollection-add><a href=#dom-htmloptionscollection-add>add</a></code>(<var title="">element</var> [, <var title="">before</var> ] )</dt> <dd> <p>Inserts <var title="">element</var> before the node given by <var title="">before</var>.</p> <p>The <var title="">before</var> argument can be a number, in which case <var title="">element</var> is inserted before the item with that number, or an element from the collection, in which case <var title="">element</var> is inserted before that element.</p> <p>If <var title="">before</var> is omitted, null, or a number out of range, then <var title="">element</var> will be added at the end of the list.</p> <p>This method will throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception if <var title="">element</var> is an ancestor of the element into which it is to be inserted.</p> </dd> <dt><var title="">collection</var> . <code title=dom-HTMLOptionsCollection-selectedIndex><a href=#dom-htmloptionscollection-selectedindex>selectedIndex</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the index of the first selected item, if any, or −1 if there is no selected item.</p> <p>Can be set, to change the selection.</p> </dd> </dl><div class=impl> <p>The object's <a href=#supported-property-indices>supported property indices</a> are as defined for <code><a href=#htmlcollection>HTMLCollection</a></code> objects.</p> <p>On getting, the <dfn id=dom-htmloptionscollection-length title=dom-HTMLOptionsCollection-length><code>length</code></dfn> attribute must return the number of nodes <a href=#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 href=#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 title="">n</var> new <code><a href=#the-option-element>option</a></code> elements with no attributes and no child nodes must be appended to the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted, where <var title="">n</var> is the difference between the two numbers (new value minus old value). Mutation events must be fired as if a <code><a href=#documentfragment>DocumentFragment</a></code> containing the new <code><a href=#the-option-element>option</a></code> elements had been inserted. If the new value is lower, then the last <var title="">n</var> nodes in the collection must be removed from their parent nodes, where <var title="">n</var> is the difference between the two numbers (old value minus new value).</p> <p class=note>Setting <code title=dom-HTMLOptionsCollection-length><a href=#dom-htmloptionscollection-length>length</a></code> never removes or adds any <code><a href=#the-optgroup-element>optgroup</a></code> elements, and never adds new children to existing <code><a href=#the-optgroup-element>optgroup</a></code> elements (though it can remove children from them).</p> <p>The <a href=#supported-property-names>supported property names</a> consist of the values of all the <code title=attr-id><a href=#the-id-attribute>id</a></code> and <code title=attr-option-name><a href=#attr-option-name>name</a></code> attributes of all the elements <a href=#represented-by-the-collection>represented by the collection</a>.</p> <p>The <dfn id=dom-htmloptionscollection-nameditem title=dom-HTMLOptionsCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must act according to the following algorithm:</p> <ol><li>If, at the time the method is called, there is exactly one node in the collection that has either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>, then return that node and stop the algorithm.</li> <li>Otherwise, if there are no nodes in the collection that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>, then return null and stop the algorithm.</li> <!-- IE returns an HTMLCollection instead; we may need to change to that for compat --> <li>Otherwise, create a new <code><a href=#nodelist>NodeList</a></code> object representing a <a href=#live>live</a> view of the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> object, further filtered so that the only nodes in the <code><a href=#nodelist>NodeList</a></code> object are those that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-option-name><a href=#attr-option-name>name</a></code> attribute equal to <var title="">name</var>. The nodes in the <code><a href=#nodelist>NodeList</a></code> object must be sorted in <a href=#tree-order>tree order</a>.</li> <li>Return that <code><a href=#nodelist>NodeList</a></code> object.</li> </ol><p>When the user agent is to <dfn id=dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new indexed property</dfn> for a given property index <var title="">index</var> to a new value <var title="">value</var>, it must run the following algorithm:</p> <ol><li><p>Let <var title="">length</var> be the number of nodes <a href=#represented-by-the-collection>represented by the collection</a>.</li> <li><p>Let <var title="">n</var> be <var title="">index</var> minus <var title="">length</var>.</li> <li><p>If <var title="">n</var> is greater than zero, then append <span title=""><var title="">n</var>-1</span> new <code><a href=#the-option-element>option</a></code> elements with no attributes and no child nodes to the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted. Mutation events must be fired as if a <code><a href=#documentfragment>DocumentFragment</a></code> containing the new <code><a href=#the-option-element>option</a></code> elements had been inserted.</li> <li><p>If <var title="">n</var> is greater than or equal to zero, append <var title="">value</var> to the <code><a href=#the-select-element>select</a></code> element. Otherwise, replace the <var title="">index</var>th element in the collection by <var title="">value</var>.</li> </ol><p>The <dfn id=dom-htmloptionscollection-add title=dom-HTMLOptionsCollection-add><code>add(<var title="">element</var>, <var title="">before</var>)</code></dfn> method must act according to the following algorithm:</p> <ol><li><p>If <var title="">element</var> is an ancestor of the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted, then throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</li> <li><p>If <var title="">before</var> is an element, but that element isn't a descendant of the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted, then throw a <code><a href=#notfounderror>NotFoundError</a></code> exception.</li> <li><p>If <var title="">element</var> and <var title="">before</var> are the same element, then return and abort these steps.</li> <li><p>If <var title="">before</var> is a node, then let <var title="">reference</var> be that node. Otherwise, if <var title="">before</var> is an integer, and there is a <var title="">before</var>th node in the collection, let <var title="">reference</var> be that node. Otherwise, let <var title="">reference</var> be null.</li> <li><p>If <var title="">reference</var> is not null, let <var title="">parent</var> be the parent node of <var title="">reference</var>. Otherwise, let <var title="">parent</var> be the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted.</li> <li><p>Act as if the DOM Core <code title=dom-Node-insertBefore><a href=#dom-node-insertbefore>insertBefore()</a></code> method was invoked on the <var title="">parent</var> node, with <var title="">element</var> as the first argument and <var title="">reference</var> as the second argument.</p> </ol><p>The <dfn id=dom-htmloptionscollection-remove title=dom-HTMLOptionsCollection-remove><code>remove(<var title="">index</var>)</code></dfn> method must act according to the following algorithm:</p> <ol><li><p>If the number of nodes <a href=#represented-by-the-collection>represented by the collection</a> is zero, abort these steps.</li> <li><p>If <var title="">index</var> is not a number greater than or equal to 0 and less than the number of nodes <a href=#represented-by-the-collection>represented by the collection</a>, let <var title="">element</var> be the first element in the collection. Otherwise, let <var title="">element</var> be the <var title="">index</var>th element in the collection.</li> <li><p>Remove <var title="">element</var> from its parent node.</li> </ol><p>The <dfn id=dom-htmloptionscollection-selectedindex title=dom-HTMLOptionsCollection-selectedIndex><code>selectedIndex</code></dfn> IDL attribute must act like the identically named attribute on the <code><a href=#the-select-element>select</a></code> element on which the <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted</p> <!-- see also http://ln.hixie.ch/?start=1161042744&count=1 --> </div> <!--MD--> <div data-component="HTML Microdata (editor: Ian Hickson)"> <h5 id=htmlpropertiescollection-0><span class=secno>2.8.2.4 </span>HTMLPropertiesCollection</h5> <p>The <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> interface represents a <a href=#collections title=collections>collection</a> of elements that add name-value pairs to a particular <a href=#concept-item title=concept-item>item</a> in the <a href=#microdata>microdata</a> model.</p> <pre class=idl>interface <dfn id=htmlpropertiescollection>HTMLPropertiesCollection</dfn> : <a href=#htmlcollection>HTMLCollection</a> { // inherits <span title=dom-HTMLCollection-length>length</span> and <span title=dom-HTMLCollection-item>item</span>() legacycaller getter <a href=#propertynodelist>PropertyNodeList</a>? <a href=#dom-htmlpropertiescollection-nameditem title=dom-HTMLPropertiesCollection-namedItem>namedItem</a>(DOMString name); // overrides inherited namedItem() readonly attribute <a href=#domstringlist>DOMStringList</a> <a href=#dom-htmlpropertiescollection-names title=dom-HTMLPropertiesCollection-names>names</a>; }; typedef sequence<any> <dfn id=propertyvaluearray>PropertyValueArray</dfn>; interface <dfn id=propertynodelist>PropertyNodeList</dfn> : <a href=#nodelist>NodeList</a> { <a href=#propertyvaluearray>PropertyValueArray</a> <a href=#dom-propertynodelist-getvalues title=dom-PropertyNodeList-getValues>getValues</a>(); };</pre> <dl class=domintro><dt><var title="">collection</var> . <code title=dom-HTMLCollection-length>length</code></dt> <dd> <p>Returns the number of elements in the collection.</p> </dd> <dt><var title="">element</var> = <var title="">collection</var> . <code title=dom-HTMLCollection-item>item</code>(<var title="">index</var>)</dt> <dt><var title="">collection</var>[<var title="">index</var>]</dt> <dt><var title="">collection</var>(<var title="">index</var>)</dt> <dd> <p>Returns the element with index <var title="">index</var> from the collection. The items are sorted in <a href=#tree-order>tree order</a>.</p> </dd> <dt><var title="">propertyNodeList</var> = <var title="">collection</var> . <code title=dom-HTMLPropertiesCollection-namedItem><a href=#dom-htmlpropertiescollection-nameditem>namedItem</a></code>(<var title="">name</var>)</dt> <dt><var title="">collection</var>(<var title="">name</var>)</dt> <dd> <p>Returns a <code><a href=#propertynodelist>PropertyNodeList</a></code> object containing any elements that add a property named <var title="">name</var>.</p> </dd> <dt><var title="">collection</var>[<var title="">name</var>]</dt> <dd> <p>Returns a <code><a href=#propertynodelist>PropertyNodeList</a></code> object containing any elements that add a property named <var title="">name</var>. The <var title="">name</var> index has to be one of the values listed in the <code title=dom-HTMLPropertiesCollection-names><a href=#dom-htmlpropertiescollection-names>names</a></code> list.</p> </dd> <dt><var title="">collection</var> . <code title=dom-HTMLPropertiesCollection-names><a href=#dom-htmlpropertiescollection-names>names</a></code></dt> <dd> <p>Returns a <code><a href=#domstringlist>DOMStringList</a></code> with the <a href=#property-names>property names</a> of the elements in the collection.</p> </dd> <dt><var title="">propertyNodeList</var> . <code title=dom-PropertyNodeList-getVlues>getValues</code>()</dt> <dd> <p>Returns an array of the various values that the relevant elements have.</p> </dd> </dl><div class=impl> <p>The object's <a href=#supported-property-indices>supported property indices</a> are as defined for <code><a href=#htmlcollection>HTMLCollection</a></code> objects.</p> <p>The <a href=#supported-property-names>supported property names</a> consist of the <a href=#property-names>property names</a> of all the elements <a href=#represented-by-the-collection>represented by the collection</a>.</p> <p>The <dfn id=dom-htmlpropertiescollection-names title=dom-HTMLPropertiesCollection-names><code>names</code></dfn> attribute must return a <a href=#live>live</a> <code><a href=#domstringlist>DOMStringList</a></code> object giving the <a href=#property-names>property names</a> of all the elements <a href=#represented-by-the-collection>represented by the collection</a>, listed in <a href=#tree-order>tree order</a>, but with duplicates removed, leaving only the first occurrence of each name. The same object must be returned each time.</p> <p>The <dfn id=dom-htmlpropertiescollection-nameditem title=dom-HTMLPropertiesCollection-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must return a <code><a href=#propertynodelist>PropertyNodeList</a></code> object representing a <a href=#live>live</a> view of the <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> object, further filtered so that the only nodes in the <code><a href=#propertynodelist>PropertyNodeList</a></code> object are those that have a <a href=#property-names title="property names">property name</a> equal to <var title="">name</var>. The nodes in the <code><a href=#propertynodelist>PropertyNodeList</a></code> object must be sorted in <a href=#tree-order>tree order</a>, and the same object must be returned each time a particular <var title="">name</var> is queried.</p> <hr><p>Members of the <code><a href=#propertynodelist>PropertyNodeList</a></code> interface inherited from the <code><a href=#nodelist>NodeList</a></code> interface must behave as they would on a <code><a href=#nodelist>NodeList</a></code> object.</p> <p>The <dfn id=dom-propertynodelist-getvalues title=dom-PropertyNodeList-getValues><code>getValues</code></dfn> method the <code><a href=#propertynodelist>PropertyNodeList</a></code> object must return a newly constructed array whose values are the values obtained from the <code title=dom-itemValue><a href=#dom-itemvalue>itemValue</a></code> DOM property of each of the elements represented by the object, in <a href=#tree-order>tree order</a>.</p> </div> </div><!--data-component--> <!--MD--> <h4 id=domstringmap-0><span class=secno>2.8.3 </span>DOMStringMap</h4> <p>The <code><a href=#domstringmap>DOMStringMap</a></code> interface represents a set of name-value pairs. It exposes these using the scripting language's native mechanisms for property access.</p> <div class=impl> <p>When a <code><a href=#domstringmap>DOMStringMap</a></code> object is instantiated, it is associated with three algorithms, one for getting the list of name-value pairs, one for setting names to certain values, and one for deleting names.</p> <pre class=idl>interface <dfn id=domstringmap>DOMStringMap</dfn> { <a href=#dom-domstringmap-nameditem title=dom-DOMStringMap-namedItem>getter</a> DOMString (DOMString name); <a href=#dom-domstringmap-setitem title=dom-DOMStringMap-setItem>setter</a> void (DOMString name, DOMString value); <a href=#dom-domstringmap-additem title=dom-DOMStringMap-addItem>creator</a> void (DOMString name, DOMString value); <a href=#dom-domstringmap-removeitem title=dom-DOMStringMap-removeItem>deleter</a> void (DOMString name); };</pre> <p>The <a href=#supported-property-names>supported property names</a> on a <code><a href=#domstringmap>DOMStringMap</a></code> object at any instant are the names of each pair returned from the algorithm for getting the list of name-value pairs at that instant.</p> <p>To <dfn id=dom-domstringmap-nameditem title=dom-DOMStringMap-namedItem>determine the value of a named property</dfn> <var title="">name</var> in a <code><a href=#domstringmap>DOMStringMap</a></code>, the user agent must return the value component of the name-value pair whose name component is <var title="">name</var> in the list returned by the algorithm for getting the list of name-value pairs.</p> <p>To set the value of a <dfn id=dom-domstringmap-additem title=dom-DOMStringMap-addItem>new</dfn> or <dfn id=dom-domstringmap-setitem title=dom-DOMStringMap-setItem>existing</dfn> named property <var title="">name</var> to value <var title="">value</var>, the algorithm for setting names to certain values must be run, passing <var title="">name</var> as the name and the result of converting <var title="">value</var> to a <code>DOMString</code> as the value.</p> <p>To <dfn id=dom-domstringmap-removeitem title=dom-DOMStringMap-removeItem>delete an existing named property</dfn> <var title="">name</var>, the algorithm for deleting names must be run, passing <var title="">name</var> as the name.</p> <p class=note>The <code><a href=#domstringmap>DOMStringMap</a></code> interface definition here is only intended for JavaScript environments. Other language bindings will need to define how <code><a href=#domstringmap>DOMStringMap</a></code> is to be implemented for those languages.</p> </div> <div class=example> <p>The <code title=dom-dataset><a href=#dom-dataset>dataset</a></code> attribute on elements exposes the <code title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes on the element.</p> <p>Given the following fragment and elements with similar constructions:</p> <pre><img class="tower" id="tower5" data-x="12" data-y="5" data-ai="robotarget" data-hp="46" data-ability="flames" src="towers/rocket.png alt="Rocket Tower"></pre> <p>...one could imagine a function <code title="">splashDamage()</code> that takes some arguments, the first of which is the element to process:</p> <pre>function splashDamage(node, x, y, damage) { if (node.classList.contains('tower') && // checking the 'class' attribute node.dataset.x == x && // reading the 'data-x' attribute node.dataset.y == y) { // reading the 'data-y' attribute var hp = parseInt(node.dataset.hp); // reading the 'data-hp' attribute hp = hp - damage; if (hp < 0) { hp = 0; node.dataset.ai = 'dead'; // setting the 'data-ai' attribute delete node.dataset.ability; // removing the 'data-ability' attribute } node.dataset.hp = hp; // setting the 'data-hp' attribute } }</pre> </div> <!--CSSREF--> <h4 id=domelementmap-0><span class=secno>2.8.4 </span>DOMElementMap</h4> <p>The <code><a href=#domelementmap>DOMElementMap</a></code> interface represents a set of name-element mappings. It exposes these using the scripting language's native mechanisms for property access.</p> <div class=impl> <p>When a <code><a href=#domelementmap>DOMElementMap</a></code> object is instantiated, it is associated with three algorithms, one for getting the list of name-element mappings, one for mapping a name to a certain element, and one for deleting mappings by name.</p> <pre class=idl>interface <dfn id=domelementmap>DOMElementMap</dfn> { <a href=#dom-domelementmap-nameditem title=dom-DOMElementMap-namedItem>getter</a> <a href=#element>Element</a> (DOMString name); <a href=#dom-domelementmap-setitem title=dom-DOMElementMap-setItem>setter</a> void (DOMString name, <a href=#element>Element</a> value); <a href=#dom-domelementmap-additem title=dom-DOMElementMap-addItem>creator</a> void (DOMString name, <a href=#element>Element</a> value); <a href=#dom-domelementmap-removeitem title=dom-DOMElementMap-removeItem>deleter</a> void (DOMString name); };</pre> <p>The <a href=#supported-property-names>supported property names</a> on a <code><a href=#domelementmap>DOMElementMap</a></code> object at any instant are the names for each mapping returned from the algorithm for getting the list of name-element mappings at that instant.</p> <p>To <dfn id=dom-domelementmap-nameditem title=dom-DOMElementMap-namedItem>determine the value of a named property</dfn> <var title="">name</var> in a <code><a href=#domelementmap>DOMElementMap</a></code>, the user agent must return the element component of the name-element mapping whose name component is <var title="">name</var> in the list returned by the algorithm for getting the list of name-element mappings.</p> <p>To set the value of a <dfn id=dom-domelementmap-additem title=dom-DOMElementMap-addItem>new</dfn> or <dfn id=dom-domelementmap-setitem title=dom-DOMElementMap-setItem>existing</dfn> named property <var title="">name</var> to value <var title="">value</var>, the algorithm for mapping a name to a certain element must be run, passing <var title="">name</var> as the name <var title="">value</var> as the element.</p> <p>To <dfn id=dom-domelementmap-removeitem title=dom-DOMElementMap-removeItem>delete an existing named property</dfn> <var title="">name</var>, the algorithm for deleting mappings must be run, passing <var title="">name</var> as the name component of the mapping to be deleted.</p> <p class=note>The <code><a href=#domelementmap>DOMElementMap</a></code> interface definition here is only intended for JavaScript environments. Other language bindings will need to define how <code><a href=#domelementmap>DOMElementMap</a></code> is to be implemented for those languages.</p> </div> <!--CSSREF--> <h4 id=transferable-objects><span class=secno>2.8.5 </span>Transferable objects</h4> <p>Some objects support being copied and closed in one operation. This is called <i>transferring</i> the object, and is used in particular to transfer ownership of unsharable or expensive resources across worker boundaries.</p> <pre class=idl>[NoInterfaceObject] interface <dfn id=transferable>Transferable</dfn> { };</pre> <div class=impl> <p>To <dfn id=transfer-a-transferable-object>transfer a <code>Transferable</code> object</dfn> to a new owner, the user agent must run the steps defined for the type of object in question. The steps will return a new object of the same type, and will permanently <dfn id=concept-transferable-neutered title=concept-Transferable-neutered>neuter</dfn> the original object. (This is an irreversible and non-idempotent operation; once an object has been transferred, it cannot be transferred, or indeed used, again.)</p> </div> <p>The following <code><a href=#transferable>Transferable</a></code> types exist:</p> <ul class=brief><li><code><a href=#messageport>MessagePort</a></code> <!--<li><code>ArrayBuffer</code>--> </ul><div class=impl> <h4 id=safe-passing-of-structured-data><span class=secno>2.8.6 </span>Safe passing of structured data</h4> <p>When a user agent is required to obtain a <dfn id=structured-clone>structured clone</dfn> of a value, optionally with a <i>transfer map</i>, it must run the following algorithm, which either returns a separate value, or throws an exception. If a <i>transfer map</i> is provided, it consists of an association list of <code><a href=#transferable>Transferable</a></code> objects to placeholder objects.</p> <ol><li><p>Let <var title="">input</var> be the value being cloned.</li> <li><p>Let <var title="">transfer map</var> be the <i>transfer map</i> passed to the algorithm, if any, or the empty list otherwise.</li> <li><p>Let <var title="">memory</var> be an association list of pairs of objects, initially empty. This is used to handle duplicate references. In each pair of objects, one is called the <em>source</em> object and the other the <em>destination</em> object.</li> <li><p>For each mapping in <var title="">transfer map</var>, add a mapping from the <code><a href=#transferable>Transferable</a></code> object (the source object) to the placeholder object (the destination object) to <var title="">memory</var>.</li> <li><p>Let <var title="">output</var> be the value resulting from calling the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> with <var title="">input</var> as the "<var title="">input</var>" argument, and <var title="">memory</var> as the "<var title="">memory</var>" argument.</li> <li><p>Return <var title="">output</var>.</li> </ol><p>The <dfn id=internal-structured-cloning-algorithm>internal structured cloning algorithm</dfn> is always called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior is as follows:</p> <ol><li><p>If <var title="">input</var> is the source object of a pair of objects in <var title="">memory</var>, then return the destination object in that pair of objects and abort these steps.</li> <li><p>If <var title="">input</var> is a primitive value, then return that value and abort these steps.</li> <li> <p>The <var title="">input</var> value is an object. Jump to the appropriate step below:</p> <dl class=switch><dt>If <var title="">input</var> is a Boolean object</dt> <dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</dd> <dt>If <var title="">input</var> is a Number object</dt> <dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</dd> <dt>If <var title="">input</var> is a String object</dt> <dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</dd> <dt>If <var title="">input</var> is a <code>Date</code> object</dt> <dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd> <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt> <dd> <p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p> <p class=note>The value of the <code title="">lastIndex</code> property is not copied.</p> </dd> <dt>If <var title="">input</var> is a <code><a href=#file>File</a></code> object</dt> <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#file>File</a></code> object corresponding to the same underlying data.</dd> <dt>If <var title="">input</var> is a <code><a href=#blob>Blob</a></code> object</dt> <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#blob>Blob</a></code> object corresponding to the same underlying data.</dd> <dt>If <var title="">input</var> is a <code><a href=#filelist>FileList</a></code> object</dt> <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#filelist>FileList</a></code> object containing a list of newly constructed <code><a href=#file>File</a></code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd> <!--(when we add this, make sure to throw DataCloneError if these objects are already closed) <dt>If <var title="">input</var> is an <code>ArrayBuffer</code> object</dt> <dd><p>...</p></dd> <dt>If <var title="">input</var> is an <code>ArrayBufferView</code> object</dt> <dd><p>...</p></dd> --> <dt>If <var title="">input</var> is an Array object</dt> <dd> <p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object whose <code title="">length</code> is equal to the <code title="">length</code> of <var title="">input</var>.</p> <p class=note>This means that the length of sparse arrays is preserved.</p> </dd> <dt>If <var title="">input</var> is an Object object</dt> <dd><p>Let <var title="">output</var> be a newly constructed empty <code title="">Object</code> object.</dd> <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href=#function>Function</a></code>)</dt> <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt> <dd><p>Throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort the overall <a href=#structured-clone>structured clone</a> algorithm.</dd> </dl></li> <li><p>Add a mapping from <var title="">input</var> (the source object) to <var title="">output</var> (the destination object) to <var title="">memory</var>.</li> <li> <p>If <var title="">input</var> is an Array object or an Object object, then, for each enumerable property in <var title="">input</var>, add a new property to <var title="">output</var> having the same name, and having a value created from invoking the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with the value of the property as the "<var title="">input</var>" argument and <var title="">memory</var> as the "<var title="">memory</var>" argument. The order of the properties in the <var title="">input</var> and <var title="">output</var> objects must be the same, and any properties that involve running script must be processed in that same order. If obtaining the value of the property involved executing script, and that script threw an uncaught exception, then abort the overall <a href=#structured-clone>structured clone</a> algorithm, with that exception being passed through to the caller.</p> <p class=note>This does not walk the prototype chain.</p> <p class=note>Property descriptors, setters, getters, and analogous features are not copied in this process. For example, the property in the input could be marked as read-only, but in the output it would just have the default state (typically read-write, though that could depend on the scripting environment).</p> <p class=note>Properties of Array objects are not treated any differently than those of other Objects. In particular, this means that non-index properties of arrays are copied as well.</p> </li> <li><p>Return <var title="">output</var>.</li> </ol><p class=note>This algorithm preserves cycles and preserves the identity of duplicate objects in graphs.</p> </div> <h4 id=dom-feature-strings><span class=secno>2.8.7 </span>DOM feature strings</h4> <p>DOM3 Core defines mechanisms for checking for interface support, and for obtaining implementations of interfaces, using <a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures>feature strings</a>. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p>Authors are strongly discouraged from using these, as they are notoriously unreliable and imprecise. Authors are encouraged to rely on explicit feature testing or the graceful degradation behavior intrinsic to some of the features in this specification.</p> <div class=impl> <p>For historical reasons, user agents should return the true value when the <dfn id=hasfeature title=hasFeature><code>hasFeature(<var title="">feature</var>, <var title="">version</var>)</code></dfn> method of the <code><a href=#domimplementation>DOMImplementation</a></code> interface is invoked with <var title="">feature</var> set to either "<code title="">HTML</code>" or "<code title="">XHTML</code>" and <var title="">version</var> set to either "<code>1.0</code>" or "<code>2.0</code>".</p> </div> <div class=impl> <h4 id=garbage-collection><span class=secno>2.8.8 </span>Garbage collection</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>document.location</code> attribute means that there is a strong reference from a <code><a href=#document>Document</a></code> object to its <code><a href=#location>Location</a></code> object. Similarly, there is always a strong reference from a <code><a href=#document>Document</a></code> to any descendant nodes, and from any node to its owner <code><a href=#document>Document</a></code>.</p> </div> </div> <h3 id=namespaces><span class=secno>2.9 </span>Namespaces</h3> <p>The <dfn id=html-namespace-0>HTML namespace</dfn> is: <code>http://www.w3.org/1999/xhtml</code></p> <p>The <dfn id=mathml-namespace>MathML namespace</dfn> is: <code>http://www.w3.org/1998/Math/MathML</code></p> <p>The <dfn id=svg-namespace>SVG namespace</dfn> is: <code>http://www.w3.org/2000/svg</code></p> <p>The <dfn id=xlink-namespace>XLink namespace</dfn> is: <code>http://www.w3.org/1999/xlink</code></p> <p>The <dfn id=xml-namespace>XML namespace</dfn> is: <code>http://www.w3.org/XML/1998/namespace</code></p> <p>The <dfn id=xmlns-namespace>XMLNS namespace</dfn> is: <code>http://www.w3.org/2000/xmlns/</code></p> <hr><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 above strings.</p> <hr><p class=note>In <a href=#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> <h2 id=dom><span class=secno>3 </span>Semantics, structure, and APIs of HTML documents</h2> <h3 id=documents><span class=secno>3.1 </span>Documents</h3> <p>Every XML and HTML document in an HTML UA is represented by a <code><a href=#document>Document</a></code> object. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p><dfn id="the-document's-address">The document's address</dfn> is an <a href=#absolute-url>absolute URL</a> that is set when the <code><a href=#document>Document</a></code> is created. <dfn id="the-document's-current-address">The document's current address</dfn> is an <a href=#absolute-url>absolute URL</a> that can change during the lifetime of the <code><a href=#document>Document</a></code>, for example when the user <a href=#navigate title=navigate>navigates</a> to a <a href=#scroll-to-fragid title=navigate-fragid>fragment identifier</a> on the page or when the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> method is called with a new <a href=#url>URL</a>. <span class=impl><a href="#the-document's-current-address">The document's current address</a> must be set to <a href="#the-document's-address">the document's address</a> when the <code><a href=#document>Document</a></code> is created.</span></p> <p class=note>Interactive user agents typically expose <a href="#the-document's-current-address">the document's current address</a> in their user interface.</p> <p>When a <code><a href=#document>Document</a></code> is created by a <a href=#concept-script title=concept-script>script</a> using the <code title=dom-DOMImplementation-createDocument><a href=#dom-domimplementation-createdocument>createDocument()</a></code> or <code title=dom-DOMHTMLImplementation-createHTMLDocument>createHTMLDocument()</code> APIs, <a href="#the-document's-address">the document's address</a> is the same as <a href="#the-document's-address">the document's address</a> of the <a href="#script's-document">script's document</a>, and the <code><a href=#document>Document</a></code> is both <a href=#ready-for-post-load-tasks>ready for post-load tasks</a> and <a href=#completely-loaded>completely loaded</a> immediately.</p> <p>Each <code><a href=#document>Document</a></code> object has a <dfn id=reload-override-flag>reload override flag</dfn> that is originally unset. The flag is set by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> and <code title=dom-document-open><a href=#dom-document-open>document.write()</a></code> methods in certain situations. When the flag is set, the <code><a href=#document>Document</a></code> also has a <dfn id=reload-override-buffer>reload override buffer</dfn> which is a Unicode string that is used as the source of the document when it is reloaded.</p> <p>When the user agent is to perform <dfn id=an-overridden-reload>an overridden reload</dfn>, it must act as follows:</p> <ol><li><p>Let <var title="">source</var> be the value of the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>'s <a href=#reload-override-buffer>reload override buffer</a>.</li> <li><p><a href=#navigate>Navigate</a><!--DONAV reload after d.open()--> the <a href=#browsing-context>browsing context</a> to a resource whose source is <var title="">source</var>, with <a href=#replacement-enabled>replacement enabled</a>. When the <a href=#navigate>navigate</a> algorithm creates a <code><a href=#document>Document</a></code> object for this purpose, set that <code><a href=#document>Document</a></code>'s <a href=#reload-override-flag>reload override flag</a> and set its <a href=#reload-override-buffer>reload override buffer</a> to <var title="">source</var>.</li> </ol><h4 id=documents-in-the-dom><span class=secno>3.1.1 </span>Documents in the DOM</h4> <pre class=idl>[OverrideBuiltins] partial interface <a href=#document>Document</a> { // <a href=#resource-metadata-management>resource metadata management</a> [PutForwards=<a href=#dom-location-href title=dom-location-href>href</a>] readonly attribute <a href=#location>Location</a>? <a href=#dom-document-location title=dom-document-location>location</a>; readonly attribute DOMString <a href=#dom-document-url title=dom-document-URL>URL</a>; attribute DOMString <a href=#dom-document-domain title=dom-document-domain>domain</a>; readonly attribute DOMString <a href=#dom-document-referrer title=dom-document-referrer>referrer</a>; attribute DOMString <a href=#dom-document-cookie title=dom-document-cookie>cookie</a>; readonly attribute DOMString <a href=#dom-document-lastmodified title=dom-document-lastModified>lastModified</a>; readonly attribute DOMString <a href=#dom-document-readystate title=dom-document-readyState>readyState</a>; // <a href=#dom-tree-accessors>DOM tree accessors</a> <a href=#dom-document-nameditem title=dom-document-namedItem>getter</a> object (DOMString name); attribute DOMString <a href=#document.title title=dom-document-title>title</a>; attribute DOMString <a href=#dom-document-dir title=dom-document-dir>dir</a>; attribute <a href=#htmlelement>HTMLElement</a>? <a href=#dom-document-body title=dom-document-body>body</a>; readonly attribute <a href=#htmlheadelement>HTMLHeadElement</a>? <a href=#dom-document-head title=dom-document-head>head</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-images title=dom-document-images>images</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-embeds title=dom-document-embeds>embeds</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-plugins title=dom-document-plugins>plugins</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-links title=dom-document-links>links</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-forms title=dom-document-forms>forms</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-scripts title=dom-document-scripts>scripts</a>; NodeList <a href=#dom-document-getelementsbyname title=dom-document-getElementsByName>getElementsByName</a>(DOMString elementName); <!--MD--> NodeList <a href=#dom-document-getitems title=dom-document-getItems>getItems</a>(optional DOMString typeNames); // <a href=#microdata>microdata</a> <!--WARNING: ALSO DUPLICATED IN MICRODATA SECTION--><!--MD--> <!--CSSREF--> readonly attribute <a href=#domelementmap>DOMElementMap</a> <a href=#dom-document-csselementmap title=dom-document-cssElementMap>cssElementMap</a>;<!--CSSREF--> // <a href=#dynamic-markup-insertion>dynamic markup insertion</a> <a href=#document>Document</a> <a href=#dom-document-open title=dom-document-open>open</a>(optional DOMString type, optional DOMString replace); <a href=#windowproxy>WindowProxy</a> <a href=#dom-document-open title=dom-document-open>open</a>(DOMString url, DOMString name, DOMString features, optional boolean replace); void <a href=#dom-document-close title=dom-document-close>close</a>(); void <a href=#dom-document-write title=dom-document-write>write</a>(DOMString... text); void <a href=#dom-document-writeln title=dom-document-writeln>writeln</a>(DOMString... text); // <a href=#editing>user interaction</a> readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-document-defaultview title=dom-document-defaultView>defaultView</a>; readonly attribute <a href=#element>Element</a>? <a href=#dom-document-activeelement title=dom-document-activeElement>activeElement</a>; boolean <a href=#dom-document-hasfocus title=dom-document-hasFocus>hasFocus</a>(); attribute DOMString <a href=#designMode title=dom-document-designMode>designMode</a>; boolean <a href=#execCommand title=dom-document-execCommand>execCommand</a>(DOMString commandId); boolean <a href=#execCommand title=dom-document-execCommand>execCommand</a>(DOMString commandId, boolean showUI); boolean <a href=#execCommand title=dom-document-execCommand>execCommand</a>(DOMString commandId, boolean showUI, DOMString value); boolean <a href=#dom-document-querycommandenabled title=dom-document-queryCommandEnabled>queryCommandEnabled</a>(DOMString commandId); boolean <a href=#dom-document-querycommandindeterm title=dom-document-queryCommandIndeterm>queryCommandIndeterm</a>(DOMString commandId); boolean <a href=#dom-document-querycommandstate title=dom-document-queryCommandState>queryCommandState</a>(DOMString commandId); boolean <a href=#dom-document-querycommandsupported title=dom-document-queryCommandSupported>queryCommandSupported</a>(DOMString commandId); DOMString <a href=#dom-document-querycommandvalue title=dom-document-queryCommandValue>queryCommandValue</a>(DOMString commandId); readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-commands title=dom-document-commands>commands</a>; // <a href=#event-handler-idl-attributes>event handler IDL attributes</a> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onabort title=handler-onabort>onabort</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onblur title=handler-onblur>onblur</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplay title=handler-oncanplay>oncanplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplaythrough title=handler-oncanplaythrough>oncanplaythrough</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onchange title=handler-onchange>onchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onclick title=handler-onclick>onclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncontextmenu title=handler-oncontextmenu>oncontextmenu</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncuechange title=handler-oncuechange>oncuechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondblclick title=handler-ondblclick>ondblclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrag title=handler-ondrag>ondrag</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragend title=handler-ondragend>ondragend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragenter title=handler-ondragenter>ondragenter</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragleave title=handler-ondragleave>ondragleave</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragover title=handler-ondragover>ondragover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragstart title=handler-ondragstart>ondragstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrop title=handler-ondrop>ondrop</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondurationchange title=handler-ondurationchange>ondurationchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onemptied title=handler-onemptied>onemptied</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onended title=handler-onended>onended</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onerror title=handler-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onfocus title=handler-onfocus>onfocus</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninput title=handler-oninput>oninput</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninvalid title=handler-oninvalid>oninvalid</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeydown title=handler-onkeydown>onkeydown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeypress title=handler-onkeypress>onkeypress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeyup title=handler-onkeyup>onkeyup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onload title=handler-onload>onload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadeddata title=handler-onloadeddata>onloadeddata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadedmetadata title=handler-onloadedmetadata>onloadedmetadata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadstart title=handler-onloadstart>onloadstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousedown title=handler-onmousedown>onmousedown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousemove title=handler-onmousemove>onmousemove</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseout title=handler-onmouseout>onmouseout</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseover title=handler-onmouseover>onmouseover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseup title=handler-onmouseup>onmouseup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousewheel title=handler-onmousewheel>onmousewheel</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onpause title=handler-onpause>onpause</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplay title=handler-onplay>onplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplaying title=handler-onplaying>onplaying</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onprogress title=handler-onprogress>onprogress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onratechange title=handler-onratechange>onratechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onreset title=handler-onreset>onreset</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onscroll title=handler-onscroll>onscroll</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeked title=handler-onseeked>onseeked</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeking title=handler-onseeking>onseeking</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onselect title=handler-onselect>onselect</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onshow title=handler-onshow>onshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onstalled title=handler-onstalled>onstalled</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsubmit title=handler-onsubmit>onsubmit</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsuspend title=handler-onsuspend>onsuspend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ontimeupdate title=handler-ontimeupdate>ontimeupdate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onvolumechange title=handler-onvolumechange>onvolumechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onwaiting title=handler-onwaiting>onwaiting</a>; // special <a href=#event-handler-idl-attributes>event handler IDL attributes</a> that only apply to Document objects [TreatNonCallableAsNull,LenientThis] attribute <a href=#function>Function</a>? <a href=#handler-onreadystatechange title=handler-onreadystatechange>onreadystatechange</a>; };</pre> <h4 id=security-document><span class=secno>3.1.2 </span>Security</h4> <p id=security>User agents <span class=impl>must</span> throw a <code><a href=#securityerror>SecurityError</a></code> exception whenever any properties of a <code><a href=#document>Document</a></code> object are accessed by scripts whose <a href=#effective-script-origin>effective script origin</a> is not the <a href=#same-origin title="same origin">same</a> as the <code><a href=#document>Document</a></code>'s <a href=#effective-script-origin>effective script origin</a>.</p> <h4 id=resource-metadata-management><span class=secno>3.1.3 </span><dfn>Resource metadata management</dfn></h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-URL><a href=#dom-document-url>URL</a></code></dt> <dd> <p>Returns <a href="#the-document's-address">the document's address</a>.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-referrer><a href=#dom-document-referrer>referrer</a></code></dt> <dd> <p>Returns <a href="#the-document's-current-address" title="the document's current address">the address</a> of the <code><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 title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> link type can be used to block the referrer.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-url title=dom-document-URL><code>URL</code></dfn> attribute must return <a href="#the-document's-address">the document's address</a>.</p> <p>The <dfn id=dom-document-referrer title=dom-document-referrer><code>referrer</code></dfn> attribute must return either the <a href="#the-document's-current-address" title="the document's current address">current address</a> of the <a href=#active-document>active document</a> of the <a href=#source-browsing-context>source browsing context</a> <em>at the time the navigation was started</em> (that is, the page which <a href=#navigate title=navigate>navigated</a> the <a href=#browsing-context>browsing context</a> to the current document), with any <a href=#url-fragment title=url-fragment><fragment></a> component removed; or the empty string if there is no such originating page, or if the UA has been configured not to report referrers in this case, or if the navigation was initiated for a <a href=#hyperlink>hyperlink</a> with a <code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> keyword.</p> </div> <p class=note>In the case of HTTP, the <code title=dom-document-referrer><a href=#dom-document-referrer>referrer</a></code> IDL attribute will match the <code title=http-referer>Referer</code> (sic) header that was sent when <a href=#fetch title=fetch>fetching</a> the current page.</p> <p class=note>Typically user agents are configured to not report referrers in the case where the referrer uses an encrypted protocol and the current page does not (e.g. when navigating from an <code title="">https:</code> page to an <code title="">http:</code> page).</p> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-cookie><a href=#dom-document-cookie>cookie</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the HTTP cookies that apply to the <code><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 title="sandboxed origin browsing context flag">sandboxed into a unique origin</a> (in an <code><a href=#the-iframe-element>iframe</a></code> with the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute), a <code><a href=#securityerror>SecurityError</a></code> exception will be thrown on getting and setting.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-cookie title=dom-document-cookie><code>cookie</code></dfn> attribute represents the cookies of the resource from which the <code><a href=#document>Document</a></code> was created.</p> <p>A <code><a href=#document>Document</a></code> object that falls into one of the following conditions is a <dfn id=cookie-free-document-object>cookie-free <code>Document</code> object</dfn>:</p> <ul><li>A <code><a href=#document>Document</a></code> that has no <a href=#browsing-context>browsing context</a>.</li> <li>A <code><a href=#document>Document</a></code> whose <a href="#the-document's-address" title="the document's address">address</a> does not use a server-based naming authority.</li> </ul><!--Other specifications can also define <code>Document</code> objects as being <span title="cookie-free Document object">cookie-free <code>Document</code> objects</span>.--><p id=sandboxCookies>On getting, if the document is a <a href=#cookie-free-document-object>cookie-free <code>Document</code> object</a>, then the user agent must return the empty string. Otherwise, if the <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a> is not a scheme/host/port tuple, the user agent must throw a <code><a href=#securityerror>SecurityError</a></code> exception. Otherwise, the user agent must first <a href=#obtain-the-storage-mutex>obtain the storage mutex</a> and then return the cookie-string for <a href="#the-document's-address">the document's address</a> for a "non-HTTP" API, <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>. <a href=#refsCOOKIES>[COOKIES]</a></p> <p>On setting, if the document is a <a href=#cookie-free-document-object>cookie-free <code>Document</code> object</a>, then the user agent must do nothing. Otherwise, if the <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a> is not a scheme/host/port tuple, the user agent must throw a <code><a href=#securityerror>SecurityError</a></code> exception. Otherwise, the user agent must <a href=#obtain-the-storage-mutex>obtain the storage mutex</a> and then act as it would when <a href=#receives-a-set-cookie-string title="receives a set-cookie-string">receiving a set-cookie-string</a> for <a href="#the-document's-address">the document's address</a> via a "non-HTTP" API, consisting of the new value encoded as UTF-8. <a href=#refsCOOKIES>[COOKIES]</a> <a href=#refsRFC3629>[RFC3629]</a></p> <p class=note>Since the <code title=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> <hr></div> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-lastmodified><a href=#dom-document-lastmodified>lastModified</a></code></dt> <dd> <p>Returns the date of the last modification to the document, as reported by the server, in the form "<code title="">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> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-lastmodified title=dom-document-lastModified><code>lastModified</code></dfn> attribute, on getting, must return the date and time of the <code><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> <li> A U+002F SOLIDUS character (/). </li> <li> The day component of the date. </li> <li> A U+002F SOLIDUS character (/). </li> <li> The year component of the date. </li> <li> A U+0020 SPACE character. </li> <li> The hours component of the time. </li> <li> A U+003A COLON character (:). </li> <li> The minutes component of the time. </li> <li> A U+003A COLON character (:). </li> <li> The seconds component of the time. </li> </ol><p>All the numeric components above, other than the year, must be given as two digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) representing the number in base ten, zero-padded if necessary. The year must be given as the shortest possible string of four or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) representing the number in base ten, zero-padded if necessary.</p> <p>The <code><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 title=http-last-modified>Last-Modified</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></div> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-readyState><a href=#dom-document-readystate>readyState</a></code></dt> <dd> <p>Returns "<code title="">loading</code>" while the <code><a href=#document>Document</a></code> is loading, "<code title="">interactive</code>" once it is finished parsing but still loading sub-resources, and "<code title="">complete</code>" once it has loaded.</p> <p>The <code title=event-readystatechange><a href=#event-readystatechange>readystatechange</a></code> event fires on the <code><a href=#document>Document</a></code> object when this value changes.</p> </dd> </dl><div class=impl> <p>Each document has a <dfn id=current-document-readiness>current document readiness</dfn>. When a <code><a href=#document>Document</a></code> object is created, it must have its <a href=#current-document-readiness>current document readiness</a> set to the string "<code title="">loading</code>" if the document is associated with an <a href=#html-parser>HTML parser</a> or an <a href=#xml-parser>XML parser</a>, or to the string "<code title="">complete</code>" otherwise. Various algorithms during page loading affect this value. When the value is set, the user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <dfn id=event-readystatechange title=event-readystatechange><code>readystatechange</code></dfn> at the <code><a href=#document>Document</a></code> object.</p> <p>A <code><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>HTML parser</a> or an <a href=#xml-parser>XML parser</a> that has not yet been <a href=#stop-parsing title="stop parsing">stopped</a> or <a href=#abort-a-parser title="abort a parser">aborted</a>.</p> <p>The <dfn id=dom-document-readystate title=dom-document-readyState><code>readyState</code></dfn> IDL attribute must, on getting, return the <a href=#current-document-readiness>current document readiness</a>.</p> </div> <h4 id=dom-tree-accessors><span class=secno>3.1.4 </span><dfn>DOM tree accessors</dfn></h4> <p><dfn id=the-html-element-0>The <code>html</code> element</dfn> of a document is the document's root element, if there is one and it's an <code><a href=#the-html-element>html</a></code> element, or null otherwise.</p> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-head><a href=#dom-document-head>head</a></code></dt> <dd> <p>Returns <a href=#the-head-element-0>the <code>head</code> element</a>.</p> </dd> </dl><p><dfn id=the-head-element-0>The <code>head</code> element</dfn> of a document is the first <code><a href=#the-head-element>head</a></code> element that is a child of <a href=#the-html-element-0>the <code>html</code> element</a>, if there is one, or null otherwise.</p> <div class=impl> <p>The <dfn id=dom-document-head title=dom-document-head><code>head</code></dfn> attribute, on getting, must return <a href=#the-head-element-0>the <code>head</code> element</a> of the document (a <code><a href=#the-head-element>head</a></code> element or null).</p> </div> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-title><a href=#document.title>title</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the document's title, as given by <a href=#the-title-element-0>the <code>title</code> element</a>.</p> <p>Can be set, to update the document's title. If there is no <a href=#the-head-element-0 title="the head element"><code>head</code> element</a>, the new value is ignored.</p> <p>In SVG documents, the <code>SVGDocument</code> interface's <code title=dom-svg-title>title</code> attribute takes precedence.</p> </dd> </dl><p><dfn id=the-title-element-0>The <code>title</code> element</dfn> of a document is the first <code><a href=#the-title-element>title</a></code> element in the document (in tree order), if there is one, or null otherwise.</p> <div class=impl> <p>The <dfn id=document.title title=dom-document-title><code>title</code></dfn> attribute must, on getting, run the following algorithm:</p> <ol><li><p>If the <a href=#root-element>root element</a> is an <code><a href=#svg>svg</a></code> element in the "<code title="">http://www.w3.org/2000/svg</code>" namespace, and the user agent supports SVG, then return the value that would have been returned by the IDL attribute of the same name on the <code>SVGDocument</code> interface. <a href=#refsSVG>[SVG]</a></li> <li><p>Otherwise, let <var title="">value</var> be a concatenation of the data of all the child <a href=#text-node title="text node">text nodes</a> of <a href=#the-title-element-0>the <code>title</code> element</a>, in <a href=#tree-order>tree order</a>, or the empty string if <a href=#the-title-element-0>the <code>title</code> element</a> is null.</li> <li><p>Replace any sequence of one or more consecutive <a href=#space-character title="space character">space characters</a> in <var title="">value</var> with a single U+0020 SPACE character.</li> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">value</var>.</li> <li><p>Return <var title="">value</var>.</li> </ol><p>On setting, the following algorithm must be run. Mutation events must be fired as appropriate.</p> <ol><li><p>If the <a href=#root-element>root element</a> is an <code><a href=#svg>svg</a></code> element in the "<code title="">http://www.w3.org/2000/svg</code>" namespace, and the user agent supports SVG, then the setter must act as if it was the setter for the IDL attribute of the same name on the <code><a href=#document>Document</a></code> interface defined by the SVG specification. Stop the algorithm here. <a href=#refsSVG>[SVG]</a></li> <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null and <a href=#the-head-element-0>the <code>head</code> element</a> is null, then the attribute must do nothing. Stop the algorithm here.</li> <li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null, then a new <code><a href=#the-title-element>title</a></code> element must be created and appended to <a href=#the-head-element-0>the <code>head</code> element</a>. Let <var title="">element</var> be that element. Otherwise, let <var title="">element</var> be <a href=#the-title-element-0>the <code>title</code> element</a>.</li> <li>The children of <var title="">element</var> (if any) must all be removed.</li> <li>A single <code><a href=#text>Text</a></code> node whose data is the new value being assigned must be appended to <var title="">element</var>.</li> </ol><p>The <code title=dom-document-title><a href=#document.title>title</a></code> IDL attribute defined above must replace the attribute of the same name on the <code><a href=#document>Document</a></code> interface defined by the SVG specification when the user agent supports both HTML and SVG. <a href=#refsSVG>[SVG]</a></p> </div> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-body><a href=#dom-document-body>body</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns <a href=#the-body-element-0>the body element</a>.</p> <p>Can be set, to replace <a href=#the-body-element-0>the body element</a>.</p> <p>If the new value is not a <code><a href=#the-body-element>body</a></code> or <code><a href=#frameset>frameset</a></code> element, this will throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</p> </dd> </dl><p><dfn id=the-body-element-0>The body element</dfn> of a document is the first child of <a href=#the-html-element-0>the <code>html</code> element</a> that is either a <code><a href=#the-body-element>body</a></code> element or a <code><a href=#frameset>frameset</a></code> element. If there is no such element, it is null.</p> <div class=impl> <p>The <dfn id=dom-document-body title=dom-document-body><code>body</code></dfn> attribute, on getting, must return <a href=#the-body-element-0>the body element</a> of the document (either a <code><a href=#the-body-element>body</a></code> element, a <code><a href=#frameset>frameset</a></code> element, or null). On setting, the following algorithm must be run:</p> <ol><!-- if changes are requested: http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp search for ::GetBody ::SetBody http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLDocument.cpp search for ::setBody http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/dom/Document.cpp search for ::body --><li>If the new value is not a <code><a href=#the-body-element>body</a></code> or <code><a href=#frameset>frameset</a></code> element, then throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception and abort these steps.</li> <li>Otherwise, if the new value is the same as <a href=#the-body-element-0>the body element</a>, do nothing. Abort these steps.</li> <li>Otherwise, if <a href=#the-body-element-0>the body element</a> is not null, then replace that element with the new value in the DOM, as if the root element's <code title="">replaceChild()</code> method had been called with the new value and <a href=#the-body-element-0 title="the body element">the incumbent body element</a> as its two arguments respectively, then abort these steps.</li> <li>Otherwise, <a href=#the-body-element-0>the body element</a> is null. Append the new value to the root element.</li> </ol></div> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-images><a href=#dom-document-images>images</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-img-element>img</a></code> elements in the <code><a href=#document>Document</a></code>.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-embeds><a href=#dom-document-embeds>embeds</a></code></dt> <dt><var title="">document</var> . <code title=dom-document-plugins><a href=#dom-document-plugins>plugins</a></code></dt> <dd> <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-embed-element>embed</a></code> elements in the <code><a href=#document>Document</a></code>.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-links><a href=#dom-document-links>links</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements in the <code><a href=#document>Document</a></code> that have <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attributes.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-forms><a href=#dom-document-forms>forms</a></code></dt> <dd> <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-form-element>form</a></code> elements in the <code><a href=#document>Document</a></code>.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-scripts><a href=#dom-document-scripts>scripts</a></code></dt> <dd> <p>Return an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-script-element>script</a></code> elements in the <code><a href=#document>Document</a></code>.</p> </dd> </dl><div class=impl> <!-- these all return the same object each time because of a rule in the collection section --> <p>The <dfn id=dom-document-images title=dom-document-images><code>images</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-img-element>img</a></code> elements.</p> <p>The <dfn id=dom-document-embeds title=dom-document-embeds><code>embeds</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-embed-element>embed</a></code> elements.</p> <p>The <dfn id=dom-document-plugins title=dom-document-plugins><code>plugins</code></dfn> attribute must return the same object as that returned by the <code title=dom-document-embeds><a href=#dom-document-embeds>embeds</a></code> attribute.</p> <p>The <dfn id=dom-document-links title=dom-document-links><code>links</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-a-element>a</a></code> elements with <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attributes and <code><a href=#the-area-element>area</a></code> elements with <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attributes.</p> <p>The <dfn id=dom-document-forms title=dom-document-forms><code>forms</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-form-element>form</a></code> elements.</p> <p>The <dfn id=dom-document-scripts title=dom-document-scripts><code>scripts</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-script-element>script</a></code> elements.</p> <hr></div> <dl class=domintro><dt><var title="">collection</var> = <var title="">document</var> . <code title=dom-document-getElementsByName><a href=#dom-document-getelementsbyname>getElementsByName</a></code>(<var title="">name</var>)</dt> <dd> <p>Returns a <code><a href=#nodelist>NodeList</a></code> of elements in the <code><a href=#document>Document</a></code> that have a <code title="">name</code> attribute with the value <var title="">name</var>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-getelementsbyname title=dom-document-getElementsByName><code>getElementsByName(<var title="">name</var>)</code></dfn> method takes a string <var title="">name</var>, and must return a <a href=#live>live</a> <code><a href=#nodelist>NodeList</a></code> containing all the <a href=#html-elements>HTML elements</a> in that document that have a <code title="">name</code> attribute whose value is equal to the <var title="">name</var> argument (in a <a href=#case-sensitive>case-sensitive</a> manner), in <a href=#tree-order>tree order</a>. When the method is invoked on a <code><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><a href=#nodelist>NodeList</a></code> object must be returned.</p> </div> <!--CSSREF--> <hr><dl class=domintro><dt><var title="">element</var> . <code title=dom-document-cssElementMap><a href=#dom-document-csselementmap>cssElementMap</a></code></dt> <dd> <p>Returns a <code><a href=#domelementmap>DOMElementMap</a></code> object for the <code><a href=#document>Document</a></code> representing the current <a href=#css-element-reference-identifier title="CSS element reference identifier">CSS element reference identifiers</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-csselementmap title=dom-document-cssElementMap><code>cssElementMap</code></dfn> IDL attribute allows authors to define <a href=#css-element-reference-identifier title="CSS element reference identifier">CSS element reference identifiers</a>, which are used in certain CSS features to override the normal <a href=#concept-id title=concept-id>ID</a>-based mapping. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p> <p>When a <code><a href=#document>Document</a></code> is created, it must be associated with an initially-empty <dfn id=css-id-overrides-list>CSS ID overrides list</dfn>, which consists of a list of mappings each of which consists of a string name mapped to an <code><a href=#element>Element</a></code> node.</p> <p>Each entry in the <a href=#css-id-overrides-list>CSS ID overrides list</a>, while it is in the list and is either <a href=#in-a-document title="in a Document">in the <code>Document</code></a> or is an <code><a href=#the-img-element>img</a></code>, <code><a href=#the-video-element>video</a></code>, or <code><a href=#the-canvas-element>canvas</a></code> element, defines a <a href=#css-element-reference-identifier>CSS element reference identifier</a> mapping the given name to the given <code><a href=#element>Element</a></code>. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p> <p>On getting, the <code title=dom-document-cssElementMap><a href=#dom-document-csselementmap>cssElementMap</a></code> IDL attribute must return a <code><a href=#domelementmap>DOMElementMap</a></code> object, associated with the following algorithms, which expose the current mappings:</p> <dl><dt>The algorithm for getting the list of name-element mappings</dt> <dd> <p>Return the <code><a href=#document>Document</a></code>'s <a href=#css-id-overrides-list>CSS ID overrides list</a>, maintaining the order in which the entries were originally added to the list.</p> </dd> <dt>The algorithm for for mapping a name to a certain element</dt> <dd> <p>Let <var title="">name</var> be the name passed to the algorithm and <var title="">element</var> be the <code><a href=#element>Element</a></code> passed to the algorithm.</p> <p>If <var title="">element</var> is null, run the algorithm for deleting mappings by name, passing it <var title="">name</var>.</p> <p>Otherwise, if there is an entry in the <code><a href=#document>Document</a></code>'s <a href=#css-id-overrides-list>CSS ID overrides list</a> whose name is <var title="">name</var>, replace its current value with <var title="">element</var>.</p> <p>Otherwise, add a mapping to the <code><a href=#document>Document</a></code>'s <a href=#css-id-overrides-list>CSS ID overrides list</a> whose name is <var title="">name</var> and whose element is <var title="">element</var>.</p> </dd> <dt>The algorithm for deleting mappings by name</dt> <dd> <p>If there is an entry in the <code><a href=#document>Document</a></code>'s <a href=#css-id-overrides-list>CSS ID overrides list</a> whose name is the name passed to this algorithm, remove it. This also undefines the <a href=#css-element-reference-identifier>CSS element reference identifier</a> for that name. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p> </dd> </dl><p>The same object must be returned each time.</p> </div> <!--CSSREF--> <div class=impl> <hr><p>The <code><a href=#document>Document</a></code> interface <span title="support named properties">supports named properties</span>. The <a href=#supported-property-names>supported property names</a> at any moment consist of the values of the <code title=attr-name>name</code> content attributes of all the <code><a href=#the-applet-element>applet</a></code>, <a href=#exposed>exposed</a> <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, and <a href=#exposed>exposed</a> <code><a href=#the-object-element>object</a></code> elements in the <code><a href=#document>Document</a></code> that have <code title=attr-name>name</code> content attributes, and the values of the <code title=attr-id><a href=#the-id-attribute>id</a></code> content attributes of all the <code><a href=#the-applet-element>applet</a></code> and <a href=#exposed>exposed</a> <code><a href=#the-object-element>object</a></code> elements in the <code><a href=#document>Document</a></code> that have <code title=attr-id><a href=#the-id-attribute>id</a></code> content attributes, and the values of the <code title=attr-id><a href=#the-id-attribute>id</a></code> content attributes of all the <code><a href=#the-img-element>img</a></code> elements in the <code><a href=#document>Document</a></code> that have both <code title=attr-name>name</code> content attributes and <code title=attr-id><a href=#the-id-attribute>id</a></code> content attributes.</p> <p>To <a href=#determine-the-value-of-a-named-property>determine the value of a named property</a> <var title="">name</var> when <dfn id=dom-document-nameditem title=dom-document-namedItem>the <code>Document</code> object is indexed for property retrieval</dfn>, the user agent must return the value obtained using the following steps:</p> <ol><li> <p>Let <var title="">elements</var> be the list of <a href=#dom-document-nameditem-filter title=dom-document-namedItem-filter>named elements</a> with the name <var title="">name</var> in the <code><a href=#document>Document</a></code>. <p class=note>There will be at least one such element, by definition.<!-- (If there wasn't, then this algorithm wouldn't have been invoked by Web IDL.) --></p> </li> <li> <p>If <var title="">elements</var> has only one element, and that element is an <code><a href=#the-iframe-element>iframe</a></code> element, then return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#nested-browsing-context>nested browsing context</a> represented by that <code><a href=#the-iframe-element>iframe</a></code> element, and abort these steps.</p> </li> <li> <p>Otherwise, if <var title="">elements</var> has only one element, return that element and abort these steps.</p> </li> <li> <p>Otherwise return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <a href=#dom-document-nameditem-filter title=dom-document-namedItem-filter>named elements</a> with the name <var title="">name</var>.</p> <!-- the same one each time is returned, because of the rule under collections --> </li> <!-- Note that this named getter overrides built-in properties, as in: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0D%0A...%3Ciframe%20name%3Dbody%3E%3C%2Fiframe%3E%3Cscript%3Ew(document.body)%3C%2Fscript%3E This is what the "OverrideBuiltins" bit means in the IDL. --> </ol><p><dfn id=dom-document-nameditem-filter title=dom-document-nameditem-filter>Named elements</dfn> with the name <var title="">name</var>, for the purposes of the above algorithm, are those that are either:</p> <ul><li><code><a href=#the-applet-element>applet</a></code>, <a href=#exposed>exposed</a> <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <a href=#exposed>exposed</a> <code><a href=#the-object-element>object</a></code> elements that have a <code title=attr-name>name</code> content attribute whose value is <var title="">name</var>, or</li> <li><code><a href=#the-applet-element>applet</a></code> or <a href=#exposed>exposed</a> <code><a href=#the-object-element>object</a></code> elements that have an <code title=attr-id><a href=#the-id-attribute>id</a></code> content attribute whose value is <var title="">name</var>, or</li> <li><code><a href=#the-img-element>img</a></code> elements that have an <code title=attr-id><a href=#the-id-attribute>id</a></code> content attribute whose value is <var title="">name</var>, and that have a <code title=attr-name>name</code> content attribute present also.</li> </ul><p>An <code><a href=#the-embed-element>embed</a></code> or <code><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>exposed</a> <code><a href=#the-object-element>object</a></code> ancestor, and, for <code><a href=#the-object-element>object</a></code> elements, is additionally either not showing its <a href=#fallback-content>fallback content</a> or has no <code><a href=#the-object-element>object</a></code> or <code><a href=#the-embed-element>embed</a></code> descendants.</p> </div> <hr><p class=note>The <code title=dom-document-dir><a href=#dom-document-dir>dir</a></code> attribute on the <code><a href=#document>Document</a></code> interface is defined along with the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content attribute.</p> <div class=impl> <!-- very deprecated API; use XHR instead --> <h4 id=loading-xml-documents><span class=secno>3.1.5 </span>Loading XML documents</h4> <pre class=idl>partial interface <dfn id=xmldocument>XMLDocument</dfn> { <!--SYNCLOAD attribute boolean <span title="dom-XMLDocument-async">async</span>; --> boolean <a href=#dom-xmldocument-load title=dom-XMLDocument-load>load</a>(DOMString url); };</pre> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/576 --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/577 --> <!-- http://www.hixie.ch/tests/adhoc/dom/level0/document/load/001.html --> <!--SYNCLOAD <p>The <dfn title="dom-XMLDocument-async"><code>async</code></dfn> attribute must initially be true. On getting, it must return its current value. On setting, its current value must be changed to the new value.</p> --> <p>The <dfn id=dom-xmldocument-load title=dom-XMLDocument-load><code>load(<var title="">url</var>)</code></dfn> method must run the following steps:</p> <ol><!--SYNCLOAD <li><p>If <code title="dom-XMLDocument-async">async</code> is set to false and the <var title="">document</var> is <span>load-blocked</span>, return false and abort these steps.</p></li> --><li><p>Let <var title="">document</var> be the <code><a href=#xmldocument>XMLDocument</a></code> object on which the method was invoked.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the method's first argument, relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>. If this is not successful, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps. Otherwise, let <var title="">url</var> be the resulting <a href=#absolute-url>absolute URL</a>.</li> <li><p>If the <a href=#origin>origin</a> of <var title="">url</var> is not the same as the <a href=#origin>origin</a> of <var title="">document</var>, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</li> <!--SYNCLOAD <li><p>If <code title="dom-XMLDocument-async">async</code> is set to false, let <var title="">document</var> be <dfn>load-blocked</dfn>.</p></li> --> <li><p>Remove all child nodes of <var title="">document</var>, without firing any mutation events.</li> <!-- as of 2010-07-26, only Opera fired mutation events here. --> <li><p>Set the <a href=#current-document-readiness>current document readiness</a> of <var title="">document</var> to "<code title="">loading</code>".</li> <li><p><!--SYNCLOAD If <code title="dom-XMLDocument-async">async</code> is set to true, then run--> Run the remainder of these steps asynchronously, and return true from the method.<!--SYNCLOAD Otherwise, continue running these steps without yet returning.--></li> <li><p>Let <var title="">result</var> be a <code><a href=#document>Document</a></code> object.</li> <li><p>Let <var title="">success</var> be false.</li> <li><p><a href=#fetch>Fetch</a> <var title="">url</var> from the <a href=#origin>origin</a> of <var title="">document</var>, with the <i title="">synchronous flag</i> set and the <i title="">force same-origin flag</i> set.</li> <li> <p>If the fetch attempt was successful, and the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a> is an <a href=#xml-mime-type>XML MIME type</a>, then run these substeps:</p> <ol><li><p>Create a new <a href=#xml-parser>XML parser</a> associated with the <var title="">result</var> document.</li> <li><p>Pass this parser the fetched document.</li> <!-- no worries about scripts running; there's no browsing context for the document so scripts are automatically disabled --> <li><p>If there is an XML well-formedness or XML namespace well-formedness error, then remove all child nodes from <var title="">result</var>. Otherwise let <var title="">success</var> be true.</li> </ol></li> <li> <p><!--SYNCLOAD If <code title="dom-XMLDocument-async">async</code> is set to true, then <span>queue--> <a href=#queue-a-task>Queue a task</a> to run the following steps. <!--SYNCLOAD Otherwise, run them synchronously.--></p> <ol><li><p>Set the <a href=#current-document-readiness>current document readiness</a> of <var title="">document</var> to "<code title="">complete</code>".</li> <li><p>Replace all the children of <var title="">document</var> by the children of <var title="">result</var> (even if it has no children), firing mutation events as if a <code><a href=#documentfragment>DocumentFragment</a></code> containing the new children had been inserted.</li> <!-- as of 2010-07-26, both Firefox and Opera fired mutation events here. --> <!-- If the document doesn't have no nodes here, at time of writing, Opera would leave the new nodes and drop the parsed ones, while Firefox would basically abort instead, failing to fire the 'load' event --> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-load>load</code> at <var title="">document</var>.</li> </ol></li> <!--SYNCLOAD <li><p>If <code title="dom-XMLDocument-async">async</code> was set to false when this algorithm started, let <var title="">document</var> be no longer <span>load-blocked</span>.</p></li> <li><p>If <code title="dom-XMLDocument-async">async</code> was set to false when this algorithm started, return <var title="">success</var>.</p></li> --> </ol></div> <h3 id=elements><span class=secno>3.2 </span>Elements</h3> <h4 id=semantics-0><span class=secno>3.2.1 </span>Semantics</h4> <p>Elements, attributes, and attribute values in HTML are defined (by this specification) to have certain meanings (semantics). For example, the <code><a href=#the-ol-element>ol</a></code> element represents an ordered list, and the <code title=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. 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 the 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 document is non-conforming, despite being syntactically correct:</p> <pre class=bad><!DOCTYPE HTML> <html lang="en-GB"> <head> <title> Demonstration </title> </head> <body> <table> <tr> <td> My favourite animal is the cat. </td> </tr> <tr> <td> —<a href="http://example.org/~ernest/"><cite>Ernest</cite></a>, in an essay from 1992 </td> </tr> </table> </body> </html></pre> <p>...because the data placed in the cells is clearly not tabular data (and the <code><a href=#the-cite-element>cite</a></code> element mis-used). 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><!DOCTYPE HTML> <html lang="en-GB"> <head> <title> Demonstration </title> </head> <body> <blockquote> <p> My favourite animal is the cat. </p> </blockquote> <p> —<a href="http://example.org/~ernest/">Ernest</a>, in an essay from 1992 </p> </body> </html></pre> </div> <div class=example> <p>This next document fragment, intended to represent the heading of a corporate site, is similarly 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><body> <h1>ABC Company</h1> <h2>Leading the way in widget design since 1432</h2> ...</pre> <p>The <code><a href=#the-hgroup-element>hgroup</a></code> element is intended for these kinds of situations:</p> <pre><body> <hgroup> <h1>ABC Company</h1> <h2>Leading the way in widget design since 1432</h2> </hgroup> ...</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>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><label>Carpet: <input type="carpet" name="c" texture="deep pile"></label></pre> <p>Here would be an alternative and correct way to mark this up:</p> <pre><label>Carpet: <input type="text" class="carpet" name="c" data-texture="deep pile"></label></pre> </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 <span class=impl>must</span> update their presentation of the document as this occurs.</p> <p class=example>HTML has a <code><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</h4> <p>The nodes representing <a href=#html-elements>HTML elements</a> in the DOM <span class=impl>must</span> implement, and expose to scripts, the interfaces listed for them in the relevant sections of this specification. This includes <a href=#html-elements>HTML elements</a> in <a href=#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 <a href=#represents title=represents>represent</a> things; that is, they have intrinsic <em>meaning</em>, also known as semantics.</p> <p class=example>For example, an <code><a href=#the-ol-element>ol</a></code> element represents an ordered list.</p> <p>The basic interface, from which all the <a href=#html-elements>HTML elements</a>' interfaces inherit, <span class=impl>and which must be used by elements that have no additional requirements,</span> is the <code><a href=#htmlelement>HTMLElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlelement>HTMLElement</dfn> : <a href=#element>Element</a> { // <span>metadata attributes</span> attribute DOMString <a href=#dom-title title=dom-title>title</a>; attribute DOMString <a href=#dom-lang title=dom-lang>lang</a>; attribute DOMString <a href=#dom-dir title=dom-dir>dir</a>; attribute <span>DOMString</span> <a href=#dom-classname title=dom-className>className</a>; readonly attribute <a href=#domtokenlist>DOMTokenList</a> <a href=#dom-classlist title=dom-classList>classList</a>; readonly attribute <a href=#domstringmap>DOMStringMap</a> <a href=#dom-dataset title=dom-dataset>dataset</a>; <!--MD--> // <a href=#microdata>microdata</a> <!--WARNING: ALSO DUPLICATED IN MICRODATA SECTION--> attribute boolean <a href=#dom-itemscope title=dom-itemScope>itemScope</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-itemtype title=dom-itemType>itemType</a>; attribute DOMString <a href=#dom-itemid title=dom-itemId>itemId</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-itemref title=dom-itemRef>itemRef</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-itemprop title=dom-itemProp>itemProp</a>; readonly attribute <a href=#htmlpropertiescollection>HTMLPropertiesCollection</a> <a href=#dom-properties title=dom-properties>properties</a>; attribute any <a href=#dom-itemvalue title=dom-itemValue>itemValue</a>; <!--MD--> // <a href=#editing>user interaction</a> attribute boolean <a href=#dom-hidden title=dom-hidden>hidden</a>; void <a href=#dom-click title=dom-click>click</a>(); attribute long <a href=#dom-tabindex title=dom-tabindex>tabIndex</a>; void <a href=#dom-focus title=dom-focus>focus</a>(); void <a href=#dom-blur title=dom-blur>blur</a>(); attribute DOMString <a href=#dom-accesskey title=dom-accessKey>accessKey</a>; readonly attribute DOMString <a href=#dom-accesskeylabel title=dom-accessKeyLabel>accessKeyLabel</a>; attribute boolean <a href=#dom-draggable title=dom-draggable>draggable</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-dropzone title=dom-dropzone>dropzone</a>; attribute DOMString <a href=#dom-contenteditable title=dom-contentEditable>contentEditable</a>; readonly attribute boolean <a href=#dom-iscontenteditable title=dom-isContentEditable>isContentEditable</a>; attribute <a href=#htmlmenuelement>HTMLMenuElement</a>? <a href=#dom-contextmenu title=dom-contextMenu>contextMenu</a>; attribute boolean <a href=#dom-spellcheck title=dom-spellcheck>spellcheck</a>; // <a href=#command-api>command API</a> readonly attribute DOMString? <a href=#dom-command-ro-commandtype title=dom-command-ro-commandType>commandType</a>; readonly attribute DOMString? <a href=#dom-command-ro-commandlabel title=dom-command-ro-commandLabel>commandLabel</a>; readonly attribute DOMString? <a href=#dom-command-ro-commandicon title=dom-command-ro-commandIcon>commandIcon</a>; readonly attribute boolean? <a href=#dom-command-ro-commandhidden title=dom-command-ro-commandHidden>commandHidden</a>; readonly attribute boolean? <a href=#dom-command-ro-commanddisabled title=dom-command-ro-commandDisabled>commandDisabled</a>; readonly attribute boolean? <a href=#dom-command-ro-commandchecked title=dom-command-ro-commandChecked>commandChecked</a>;<!-- v2COMMAND readonly attribute <span>HTMLCollection</span> <span title="dom-command-ro-commandTriggers">commandTriggers</span>;--> // <span>styling</span> readonly attribute <a href=#cssstyledeclaration>CSSStyleDeclaration</a> <a href=#dom-style title=dom-style>style</a>; // <a href=#event-handler-idl-attributes>event handler IDL attributes</a> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onabort title=handler-onabort>onabort</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onblur title=handler-onblur>onblur</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplay title=handler-oncanplay>oncanplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplaythrough title=handler-oncanplaythrough>oncanplaythrough</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onchange title=handler-onchange>onchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onclick title=handler-onclick>onclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncontextmenu title=handler-oncontextmenu>oncontextmenu</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncuechange title=handler-oncuechange>oncuechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondblclick title=handler-ondblclick>ondblclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrag title=handler-ondrag>ondrag</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragend title=handler-ondragend>ondragend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragenter title=handler-ondragenter>ondragenter</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragleave title=handler-ondragleave>ondragleave</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragover title=handler-ondragover>ondragover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragstart title=handler-ondragstart>ondragstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrop title=handler-ondrop>ondrop</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondurationchange title=handler-ondurationchange>ondurationchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onemptied title=handler-onemptied>onemptied</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onended title=handler-onended>onended</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onerror title=handler-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onfocus title=handler-onfocus>onfocus</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninput title=handler-oninput>oninput</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninvalid title=handler-oninvalid>oninvalid</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeydown title=handler-onkeydown>onkeydown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeypress title=handler-onkeypress>onkeypress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeyup title=handler-onkeyup>onkeyup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onload title=handler-onload>onload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadeddata title=handler-onloadeddata>onloadeddata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadedmetadata title=handler-onloadedmetadata>onloadedmetadata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadstart title=handler-onloadstart>onloadstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousedown title=handler-onmousedown>onmousedown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousemove title=handler-onmousemove>onmousemove</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseout title=handler-onmouseout>onmouseout</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseover title=handler-onmouseover>onmouseover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseup title=handler-onmouseup>onmouseup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousewheel title=handler-onmousewheel>onmousewheel</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onpause title=handler-onpause>onpause</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplay title=handler-onplay>onplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplaying title=handler-onplaying>onplaying</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onprogress title=handler-onprogress>onprogress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onratechange title=handler-onratechange>onratechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onreset title=handler-onreset>onreset</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onscroll title=handler-onscroll>onscroll</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeked title=handler-onseeked>onseeked</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeking title=handler-onseeking>onseeking</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onselect title=handler-onselect>onselect</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onshow title=handler-onshow>onshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onstalled title=handler-onstalled>onstalled</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsubmit title=handler-onsubmit>onsubmit</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsuspend title=handler-onsuspend>onsuspend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ontimeupdate title=handler-ontimeupdate>ontimeupdate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onvolumechange title=handler-onvolumechange>onvolumechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onwaiting title=handler-onwaiting>onwaiting</a>; }; interface <dfn id=htmlunknownelement>HTMLUnknownElement</dfn> : <a href=#htmlelement>HTMLElement</a> { };</pre> <p>The <code><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> <div class=impl> <p>The <code><a href=#htmlunknownelement>HTMLUnknownElement</a></code> interface must be used for <a href=#html-elements>HTML elements</a> that are not defined by this specification (or <a href=#other-applicable-specifications>other applicable specifications</a>).</p> </div> <h4 id=global-attributes><span class=secno>3.2.3 </span><dfn>Global attributes</dfn></h4> <p>The following attributes are common to and may be specified on all <a href=#html-elements>HTML elements</a><span class=impl> (even those not defined in this specification)</span>:</p> <ul class=brief><li><code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code></li> <li><code title=attr-class><a href=#classes>class</a></code></li> <li><code title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code></li> <li><code title=attr-contextmenu><a href=#attr-contextmenu>contextmenu</a></code></li> <li><code title=attr-dir><a href=#the-dir-attribute>dir</a></code></li> <li><code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code></li> <li><code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code></li> <li><code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code></li> <li><code title=attr-id><a href=#the-id-attribute>id</a></code></li> <!--MD--><!--WARNING: ALSO DUPLICATED IN MICRODATA SECTION --> <li><code title=attr-itemid><a href=#attr-itemid>itemid</a></code></li> <li><code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code></li> <li><code title=attr-itemref><a href=#attr-itemref>itemref</a></code></li> <li><code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code></li> <li><code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code></li> <!--MD--> <li><code title=attr-lang><a href=#attr-lang>lang</a></code></li> <li><code title=attr-spellcheck><a href=#attr-spellcheck>spellcheck</a></code></li> <li><code title=attr-style><a href=#the-style-attribute>style</a></code></li> <li><code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code></li> <li><code title=attr-title><a href=#the-title-attribute>title</a></code></li> </ul><div class=impl> <p>These attributes are only defined by this specification as attributes for <a href=#html-elements>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 title="">bogus</code>" element does not have a <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute as defined in this specification, despite having an attribute with the literal name "<code title="">dir</code>". Thus, <a href=#the-directionality>the directionality</a> of the inner-most <code><a href=#the-span-element>span</a></code> element is '<a href=#concept-rtl title=concept-rtl>rtl</a>', inherited from the <code><a href=#the-div-element>div</a></code> element indirectly through the "<code title="">bogus</code>" element.</p> <pre class=bad><div xmlns="http://www.w3.org/1999/html" dir="rtl"> <bogus xmlns="http://example.net/ns" dir="ltr"> <span xmlns="http://www.w3.org/1999/html"> </span> </bogus> </div></pre> </div> </div> <hr><p>The following <a href=#event-handler-content-attributes>event handler content attributes</a> may be specified on any <a href=#html-elements title="HTML elements">HTML element</a>:</p> <ul class=brief><li><code title=handler-onabort><a href=#handler-onabort>onabort</a></code></li> <li><code title=handler-onblur><a href=#handler-onblur>onblur</a></code>*</li> <li><code title=handler-oncanplay><a href=#handler-oncanplay>oncanplay</a></code></li> <li><code title=handler-oncanplaythrough><a href=#handler-oncanplaythrough>oncanplaythrough</a></code></li> <li><code title=handler-onchange><a href=#handler-onchange>onchange</a></code></li> <li><code title=handler-onclick><a href=#handler-onclick>onclick</a></code></li> <li><code title=handler-oncontextmenu><a href=#handler-oncontextmenu>oncontextmenu</a></code></li> <li><code title=handler-oncuechange><a href=#handler-oncuechange>oncuechange</a></code></li> <li><code title=handler-ondblclick><a href=#handler-ondblclick>ondblclick</a></code></li> <li><code title=handler-ondrag><a href=#handler-ondrag>ondrag</a></code></li> <li><code title=handler-ondragend><a href=#handler-ondragend>ondragend</a></code></li> <li><code title=handler-ondragenter><a href=#handler-ondragenter>ondragenter</a></code></li> <li><code title=handler-ondragleave><a href=#handler-ondragleave>ondragleave</a></code></li> <li><code title=handler-ondragover><a href=#handler-ondragover>ondragover</a></code></li> <li><code title=handler-ondragstart><a href=#handler-ondragstart>ondragstart</a></code></li> <li><code title=handler-ondrop><a href=#handler-ondrop>ondrop</a></code></li> <li><code title=handler-ondurationchange><a href=#handler-ondurationchange>ondurationchange</a></code></li> <li><code title=handler-onemptied><a href=#handler-onemptied>onemptied</a></code></li> <li><code title=handler-onended><a href=#handler-onended>onended</a></code></li> <li><code title=handler-onerror><a href=#handler-onerror>onerror</a></code>*</li> <li><code title=handler-onfocus><a href=#handler-onfocus>onfocus</a></code>*</li> <li><code title=handler-oninput><a href=#handler-oninput>oninput</a></code></li> <li><code title=handler-oninvalid><a href=#handler-oninvalid>oninvalid</a></code></li> <li><code title=handler-onkeydown><a href=#handler-onkeydown>onkeydown</a></code></li> <li><code title=handler-onkeypress><a href=#handler-onkeypress>onkeypress</a></code></li> <li><code title=handler-onkeyup><a href=#handler-onkeyup>onkeyup</a></code></li> <li><code title=handler-onload><a href=#handler-onload>onload</a></code>*</li> <li><code title=handler-onloadeddata><a href=#handler-onloadeddata>onloadeddata</a></code></li> <li><code title=handler-onloadedmetadata><a href=#handler-onloadedmetadata>onloadedmetadata</a></code></li> <li><code title=handler-onloadstart><a href=#handler-onloadstart>onloadstart</a></code></li> <li><code title=handler-onmousedown><a href=#handler-onmousedown>onmousedown</a></code></li> <li><code title=handler-onmousemove><a href=#handler-onmousemove>onmousemove</a></code></li> <li><code title=handler-onmouseout><a href=#handler-onmouseout>onmouseout</a></code></li> <li><code title=handler-onmouseover><a href=#handler-onmouseover>onmouseover</a></code></li> <li><code title=handler-onmouseup><a href=#handler-onmouseup>onmouseup</a></code></li> <li><code title=handler-onmousewheel><a href=#handler-onmousewheel>onmousewheel</a></code></li> <li><code title=handler-onpause><a href=#handler-onpause>onpause</a></code></li> <li><code title=handler-onplay><a href=#handler-onplay>onplay</a></code></li> <li><code title=handler-onplaying><a href=#handler-onplaying>onplaying</a></code></li> <li><code title=handler-onprogress><a href=#handler-onprogress>onprogress</a></code></li> <li><code title=handler-onratechange><a href=#handler-onratechange>onratechange</a></code></li> <li><code title=handler-onreset><a href=#handler-onreset>onreset</a></code></li> <li><code title=handler-onscroll><a href=#handler-onscroll>onscroll</a></code>*</li> <li><code title=handler-onseeked><a href=#handler-onseeked>onseeked</a></code></li> <li><code title=handler-onseeking><a href=#handler-onseeking>onseeking</a></code></li> <li><code title=handler-onselect><a href=#handler-onselect>onselect</a></code></li> <li><code title=handler-onshow><a href=#handler-onshow>onshow</a></code></li> <li><code title=handler-onstalled><a href=#handler-onstalled>onstalled</a></code></li> <li><code title=handler-onsubmit><a href=#handler-onsubmit>onsubmit</a></code></li> <li><code title=handler-onsuspend><a href=#handler-onsuspend>onsuspend</a></code></li> <li><code title=handler-ontimeupdate><a href=#handler-ontimeupdate>ontimeupdate</a></code></li> <li><code title=handler-onvolumechange><a href=#handler-onvolumechange>onvolumechange</a></code></li> <li><code title=handler-onwaiting><a href=#handler-onwaiting>onwaiting</a></code></li> </ul><p class=note>The attributes marked with an asterisk have a different meaning when specified on <code><a href=#the-body-element>body</a></code> elements as those elements expose <a href=#event-handlers>event handlers</a> of the <code><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 title="media element">media elements</a> will ever receive a <code title=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 title="custom data attribute">Custom data attributes</a> (e.g. <code title="">data-foldername</code> or <code title="">data-msgid</code>) can be specified on any <a href=#html-elements title="HTML elements">HTML element</a>, to store custom data specific to the page.</p> <hr><p>In <a href=#html-documents>HTML documents</a>, elements in the <a href=#html-namespace-0>HTML namespace</a> may have an <code title="">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 href=#xml-documents>XML documents</a>.</p> <p class=note>In HTML, the <code title="">xmlns</code> attribute has absolutely no effect. It is basically a talisman. It is allowed merely to make migration to and from XHTML mildly easier. When parsed by an <a href=#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 title="">xmlns</code> attribute is part of the namespace declaration mechanism, and an element cannot actually have an <code title="">xmlns</code> attribute in no namespace specified.</p> <hr><p>The XML specification also allows the use of the <code title=attr-xml-space>xml:space</code> attribute in the <a href=#xml-namespace>XML namespace</a> on any element in an <a href=#xml-documents title="XML documents">XML document</a>. This attribute has no effect on <a href=#html-elements>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 title=attr-xml-space>xml:space</code> attribute on <a href=#html-elements>HTML elements</a> in the <code><a href=#text/html>text/html</a></code> syntax.</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 title=WAI-ARIA>annotations for assistive technology products</a> can be specified (the ARIA <code title=attr-aria-role>role</code> and <code title=attr-aria-*>aria-*</code> attributes).</p> <h5 id=the-id-attribute><span class=secno>3.2.3.1 </span>The <dfn title=attr-id><code>id</code></dfn> attribute</h5> <p>The <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute specifies its element's <a href=#concept-id title=concept-id>unique identifier (ID)</a>. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p>The value must be unique amongst all the <a href=#concept-id title=concept-id>IDs</a> in the element's <a href=#home-subtree>home subtree</a> and must contain at least one character. The value must not contain any <a href=#space-character title="space character">space characters</a>.</p> <!-- space characters are disallowed because space-separated lists of IDs otherwise would not be able to reach all valid IDs --> <p class=note>An element's <a href=#concept-id title=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 fragment identifiers, as a way to target an element when scripting, and as a way to style a specific element from CSS.</p> <div class=impl> <p>Identifiers are opaque strings. Particular meanings should not be derived from the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute.</p> </div> <h5 id=the-title-attribute><span class=secno>3.2.3.2 </span>The <dfn title=attr-title><code>title</code></dfn> attribute</h5> <p>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute <a href=#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; and so forth. The value is text.</p> <p>If this attribute is omitted from an element, then it implies that the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the nearest ancestor <a href=#html-elements title="HTML elements">HTML element</a> with a <code title=attr-title><a href=#the-title-attribute>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 title=attr-title><a href=#the-title-attribute>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 title=attr-title><a href=#the-title-attribute>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><p>My logs show that there was some interest in <abbr title="Hypertext Transport Protocol">HTTP</abbr> today.</p></pre> </div> <p>Some elements, such as <code><a href=#the-link-element>link</a></code>, <code><a href=#the-abbr-element>abbr</a></code>, and <code><a href=#the-input-element>input</a></code>, define additional semantics for the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute beyond the semantics described above.</p> <div class=impl> <hr><p>The <dfn id=dom-title title=dom-title><code>title</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-title><a href=#the-title-attribute>title</a></code> content attribute.</p> </div> <h5 id=the-lang-and-xml:lang-attributes><span class=secno>3.2.3.3 </span>The <code title=attr-lang><a href=#attr-lang>lang</a></code> and <code title=attr-xml-lang><a href=#attr-xml-lang>xml:lang</a></code> attributes</h5> <p>The <dfn id=attr-lang title=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<!-- UA conformance requirements for this are below -->. <a href=#refsBCP47>[BCP47]</a></p> <p>The <dfn id=attr-xml-lang title=attr-xml-lang><code title="">lang</code></dfn> attribute in the <a href=#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 title=attr-lang><a href=#attr-lang>lang</a></code> attribute in no namespace may be used on any <a href=#html-elements title="HTML elements">HTML element</a>.</p> <p>The <a href=#attr-xml-lang title=attr-xml-lang><code title="">lang</code> attribute in the <span>XML namespace</span></a> may be used on <a href=#html-elements>HTML elements</a> in <a href=#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 title=attr-xml-lang><code title="">lang</code> attributes in the <span>XML namespace</span></a> to be specified on their elements). If both the <code title=attr-lang><a href=#attr-lang>lang</a></code> attribute in no namespace and the <a href=#attr-xml-lang title=attr-xml-lang><code title="">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 href=#ascii-case-insensitive>ASCII case-insensitive</a> manner.</p> <p>Authors must not use the <a href=#attr-xml-lang title=attr-xml-lang><code title="">lang</code> attribute in the <span>XML namespace</span></a> on <a href=#html-elements>HTML elements</a> in <a href=#html-documents>HTML documents</a>. To ease migration to and from XHTML, authors may specify an attribute in no namespace with no prefix and with the literal localname "<code title="">xml:lang</code>" on <a href=#html-elements>HTML elements</a> in <a href=#html-documents>HTML documents</a>, but such attributes must only be specified if a <code title=attr-lang><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 href=#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 title="">xml:lang</code>" has no effect on language processing.</p> <div class=impl> <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 title=attr-xml-lang><code title="">lang</code> attribute in the <span>XML namespace</span></a> set or is an <a href=#html-elements title="HTML elements">HTML element</a> and has a <code title=attr-lang><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 title=attr-lang><a href=#attr-lang>lang</a></code> attribute in no namespace and the <a href=#attr-xml-lang title=attr-xml-lang><code title="">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 title=attr-xml-lang><code title="">lang</code> attribute in the <span>XML namespace</span></a>, and the <code title=attr-lang><a href=#attr-lang>lang</a></code> attribute in no namespace must be <a href=#ignore title=ignore>ignored</a> for the purposes of determining the element's language.</p> <p>If none of the node's ancestors, including the <a href=#root-element>root element</a>, have either attribute set, but there is a <a href=#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>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.</p> <p class=example>Thus, for instance, an element with <code title="">lang="xyzzy"</code> would be matched by the selector <code title="">:lang(xyzzy)</code> (e.g. in CSS), but it would not be matched by <code title="">: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.</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, or for dictionary selection). <!--User agents must not use the element's language to determine text directionality. (commented out because text directionality is a rendering-level concern.)--></p> <hr><p>The <dfn id=dom-lang title=dom-lang><code>lang</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-lang><a href=#attr-lang>lang</a></code> content attribute in no namespace.</p> </div> <h5 id=the-xml:base-attribute-(xml-only)><span class=secno>3.2.3.4 </span>The <dfn title=attr-xml-base><code>xml:base</code></dfn> attribute (XML only)</h5> <p>The <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attribute is defined in XML Base. <a href=#refsXMLBASE>[XMLBASE]</a></p> <p>The <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attribute may be used on elements of <a href=#xml-documents>XML documents</a>. Authors must not use the <code title=attr-xml-base><a href=#the-xml:base-attribute-(xml-only)>xml:base</a></code> attribute in <a href=#html-documents>HTML documents</a>.</p> <h5 id=the-dir-attribute><span class=secno>3.2.3.5 </span>The <dfn title=attr-dir><code>dir</code></dfn> attribute</h5> <p>The <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute specifies the element's text directionality. The attribute is an <a href=#enumerated-attribute>enumerated attribute</a> with the following keywords and states:</p> <dl><dt>The <dfn id=attr-dir-ltr title=attr-dir-ltr><code>ltr</code></dfn> keyword, which maps to the <dfn id=attr-dir-ltr-state title=attr-dir-ltr-state>ltr</dfn> state</dt> <dd> <p>Indicates that the contents of the element are explicitly directionally embedded left-to-right text.</p> </dd> <dt>The <dfn id=attr-dir-rtl title=attr-dir-rtl><code>rtl</code></dfn> keyword, which maps to the <dfn id=attr-dir-rtl-state title=attr-dir-rtl-state>rtl</dfn> state</dt> <dd> <p>Indicates that the contents of the element are explicitly directionally embedded right-to-left text.</p> </dd> <dt>The <dfn id=attr-dir-auto title=attr-dir-auto><code>auto</code></dfn> keyword, which maps to the <dfn id=attr-dir-auto-state title=attr-dir-auto-state>auto</dfn> state</dt> <dd> <p>Indicates that the contents of the element are explicitly embedded 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.</p> <p class=note>For <code><a href=#the-textarea-element>textarea</a></code> and <code><a href=#the-pre-element>pre</a></code> elements, the heuristic is applied on a per-paragraph level.</p> </dd> </dl><p>The attribute has no <i>invalid value default</i> and no <i>missing value default</i>.</p> <p><dfn id=the-directionality>The directionality</dfn> of an element is either '<dfn id=concept-ltr title=concept-ltr>ltr</dfn>' or '<dfn id=concept-rtl title=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 title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-ltr-state title=attr-dir-ltr-state>ltr</a> state</dt> <dd><p><a href=#the-directionality>The directionality</a> of the element is '<a href=#concept-ltr title=concept-ltr>ltr</a>'.</dd> <dt>If the element's <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-rtl-state title=attr-dir-rtl-state>rtl</a> state</dt> <dd><p><a href=#the-directionality>The directionality</a> of the element is '<a href=#concept-rtl title=concept-rtl>rtl</a>'.</dd> <dt>If the element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a>, <a href=#text-state-and-search-state title=attr-input-type-search>Search</a>, <a href=#telephone-state title=attr-input-type-tel>Telephone</a>, <a href=#url-state title=attr-input-type-url>URL</a>, or <a href=#e-mail-state title=attr-input-type-email>E-mail</a> state, and the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-auto-state title=attr-dir-auto-state>auto</a> state</dt> <dt>If the element is a <code><a href=#the-textarea-element>textarea</a></code> element and the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-auto-state title=attr-dir-auto-state>auto</a> state</dt> <dd> <p>If the element's <a href=#concept-fe-value title=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 title=concept-fe-value>value</a>, then <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-rtl title=concept-rtl>rtl</a>'. Otherwise, <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-ltr title=concept-ltr>ltr</a>'.</p> </dd> <dt>If the element's <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-auto-state title=attr-dir-auto-state>auto</a> state</dt> <dt>If the element is a <code><a href=#the-bdi-element>bdi</a></code> element and the <code title=attr-dir><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> <dd> <p>Find the first character in <a href=#tree-order>tree order</a> that matches the following criteria:</p> <ul><li><p>The character is from a <a href=#text-node>text node</a> that is a descendant of the element whose <a href=#the-directionality title="the directionality">directionality</a> is being determined.</li> <li><p>The character is of bidirectional character type L, AL, or R. <a href=#refsBIDI>[BIDI]</a></li> <li> <p>The character is not in a text node that has an ancestor element that is a descendant of the element whose <a href=#the-directionality title="the directionality">directionality</a> is being determined and that is either:</p> <ul class=brief><li>A <code><a href=#the-bdi-element>bdi</a></code> element. <li>A <code><a href=#the-script-element>script</a></code> element. <li>A <code><a href=#the-style-element>style</a></code> element. <li>A <code><a href=#the-textarea-element>textarea</a></code> element. <li>An element with a <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute in a defined state. </ul></li> </ul><p>If such a character is found and it is of bidirectional character type AL or R, <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-rtl title=concept-rtl>rtl</a>'.</p> <p>Otherwise, <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-ltr title=concept-ltr>ltr</a>'.</p> </dd> <dt>If the element is a <a href=#root-element>root element</a> and the <code title=attr-dir><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> <dd><p><a href=#the-directionality>The directionality</a> of the element is '<a href=#concept-ltr title=concept-ltr>ltr</a>'.</dd> <dt>If the element has a parent element and the <code title=attr-dir><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> <dd><p><a href=#the-directionality>The directionality</a> of the element is the same as the element's parent element's <a href=#the-directionality title="the directionality">directionality</a>.</dd> </dl><p>The effect of this attribute is primarily on the presentation layer. For example, the rendering section in this specification defines a mapping from this attribute to the CSS 'direction' and 'unicode-bidi' properties, and CSS defines rendering in terms of those properties.</p> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-dir><a href=#dom-dir>dir</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value, if any.</p> <p>Can be set, to either "<code title="">ltr</code>", "<code title="">rtl</code>", or "<code title="">auto</code>" to replace <a href=#the-html-element-0>the <code>html</code> element</a>'s <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute's value.</p> <p>If there is no <a href=#the-html-element-0 title="the html element"><code>html</code> element</a>, returns the empty string and ignores new values.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-dir title=dom-dir><code>dir</code></dfn> IDL attribute on an element must <a href=#reflect>reflect</a> the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content attribute of that element, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> <p>The <dfn id=dom-document-dir title=dom-document-dir><code>dir</code></dfn> IDL attribute on <code><a href=#document>Document</a></code> objects must <a href=#reflect>reflect</a> the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content attribute of <a href=#the-html-element-0>the <code>html</code> element</a>, if any, <a href=#limited-to-only-known-values>limited to only known values</a>. If there is no such element, then the attribute must return the empty string and do nothing on setting.</p> </div> <p class=note>Authors are strongly encouraged to use the <code title=attr-dir><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><p dir=auto class="u1"><b><bdi>Student</bdi>:</b> How do you write "What's your name?" in Arabic?</p> <p dir=auto class="u2"><b><bdi>Teacher</bdi>:</b> ما اسمك؟</p> <p dir=auto class="u1"><b><bdi>Student</bdi>:</b> Thanks.</p> <p dir=auto class="u2"><b><bdi>Teacher</bdi>:</b> That's written "شكرًا".</p> <p dir=auto class="u2"><b><bdi>Teacher</bdi>:</b> Do you know how to write "Please"?</p> <p dir=auto class="u1"><b><bdi>Student</bdi>:</b> "من فضلك", right?</p></pre> <!-- <!DOCTYPE html> <style> div { border: groove #FFFF99; padding: 0.25em; width: 22em; background: #FFFFEE; color: black; } p { margin: 0.25em 0; font: 1em/1 InaiMathi; color: purple; } .u1 { color: teal; } </style> <div> <p dir=ltr class="u1"><b><bdi>Student</bdi>:</b> How do you write "What's your name?" in Arabic?</p> <p dir=rtl class="u2"><b><bdi>Teacher</bdi>:</b> ما اسمك؟</p> <p dir=ltr class="u1"><b><bdi>Student</bdi>:</b> Thanks.</p> <p dir=ltr class="u2"><b><bdi>Teacher</bdi>:</b> That's written "شكرًا".</p> <p dir=ltr class="u2"><b><bdi>Teacher</bdi>:</b> Do you know how to write "Please"?</p> <p dir=rtl class="u1"><b><bdi>Student</bdi>:</b> "من فضلك", right?</p> --> <p>Given a suitable style sheet and the default alignment styles for the <code><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 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." src=http://images.whatwg.org/im.png></p> <p>As noted earlier, the <code title=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=classes><span class=secno>3.2.3.6 </span>The <dfn title=attr-class><code>class</code></dfn> attribute</h5> <p>Every <a href=#html-elements title="HTML elements">HTML element</a> may have a <code title=attr-class><a href=#classes>class</a></code> attribute specified.</p> <p>The attribute, if specified, must have a value that is a <a href=#set-of-space-separated-tokens>set of space-separated tokens</a> representing the various classes that the element belongs to.</p> <div class=impl> <p>The classes that an <a href=#html-elements title="HTML elements">HTML element</a> has assigned to it consists of all the classes returned when the value of the <code title=attr-class><a href=#classes>class</a></code> attribute is <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>. (Duplicates are ignored.)</p> </div> <p class=note>Assigning classes to an element affects class matching in selectors in CSS, the <code title=dom-document-getElementsByClassName>getElementsByClassName()</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 title=attr-class><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 class=impl> <hr><p>The <dfn id=dom-classname title=dom-className><code>className</code></dfn> and <dfn id=dom-classlist title=dom-classList><code>classList</code></dfn> IDL attributes must both <a href=#reflect>reflect</a> the <code title=attr-class><a href=#classes>class</a></code> content attribute.</p> </div> <h5 id=the-style-attribute><span class=secno>3.2.3.7 </span>The <dfn title=attr-style><code>style</code></dfn> attribute</h5> <p>All <a href=#html-elements>HTML elements</a> may have the <code title=attr-style><a href=#the-style-attribute>style</a></code> content attribute set. This is a <span>CSS styling attribute</span> as defined by the CSS Styling Attribute Syntax specification. <a href=#refsCSSATTR>[CSSATTR]</a></p> <div class=impl> <p>In user agents that support CSS, the attribute's value must be parsed when the attribute is added or has its value changed<!-- so dynamic changes to the base URL don't affect the CSS -->, according to the rules given for <span>CSS styling attributes</span>. <a href=#refsCSSATTR>[CSSATTR]</a></p> </div> <p>Documents that use <code title=attr-style><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 title=attr-style><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 title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute.)</p> <hr><dl class=domintro><dt><var title="">element</var> . <code title=dom-style><a href=#dom-style>style</a></code></dt> <dd> <p>Returns a <code><a href=#cssstyledeclaration>CSSStyleDeclaration</a></code> object for the element's <code title=attr-style><a href=#the-style-attribute>style</a></code> attribute.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-style title=dom-style><code>style</code></dfn> IDL attribute must return a <code><a href=#cssstyledeclaration>CSSStyleDeclaration</a></code> whose value represents the declarations specified in the attribute, if present. Mutating the <code><a href=#cssstyledeclaration>CSSStyleDeclaration</a></code> object must create a <code title=attr-style><a href=#the-style-attribute>style</a></code> attribute on the element (if there isn't one already) and then change its value to be a value representing the serialized form of the <code><a href=#cssstyledeclaration>CSSStyleDeclaration</a></code> object. The same object must be returned each time. <a href=#refsCSSOM>[CSSOM]</a></p> </div> <div class=example> <p>In the following example, the words that refer to colors are marked up using the <code><a href=#the-span-element>span</a></code> element and the <code title=attr-style><a href=#the-style-attribute>style</a></code> attribute to make those words show up in the relevant colors in visual media.</p> <pre><p>My sweat suit is <span style="color: green; background: transparent">green</span> and my eyes are <span style="color: blue; background: transparent">blue</span>.</p></pre> </div> <h5 id=embedding-custom-non-visible-data-with-the-data-*-attributes><span class=secno>3.2.3.8 </span><dfn>Embedding custom non-visible data</dfn> with the <code title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes</h5> <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-* title=attr-data-*><code>data-</code></dfn>", has at least one character after the hyphen, is <a href=#xml-compatible>XML-compatible</a>, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).</p> <p class=note>All attributes on <a href=#html-elements>HTML elements</a> in <a href=#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 title="custom data attribute">Custom data attributes</a> are intended to store custom data 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 independent of the site that uses the attributes.</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><ol> <li data-length="2m11s">Beyond The Sea</li> ... </ol></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> <p>Every <a href=#html-elements title="HTML elements">HTML element</a> may have any number of <a href=#custom-data-attribute title="custom data attribute">custom data attributes</a> specified, with any value.</p> <hr><dl class=domintro><dt><var title="">element</var> . <code title=dom-dataset><a href=#dom-dataset>dataset</a></code></dt> <dd> <p>Returns a <code><a href=#domstringmap>DOMStringMap</a></code> object for the element's <code title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes.</p> <p>Hyphenated names become camel-cased. For example, <code title="">data-foo-bar=""</code> becomes <code title="">element.dataset.fooBar</code>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-dataset title=dom-dataset><code>dataset</code></dfn> IDL attribute provides convenient accessors for all the <code title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes on an element. On getting, the <code title=dom-dataset><a href=#dom-dataset>dataset</a></code> IDL attribute must return a <code><a href=#domstringmap>DOMStringMap</a></code> object, associated with the following algorithms, which expose these attributes on their element:</p> <dl><dt>The algorithm for getting the list of name-value pairs</dt> <dd> <ol><li>Let <var title="">list</var> be an empty list of name-value pairs.</li> <li>For each content attribute on the element whose first five characters are the string "<code title="">data-</code>" and whose remaining characters (if any) do not include any characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z), add a name-value pair to <var title="">list</var> whose name is the attribute's name with the first five characters removed and whose value is the attribute's value.</li> <li>For each name on the list, for each U+002D HYPHEN-MINUS character (-) in the name that is followed by a character in the range U+0061 to U+007A (U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z), remove the U+002D HYPHEN-MINUS character (-) and replace the character that followed it by the same character <a href=#converted-to-ascii-uppercase>converted to ASCII uppercase</a>.</li> <li>Return <var title="">list</var>.</li> </ol></dd> <dt>The algorithm for setting names to certain values</dt> <dd> <ol><li>Let <var title="">name</var> be the name passed to the algorithm.</li> <li>Let <var title="">value</var> be the value passed to the algorithm.</li> <li>If <var title="">name</var> contains a U+002D HYPHEN-MINUS character (-) followed by a character in the range U+0061 to U+007A (U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z), throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps.</li> <li>For each character in the range U+0041 to U+005A (U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z) in <var title="">name</var>, insert a U+002D HYPHEN-MINUS character (-) before the character and replace the character with the same character <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li>Insert the string <code title="">data-</code> at the front of <var title="">name</var>.</li> <li>Set the value of the attribute with the name <var title="">name</var>, to the value <var title="">value</var>, replacing any previous value if the attribute already existed. If <code title="">setAttribute()</code> would have thrown an exception when setting an attribute with the name <var title="">name</var>, then this must throw the same exception.</li> </ol></dd> <dt>The algorithm for deleting names</dt> <dd> <ol><li>Let <var title="">name</var> be the name passed to the algorithm.</li> <!--(can't happen while the DOMStringMap deleter has no name) <li>If <var title="">name</var> contains a U+002D HYPHEN-MINUS character (-) followed by a character in the range U+0061 to U+007A (U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z), throw a <code>SyntaxError</code> exception and abort these steps.</li> --> <li>For each character in the range U+0041 to U+005A (U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z) in <var title="">name</var>, insert a U+002D HYPHEN-MINUS character (-) before the character and replace the character with the same character <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li>Insert the string <code title="">data-</code> at the front of <var title="">name</var>.</li> <li>Remove the attribute with the name <var title="">name</var>, if such an attribute exists. Do nothing otherwise.</li> </ol></dd> </dl><p>The same object must be returned each time.</p> </div> <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 title=attr-class><a href=#classes>class</a></code> attribute along with <code title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes:</p> <pre><div class="spaceship" data-ship-id="92432" data-weapons="laser 2" data-shields="50%" data-x="30" data-y="10" data-z="90"> <button class="fire" onclick="spaceships[this.parentNode.dataset.shipId].fire()"> Fire </button> </div></pre> <p>Notice how the hyphenated attribute name becomes camel-cased in the API.</p> </div> <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> <div class=impl> <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> </div> <p>JavaScript libraries may use the <a href=#custom-data-attribute title="custom data attribute">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 title="">data-doquery-range</code>, and a library called "jJo" could use attributes names like <code title="">data-jjo-range</code>. The jJo library could also provide an API to set which prefix to use (e.g. <code title="">J.setDataPrefix('j2')</code>, making the attributes have names like <code title="">data-j2-range</code>).</p> </div> <h4 id=element-definitions><span class=secno>3.2.4 </span>Element definitions</h4> <p>Each element in this specification has a definition that includes the following information:</p> <dl><dt>Categories</dt> <dd><p>A list of <a href=#content-categories title="content categories">categories</a> to which the element belongs. These are used when defining the <a href=#content-models>content models</a> for each element.</dd> <dt>Contexts in which this element can be used</dt> <dd> <p>A <em>non-normative</em> description of where the element can be used. This information is redundant with the content models of elements that allow this one as a child, and is provided only as a convenience.</p> <p class=note>For simplicity, only the most specific expectations are listed. For example, an element that is both <a href=#flow-content>flow content</a> and <a href=#phrasing-content>phrasing content</a> can be used anywhere that either <a href=#flow-content>flow content</a> or <a href=#phrasing-content>phrasing content</a> is expected, but since anywhere that <a href=#flow-content>flow content</a> is expected, <a href=#phrasing-content>phrasing content</a> is also expected (since all <a href=#phrasing-content>phrasing content</a> is <a href=#flow-content>flow content</a>), only "where <a href=#phrasing-content>phrasing content</a> is expected" will be listed.</p> </dd> <dt>Content model</dt> <dd><p>A normative description of what content must be included as children and descendants of the element.</dd> <dt>Content attributes</dt> <dd><p>A normative list of attributes that may be specified on the element (except where otherwise disallowed).</dd> <dt>DOM interface</dt> <dd><p>A normative definition of a DOM interface that such elements must implement.</dd> </dl><p>This is then followed by a description of what the element <a href=#represents>represents</a>, along with any additional normative conformance criteria that may apply to authors<span class=impl title=""> and implementations</span>. Examples are sometimes also included.</p> <h5 id=attributes><span class=secno>3.2.4.1 </span>Attributes</h5> <p id=attribute-text>Except where otherwise specified, attributes on <a href=#html-elements>HTML elements</a> may have any string value, including the empty string. Except where explicitly stated, there is no restriction on what text can be specified in such attributes.</p> <h4 id=content-models><span class=secno>3.2.5 </span><dfn>Content models</dfn></h4> <p>Each element defined in this specification has a content model: a description of the element's expected contents. An <a href=#html-elements title="HTML elements">HTML element</a> must have contents that match the requirements described in the element's content model.</p> <p class=note>As noted in the conformance and terminology sections, for the purposes of determining if an element matches its content model or not, <a href=#text-node title="text node"><code>CDATASection</code> nodes in the DOM are treated as equivalent to <code>Text</code> nodes</a><!--, and <a href="#entity-references">entity reference nodes are treated as if they were expanded in place</a>--><!--ENTITY-->.</p> <p>The <a href=#space-character title="space character">space characters</a> are always allowed between elements. User agents represent these characters between elements in the source markup as text nodes in the DOM.<!-- not a conf criteria since the parser now requires this --> Empty <a href=#text-node title="text node">text nodes</a> and <a href=#text-node title="text node">text nodes</a> 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>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 title="">A</var> is said to be <i>preceded or followed</i> by a second element <var title="">B</var> if <var title="">A</var> and <var title="">B</var> have the same parent node and there are no other element nodes or text nodes (other than <a href=#inter-element-whitespace>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>inter-element whitespace</a>, comment nodes, and processing instruction nodes.</p> <p>Authors must not use <a href=#html-elements>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 title="">content</code> element. When its <code title="">type</code> attribute has the value <code title="">xhtml</code>, the Atom specification requires that it contain a single HTML <code><a href=#the-div-element>div</a></code> element. Thus, a <code><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>HTML elements</a> may be orphan nodes (i.e. without a parent node).</p> <div class=example> <p>For example, creating a <code><a href=#the-td-element>td</a></code> element and storing it in a global variable in a script is conforming, even though <code><a href=#the-td-element>td</a></code> elements are otherwise only supposed to be used inside <code><a href=#the-tr-element>tr</a></code> elements.</p> <pre>var data = { name: "Banana", cell: document.createElement('td'), };</pre> </div> <h5 id=kinds-of-content><span class=secno>3.2.5.1 </span>Kinds of content</h5> <p>Each element in HTML falls into zero or more <dfn id=content-categories title="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>Metadata content</a></li> <li><a href=#flow-content>Flow content</a></li> <li><a href=#sectioning-content>Sectioning content</a></li> <li><a href=#heading-content>Heading content</a></li> <li><a href=#phrasing-content>Phrasing content</a></li> <li><a href=#embedded-content>Embedded content</a></li> <li><a href=#interactive-content>Interactive content</a></li> </ul><p class=note>Some elements also fall into other categories, which are defined in other parts of this specification.</p> <p>These categories are related as follows:</p> <p><object data=images/content-venn.svg height=288 width=1000><img alt="Sectioning content, heading content, phrasing content, and embedded content are all types of flow content. Embedded content is also a type of phrasing content." src=http://images.whatwg.org/content-venn.png></object></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-0><span class=secno>3.2.5.1.1 </span>Metadata content</h6> <p><dfn id=metadata-content>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> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-base-element>base</a></code></li> <li><code><a href=#the-command-element>command</a></code></li> <li><code><a href=#the-link-element>link</a></code></li> <li><code><a href=#the-meta-element>meta</a></code></li> <li><code><a href=#the-noscript-element>noscript</a></code></li> <li><code><a href=#the-script-element>script</a></code></li> <li><code><a href=#the-style-element>style</a></code></li> <li><code><a href=#the-title-element>title</a></code></li> </ul><p>Elements from other namespaces whose semantics are primarily metadata-related (e.g. RDF) are also <a href=#metadata-content>metadata content</a>.</p> <div class=example> <p>Thus, in the XML serialization, one can use RDF, like this:</p> <pre><html xmlns="http://www.w3.org/1999/xhtml" xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <head> <title>Hedral's Home Page</title> <r:RDF> <Person xmlns="http://www.w3.org/2000/10/swap/pim/contact#" r:about="http://hedral.example.com/#"> <fullName>Cat Hedral</fullName> <mailbox r:resource="mailto:hedral@damowmow.com"/> <personalTitle>Sir</personalTitle> </Person> </r:RDF> </head> <body> <h1>My home page</h1> <p>I like playing with string, I guess. Sister says squirrels are fun too so sometimes I follow her to play with them.</p> </body> </html></pre> <p>This isn't possible in the HTML serialization, however.</p> </div> <h6 id=flow-content-0><span class=secno>3.2.5.1.2 </span>Flow content</h6> <p>Most elements that are used in the body of documents and applications are categorized as <dfn id=flow-content>flow content</dfn>.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code></li> <li><code><a href=#the-abbr-element>abbr</a></code></li> <li><code><a href=#the-address-element>address</a></code></li> <li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li> <li><code><a href=#the-article-element>article</a></code></li> <li><code><a href=#the-aside-element>aside</a></code></li> <li><code><a href=#the-audio-element>audio</a></code></li> <li><code><a href=#the-b-element>b</a></code></li> <li><code><a href=#the-bdi-element>bdi</a></code></li> <li><code><a href=#the-bdo-element>bdo</a></code></li> <li><code><a href=#the-blockquote-element>blockquote</a></code></li> <li><code><a href=#the-br-element>br</a></code></li> <li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-canvas-element>canvas</a></code></li> <li><code><a href=#the-cite-element>cite</a></code></li> <li><code><a href=#the-code-element>code</a></code></li> <li><code><a href=#the-command-element>command</a></code></li> <li><code><a href=#the-data-element>data</a></code></li> <li><code><a href=#the-datalist-element>datalist</a></code></li> <li><code><a href=#the-del-element>del</a></code></li> <li><code><a href=#the-details-element>details</a></code></li> <li><code><a href=#the-dfn-element>dfn</a></code></li> <li><code><a href=#the-div-element>div</a></code></li> <li><code><a href=#the-dl-element>dl</a></code></li> <li><code><a href=#the-em-element>em</a></code></li> <li><code><a href=#the-embed-element>embed</a></code></li> <li><code><a href=#the-fieldset-element>fieldset</a></code></li> <li><code><a href=#the-figure-element>figure</a></code></li> <li><code><a href=#the-footer-element>footer</a></code></li> <li><code><a href=#the-form-element>form</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></li> <li><code><a href=#the-header-element>header</a></code></li> <li><code><a href=#the-hgroup-element>hgroup</a></code></li> <li><code><a href=#the-hr-element>hr</a></code></li> <li><code><a href=#the-i-element>i</a></code></li> <li><code><a href=#the-iframe-element>iframe</a></code></li> <li><code><a href=#the-img-element>img</a></code></li> <li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-ins-element>ins</a></code></li> <li><code><a href=#the-kbd-element>kbd</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-label-element>label</a></code></li> <!--MD--> <li><code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li> <!--MD--> <li><code><a href=#the-map-element>map</a></code></li> <li><code><a href=#the-mark-element>mark</a></code></li> <li><code><a href=#math>math</a></code></li> <li><code><a href=#the-menu-element>menu</a></code></li> <!--MD--> <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li> <!--MD--> <li><code><a href=#the-meter-element>meter</a></code></li> <li><code><a href=#the-nav-element>nav</a></code></li> <li><code><a href=#the-noscript-element>noscript</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-ol-element>ol</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-p-element>p</a></code></li> <li><code><a href=#the-pre-element>pre</a></code></li> <li><code><a href=#the-progress-element>progress</a></code></li> <li><code><a href=#the-q-element>q</a></code></li> <li><code><a href=#the-ruby-element>ruby</a></code></li> <li><code><a href=#the-s-element>s</a></code></li> <li><code><a href=#the-samp-element>samp</a></code></li> <li><code><a href=#the-script-element>script</a></code></li> <li><code><a href=#the-section-element>section</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-small-element>small</a></code></li> <li><code><a href=#the-span-element>span</a></code></li> <li><code><a href=#the-strong-element>strong</a></code></li> <li><code><a href=#the-style-element>style</a></code> (if the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present)</li> <li><code><a href=#the-sub-and-sup-elements>sub</a></code></li> <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li> <li><code><a href=#svg>svg</a></code></li> <li><code><a href=#the-table-element>table</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> <li><code><a href=#the-u-element>u</a></code></li> <li><code><a href=#the-ul-element>ul</a></code></li> <li><code><a href=#the-var-element>var</a></code></li> <li><code><a href=#the-video-element>video</a></code></li> <li><code><a href=#the-wbr-element>wbr</a></code></li> <li><a href=#text-content title="text content">Text</a></li> </ul><h6 id=sectioning-content-0><span class=secno>3.2.5.1.3 </span>Sectioning content</h6> <p><dfn id=sectioning-content>Sectioning content</dfn> is content that defines the scope of <a href=#heading-content title="heading content">headings</a> and <a href=#the-footer-element title=footer>footers</a>.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-article-element>article</a></code></li> <li><code><a href=#the-aside-element>aside</a></code></li> <li><code><a href=#the-nav-element>nav</a></code></li> <li><code><a href=#the-section-element>section</a></code></li> </ul><p>Each <a href=#sectioning-content>sectioning content</a> element potentially has a heading and an <a href=#outline>outline</a>. See the section on <a href=#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 title="sectioning root">sectioning roots</a>. These are distinct from <a href=#sectioning-content>sectioning content</a>, but they can also have an <a href=#outline>outline</a>.</p> <h6 id=heading-content-0><span class=secno>3.2.5.1.4 </span>Heading content</h6> <p><dfn id=heading-content>Heading content</dfn> defines the header of a section (whether explicitly marked up using <a href=#sectioning-content>sectioning content</a> elements, or implied by the heading content itself).</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></li> <li><code><a href=#the-hgroup-element>hgroup</a></code></li> </ul><h6 id=phrasing-content-0><span class=secno>3.2.5.1.5 </span>Phrasing content</h6> <p><dfn id=phrasing-content>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>phrasing content</a> form <a href=#paragraph title=paragraph>paragraphs</a>.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li> <li><code><a href=#the-abbr-element>abbr</a></code></li> <li><code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element)</li> <li><code><a href=#the-audio-element>audio</a></code></li> <li><code><a href=#the-b-element>b</a></code></li> <li><code><a href=#the-bdi-element>bdi</a></code></li> <li><code><a href=#the-bdo-element>bdo</a></code></li> <li><code><a href=#the-br-element>br</a></code></li> <li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-canvas-element>canvas</a></code></li> <li><code><a href=#the-cite-element>cite</a></code></li> <li><code><a href=#the-code-element>code</a></code></li> <li><code><a href=#the-command-element>command</a></code></li> <li><code><a href=#the-data-element>data</a></code></li> <li><code><a href=#the-datalist-element>datalist</a></code></li> <li><code><a href=#the-del-element>del</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li> <li><code><a href=#the-dfn-element>dfn</a></code></li> <li><code><a href=#the-em-element>em</a></code></li> <li><code><a href=#the-embed-element>embed</a></code></li> <li><code><a href=#the-i-element>i</a></code></li> <li><code><a href=#the-iframe-element>iframe</a></code></li> <li><code><a href=#the-img-element>img</a></code></li> <li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-ins-element>ins</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li> <li><code><a href=#the-kbd-element>kbd</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-label-element>label</a></code></li> <!--MD--> <li><code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li> <!--MD--> <li><code><a href=#the-map-element>map</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)</li> <li><code><a href=#the-mark-element>mark</a></code></li> <li><code><a href=#math>math</a></code></li> <!--MD--> <li><code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)</li> <!--MD--> <li><code><a href=#the-meter-element>meter</a></code></li> <li><code><a href=#the-noscript-element>noscript</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-progress-element>progress</a></code></li> <li><code><a href=#the-q-element>q</a></code></li> <li><code><a href=#the-ruby-element>ruby</a></code></li> <li><code><a href=#the-s-element>s</a></code></li> <li><code><a href=#the-samp-element>samp</a></code></li> <li><code><a href=#the-script-element>script</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-small-element>small</a></code></li> <li><code><a href=#the-span-element>span</a></code></li> <li><code><a href=#the-strong-element>strong</a></code></li> <li><code><a href=#the-sub-and-sup-elements>sub</a></code></li> <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li> <li><code><a href=#svg>svg</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> <li><code><a href=#the-u-element>u</a></code></li> <li><code><a href=#the-var-element>var</a></code></li> <li><code><a href=#the-video-element>video</a></code></li> <li><code><a href=#the-wbr-element>wbr</a></code></li> <li><a href=#text-content title="text content">Text</a></li> </ul><p>As a general rule, elements whose content model allows any <a href=#phrasing-content>phrasing content</a> should have either at least one descendant <a href=#text-node>text node</a> that is not <a href=#inter-element-whitespace>inter-element whitespace</a>, or at least one descendant element node that is <a href=#embedded-content>embedded content</a>. For the purposes of this requirement, nodes that are descendants of <code><a href=#the-del-element>del</a></code> elements must not be counted as contributing to the ancestors of the <code><a href=#the-del-element>del</a></code> element.</p> <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 title="text content">Text</dfn>, in the context of content models, means <a href=#text-node title="text node">text nodes</a>. <a href=#text-content title="text content">Text</a> is sometimes used as a content model on its own, but is also <a href=#phrasing-content>phrasing content</a>, and can be <a href=#inter-element-whitespace>inter-element whitespace</a> (if the <a href=#text-node title="text node">text nodes</a> are empty or contain just <a href=#space-character title="space character">space characters</a>).</p> <!--<p><span title="text node">Text nodes</span> and attribute values may begin with an <i>isolated combining character</i>. <a href="#refsUNICODE">[UNICODE]</a></p>--> <!-- commented out since nothing disallows it currently, so it's implicit; however, if we ever make charmod a normative reference, this will be needed to override it --> <h6 id=embedded-content-0><span class=secno>3.2.5.1.6 </span>Embedded content</h6> <p><dfn id=embedded-content>Embedded content</dfn> is content that imports another resource into the document, or content from another vocabulary that is inserted into the document.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-audio-element>audio</a></code></li> <li><code><a href=#the-canvas-element>canvas</a></code></li> <li><code><a href=#the-embed-element>embed</a></code></li> <li><code><a href=#the-iframe-element>iframe</a></code></li> <li><code><a href=#the-img-element>img</a></code></li> <li><code><a href=#math>math</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#svg>svg</a></code></li> <li><code><a href=#the-video-element>video</a></code></li> </ul><p>Elements that are from namespaces other than the <a href=#html-namespace-0>HTML namespace</a> and that convey content but not metadata, are <a href=#embedded-content>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> <!-- we might not need to define fallback content at all. consider removing it if we don't end up using it anywhere (e.g. Selection) --> <h6 id=interactive-content-0><span class=secno>3.2.5.1.7 </span>Interactive content</h6> <!-- TESTS: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Cp%20tabindex%3D1%3Etest%20%3Ca%20href%3D%22%22%3E%20%3Cem%3Etest%3C/em%3E%20%3C/a%3E%0A%3Cscript%3E%0A%20function%20test%20%28e%29%20%7B%20w%28e.type%20+%20%27%20on%20%27%20+%20e.target.tagName%20+%20%27%20through%20%27%20+%20e.currentTarget.tagName%29%3B%20%7D%0A%20document.getElementsByTagName%28%27a%27%29%5B0%5D.addEventListener%28%27click%27%2C%20test%2C%20false%29%3B%0A%20document.getElementsByTagName%28%27a%27%29%5B0%5D.addEventListener%28%27DOMActivate%27%2C%20test%2C%20false%29%3B%0A%20document.getElementsByTagName%28%27p%27%29%5B0%5D.addEventListener%28%27click%27%2C%20test%2C%20false%29%3B%0A%20document.getElementsByTagName%28%27p%27%29%5B0%5D.addEventListener%28%27DOMActivate%27%2C%20test%2C%20false%29%3B%0A%3C/script%3E%0A http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0A%3Ca%20href%3Dhttp%3A//google.com/%20target%3Da%3EA%3C/a%3E%3Ca%20href%3Dhttp%3A//yahoo.com/%20target%3Db%3EB%3C/a%3E%3Cbr%3E%0A%3Ciframe%20name%3Da%3E%3C/iframe%3E%3Ciframe%20name%3Db%3E%3C/iframe%3E%0A%3Cscript%3E%0A%20var%20a%20%3D%20document.getElementsByTagName%28%27a%27%29%5B0%5D%3B%0A%20var%20b%20%3D%20document.getElementsByTagName%28%27a%27%29%5B1%5D%3B%0A%20a.appendChild%28b%29%3B%0A%3C/script%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0A%3Cform%20action%3D%22http%3A//google.com/%22%20onsubmit%3D%22w%28%27onsubmit%27%29%22%3E%3Cem%3EA%3C/em%3E%3C/form%3E%0A%3Cscript%3E%0Adocument.getElementsByTagName%28%27form%27%29%5B0%5D.attachEvent%28%27onsubmit%27%2C%20function%20%28%29%20%7B%20w%28%27submit%20fired%27%29%20%7D%29%3B%0Adocument.getElementsByTagName%28%27form%27%29%5B0%5D.fireEvent%28%27onsubmit%27%29%3B%0A%3C/script%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0A%3Cform%20action%3D%22http%3A//google.com/%22%3EX%3C/form%3E%0A%3Cscript%3E%0Avar%20evt%20%3D%20document.createEvent%28%22Events%22%29%3B%0Aevt.initEvent%28%22submit%22%2C%20true%2C%20true%29%3B%0Adocument.getElementsByTagName%28%27form%27%29%5B0%5D.dispatchEvent%28evt%29%3B%0A%3C/script%3E --> <p><dfn id=interactive-content>Interactive content</dfn> is content that is specifically intended for user interaction.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code></li> <li><code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li> <li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-details-element>details</a></code></li> <li><code><a href=#the-embed-element>embed</a></code></li> <li><code><a href=#the-iframe-element>iframe</a></code></li> <li><code><a href=#the-img-element>img</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)</li> <li><code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state)</li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-label-element>label</a></code></li> <li><code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state)</li> <li><code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section --></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> <li><code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li> </ul><p>Certain elements in HTML have an <a href=#activation-behavior>activation behavior</a>, which means that the user can activate them. This triggers a sequence of events dependent on the activation mechanism, and normally culminating in a <code title=event-click><a href=#event-click>click</a></code> event<span class=impl>, as described below</span>.</p> <div class=impl> <p>The user agent should allow the user to manually trigger elements that have an <a href=#activation-behavior>activation behavior</a>, for instance using keyboard or voice input, or through mouse clicks. When the user triggers an element with a defined <a href=#activation-behavior>activation behavior</a> in a manner other than clicking it, the default action of the interaction event must be to <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the element.</p> <!-- interaction event spec point --> <p>Each element has a <var title="">click in progress</var> flag, initially set to false.</p> <p>When a user agent is to <dfn id=run-synthetic-click-activation-steps>run synthetic click activation steps</dfn> on an element, the user agent must run the following steps:</p> <ol><li><p>If the element's <var title="">click in progress</var> flag is set to true, then abort these steps.</li> <li><p>Set the <var title="">click in progress</var> flag on the element to true.</li> <li><p><a href=#run-pre-click-activation-steps>Run pre-click activation steps</a> on the element.</li> <li><p><a href=#fire-a-click-event>Fire a <code title=event-click>click</code> event</a> at the element.</li> <li> <p>If this <code title=event-click><a href=#event-click>click</a></code> event is not canceled, <a href=#run-post-click-activation-steps>run post-click activation steps</a> on the element.</p> <p>If the event <em>is</em> canceled, the user agent must <a href=#run-canceled-activation-steps>run canceled activation steps</a> on the element instead.</p> </li> <li><p>Set the <var title="">click in progress</var> flag on the element to false.</li> </ol><p>When a pointing device is clicked, the user agent must run these steps:</p> <ol><li><p>If the element's <var title="">click in progress</var> flag is set to true, then abort these steps.</li> <li><p>Set the <var title="">click in progress</var> flag on the element to true.</li> <li><p>Let <var title="">e</var> be the <a href=#nearest-activatable-element>nearest activatable element</a> of the element designated by the user (defined below), if any.</li> <li><p>If there is an element <var title="">e</var>, <a href=#run-pre-click-activation-steps>run pre-click activation steps</a> on it.</li> <li> <p>Dispatch the required <code title=event-click><a href=#event-click>click</a></code> event.</p> <!-- interaction event spec point --> <p>If there is an element <var title="">e</var> and the <code title=event-click><a href=#event-click>click</a></code> event is not canceled, <a href=#run-post-click-activation-steps>run post-click activation steps</a> on element <var title="">e</var>.</p> <p>If there is an element <var title="">e</var> and the event <em>is</em> canceled, <a href=#run-canceled-activation-steps>run canceled activation steps</a> on element <var title="">e</var>.</p> </li> <li><p>Set the <var title="">click in progress</var> flag on the element to false.</li> </ol><p class=note>The above doesn't happen for arbitrary synthetic events dispatched by author script. However, the <code title=dom-click><a href=#dom-click>click()</a></code> method can be used to make it happen programmatically.</p> <p class=note>Click-focusing behavior (e.g. the focusing of a text field when user clicks in one) typically happens before the click, when the mouse button is first depressed, and is therefore not discussed here.</p> <!-- interaction event spec point --> <p>Given an element <var title="">target</var>, the <dfn id=nearest-activatable-element>nearest activatable element</dfn> is the element returned by the following algorithm:</p> <ol><li><p>If <var title="">target</var> has a defined <a href=#activation-behavior>activation behavior</a>, then return <var title="">target</var> and abort these steps.</li> <li><p>If <var title="">target</var> has a parent element, then set <var title="">target</var> to that parent element and return to the first step.</li> <li><p>Otherwise, there is no <a href=#nearest-activatable-element>nearest activatable element</a>.</li> </ol><p>When a user agent is to <dfn id=run-pre-click-activation-steps>run pre-click activation steps</dfn> on an element, it must run the <dfn id=pre-click-activation-steps>pre-click activation steps</dfn> defined for that element, if any.</p> <p>When a user agent is to <dfn id=run-canceled-activation-steps>run canceled activation steps</dfn> on an element, it must run the <dfn id=canceled-activation-steps>canceled activation steps</dfn> defined for that element, if any.</p> <p>When a user agent is to <dfn id=run-post-click-activation-steps>run post-click activation steps</dfn> on an element, it must run the <dfn id=activation-behavior>activation behavior</dfn> defined for that element, if any. Activation behaviors can refer to the <code title=event-click><a href=#event-click>click</a></code> event that was fired by the steps above leading up to this point.</p> </div> <h6 id=palpable-content-0><span class=secno>3.2.5.1.8 </span>Palpable content</h6> <p>As a general rule, elements whose content model allows any <a href=#flow-content>flow content</a> or <a href=#phrasing-content>phrasing content</a> should have at least one child node that is <dfn id=palpable-content>palpable content</dfn> and that does not have the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute specified.</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> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-a-element>a</a></code></li> <li><code><a href=#the-abbr-element>abbr</a></code></li> <li><code><a href=#the-address-element>address</a></code></li> <li><code><a href=#the-article-element>article</a></code></li> <li><code><a href=#the-aside-element>aside</a></code></li> <li><code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present)</li> <li><code><a href=#the-b-element>b</a></code></li> <li><code><a href=#the-bdi-element>bdi</a></code></li> <li><code><a href=#the-bdo-element>bdo</a></code></li> <li><code><a href=#the-blockquote-element>blockquote</a></code></li> <li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-canvas-element>canvas</a></code></li> <li><code><a href=#the-cite-element>cite</a></code></li> <li><code><a href=#the-code-element>code</a></code></li> <li><code><a href=#the-data-element>data</a></code></li> <li><code><a href=#the-details-element>details</a></code></li> <li><code><a href=#the-dfn-element>dfn</a></code></li> <li><code><a href=#the-div-element>div</a></code></li> <li><code><a href=#the-dl-element>dl</a></code> (if the element's children include at least one name-value group)</li> <li><code><a href=#the-em-element>em</a></code></li> <li><code><a href=#the-embed-element>embed</a></code></li> <li><code><a href=#the-fieldset-element>fieldset</a></code></li> <li><code><a href=#the-figure-element>figure</a></code></li> <li><code><a href=#the-footer-element>footer</a></code></li> <li><code><a href=#the-form-element>form</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code></li> <li><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></li> <li><code><a href=#the-header-element>header</a></code></li> <li><code><a href=#the-hgroup-element>hgroup</a></code></li> <li><code><a href=#the-i-element>i</a></code></li> <li><code><a href=#the-iframe-element>iframe</a></code></li> <li><code><a href=#the-img-element>img</a></code></li> <li><code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state)</li> <li><code><a href=#the-ins-element>ins</a></code></li> <li><code><a href=#the-kbd-element>kbd</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-label-element>label</a></code></li> <li><code><a href=#the-map-element>map</a></code></li> <li><code><a href=#the-mark-element>mark</a></code></li> <li><code><a href=#math>math</a></code></li> <li><code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state or the <a href=#list-state title="list state">list</a> state)</li> <li><code><a href=#the-meter-element>meter</a></code></li> <li><code><a href=#the-nav-element>nav</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-ol-element>ol</a></code> (if the element's children include at least one <code><a href=#the-li-element>li</a></code> element)</li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-p-element>p</a></code></li> <li><code><a href=#the-pre-element>pre</a></code></li> <li><code><a href=#the-progress-element>progress</a></code></li> <li><code><a href=#the-q-element>q</a></code></li> <li><code><a href=#the-ruby-element>ruby</a></code></li> <li><code><a href=#the-s-element>s</a></code></li> <li><code><a href=#the-samp-element>samp</a></code></li> <li><code><a href=#the-section-element>section</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-small-element>small</a></code></li> <li><code><a href=#the-span-element>span</a></code></li> <li><code><a href=#the-strong-element>strong</a></code></li> <li><code><a href=#the-sub-and-sup-elements>sub</a></code></li> <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li> <li><code><a href=#svg>svg</a></code></li> <li><code><a href=#the-table-element>table</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> <li><code><a href=#the-u-element>u</a></code></li> <li><code><a href=#the-ul-element>ul</a></code> (if the element's children include at least one <code><a href=#the-li-element>li</a></code> element)</li> <li><code><a href=#the-var-element>var</a></code></li> <li><code><a href=#the-video-element>video</a></code></li> <li><a href=#text-content title="text content">Text</a> that is not <a href=#inter-element-whitespace>inter-element whitespace</a></li> </ul><h5 id=transparent-content-models><span class=secno>3.2.5.2 </span>Transparent content models</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>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><a href=#the-ins-element>ins</a></code> element inside a <code><a href=#the-ruby-element>ruby</a></code> element cannot contain an <code><a href=#the-rt-element>rt</a></code> element, because the part of the <code><a href=#the-ruby-element>ruby</a></code> element's content model that allows <code><a href=#the-ins-element>ins</a></code> elements is the part that allows <a href=#phrasing-content>phrasing content</a>, and the <code><a href=#the-rt-element>rt</a></code> element is not <a href=#phrasing-content>phrasing content</a>.</p> </div> <!--(as far as I can tell, there's no way to violate this requirement without first violating the earlier requirement) <p>Furthermore, when a content model includes a part that is "transparent", those parts must not contain content that would not be conformant if all transparent elements in the tree were replaced, in their parent element, by the children in the "transparent" part of their content model, retaining order.</p> <div class="example"> <p>Consider the following markup fragment:</p> <pre><p>Hello <a href="world.html"><em>wonderful</em> world</a>!</p></pre> <p>Its DOM looks like the following:</p> <ul class="domTree"><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">Hello </span></li><li class="t1"><code>a</code> <span class="t2" title=""><code class="attribute name">href</code>="<code class="attribute value">world.html</code>"</span><ul><li class="t1"><code>em</code><ul><li class="t3"><code>#text</code>: <span title="">wonderful</span></li></ul></li><li class="t3"><code>#text</code>: <span title=""> world</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">!</span></li></ul></li></ul> <p>The content model of the <code>a</code> element is <span>transparent</span>. To see if its contents are conforming, therefore, the element is replaced by its contents:</p> <ul class="domTree"><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">Hello </span></li><li class="t1"><code>em</code><ul><li class="t3"><code>#text</code>: <span title="">wonderful</span></li></ul></li><li class="t3"><code>#text</code>: <span title=""> world</span></li><li class="t3"><code>#text</code>: <span title="">!</span></li></ul></li></ul> <p>Since that is conforming, the contents of the <code>a</code> are conforming in the original fragment (there is no complication regarding the various parts of the <code>p</code> element's content model, since that element's content model has only one part).</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><p><object><param><ins><map><a href="/">Apples</a></map></ins></object></p></pre> <p>To check whether "Apples" is allowed inside the <code><a href=#the-a-element>a</a></code> element, the content models are examined. The <code><a href=#the-a-element>a</a></code> element's content model is transparent, as is the <code><a href=#the-map-element>map</a></code> element's, as is the <code><a href=#the-ins-element>ins</a></code> element's, as is the part of the <code><a href=#the-object-element>object</a></code> element's in which the <code><a href=#the-ins-element>ins</a></code> element is found. The <code><a href=#the-object-element>object</a></code> element is found in the <code><a href=#the-p-element>p</a></code> element, whose content model is <a href=#phrasing-content>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>flow content</a>.</p> <h5 id=paragraphs><span class=secno>3.2.5.3 </span>Paragraphs</h5> <p class=note>The term <a href=#paragraph>paragraph</a> as defined in this section is distinct from (though related to) the <code><a href=#the-p-element>p</a></code> element defined later. The <a href=#paragraph>paragraph</a> concept defined here is used to describe how to interpret documents.</p> <p>A <dfn id=paragraph>paragraph</dfn> is typically a run of <a href=#phrasing-content>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>inter-element whitespace</a> do not form paragraphs.</p> <pre><section> <h1>Example of paragraphs</h1> This is the <em>first</em> paragraph in this example. <p>This is the second.</p> <!-- This is not a paragraph. --> </section></pre> </div> <p>Paragraphs in <a href=#flow-content>flow content</a> are defined relative to what the document looks like without the <code><a href=#the-a-element>a</a></code>, <code><a href=#the-ins-element>ins</a></code>, <code><a href=#the-del-element>del</a></code>, and <code><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><a href=#the-ins-element>ins</a></code> and <code><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><a href=#the-ins-element>ins</a></code> and <code><a href=#the-del-element>del</a></code> elements — the <code><a href=#the-ins-element>ins</a></code> element straddles the heading and the first paragraph, and the <code><a href=#the-del-element>del</a></code> element straddles the boundary between the two paragraphs.</p> <pre><section> <ins><h1>Example of paragraphs</h1> This is the <em>first</em> paragraph in</ins> this example<del>. <p>This is the second.</p></del> <!-- This is not a paragraph. --> </section></pre> </div> <div class=impl> <p>Let <var title="">view</var> be a view of the DOM that replaces all <code><a href=#the-a-element>a</a></code>, <code><a href=#the-ins-element>ins</a></code>, <code><a href=#the-del-element>del</a></code>, and <code><a href=#the-map-element>map</a></code> elements in the document with their contents. Then, in <var title="">view</var>, for each run of sibling <a href=#phrasing-content>phrasing content</a> nodes uninterrupted by other types of content, in an element that accepts content other than <a href=#phrasing-content>phrasing content</a> as well as <a href=#phrasing-content>phrasing content</a>, let <var title="">first</var> be the first node of the run, and let <var title="">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>embedded content</a> nor <a href=#inter-element-whitespace>inter-element whitespace</a>, a paragraph exists in the original DOM from immediately before <var title="">first</var> to immediately after <var title="">last</var>. (Paragraphs can thus span across <code><a href=#the-a-element>a</a></code>, <code><a href=#the-ins-element>ins</a></code>, <code><a href=#the-del-element>del</a></code>, and <code><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><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, <code><a href=#the-audio-element>audio</a></code>, and <code><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 <code><a href=#svg>svg</a></code> or <code><a href=#math>math</a></code>).</p> <!-- example below --> </div> <p>A <a href=#paragraph>paragraph</a> is also formed explicitly by <code><a href=#the-p-element>p</a></code> elements.</p> <p class=note>The <code><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><aside> Welcome! <a href="about.html"> This is home of... <h1>The Falcons!</h1> The Lockheed Martin multirole jet fighter aircraft! </a> This page discusses the F-16 Fighting Falcon's innermost secrets. </aside></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><aside> <p>Welcome! <a href="about.html">This is home of...</a></p> <h1><a href="about.html">The Falcons!</a></h1> <p><a href="about.html">The Lockheed Martin multirole jet fighter aircraft!</a> This page discusses the F-16 Fighting Falcon's innermost secrets.</p> </aside></pre> </div> <div class=example> <!-- I don't know if there's a better way to deal with this, but if there is, let me know... --> <p>It is possible for paragraphs to overlap when using certain elements that define fallback content. For example, in the following section:</p> <pre><section> <h1>My Cats</h1> You can play with my cat simulator. <object data="cats.sim"> To see the cat simulator, use one of the following links: <ul> <li><a href="cats.sim">Download simulator file</a> <li><a href="http://sims.example.com/watch?v=LYds5xY4INU">Use online simulator</a> </ul> Alternatively, upgrade to the Mellblom Browser. </object> I'm quite proud of it. </section></pre> <p>There are five paragraphs:</p> <ol class=brief><li>The paragraph that says "You can play with my cat simulator. <i title="">object</i> I'm quite proud of it.", where <i title="">object</i> is the <code><a href=#the-object-element>object</a></code> element.</li> <li>The paragraph that says "To see the cat simulator, use one of the following links:".</li> <li>The paragraph that says "Download simulator file".</li> <li>The paragraph that says "Use online simulator".</li> <li>The paragraph that says "Alternatively, upgrade to the Mellblom Browser.".</li> </ol><p>The first paragraph is overlapped by the other four. A user agent that supports the "cats.sim" resource will only show the first one, but a user agent that shows the fallback will confusingly show the first sentence of the first paragraph as if it was in the same paragraph as the second one, and will show the last paragraph as if it was at the start of the second sentence of the first paragraph.</p> <p>To avoid this confusion, explicit <code><a href=#the-p-element>p</a></code> elements can be used.</p> </div> <h4 id=requirements-relating-to-bidirectional-algorithm-formatting-characters><span class=secno>3.2.6 </span>Requirements relating to bidirectional-algorithm formatting characters</h4> <p><a href=#text-content>Text content</a> in <a href=#html-elements>HTML elements</a> with child <a href=#text-node title="text node">text nodes</a>, and text in attributes of <a href=#html-elements>HTML elements</a> that allow free-form text, may contain characters in the range U+202A to U+202E (the bidirectional-algorithm formatting characters). However, the use of these characters is restricted so that any embedding or overrides generated by these characters do not start and end with different parent elements, and so that all such embeddings and overrides are explicitly terminated by a U+202C POP DIRECTIONAL FORMATTING character. This helps reduce incidences of text being reused in a manner that has unforeseen effects on the bidirectional algorithm.</p> <p>The aforementioned restrictions are defined by specifying that certain parts of documents form <a href=#bidirectional-algorithm-formatting-character-ranges>bidirectional-algorithm formatting character ranges</a>, and then imposing a requirement on such ranges.</p> <p>The strings resulting from applying the following algorithm to an <a href=#html-elements title="HTML elements">HTML element</a> <var title="">element</var> are <a href=#bidirectional-algorithm-formatting-character-ranges>bidirectional-algorithm formatting character ranges</a>:</p> <ol><li><p>Let <var title="">output</var> be an empty list of strings.</li> <li><p>Let <var title="">string</var> be an empty string.</li> <li><p>Let <var title="">node</var> be the first child node of <var title="">element</var>, if any, or null otherwise.</li> <!-- while node != null do --> <li><p><i>Loop</i>: If <var title="">node</var> is null, jump to the step labeled <i>end</i>.</li> <li> <p>Process <var title="">node</var> according to the first matching step from the following list:</p> <dl class=switch><dt>If <var title="">node</var> is a <a href=#text-node>text node</a></dt> <dd><p>Append the text data of <var title="">node</var> to <var title="">string</var>.</dd> <dt>If <var title="">node</var> is a <code><a href=#the-br-element>br</a></code> element</dt> <dt>If <var title="">node</var> is an <a href=#html-elements title="HTML elements">HTML element</a> that is <a href=#flow-content>flow content</a> but that is not also <a href=#phrasing-content>phrasing content</a></dt> <dd><p>If <var title="">string</var> is not the empty string, push <var title="">string</var> onto <var title="">output</var>, and let <var title="">string</var> be empty string.</dd> <dt>Otherwise</dt> <dd>Do nothing.</dd> </dl></li> <li><p>Let <var title="">node</var> be <var title="">node</var>'s next sibling, if any, or null otherwise.</li> <li><p>Jump to the step labeled <i>loop</i>.</li> <!-- end while --> <li><p><i>End</i>: If <var title="">string</var> is not the empty string, push <var title="">string</var> onto <var title="">output</var>.</li> <li><p>Return <var title="">output</var> as the <a href=#bidirectional-algorithm-formatting-character-ranges>bidirectional-algorithm formatting character ranges</a>.</li> </ol><p>The value of a namespace-less attribute of an <a href=#html-elements title="HTML elements">HTML element</a> is a <a href=#bidirectional-algorithm-formatting-character-ranges title="bidirectional-algorithm formatting character ranges">bidirectional-algorithm formatting character range</a>.</p> <!--(this is unnecessarily pedantic) <p>The text data of a comment node is a <span title="bidirectional-algorithm formatting character ranges">bidirectional-algorithm formatting character range</span>.</p> --> <p>Any strings that, as described above, are <dfn id=bidirectional-algorithm-formatting-character-ranges>bidirectional-algorithm formatting character ranges</dfn> must match the <code title="">string</code> production in the following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p> <pre>string = *( plaintext ( embedding / override ) ) plaintext embedding = ( lre / rle ) string pdf override = ( lro / rlo ) string pdf lre = %x202A ; U+202A LEFT-TO-RIGHT EMBEDDING rle = %x202B ; U+202B RIGHT-TO-LEFT EMBEDDING lro = %x202D ; U+202D LEFT-TO-RIGHT OVERRIDE rlo = %x202E ; U+202E RIGHT-TO-LEFT OVERRIDE pdf = %x202C ; U+202C POP DIRECTIONAL FORMATTING plaintext = *( %x0000-2029 / %x202F-10FFFF ) ; any string with no bidirectional-algorithm formatting characters</pre> <p class=note>Authors are encouraged to use the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute, the <code><a href=#the-bdo-element>bdo</a></code> element, and the <code><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> <h4 id=wai-aria><span class=secno>3.2.7 </span><dfn>WAI-ARIA</dfn></h4> <p>Authors may use the ARIA <code title=attr-aria-role>role</code> and <code title=attr-aria-*>aria-*</code> attributes on <a href=#html-elements>HTML elements</a>, in accordance with the requirements described in the ARIA specifications, except where these conflict with the <span>strong native semantics</span> <!--FORK--><!--bug 11557--> or are equal to the <span>default implied ARIA semantics</span> <!--FORK--><!--bug 11557--> described below. These exceptions are intended to prevent authors from making assistive technology products report nonsensical states that do not represent the actual state of the document. <a href=#refsARIA>[ARIA]</a></p> <!--FORK--><!--bug 11557--> <p>Authors must not set the ARIA <code title=attr-aria-role>role</code> and <code title=attr-aria-*>aria-*</code> attributes in a manner that conflicts with the semantics described in the following table, except that the <code title=attr-aria-role-presentation>presentation</code> role may always be used. Authors must not set the ARIA <code title=attr-aria-role>role</code> and <code title=attr-aria-*>aria-*</code> attributes to values that match the <span>default implicit ARIA semantics</span> defined in the following two tables.</p> <!--FORK--><!--bug 11557--> <div class=impl> <p>User agents are required to implement ARIA semantics on all <a href=#html-elements>HTML elements</a>, as defined in the ARIA specifications. The <span>implicit ARIA semantics</span> defined below must be recognized by implementations for the purposes of ARIA processing. <a href=#refsARIAIMPL>[ARIAIMPL]</a></p> <p class=note>The ARIA attributes defined in the ARIA specifications, and the <span>strong native semantics</span> and <span>default implicit ARIA semantics</span> defined below, do not have any effect on CSS pseudo-class matching, user interface modalities that don't use assistive technologies, or the default actions of user interaction events as described in this specification.</p> <!-- this is a truism, in that there are no requirements that require that those attributes have such an effect, and no requirements that relax the requirements on those effects such that they could be affected by those attributes --> </div> <p>The following table defines the <span>strong native semantics</span> and corresponding <span>default implicit ARIA semantics</span> that apply to <a href=#html-elements>HTML elements</a>. Each language feature (element or attribute) in a cell in the first column implies the ARIA semantics (role, states, and/or properties) given in the cell in the second column of the same row. <span class=impl>When multiple rows apply to an element, the role from the last row to define a role must be applied, and the states and properties from all the rows must be combined.</span></p> <table id=table-aria-strong><thead><tr><th>Language feature <th><span>Strong native semantics</span> and <span>default implied ARIA semantics</span> <tbody><tr><td><code><a href=#the-area-element>area</a></code> element that creates a <a href=#hyperlink>hyperlink</a> <td><code title=attr-aria-role-link>link</code> role <tr><td><code><a href=#the-base-element>base</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-datalist-element>datalist</a></code> element <td><code title=attr-aria-role-listbox>listbox</code> role, with the <code title=attr-aria-multiselectable>aria-multiselectable</code> property set to "false" <tr><td><code><a href=#the-details-element>details</a></code> element <td><code title=attr-aria-expanded>aria-expanded</code> state set to "true" if the element's <code title=attr-details-open><a href=#attr-details-open>open</a></code> attribute is present, and set to "false" otherwise <tr><td><code><a href=#the-head-element>head</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-hgroup-element>hgroup</a></code> element <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <tr><td><code><a href=#the-hr-element>hr</a></code> element <td><code title=attr-aria-role-separator>separator</code> role <tr><td><code><a href=#the-html-element>html</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-img-element>img</a></code> element whose <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value is empty <td><code title=attr-aria-role-presentation>presentation</code> role <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state <td><code title=attr-aria-checked>aria-checked</code> state set to "mixed" if the element's <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute is true, or "true" if the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is true, or "false" otherwise <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#color-state title=attr-input-type-color>Color</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#date-state title=attr-input-type-date>Date</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#local-date-and-time-state title=attr-input-type-datetime-local>Local Date and Time</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#e-mail-state title=attr-input-type-email>E-mail</a> state with no <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#file-upload-state title=attr-input-type-file>File Upload</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#month-state title=attr-input-type-month>Month</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#number-state title=attr-input-type-number>Number</a> state <td><code title=attr-aria-role-spinbutton>spinbutton</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute, the <code title=attr-aria-valuemax>aria-valuemax</code> property set to the element's <a href=#concept-input-max title=concept-input-max>maximum</a>, the <code title=attr-aria-valuemin>aria-valuemin</code> property set to the element's <a href=#concept-input-min title=concept-input-min>minimum</a>, and, if the result of applying the <a href=#rules-for-parsing-floating-point-number-values>rules for parsing floating point number values</a> to the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is a number, with the <code title=attr-aria-valuenow>aria-valuenow</code> property set to that number <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#password-state title=attr-input-type-password>Password</a> state <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state <td><code title=attr-aria-checked>aria-checked</code> state set to "true" if the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is true, or "false" otherwise <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#range-state title=attr-input-type-range>Range</a> state <td><code title=attr-aria-role-slider>slider</code> role, with the <code title=attr-aria-valuemax>aria-valuemax</code> property set to the element's <a href=#concept-input-max title=concept-input-max>maximum</a>, the <code title=attr-aria-valuemin>aria-valuemin</code> property set to the element's <a href=#concept-input-min title=concept-input-min>minimum</a>, and the <code title=attr-aria-valuenow>aria-valuenow</code> property set to the result of applying the <a href=#rules-for-parsing-floating-point-number-values>rules for parsing floating point number values</a> to the element's <a href=#concept-fe-value title=concept-fe-value>value</a>, if that results in a number, or the <a href=#concept-input-value-default-range title=concept-input-value-default-range>default value</a> otherwise <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a> state <td><code title=attr-aria-role-button>button</code> role <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state with no <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a> state <td><code title=attr-aria-role-button>button</code> role <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#telephone-state title=attr-input-type-tel>Telephone</a> state with no <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state with no <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a>, <a href=#text-state-and-search-state title=attr-input-type-search>Search</a>, <a href=#telephone-state title=attr-input-type-tel>Telephone</a>, <a href=#url-state title=attr-input-type-url>URL</a>, or <a href=#e-mail-state title=attr-input-type-email>E-mail</a> states with a <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-combobox>combobox</code> role, with the <code title=attr-aria-owns>aria-owns</code> property set to the same value as the <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute, and the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#time-state title=attr-input-type-time>Time</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#url-state title=attr-input-type-url>URL</a> state with no <a href=#concept-input-list title=concept-input-list>suggestions source element</a> <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#week-state title=attr-input-type-week>Week</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-input-element>input</a></code> element that is <a href=#concept-input-required title=concept-input-required>required</a> <td>The <code title=title-aria-required>aria-required</code> state set to "true" <tr><td><code><a href=#the-keygen-element>keygen</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-label-element>label</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-link-element>link</a></code> element that creates a <a href=#hyperlink>hyperlink</a> <td><code title=attr-aria-role-link>link</code> role <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#context-menu-state title="context menu state">context menu</a> state <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state <td><code title=attr-aria-role-menu>menu</code> role <tr><td><code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state <td><code title=attr-aria-role-toolbar>toolbar</code> role <tr><td><code><a href=#the-meta-element>meta</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-meter-element>meter</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-nav-element>nav</a></code> element <td><code title=attr-aria-role-navigation>navigation</code> role <tr><td><code><a href=#the-noscript-element>noscript</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-optgroup-element>optgroup</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-option-element>option</a></code> element that is in a <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> or that represents a suggestion in a <code><a href=#the-datalist-element>datalist</a></code> element <td><code title=attr-aria-role-option>option</code> role, with the <code title=attr-aria-selected>aria-selected</code> state set to "true" if the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, or "false" otherwise. <tr><td><code><a href=#the-param-element>param</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-progress-element>progress</a></code> element <td><code title=attr-aria-role-progressbar>progressbar</code> role, with, if the progress bar is determinate, the <code title=attr-aria-valuemax>aria-valuemax</code> property set to the maximum value of the progress bar, the <code title=attr-aria-valuemin>aria-valuemin</code> property set to zero, and the <code title=attr-aria-valuenow>aria-valuenow</code> property set to the current value of the progress bar <tr><td><code><a href=#the-script-element>script</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-select-element>select</a></code> element with a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute <td><code title=attr-aria-role-listbox>listbox</code> role, with the <code title=attr-aria-multiselectable>aria-multiselectable</code> property set to "true" <tr><td><code><a href=#the-select-element>select</a></code> element with no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute <td><code title=attr-aria-role-listbox>listbox</code> role, with the <code title=attr-aria-multiselectable>aria-multiselectable</code> property set to "false" <tr><td><code><a href=#the-select-element>select</a></code> element with a <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute <td>The <code title=title-aria-required>aria-required</code> state set to "true" <tr><td><code><a href=#the-source-element>source</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-style-element>style</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-summary-element>summary</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td><code><a href=#the-textarea-element>textarea</a></code> element <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=attr-aria-multiline>aria-multiline</code> property set to "true", and the <code title=title-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute <tr><td><code><a href=#the-textarea-element>textarea</a></code> element with a <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute <td>The <code title=title-aria-required>aria-required</code> state set to "true" <tr><td><code><a href=#the-title-element>title</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "checkbox", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state <td><code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "command", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state <td><code title=attr-aria-role-menuitem>menuitem</code> role <tr><td>An element that <a href=#concept-command title=concept-command>defines a command</a>, whose <a href=#command-facet-type title=command-facet-type>Type</a> facet is "radio", and that is a descendant of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#list-state title="list state">list</a> state <td><code title=attr-aria-role-menuitemradio>menuitemradio</code> role, with the <code title=attr-aria-checked>aria-checked</code> state set to "true" if the command's <a href=#command-facet-checkedstate title=command-facet-checkedstate>Checked State</a> facet is true, and "false" otherwise <tr><td>Element that is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a> <td>The <code title=title-aria-disabled>aria-disabled</code> state set to "true" <tr><td>Element with a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute <td>The <code title=title-aria-hidden>aria-hidden</code> state set to "true" <tr><td>Element that is a <a href=#candidate-for-constraint-validation>candidate for constraint validation</a> but that does not <a href=#concept-fv-valid title=concept-fv-valid>satisfy its constraints</a> <td>The <code title=title-aria-invalid>aria-invalid</code> state set to "true" </table><p>Some <a href=#html-elements>HTML elements</a> have native semantics that can be overridden. The following table lists these elements and their <span>default implicit ARIA semantics</span>, along with the restrictions that apply to those elements. Each language feature (element or attribute) in a cell in the first column implies, unless otherwise overridden, the ARIA semantic (role, state, or property) given in the cell in the second column of the same row, but this semantic may be overridden under the conditions listed in the cell in the third column of that row. In addition, any element may be given the <code title=attr-aria-role-presentation>presentation</code> role, regardless of the restrictions below.</p> <table id=table-aria-weak><thead><tr><th>Language feature <th>Default implied ARIA semantic <th>Restrictions <tbody><tr><td><code><a href=#the-a-element>a</a></code> element that creates a <a href=#hyperlink>hyperlink</a> <td><code title=attr-aria-role-link>link</code> role <td>Role must be either <code title=attr-aria-role-link>link</code>, <code title=attr-aria-role-button>button</code><!--!-->, <code title=attr-aria-role-checkbox>checkbox</code><!--!-->, <code title=attr-aria-role-menuitem>menuitem</code>, <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code><!--!-->, <code title=attr-aria-role-menuitemradio>menuitemradio</code><!--!-->, <code title=attr-aria-role-tab>tab</code>, or <code title=attr-aria-role-treeitem>treeitem</code><!--!--> <tr><td><code><a href=#the-address-element>address</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be <code title=attr-aria-role-contentinfo>contentinfo</code> <tr><td><code><a href=#the-article-element>article</a></code> element <td><code title=attr-aria-role-article>article</code> role <td>Role must be either <code title=attr-aria-role-article>article</code>, <code title=attr-aria-role-document>document</code>, <code title=attr-aria-role-application>application</code>, or <code title=attr-aria-role-main>main</code> <tr><td><code><a href=#the-aside-element>aside</a></code> element <td><code title=attr-aria-role-note>note</code> role <td>Role must be either <code title=attr-aria-role-note>note</code>, <code title=attr-aria-role-complementary>complementary</code>, or <code title=attr-aria-role-search>search</code> <tr><td><code><a href=#the-audio-element>audio</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be <code title=attr-aria-role-application>application</code> <tr><td><code><a href=#the-button-element>button</a></code> element <td><code title=attr-aria-role-button>button</code> role <td>Role must be either <code title=attr-aria-role-button>button</code>, <code title=attr-aria-role-link>link</code><!--!-->, <code title=attr-aria-role-menuitem>menuitem</code>, <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code><!--!-->, <code title=attr-aria-role-menuitemradio>menuitemradio</code><!--!-->, <code title=attr-aria-role-radio>radio</code><!--!--> <tr><td><code><a href=#the-details-element>details</a></code> element <td><code title=attr-aria-role-group>group</code> role <td>Role must be a role that supports <code title=attr-aria-expanded>aria-expanded</code> <tr><td><code><a href=#the-embed-element>embed</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be either <code title=attr-aria-role-application>application</code>, <code title=attr-aria-role-document>document</code>, or <code title=attr-aria-role-img>img</code> <tr><td><code><a href=#the-footer-element>footer</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be <code title=attr-aria-role-contentinfo>contentinfo</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> element that does not have an <code><a href=#the-hgroup-element>hgroup</a></code> ancestor <td><code title=attr-aria-role-heading>heading</code> role, with the <code title=attr-aria-level>aria-level</code> property set to the element's <a href=#outline-depth>outline depth</a> <td>Role must be either <code title=attr-aria-role-heading>heading</code> or <code title=attr-aria-role-tab>tab</code> <tr><td><code><a href=#the-header-element>header</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be <code title=attr-aria-role-banner>banner</code> <tr><td><code><a href=#the-iframe-element>iframe</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be either <code title=attr-aria-role-application>application</code>, <code title=attr-aria-role-document>document</code>, or <code title=attr-aria-role-img>img</code> <tr><td><code><a href=#the-img-element>img</a></code> element whose <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value is absent <td><code title=attr-aria-role-img>img</code> role <td>No restrictions <tr><!--!--><!--(there's no reason to convey <img> elements with alt="" text as images to an AT)--><td><code><a href=#the-img-element>img</a></code> element whose <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value is present and not empty <td><code title=attr-aria-role-img>img</code> role <td>No restrictions <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#button-state title=attr-input-type-button>Button</a> state <td><code title=attr-aria-role-button>button</code> role <td>Role must be either <code title=attr-aria-role-button>button</code>, <code title=attr-aria-role-link>link</code><!--!-->, <code title=attr-aria-role-menuitem>menuitem</code>, <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code><!--!-->, <code title=attr-aria-role-menuitemradio>menuitemradio</code><!--!-->, <code title=attr-aria-role-radio>radio</code><!--!--> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state <td><code title=attr-aria-role-checkbox>checkbox</code> role <td>Role must be either <code title=attr-aria-role-checkbox>checkbox</code> or <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state <td><code title=attr-aria-role-button>button</code> role <td>Role must be either <code title=attr-aria-role-button>button</code>, <code title=attr-aria-role-link>link</code><!--!-->, <code title=attr-aria-role-menuitem>menuitem</code>, <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code><!--!-->, <code title=attr-aria-role-menuitemradio>menuitemradio</code><!--!-->, <code title=attr-aria-role-radio>radio</code><!--!--> <tr><td><code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state <td><code title=attr-aria-role-radio>radio</code> role <td>Role must be either <code title=attr-aria-role-radio>radio</code> or <code title=attr-aria-role-menuitemradio>menuitemradio</code> <tr><td><code><a href=#the-li-element>li</a></code> element whose parent is an <code><a href=#the-ol-element>ol</a></code> or <code><a href=#the-ul-element>ul</a></code> element <td><code title=attr-aria-role-listitem>listitem</code> role <td>Role must be either <code title=attr-aria-role-listitem>listitem</code>, <code title=attr-aria-role-menuitemcheckbox>menuitemcheckbox</code>, <code title=attr-aria-role-menuitemradio>menuitemradio</code>, <code title=attr-aria-role-option>option</code>, <code title=attr-aria-role-tab>tab</code>, or <code title=attr-aria-role-treeitem>treeitem</code> <tr><td><code><a href=#the-object-element>object</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be either <code title=attr-aria-role-application>application</code>, <code title=attr-aria-role-document>document</code>, or <code title=attr-aria-role-img>img</code> <tr><td><code><a href=#the-ol-element>ol</a></code> element <td><code title=attr-aria-role-list>list</code> role <td>Role must be either <code title=attr-aria-role-directory>directory</code>, <code title=attr-aria-role-list>list</code>, <code title=attr-aria-role-listbox>listbox</code>, <code title=attr-aria-role-menu>menu</code>, <code title=attr-aria-role-menubar>menubar</code>, <code title=attr-aria-role-tablist>tablist</code>, <code title="attr-aria-role-toolbar ">toolbar</code>, <code title=attr-aria-role-tree>tree</code> <tr><td><code><a href=#the-output-element>output</a></code> element <td><code title=attr-aria-role-status>status</code> role <td>No restrictions <tr><td><code><a href=#the-section-element>section</a></code> element <td><code title=attr-aria-role-region>region</code> role <td>Role must be either <code title=attr-aria-role-alert>alert</code>, <code title=attr-aria-role-alertdialog>alertdialog</code>, <code title=attr-aria-role-application>application</code>, <code title=attr-aria-role-contentinfo>contentinfo</code>, <code title=attr-aria-role-dialog>dialog</code>, <code title=attr-aria-role-document>document</code>, <code title=attr-aria-role-log>log</code>, <code title=attr-aria-role-main>main</code>, <code title=attr-aria-role-marquee>marquee</code>, <code title=attr-aria-role-region>region</code>, <code title=attr-aria-role-search>search</code>, or <code title=attr-aria-role-status>status</code> <tr><td><code><a href=#the-ul-element>ul</a></code> element <td><code title=attr-aria-role-list>list</code> role <td>Role must be either <code title=attr-aria-role-directory>directory</code>, <code title=attr-aria-role-list>list</code>, <code title=attr-aria-role-listbox>listbox</code>, <code title=attr-aria-role-menu>menu</code>, <code title=attr-aria-role-menubar>menubar</code>, <code title=attr-aria-role-tablist>tablist</code>, <code title="attr-aria-role-toolbar ">toolbar</code>, <code title=attr-aria-role-tree>tree</code> <tr><td><code><a href=#the-video-element>video</a></code> element <td><a href=#concept-role-none title=concept-role-none>No role</a> <td>If specified, role must be <code title=attr-aria-role-application>application</code> <tr><td><a href=#the-body-element-0>The body element</a> <td><code title=attr-aria-role-document>document</code> role <td>Role must be either <code title=attr-aria-role-document>document</code> or <code title=attr-aria-role-application>application</code> </table><p>The entry "<dfn id=concept-role-none title=concept-role-none>no role</dfn>", when used as a <span title="strong native semantics">strong native semantic</span>, means that no role other than <code title=attr-aria-role-presentation>presentation</code> can be used. When used as a <span title="default implied ARIA semantics">default implied ARIA semantic</span>, it means the user agent has no default mapping to ARIA roles. (However, it probably will have its own mappings to the accessibility layer.)</p> <div class=impl> <p>Conformance checkers are encouraged to phrase errors such that authors are encouraged to use more appropriate elements rather than remove accessibility annotations. For example, if an <code><a href=#the-a-element>a</a></code> element is marked as having the <code title=attr-aria-role-button>button</code> role, a conformance checker could say "Use a more appropriate element to represent a button, for example a <code><a href=#the-button-element>button</a></code> element or an <code><a href=#the-input-element>input</a></code> element" rather than "The <code title=attr-aria-role-button>button</code> role cannot be used with <code><a href=#the-a-element>a</a></code> elements".</p> </div> <div class=example> <p>These features can be used to make accessibility tools render content to their users in more useful ways. For example, ASCII art, which is really an image, appears to be text, and in the absence of appropriate annotations would end up being rendered by screen readers as a very painful reading of lots of punctuation. Using the features described in this section, one can instead make the ATs skip the ASCII art and just read the caption:</p> <pre><figure <strong>role="img" aria-labelledby="fish-caption"</strong>> <!-- that's "labelled" with TWO "l"s --> <pre> o .'`/ ' / ( O .-'` ` `'-._ .') _/ (o) '. .' / ) ))) >< < `\ |_\ _.' '. \ '-._ _ .-' '.) jgs `\__\ </pre> <figcaption <strong>id="fish-caption"</strong>> Joan G. Stark, "<cite>fish</cite>". October 1997. ASCII on electrons. 28×8. </figcaption> </figure> </pre> <!-- source: http://www.geocities.com/SoHo/7373/aquatic.htm#fish --> </div> <div class=impl> <h3 id=interactions-with-xpath-and-xslt><span class=secno>3.3 </span>Interactions with XPath and XSLT</h3> <p id=xpath-1.0-processors>Implementations of XPath 1.0 that operate on <a href=#html-documents>HTML documents</a> parsed or created in the manners described in this specification (e.g. as part of the <code title="">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=http://www.w3.org/TR/1999/REC-xpath-19991116#node-tests> <p>A <a href=http://www.w3.org/TR/REC-xml-names#NT-QName>QName</a> in the node test is expanded into an <a href=http://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 title="">xmlns</code> is not used: if the <a href=http://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=http://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="http://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<!-- added 2009-10-27 - http://www.w3.org/Bugs/Public/show_bug.cgi?id=8062 --> namespace declaration for this prefix in the expression context, and the corresponding<!-- typo fixed 2009-10-27 - http://www.w3.org/Bugs/Public/show_bug.cgi?id=8063 --> namespace URI is the one that is associated with this prefix. It is an error if the QName has a prefix for which there is no namespace declaration in the expression context. </p> <p>If the QName has no prefix and the principal node type of the axis is element, then the default element namespace is used. Otherwise if the QName has no prefix, the namespace URI is null. The default element namespace is a member of the context for the XPath expression. The value of the default element namespace when executing an XPath expression through the DOM3 XPath API is determined in the following way:</p> <ol><li>If the context node is from an HTML DOM, the default element namespace is "http://www.w3.org/1999/xhtml".</li> <li>Otherwise, the default element namespace URI is null.</li> </ol><p class=note>This is equivalent to adding the default element namespace feature of XPath 2.0 to XPath 1.0, and using the HTML namespace as the default element namespace for HTML documents. It is motivated by the desire to have implementations be compatible with legacy HTML content while still supporting the changes that this specification introduces to HTML regarding the namespace used for HTML elements, and by the desire to use XPath 1.0 rather than XPath 2.0.</p> </blockquote> <p class=note>This change is a <a href=#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> <!-- note: version matters for this ref --> <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 href=#html-namespace-0>HTML namespace</a>, <a href=#converted-to-ascii-lowercase title="converted to ASCII lowercase">ASCII-lowercase</a> the element's local name, and <a href=#converted-to-ascii-lowercase title="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>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> <!-- note: version matters for this ref --> <p class=note>There are also additional comments regarding the interaction of XSLT and HTML <a href=#scriptTagXSLT>in the <code>script</code> element section</a>.</p> </div> <h3 id=dynamic-markup-insertion><span class=secno>3.4 </span><dfn>Dynamic markup insertion</dfn></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 href=#html-documents>HTML documents</a> (and the <a href=#html-parser>HTML parser</a>) or XHTML in <a href=#xml-documents>XML documents</a> (and the <a href=#xml-parser>XML parser</a>).</p> <h4 id=opening-the-input-stream><span class=secno>3.4.1 </span>Opening the input stream</h4> <p>The <dfn id=dom-document-open title=dom-document-open><code>open()</code></dfn> method comes in several variants with different numbers of arguments.</p> <dl class=domintro><dt><var title="">document</var> = <var title="">document</var> . <code title=dom-document-open><a href=#dom-document-open>open</a></code>( [ <var title="">type</var> [, <var title="">replace</var> ] ] )</dt> <dd> <p>Causes the <code><a href=#document>Document</a></code> to be replaced in-place, as if it was a new <code><a href=#document>Document</a></code> object, but reusing the previous object, which is then returned.</p> <p>If the <var title="">type</var> argument is omitted or has the value "<code><a href=#text/html>text/html</a></code>", then the resulting <code><a href=#document>Document</a></code> has an HTML parser associated with it, which can be given data to parse using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>. Otherwise, all content passed to <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> will be parsed as plain text.</p> <p>If the <var title="">replace</var> argument is present and has the value "<code title="">replace</code>", the existing entries in the session history for the <code><a href=#document>Document</a></code> object are removed.</p> <p>The method has no effect if the <code><a href=#document>Document</a></code> is still being parsed.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if the <code><a href=#document>Document</a></code> is an <a href=#xml-documents title="XML documents">XML document</a>.</p> </dd> <dt><var title="">window</var> = <var title="">document</var> . <code title=dom-document-open><a href=#dom-document-open>open</a></code>( <var title="">url</var>, <var title="">name</var>, <var title="">features</var> [, <var title="">replace</var> ] )</dt> <dd> <p>Works like the <code title=dom-open><a href=#dom-open>window.open()</a></code> method.</p> </dd> </dl><div class=impl> <p>When called with two or fewer arguments, the method must act as follows:</p> <ol><li>If the <code><a href=#document>Document</a></code> object is not flagged as an <a href=#html-documents title="HTML documents">HTML document</a>, throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>Let <var title="">type</var> be the value of the first argument, if there is one, or "<code><a href=#text/html>text/html</a></code>" otherwise.</li> <li><p>Let <var title="">replace</var> be true if there is a second argument and it is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the value "replace", and false otherwise.</li> <li> <p>If the document has an <a href=#active-parser>active parser</a> that isn't a <a href=#script-created-parser>script-created parser</a>, and the <a href=#insertion-point>insertion point</a> associated with that parser's <a href=#the-input-stream>input stream</a> is not undefined (that is, it <em>does</em> point to somewhere in the input stream), then the method does nothing. Abort these steps and return the <code><a href=#document>Document</a></code> object on which the method was invoked.</p> <p class=note>This basically causes <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> to be ignored when it's called in an inline script found during the parsing of data sent over the network, while still letting it have an effect when called asynchronously or on a document that is itself being spoon-fed using these APIs.</p> </li> <li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li> <li><p>Set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</li> <li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to unload</a> the <code><a href=#document>Document</a></code> object. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then these steps must be aborted.</li> <li><p><a href=#unload-a-document title="unload a document">Unload</a> the <code><a href=#document>Document</a></code> object, with the <var title="">recycle</var> parameter set to true.</li> <li><p><a href=#abort-a-document title="abort a document">Abort</a> the <code><a href=#document>Document</a></code>.</li> <li><p>Unregister all event listeners registered on the <code><a href=#document>Document</a></code> node and its descendants.</p> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> associated with the <code><a href=#document>Document</a></code> in any <a href=#task-source>task source</a>.</li> <!-- removes callbacks that fired between this algorithm starting and the times and databases being aborted in the "unload" step above --> <li><p>Remove all child nodes of the document, without firing any mutation events.</li> <!-- as of 2009-03-30, only WebKit fired mutation events here. --> <li><p>Replace the <code><a href=#document>Document</a></code>'s singleton objects with new instances of those objects. (This includes in particular the <code><a href=#window>Window</a></code>, <code><a href=#location>Location</a></code>, <code><a href=#history-0>History</a></code>, <code><a href=#applicationcache>ApplicationCache</a></code>, and <code><a href=#navigator>Navigator</a></code>, objects, the various <code><a href=#barprop>BarProp</a></code> objects, the two <code><a href=#storage-0>Storage</a></code> objects, the various <code><a href=#htmlcollection>HTMLCollection</a></code> objects, and objects defined by other specifications, like <code>Selection</code> and the document's <code>UndoManager</code>. It also includes all the Web IDL prototypes in the JavaScript binding, including the <code><a href=#document>Document</a></code> object's prototype.)</li> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%20src%3D%22document%22%3E%3C%2Fiframe%3E%0A%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20f%20%3D%20document.getElementsByTagName('iframe')%5B0%5D%3B%20d%20%3D%20f.contentWindow.document%3B%20%7D%3C%2Fscript%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22w(d.documentElement.innerHTML)%22%20value%3D%22dump%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cscript%3Evar%20x%20%3D%20new%20XMLHttpRequest()%3Bx.open(%26quot%3BGET%26quot%3B%2C%20%26quot%3BGET%26quot%3B)%3Bx.onreadystatechange%3Dfunction()%20%7B%20alert(x.readyState)%3B%20%7D%3Bx.send(null)%3B%3C%2Fscript%3E')%3Bd.close()%3B%20setTimeout(function()%20%7B%20d.open()%3B%20d.write('%3Cp%3Etest%3C%2Fp%3E')%3B%20d.close()%20%7D%2C%200)%3B%22%20value%3D%22xhr%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.onclick%20%3D%20function()%20%7B%20w('click')%20%7D%22%20value%3D%22add%20click%20handler%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cp%3Etest%3C%2Fp%3E')%3B%20d.close()%22%20value%3D%22replace%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cp%3E%3Cscript%3Ei%20%3D%200%3B%20setTimeout(%26quot%3Bparent.w(i%2B%2B)%26quot%3B%2C%202000)%3C%2Fscript%3E%3C%2Fp%3E')%3B%20d.close()%22%20value%3D%22replace%20with%20timer%22%3E --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0D%0A...%3Ciframe%3E%3C%2Fiframe%3E%0D%0A%3Cscript%3E%0D%0Aonload%20%3D%20function%20()%20%7B%0D%0A%20frames%5B0%5D.test%20%3D%201%0D%0A%20w(frames%5B0%5D.test)%3B%0D%0A%20var%20a%20%3D%20frames%5B0%5D.document.location.assign%3B%0D%0A%20w(a)%3B%0D%0A%20w(frames%5B0%5D.document.location.assign%20%3D%3D%3D%20a)%3B%0D%0A%20frames%5B0%5D.document.open()%3B%0D%0A%20frames%5B0%5D.document.write('%3Cscript%3Edocument.write(test)%3C%5C%2Fscript%3E')%3B%0D%0A%20frames%5B0%5D.document.close()%3B%0D%0A%20w(frames%5B0%5D.test)%3B%0D%0A%20w(frames%5B0%5D.document.location.assign%20%3D%3D%3D%20a)%3B%0D%0A%7D%0D%0A%3C%2Fscript%3E --> <li><p>Change the <a href="#document's-character-encoding">document's character encoding</a> to UTF-8.</li> <li><p>Set the <code><a href=#document>Document</a></code> object's <a href=#reload-override-flag>reload override flag</a> and set the <code><a href=#document>Document</a></code>'s <a href=#reload-override-buffer>reload override buffer</a> to the empty string.</li> <li><p>Set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state back to true.</li> <li><p>Change <a href="#the-document's-address">the document's address</a> to the <a href=#entry-script>entry script</a>'s <a href="#script's-document" title="script's document">document</a>'s <a href="#the-document's-address" title="the document's address">address</a>.</li> <li><p>Create a new <a href=#html-parser>HTML parser</a> and associate it with the document. This is a <dfn id=script-created-parser>script-created parser</dfn> (meaning that it can be closed by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> and <code title=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 title=dom-document-close><a href=#dom-document-close>document.close()</a></code> before emitting an end-of-file token). The encoding <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> is <i>irrelevant</i>.</li> <li><p>Set the <a href=#current-document-readiness>current document readiness</a> of the document to "<code title="">loading</code>".</li> <li> <!-- text/plain handling --> <p>If the <var title="">type</var> string contains a U+003B SEMICOLON character (;), remove the first such character and all characters from it up to the end of the string.</p> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">type</var>.</p> <p>If <var title="">type</var> is <em>not</em> now an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code><a href=#text/html>text/html</a></code>", then 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<!-- to get eaten, so that a leading LF in the written text doesn't get eaten itself-->, then switch the <a href=#html-parser>HTML parser</a>'s tokenizer to the <a href=#plaintext-state>PLAINTEXT state</a>.</p> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20%0D%0A%20%20var%20d%20%3D%20document.getElementsByTagName('iframe')%5B0%5D.contentDocument%3B%0D%0A%20%20d.open('image%2Fsvg%2Bxml')%3B%0D%0A%20%20d.write(%22%3Cinput%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%20value%3D'(x)html'%2F%3E%22)%3B%0D%0A%20%20d.close()%3B%0D%0A%7D%3B%3C%2Fscript%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20%0D%0A%20%20var%20d%20%3D%20document.getElementsByTagName('iframe')%5B0%5D.contentDocument%3B%0D%0A%20%20d.open('image%2Fgif')%3B%0D%0A%20%20var%20a%20%3D%20%5B%200x47%2C%200x49%2C%200x46%2C%200x38%2C%200x39%2C%200x61%2C%200x01%2C%200x00%2C%200x01%2C%200x00%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x80%2C%200xff%2C%200x00%2C%200xc0%2C%200xc0%2C%200xc0%2C%200x00%2C%200x00%2C%200x00%2C%200x21%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200xf9%2C%200x04%2C%200x01%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%200x2c%2C%200x00%2C%200x00%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x00%2C%200x00%2C%200x01%2C%200x00%2C%200x01%2C%200x00%2C%200x00%2C%200x02%2C%200x02%2C%200x44%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x01%2C%200x00%2C%200x3b%20%5D%3B%0D%0A%20%20var%20s%20%3D%20%22%22%3B%0D%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20a.length%3B%20i%20%2B%3D%201)%0D%0A%20%20%20%20s%20%2B%3D%20String.fromCharCode(a%5Bi%5D)%3B%0D%0A%20%20d.write(s)%3B%0D%0A%20%20d.close()%3B%0D%0A%7D%3B%3C%2Fscript%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27Text%2Fplain%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27%20text%2Fplain%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27text%2Fplain%3B%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E --> </li> <li> <p>Remove all the entries in the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> after the <a href=#current-entry>current entry</a>. If the <a href=#current-entry>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> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> queued by the <a href=#history-traversal-task-source>history traversal task source</a>.</li> <li>Remove any earlier entries that share the same <code><a href=#document>Document</a></code>.</li> <li><p>If <var title="">replace</var> is false, then add a new entry, just before the last entry, and associate with the new entry the text that was parsed by the previous parser associated with the <code><a href=#document>Document</a></code> object, as well as the state of the document at the start of these steps. This allows the user to step backwards in the session history to see the page before it was blown away by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> call. This new entry does not have a <code><a href=#document>Document</a></code> object, so a new one will be created if the session history is traversed to that entry.</li> <li><p>Finally, set the <a href=#insertion-point>insertion point</a> to point at just before the end of the <a href=#the-input-stream>input stream</a> (which at this point will be empty).</li> <li><p>Return the <code><a href=#document>Document</a></code> on which the method was invoked.</li> </ol><p class=note>The <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method does not affect whether a <code><a href=#document>Document</a></code> is <a href=#ready-for-post-load-tasks>ready for post-load tasks</a> or <a href=#completely-loaded>completely loaded</a>.</p> <p>When called with three or more arguments, the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method on the <code><a href=#document>Document</a></code> object must call the <code title=dom-open><a href=#dom-open>open()</a></code> method on the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code> object, with the same arguments as the original call to the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method, and return whatever that method returned. If the <code><a href=#document>Document</a></code> object has no <code><a href=#window>Window</a></code> object, then the method must throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception.</p> </div> <h4 id=closing-the-input-stream><span class=secno>3.4.2 </span>Closing the input stream</h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-close><a href=#dom-document-close>close</a></code>()</dt> <dd> <p>Closes the input stream that was opened by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if the <code><a href=#document>Document</a></code> is an <a href=#xml-documents title="XML documents">XML document</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-close title=dom-document-close><code>close()</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#document>Document</a></code> object is not flagged as an <a href=#html-documents title="HTML documents">HTML document</a>, throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>If there is no <a href=#script-created-parser>script-created parser</a> associated with the document, then abort these steps.</li> <li><p>Insert an <a href=#explicit-eof-character>explicit "EOF" character</a> at the end of the parser's <a href=#the-input-stream>input stream</a>.</li> <li><p>If there is a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then abort these steps.</li> <li><p>Run the tokenizer, processing resulting tokens as they are emitted, and stopping when the tokenizer reaches the <a href=#explicit-eof-character>explicit "EOF" character</a> or <a href=#spin-the-event-loop title="spin the event loop">spins the event loop</a>.</li> </ol></div> <h4 id=document.write()><span class=secno>3.4.3 </span><code title=dom-document-write><a href=#dom-document-write>document.write()</a></code></h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-write><a href=#dom-document-write>write</a></code>(<var title="">text</var>...)</dt> <dd> <p>In general, adds the given string(s) to the <code><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>HTML parser</a> while the parser is running, resulting in a DOM that does not correspond to the source of the document. In other cases, the call can clear the current page first, as if <code title=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. To make matters 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>This method throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception when invoked on <a href=#xml-documents>XML documents</a>.</p> </dd> </dl><div class=impl> <p><code><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><a href=#the-script-element>script</a></code> elements to prevent external scripts from being able to use <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> to blow away the document by implicitly calling <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code>. Initially, the counter must be set to zero.</p> <p>The <dfn id=dom-document-write title=dom-document-write><code>document.write(...)</code></dfn> method must act as follows:</p> <ol><li> <p>If the method was invoked on an <a href=#xml-documents title="XML documents">XML document</a>, throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</p> <!-- Where would document.write() insert? Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script> --> </li> <li> <p>If the <a href=#insertion-point>insertion point</a> is undefined and the <code><a href=#document>Document</a></code>'s <a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> is greater than zero, then abort these steps.</p> </li> <li> <p>If the <a href=#insertion-point>insertion point</a> is undefined, call the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method on the <code title=Document><a href=#document>document</a></code> object (with no arguments). If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then abort these steps. Otherwise, the <a href=#insertion-point>insertion point</a> will point at just before the end of the (empty) <a href=#the-input-stream>input stream</a>.</p> </li> <li> <p>Insert the string consisting of the concatenation of all the arguments to the method into the <a href=#the-input-stream>input stream</a> just before the <a href=#insertion-point>insertion point</a>.</p> </li> <li> <p>If the <code><a href=#document>Document</a></code> object's <a href=#reload-override-flag>reload override flag</a> is set, then append the string consisting of the concatenation of all the arguments to the method to the <code><a href=#document>Document</a></code>'s <a href=#reload-override-buffer>reload override buffer</a>.</p> </li> <li> <p>If there is no <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, have the tokenizer process the characters that were inserted, one 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><a href=#the-script-element>script</a></code> end tag token is emitted by the tokenizer). <p class=note>If the <code title=dom-document-write><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><a href=#the-script-element>script</a></code> tags), then this is a <a href=#nestedParsing>reentrant invocation of the parser</a>.</p> </li> <li> <p>Finally, return from the method.</p> </li> </ol></div> <h4 id=document.writeln()><span class=secno>3.4.4 </span><code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code></h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-writeln><a href=#dom-document-writeln>writeln</a></code>(<var title="">text</var>...)</dt> <dd> <p>Adds the given string(s) to the <code><a href=#document>Document</a></code>'s input stream, followed by a newline character. If necessary, calls the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method implicitly first.</p> <p>This method throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception when invoked on <a href=#xml-documents>XML documents</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-writeln title=dom-document-writeln><code>document.writeln(...)</code></dfn> method, when invoked, must act as if the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method had been invoked with the same argument(s), plus an extra argument consisting of a string containing a single line feed character (U+000A).</p> </div> <h2 id=semantics><span class=secno>4 </span>The elements of HTML</h2> <h3 id=the-root-element><span class=secno>4.1 </span>The root element</h3> <h4 id=the-html-element><span class=secno>4.1.1 </span>The <dfn><code>html</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the root element of a document.</dd> <dd>Wherever a subdocument fragment is allowed in a compound document.</dd> <dt>Content model:</dt> <dd>A <code><a href=#the-head-element>head</a></code> element followed by a <code><a href=#the-body-element>body</a></code> element.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlhtmlelement>HTMLHtmlElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-html-element>html</a></code> element <a href=#represents>represents</a> the root of an HTML document.</p> <p>The <dfn id=attr-html-manifest title=attr-html-manifest><code>manifest</code></dfn> attribute gives the address of the document's <a href=#application-cache>application cache</a> <a href=#concept-appcache-manifest title=concept-appcache-manifest>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>valid non-empty URL potentially surrounded by spaces</a>.</p> <p>The <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute only <a href=#concept-appcache-init title=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 title=concept-appcache-init>application cache selection</a>, later <code><a href=#the-base-element>base</a></code> elements cannot affect the <a href=#resolve-a-url title="resolve a url">resolving of relative URLs</a> in <code title=attr-html-manifest><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 title=dom-applicationCache><a href=#dom-applicationcache>window.applicationCache</a></code> IDL attribute provides scripted access to the offline <a href=#application-cache>application cache</a> mechanism.</p> <div class=example> <p>The <code><a href=#the-html-element>html</a></code> element in the following example declares that the document's language is English.</p> <pre><!DOCTYPE html> <strong><html lang="en"></strong> <head> <title>Swapping Songs</title> </head> <body> <h1>Swapping Songs</h1> <p>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.</p> </body> <strong></html></strong></pre> </div> <h3 id=document-metadata><span class=secno>4.2 </span>Document metadata</h3> <h4 id=the-head-element><span class=secno>4.2.1 </span>The <dfn><code>head</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the first element in an <code><a href=#the-html-element>html</a></code> element.</dd> <dt>Content model:</dt> <dd>If the document is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a> or if title information is available from a higher-level protocol: Zero or more elements of <a href=#metadata-content>metadata content</a>.</dd> <dd>Otherwise: One or more elements of <a href=#metadata-content>metadata content</a>, of which exactly one is a <code><a href=#the-title-element>title</a></code> element.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlheadelement>HTMLHeadElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-head-element>head</a></code> element <a href=#represents>represents</a> a collection of metadata for the <code><a href=#document>Document</a></code>.</p> <div class=example> <p>The collection of metadata in a <code><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><!doctype html> <html> <head> <title>A document with a short head</title> </head> <body> ...</pre> <p>Here is an example of a longer one:</p> <pre><!DOCTYPE HTML> <HTML> <HEAD> <META CHARSET="UTF-8"> <BASE HREF="http://www.example.com/"> <TITLE>An application with a long head</TITLE> <LINK REL="STYLESHEET" HREF="default.css"> <LINK REL="STYLESHEET ALTERNATE" HREF="big.css" TITLE="Big Text"> <SCRIPT SRC="support.js"></SCRIPT> <META NAME="APPLICATION-NAME" CONTENT="Long headed application"> </HEAD> <BODY> ...</pre> </div> <p class=note>The <code><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><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</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-title-element>title</a></code> elements.</dd> <dt>Content model:</dt> <dd><a href=#text-content title="text content">Text</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltitleelement>HTMLTitleElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-title-text title=dom-title-text>text</a>; };</pre> </dd> </dl><p>The <code><a href=#the-title-element>title</a></code> element <a href=#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><a href=#the-title-element>title</a></code> element per document.</p> <dl class=domintro><dt><var title="">title</var> . <code title=dom-title-text><a href=#dom-title-text>text</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the contents of the element, ignoring child nodes that aren't <a href=#text-node title="text node">text nodes</a>.</p> <p>Can be set, to replace the element's children with the given value.</p> </dd> </dl><div class=impl> <p>The IDL attribute <dfn id=dom-title-text title=dom-title-text><code>text</code></dfn> must return a concatenation of the contents of all the <a href=#text-node title="text node">text nodes</a> that are children of the <code><a href=#the-title-element>title</a></code> element (ignoring any other nodes such as comments or elements), in tree order. On setting, it must act the same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> </div> <div class=example> <p>Here are some examples of appropriate titles, contrasted with the top-level headings that might be used on those same pages.</p> <pre> <title>Introduction to The Mating Rituals of Bees</title> ... <h1>Introduction</h1> <p>This companion guide to the highly successful <cite>Introduction to Medieval Bee-Keeping</cite> book is...</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> <title>Dances used during bee mating rituals</title> ... <h1>The Dances</h1></pre> </div> <p>The string to use as the document's title is given by the <code title=dom-document-title><a href=#document.title>document.title</a></code> IDL attribute.</p> <div class=impl> <p>User agents should use the document's title when referring to the document in their user interface. When the contents of a <code><a href=#the-title-element>title</a></code> element are used in this way, <a href=#the-directionality>the directionality</a> of that <code><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> </div> <h4 id=the-base-element><span class=secno>4.2.3 </span>The <dfn><code>base</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>In a <code><a href=#the-head-element>head</a></code> element containing no other <code><a href=#the-base-element>base</a></code> elements.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-base-href><a href=#attr-base-href>href</a></code></dd> <dd><code title=attr-base-target><a href=#attr-base-target>target</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlbaseelement>HTMLBaseElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-base-href title=dom-base-href>href</a>; attribute DOMString <a href=#dom-base-target title=dom-base-target>target</a>; };</pre> </dd> </dl><p>The <code><a href=#the-base-element>base</a></code> element allows authors to specify the <a href=#document-base-url>document base URL</a> for the purposes of <a href=#resolve-a-url title="resolve a url">resolving relative URLs</a>, and the name of the default <a href=#browsing-context>browsing context</a> for the purposes of <a href=#following-hyperlinks>following hyperlinks</a>. The element does not <a href=#represents title=represents>represent</a> any content beyond this information.</p> <p>There must be no more than one <code><a href=#the-base-element>base</a></code> element per document.</p> <p>A <code><a href=#the-base-element>base</a></code> element must have either an <code title=attr-base-href><a href=#attr-base-href>href</a></code> attribute, a <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute, or both.</p> <p>The <dfn id=attr-base-href title=attr-base-href><code>href</code></dfn> content attribute, if specified, must contain a <a href=#valid-url-potentially-surrounded-by-spaces>valid URL potentially surrounded by spaces</a>.</p> <p>A <code><a href=#the-base-element>base</a></code> element, if it has an <code title=attr-base-href><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=#url title=URL>URLs</a>, except the <code><a href=#the-html-element>html</a></code> element (its <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute isn't affected by <code><a href=#the-base-element>base</a></code> elements).</p> <div class=impl> <p class=note>If there are multiple <code><a href=#the-base-element>base</a></code> elements with <code title=attr-base-href><a href=#attr-base-href>href</a></code> attributes, all but the first are ignored.</p> </div> <p>The <dfn id=attr-base-target title=attr-base-target><code>target</code></dfn> attribute, if specified, must contain a <a href=#valid-browsing-context-name-or-keyword>valid browsing context name or keyword</a>, which specifies which <a href=#browsing-context>browsing context</a> is to be used as the default when <a href=#hyperlink title=hyperlink>hyperlinks</a> and <a href=#the-form-element title=form>forms</a> in the <code><a href=#document>Document</a></code> cause <a href=#navigate title=navigate>navigation</a>.</p> <p>A <code><a href=#the-base-element>base</a></code> element, if it has a <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute, must come before any elements in the tree that represent <a href=#hyperlink title=hyperlink>hyperlinks</a>.</p> <div class=impl> <p class=note>If there are multiple <code><a href=#the-base-element>base</a></code> elements with <code title=attr-base-target><a href=#attr-base-target>target</a></code> attributes, all but the first are ignored.</p> <p>The <dfn id=dom-base-href title=dom-base-href><code>href</code></dfn> and <dfn id=dom-base-target title=dom-base-target><code>target</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <div class=example> <p>In this example, a <code><a href=#the-base-element>base</a></code> element is used to set the <a href=#document-base-url>document base URL</a>:</p> <pre><!DOCTYPE html> <html> <head> <title>This is an example for the &lt;base&gt; element</title> <base href="http://www.example.com/news/index.html"> </head> <body> <p>Visit the <a href="archives.html">archives</a>.</p> </body> </html></pre> <p>The link in the above example would be a link to "<code title="">http://www.example.com/news/archives.html</code>".</p> </div> <h4 id=the-link-element><span class=secno>4.2.4 </span>The <dfn><code>link</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <!--MD--> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#flow-content>flow content</a>.</dd> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#phrasing-content>phrasing content</a>.</dd> <!--MD--> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd> <dd>In a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd> <!--MD--> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <!--MD--> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-link-href><a href=#attr-link-href>href</a></code></dd> <dd><code title=attr-link-rel><a href=#attr-link-rel>rel</a></code></dd> <dd><code title=attr-link-media><a href=#attr-link-media>media</a></code></dd> <dd><code title=attr-link-hreflang><a href=#attr-link-hreflang>hreflang</a></code></dd> <dd><code title=attr-link-type><a href=#attr-link-type>type</a></code></dd> <dd><code title=attr-link-sizes><a href=#attr-link-sizes>sizes</a></code></dd> <dd>Also, the <code title=attr-link-title><a href=#attr-link-title>title</a></code> attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmllinkelement>HTMLLinkElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-link-disabled title=dom-link-disabled>disabled</a>; attribute DOMString <a href=#dom-link-href title=dom-link-href>href</a>; attribute DOMString <a href=#dom-link-rel title=dom-link-rel>rel</a>; readonly attribute <a href=#domtokenlist>DOMTokenList</a> <a href=#dom-link-rellist title=dom-link-relList>relList</a>; attribute DOMString <a href=#dom-link-media title=dom-link-media>media</a>; attribute DOMString <a href=#dom-link-hreflang title=dom-link-hreflang>hreflang</a>; attribute DOMString <a href=#dom-link-type title=dom-link-type>type</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-link-sizes title=dom-link-sizes>sizes</a>; }; <a href=#htmllinkelement>HTMLLinkElement</a> implements <a href=#linkstyle>LinkStyle</a>;</pre> </dd> </dl><p>The <code><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 title=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>valid non-empty URL potentially surrounded by spaces</a>. <span class=impl>If the <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute is absent, then the element does not define a link.</span></p> <!--MD--> <p>A <code><a href=#the-link-element>link</a></code> element must have either a <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute or an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute, but not both.</p> <p class=note>If the <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute is used, the element is restricted to the <code><a href=#the-head-element>head</a></code> element. When used with the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute, the element can be used both in the <code><a href=#the-head-element>head</a></code> element and in the <code><a href=#the-body-element>body</a></code> of the page, subject to the constraints of the microdata model.</p> <p>The types of link indicated (the relationships) are given by the value of the <dfn id=attr-link-rel title=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>set of space-separated tokens</a>. The <a href=#linkTypes>allowed keywords and their meanings</a> are defined in a later section. <span class=impl>If the <code title=attr-link-rel><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.</span></p> <p>Two categories of links can be created using the <code><a href=#the-link-element>link</a></code> element: <a href=#external-resource-link title="external resource link">Links to external resources</a> and <a href=#hyperlink title=hyperlink>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><a href=#the-link-element>link</a></code> element can create multiple links (of which some might be external resource links and some might be hyperlinks); exactly which and how many links are created depends on the keywords given in the <code title=attr-link-rel><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><a href=#the-link-element>link</a></code> element is handled separately. For instance, if there are two <code><a href=#the-link-element>link</a></code> elements with <code title="">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><a href=#the-link-element>link</a></code> element has a <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute with the value <code title="">next stylesheet</code>, it creates both a <a href=#hyperlink>hyperlink</a> (for the <code title=rel-next><a href=#link-type-next>next</a></code> keyword) and an <a href=#external-resource-link>external resource link</a> (for the <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> keyword), and they are affected by other attributes (such as <code title=attr-link-media><a href=#attr-link-media>media</a></code> or <code title=attr-link-title><a href=#attr-link-title>title</a></code>) differently.</p> <div class=example> <p>For example, the following <code><a href=#the-link-element>link</a></code> element creates two hyperlinks (to the same page):</p> <pre><link rel="author license" href="/about"></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>The exact behavior for links to external resources depends on the exact relationship, as defined for the relevant link type. Some of the attributes control whether or not the external resource is to be applied (as defined below).</p> <div class=impl> <p>For external resources that are represented in the DOM (for example, style sheets), the DOM representation must be made available even if the resource is not applied. To <dfn id=concept-link-obtain title=concept-link-obtain>obtain the resource</dfn>, the user agent must run the following steps:</p> <ol><li><p>If the <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute's value is the empty string, then abort these steps.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <a href=#url>URL</a> given by the <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute, relative to the element.</li> <li><p>If the previous step fails, then abort these steps.</li> <li><p><a href=#fetch>Fetch</a> the resulting <a href=#absolute-url>absolute URL</a>.</li> <!-- http-origin privacy sensitive --> </ol><p>User agents may opt to only try to obtain such resources when they are needed, instead of pro-actively <a href=#fetch title=fetch>fetching</a> 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> <!-- the next few paragraph are similar to text in the <style> section --> <p>Once the attempts to obtain the resource and its <a href=#critical-subresources>critical subresources</a> are complete, the user agent must, if the loads were successful, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-link-element>link</a></code> element, or, if the resource or one of its <a href=#critical-subresources>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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><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>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the element's document until all the attempts to obtain the resource and its <a href=#critical-subresources>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>delay the load event</a>.)</p> <hr><p id=linkui>Interactive user agents may provide users with a means to <a href=#following-hyperlinks title="following hyperlinks">follow the hyperlinks</a> created using the <code><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 hyperlink created with each <code><a href=#the-link-element>link</a></code> element in the document:</p> <ul><!-- the order here is the order that makes most sense for a UI --><li>The relationship between this document and the resource (given by the <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute)</li> <li>The title of the resource (given by the <code title=attr-link-title><a href=#attr-link-title>title</a></code> attribute).</li> <li>The address of the resource (given by the <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute).</li> <li>The language of the resource (given by the <code title=attr-link-hreflang><a href=#attr-link-hreflang>hreflang</a></code> attribute).</li> <li>The optimum media for the resource (given by the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute).</li> </ul><p>User agents could also include other information, such as the type of the resource (as given by the <code title=attr-link-type><a href=#attr-link-type>type</a></code> attribute).</p> </div> <p class=note>Hyperlinks created with the <code><a href=#the-link-element>link</a></code> element and its <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute apply to the whole page. This contrasts with the <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute of <code><a href=#the-a-element>a</a></code> and <code><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 <dfn id=attr-link-media title=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>valid media query</a>.</p> <div class=impl> <p>If the link is a <a href=#hyperlink>hyperlink</a> then the <code title=attr-link-media><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>external resource link</a>, then the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute is prescriptive. The user agent must apply the external resource when the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute's value <a href=#matches-the-environment>matches the environment</a> and the other relevant conditions apply, and must not apply it otherwise.</p><!-- note similar text in <style> section --> <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 title="">@media</code> blocks. This specification does not override such further restrictions or requirements.</p><!-- note similar text in <style> section --> </div> <p id=default-media>The default, if the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute is omitted, is "<code title="">all</code>", meaning that by default links apply to all media.</p> <p>The <dfn id=attr-link-hreflang title=attr-link-hreflang><code>hreflang</code></dfn> attribute on the <code><a href=#the-link-element>link</a></code> element has the same semantics as the <a href=#attr-hyperlink-hreflang title=attr-hyperlink-hreflang><code>hreflang</code> attribute on <code>a</code> and <code>area</code> elements</a>.</p> <p>The <dfn id=attr-link-type title=attr-link-type><code>type</code></dfn> attribute gives the <a href=#mime-type>MIME type</a> of the linked resource. It is purely advisory. The value must be a <a href=#valid-mime-type>valid MIME type</a>.</p> <p>For <a href=#external-resource-link title="external resource link">external resource links</a>, the <code title=attr-link-type><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. <span class=impl>If the attribute is present, then the user agent must assume that the resource is of the given type (even if that is not a <a href=#valid-mime-type>valid MIME type</a>, e.g. the empty string). If the attribute is omitted, but the external resource link 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 href=#mime-type>MIME type</a> for the given link relationship, then the UA should not <a href=#concept-link-obtain title=concept-link-obtain>obtain</a> the resource; if the UA does support the given <a href=#mime-type>MIME type</a> for the given link relationship, then the UA should <a href=#concept-link-obtain title=concept-link-obtain>obtain</a> the resource at the appropriate time as specified for the <a href=#external-resource-link>external resource link</a>'s particular type. If the attribute is omitted, and the external resource link type does not have a default type defined, but the user agent would <a href=#concept-link-obtain title=concept-link-obtain>obtain</a> the resource if the type was known and supported, then the user agent should <a href=#concept-link-obtain title=concept-link-obtain>obtain</a> the resource under the assumption that it will be supported.</span></p> <div class=impl> <p>User agents must not consider the <code title=attr-link-type><a href=#attr-link-type>type</a></code> attribute authoritative — upon fetching the resource, user agents must not use the <code title=attr-link-type><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 external resource link type defines rules for processing the resource's <a href=#content-type title=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=#content-type-sniffing:-image title="Content-Type sniffing: image">image sniffing rules</a>, with the <var title="">official type</var> being the type determined from the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>, and use the resulting sniffed type of the resource 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 title=Content-Type>Content-Type metadata</a> to determine the type of the resource. If there is no type metadata, but the external resource link 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 title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> link type defines rules for processing the resource's <a href=#content-type title=Content-Type>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><link rel="stylesheet" href="A" type="text/plain"> <link rel="stylesheet" href="B" type="text/css"> <link rel="stylesheet" href="C"></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>text/plain</code> is not the <a href=#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>text/css</code>, it would apply the styles, but for those labeled as <code>text/plain</code>, or any other type, it would not.</p> <p>If one of the two files was returned without a <a href=#content-type>Content-Type</a> metadata, or with a syntactically incorrect type like <code title="">Content-Type: "null"</code>, then the default type for <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> links would kick in. Since that default type is <code title="">text/css</code>, the style sheet <em>would</em> nonetheless be applied.</p> </div> </div> <p>The <dfn id=attr-link-title title=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, where the <code title=attr-link-title><a href=#attr-link-title>title</a></code> attribute defines <a href=#alternative-style-sheet-sets>alternative style sheet sets</a>.</p> <p class=note>The <code title=attr-link-title><a href=#attr-link-title>title</a></code> attribute on <code><a href=#the-link-element>link</a></code> elements differs from the global <code title=attr-title><a href=#the-title-attribute>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> <p>The <code title=attr-link-sizes><a href=#attr-link-sizes>sizes</a></code> attribute is used with the <code title=rel-icon><a href=#rel-icon>icon</a></code> link type. The attribute must not be specified on <code><a href=#the-link-element>link</a></code> elements that do not have a <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute that specifies the <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword.</p> <div class=impl> <p>HTTP <code title="">Link:</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 entity header. (URLs in these headers are to be processed and resolved according to the rules given in the relevant specification; the rules of <em>this</em> specification don't apply.) <a href=#refsHTTP>[HTTP]</a> <a href=#refsWEBLINK>[WEBLINK]</a></p> <!-- WEBLINK is ref for Link: header --> <p>The IDL attributes <dfn id=dom-link-href title=dom-link-href><code>href</code></dfn>, <dfn id=dom-link-rel title=dom-link-rel><code>rel</code></dfn>, <dfn id=dom-link-media title=dom-link-media><code>media</code></dfn>, <dfn id=dom-link-hreflang title=dom-link-hreflang><code>hreflang</code></dfn>, <dfn id=dom-link-type title=dom-link-type><code>type</code></dfn>, and <dfn id=dom-link-sizes title=dom-link-sizes><code>sizes</code></dfn> each must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The IDL attribute <dfn id=dom-link-rellist title=dom-link-rellist><code>relList</code></dfn> <span class=impl>must</span> <a href=#reflect title=reflect>reflect</a> the <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> content attribute.</p> </div> <p>The IDL attribute <dfn id=dom-link-disabled title=dom-link-disabled><code>disabled</code></dfn> only applies to style sheet links. When the <code><a href=#the-link-element>link</a></code> element defines a style sheet link, then the <code title=dom-link-disabled><a href=#dom-link-disabled>disabled</a></code> attribute behaves as defined <a href=#dom-linkstyle-disabled title=dom-linkstyle-disabled>for the alternative style sheets DOM</a>. For all other <code><a href=#the-link-element>link</a></code> elements it always return false and does nothing on setting.</p> <!-- that is normatively required in the definition of dom-linkstyle-disabled --> <p>The <code><a href=#linkstyle>LinkStyle</a></code> interface is also implemented by this element; the <a href=#styling>styling processing model</a> defines how. <a href=#refsCSSOM>[CSSOM]</a></p> <div class=example> <p>Here, a set of <code><a href=#the-link-element>link</a></code> elements provide some style sheets:</p> <pre><!-- a persistent style sheet --> <link rel="stylesheet" href="default.css"> <!-- the preferred alternate style sheet --> <link rel="stylesheet" href="green.css" title="Green styles"> <!-- some alternate style sheets --> <link rel="alternate stylesheet" href="contrast.css" title="High contrast"> <link rel="alternate stylesheet" href="big.css" title="Big fonts"> <link rel="alternate stylesheet" href="wide.css" title="Wide screen"></pre> </div> <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><link rel=alternate href="/en/html" hreflang=en type=text/html title="English HTML"> <link rel=alternate href="/fr/html" hreflang=fr type=text/html title="French HTML"> <link rel=alternate href="/en/html/print" hreflang=en type=text/html media=print title="English HTML (for printing)"> <link rel=alternate href="/fr/html/print" hreflang=fr type=text/html media=print title="French HTML (for printing)"> <link rel=alternate href="/en/pdf" hreflang=en type=application/pdf title="English PDF"> <link rel=alternate href="/fr/pdf" hreflang=fr type=application/pdf title="French PDF"></pre> </div> <h4 id=the-meta-element><span class=secno>4.2.5 </span>The <dfn id=meta><code>meta</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <!--MD--> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#flow-content>flow content</a>.</dd> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: <a href=#phrasing-content>phrasing content</a>.</dd> <!--MD--> <dt>Contexts in which this element can be used:</dt> <dd>If the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute is present, or if the element's <code title=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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd> <dd>If the <code title=attr-meta-http-equiv><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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-head-element>head</a></code> element.</dd> <dd>If the <code title=attr-meta-http-equiv><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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd> <dd>If the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd> <!--MD--> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#metadata-content>metadata content</a> is expected.</dd> <dd>If the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <!--MD--> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-meta-name><a href=#attr-meta-name>name</a></code></dd> <dd><code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code></dd> <dd><code title=attr-meta-content><a href=#attr-meta-content>content</a></code></dd> <dd><code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlmetaelement>HTMLMetaElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-meta-name title=dom-meta-name>name</a>; attribute DOMString <a href=#dom-meta-httpequiv title=dom-meta-httpEquiv>httpEquiv</a>; attribute DOMString <a href=#dom-meta-content title=dom-meta-content>content</a>; };</pre> </dd> </dl><p>The <code><a href=#the-meta-element>meta</a></code> element <a href=#represents>represents</a> various kinds of metadata that cannot be expressed using the <code><a href=#the-title-element>title</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-script-element>script</a></code> elements.</p> <p>The <code><a href=#the-meta-element>meta</a></code> element can represent document-level metadata with the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute, pragma directives with the <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute, and the file's <a href=#character-encoding-declaration>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 title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute.</p> <!--MD--> <p>Exactly one of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>, <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>, <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code>, and <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attributes must be specified.</p> <p>If either <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>, <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>, or <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> is specified, then the <code title=attr-meta-content><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 title=attr-meta-charset><code>charset</code></dfn> attribute specifies the character encoding used by the document. This is a <a href=#character-encoding-declaration>character encoding declaration</a>. If the attribute is present in an <a href=#xml-documents title="XML documents">XML document</a>, its value must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">UTF-8</code>" (and the document is therefore forced to use UTF-8 as its encoding).</p> <p class=note>The <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute on the <code><a href=#the-meta-element>meta</a></code> element has no effect in XML documents, and is only allowed in order to facilitate migration to and from XHTML.</p> <p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute per document.</p> <p>The <dfn id=attr-meta-content title=attr-meta-content><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><a href=#the-meta-element>meta</a></code> element has a <dfn id=attr-meta-name title=attr-meta-name><code>name</code></dfn> attribute, it sets document metadata. Document metadata is expressed in terms of name-value pairs, the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute on the <code><a href=#the-meta-element>meta</a></code> element giving the name, and the <code title=attr-meta-content><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><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, then the value part of the metadata name-value pair is the empty string.</p> <div class=impl> <p>The <dfn id=dom-meta-name title=dom-meta-name><code>name</code></dfn> and <dfn id=dom-meta-content title=dom-meta-content><code>content</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The IDL attribute <dfn id=dom-meta-httpequiv title=dom-meta-httpEquiv><code>httpEquiv</code></dfn> must <a href=#reflect>reflect</a> the content attribute <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>.</p> </div> <h5 id=standard-metadata-names><span class=secno>4.2.5.1 </span>Standard metadata names</h5> <p>This specification defines a few names for the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute of the <code><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 href=#ascii-case-insensitive>ASCII case-insensitive</a> manner</span>.</p> <dl><dt><dfn id=meta-application-name title=meta-application-name><code>application-name</code></dfn></dt> <dd><p>The value must be a short free-form string giving the name of the Web application that the page represents. If the page is not a Web application, the <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> metadata name must not be used. There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-application-name><a href=#meta-application-name>application-name</a></code> per document. <span class=impl>User agents may use the application name in UI in preference to the page's <code><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.</span></dd> <dt><dfn id=meta-author title=meta-author><code>author</code></dfn></dt> <dd><p>The value must be a free-form string giving the name of one of the page's authors.</dd> <dt><dfn id=meta-description title=meta-description><code>description</code></dfn></dt> <dd><p>The value must be a free-form string that describes the page. The value must be appropriate for use in a directory of pages, e.g. in a search engine. There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with its <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute set to the value <code title=meta-description><a href=#meta-description>description</a></code> per document.</dd> <dt><dfn id=meta-generator title=meta-generator><code>generator</code></dfn></dt> <dd> <p>The value must be a free-form string that identifies one of the software packages used to generate the document. This value must not be used on hand-authored pages.</p> <div class=example> <p>Here is what a tool called "Frontweaver" could include in its output, in the page's <code><a href=#the-head-element>head</a></code> element, to identify itself as the tool used to generate the page:</p> <pre><meta name=generator content="Frontweaver 8.2"></pre> </div> </dd> <dt><dfn id=meta-keywords title=meta-keywords><code>keywords</code></dfn></dt> <dd> <p>The value must be a <a href=#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><a href=#the-meta-element>meta</a></code> element to specify some keywords that users might use to look for the page:</p> <pre><!DOCTYPE HTML> <html> <head> <title>Typefaces on UK motorways</title> <meta name="keywords" content="british,type face,font,fonts,highway,highways"> </head> <body> ...</pre> </div> <p class=note>Many search engines do not consider such keywords, because this feature has historically been used unreliably and even misleadingly as a way to spam search engine results in a way that is not helpful for users.</p> <div class=impl> <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 title="">keywords</var> be an empty list.</li> <li> <p>For each <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute and a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute and whose <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute's value is <code title=meta-keywords><a href=#meta-keywords>keywords</a></code>, run the following substeps:</p> <ol><li><p><a href=#split-a-string-on-commas title="split a string on commas">Split the value of the element's <code title=attr-meta-content>content</code> attribute on commas</a>.</li> <li><p>Add the resulting tokens, if any, to <var title="">keywords</var>.</li> </ol></li> <li><p>Remove any duplicates from <var title="">keywords</var>.</li> <li><p>Return <var title="">keywords</var>. This is the list of keywords that the author has specified as applicable to the page.</li> </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> </div> </dd> </dl><h5 id=other-metadata-names><span class=secno>4.2.5.2 </span>Other metadata names</h5> <p><dfn id=concept-meta-extensions title=concept-meta-extensions>Extensions to the predefined set of metadata names</dfn> may be registered in the <a href=http://wiki.whatwg.org/wiki/MetaExtensions>WHATWG Wiki MetaExtensions page</a>. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a></p> <p>Anyone is free to edit the WHATWG Wiki MetaExtensions page at any time to add a type. These new names must be specified with the following information:</p> <dl><dt>Keyword</dt> <dd><p>The actual name being defined. The name should not be confusingly similar to any other defined name (e.g. differing only in case).</dd> <dt>Brief description</dt> <dd><p>A short non-normative description of what the metadata name's meaning is, including the format the value is required to be in.</dd> <dt>Specification</dt> <dd>A link to a more detailed description of the metadata name's semantics and requirements. It could be another page on the Wiki, or a link to an external page.</dd> <dt>Synonyms</dt> <dd><p>A list of other names that have exactly the same processing requirements. Authors should not use the names defined to be synonyms, they are only intended to allow user agents to support legacy content. Anyone may remove synonyms that are not used in practice; only names that need to be processed as synonyms for compatibility with legacy content are to be registered in this way.</dd> <dt>Status</dt> <dd> <p>One of the following:</p> <dl><dt>Proposed</dt> <dd>The name has not received wide peer review and approval. Someone has proposed it and is, or soon will be, using it.</dd> <dt>Ratified</dt> <dd>The name has received wide peer review and approval. It has a specification that unambiguously defines how to handle pages that use the name, including when they use it in incorrect ways.</dd> <dt>Discontinued</dt> <dd>The metadata name has received wide peer review and it has been found wanting. Existing pages are using this metadata name, but new pages should avoid it. The "brief description" and "specification" entries will give details of what authors should use instead, if anything.</dd> </dl><p>If a metadata name is found to be redundant with existing values, it should be removed and listed as a synonym for the existing value.</p> <p>If a metadata name is 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 metadata name is added with the "proposed" status and found to be redundant with existing values, it should be removed and listed as a synonym for the existing value. If a metadata name is added with the "proposed" status and found to be harmful, then it should be changed to "discontinued" status.</p> <p>Anyone can change the status at any time, but should only do so in accordance with the definitions above.</p> </dd> </dl><div class=impl> <p>Conformance checkers must use the information given on the WHATWG Wiki MetaExtensions page to establish if a value is allowed or not: values defined in this specification or marked as "proposed" or "ratified" must be accepted, 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 metadata name 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> </div> <p>Metadata names whose values are to be <a href=#url title=URL>URLs</a> must not be proposed or accepted. Links must be represented using the <code><a href=#the-link-element>link</a></code> element, not the <code><a href=#the-meta-element>meta</a></code> element.</p> <h5 id=pragma-directives><span class=secno>4.2.5.3 </span>Pragma directives</h5> <p>When the <dfn id=attr-meta-http-equiv title=attr-meta-http-equiv><code>http-equiv</code></dfn> attribute is specified on a <code><a href=#the-meta-element>meta</a></code> element, the element is a pragma directive.</p> <p>The <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute is an <a href=#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. <span class=impl>Some of the keywords are non-conforming, as noted in the last column.</span></p> <!-- things that are neither conforming nor do anything are commented out --> <table id=table-http-equiv><thead><tr><th>State <th>Keyword <th>Notes <tbody><tr class=impl><td><a href=#attr-meta-http-equiv-content-language title=attr-meta-http-equiv-content-language>Content Language</a> <td><code title="">content-language</code> <td>Non-conforming <tr><td><a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration</a> <td><code title="">content-type</code> <td> <!-- <tr class="impl"> <td><span title="attr-meta-http-equiv-content-script-type">Content-Script-Type</span> <td><code title="">Content-Script-Type</code> <td>Non-conforming <tr class="impl"> <td><span title="attr-meta-http-equiv-content-style-type">Content-Style-Type</span> <td><code title="">Content-Style-Type</code> <td>Non-conforming --> <tr><td><a href=#attr-meta-http-equiv-default-style title=attr-meta-http-equiv-default-style>Default style</a> <td><code title="">default-style</code> <td> <tr><td><a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh</a> <td><code title="">refresh</code> <td> <tr class=impl><td><a href=#attr-meta-http-equiv-set-cookie title=attr-meta-http-equiv-set-cookie>Cookie setter</a> <td><code title="">set-cookie</code> <td>Non-conforming </table><!-- DATA: According to Henri's validator stats, here are common non-conforming values used by people who validate (sample of 400 pages): COUNT ERROR 20 Bad value "Content-Language" for attribute "http-equiv" on element "meta". 17 Bad value "Content-Style-Type" for attribute "http-equiv" on element "meta". 12 Bad value "Expires" for attribute "http-equiv" on element "meta". 11 Bad value "Pragma" for attribute "http-equiv" on element "meta". 11 Bad value "imagetoolbar" for attribute "http-equiv" on element "meta". 10 Bad value "Content-Script-Type" for attribute "http-equiv" on element "meta". 10 Bad value "content-language" for attribute "http-equiv" on element "meta". [...] http://hsivonen.iki.fi/test/moz/analysis.txt Here's some more data, this time from Philip`, on a sample of 15k pages. COUNT VALUE 1181 Content-Language 430 Content-Style-Type 342 imagetoolbar 276 content-language 269 Pragma 260 expires 227 Expires 211 pragma 146 Content-Script-Type 132 keywords 119 Page-Enter 116 description 106 reply-to 102 Cache-Control [...] http://philip.html5.org/data/meta-http-equiv.txt These numbers are low; further study is required to establish what people expect to have work and what is necessary. --><div class=impl> <p>When a <code><a href=#the-meta-element>meta</a></code> element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the document</a>, if its <code title=attr-meta-http-equiv><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> </div> <dl><dt class=impl><dfn id=attr-meta-http-equiv-content-language title=attr-meta-http-equiv-content-language>Content language state</dfn> (<code title="">http-equiv="content-language"</code>) <dd class=impl> <p class=note>This feature is non-conforming. Authors are encouraged to use the <code title=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 the pragma is successfully processed, there is no <a href=#pragma-set-default-language>pragma-set default language</a>.</p> <ol><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the <a href=#attr-meta-http-equiv-content-language title=attr-meta-http-equiv-content-language>Content Language state</a> has already been successfully processed (i.e. when it was inserted the user agent processed it and reached the last step of this list of steps), then abort these steps.</li> <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that attribute's value is the empty string, then abort these steps.</li> <li><p>If the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute contains a U+002C COMMA character (,) then abort these steps.</li><!-- if you remove this, un-comment-out the corresponding bits in the step below. --> <li><p>Let <var title="">input</var> be the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute.</li> <li><p>Let <var title="">position</var> point at the first character of <var title="">input</var>.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p><a href=#collect-a-sequence-of-characters title="collect a sequence of characters">Collect a sequence of characters</a> that are not<!--neither--> <a href=#space-character title="space character">space characters</a><!-- nor a U+002C COMMA character (,)-->.</li> <li><p>Let the <a href=#pragma-set-default-language>pragma-set default language</a> be the string that resulted from the previous step.</li> </ol><p class=note>This pragma is not exactly equivalent to the HTTP <code>Content-Language</code> header. <a href=#refsHTTP>[HTTP]</a></p> </dd> <dt><dfn id=attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</dfn> (<code title="">http-equiv="content-type"</code>) <dd> <p>The <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a> is just an alternative form of setting the <code title=meta-charset>charset</code> attribute: it is a <a href=#character-encoding-declaration>character encoding declaration</a>. <span class=impl>This state's user agent requirements are all handled by the parsing section of the specification.</span></p> <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>, the <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute must have a value that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for a string that consists of: the literal string "<code title="">text/html;</code>", optionally followed by any number of <a href=#space-character title="space character">space characters</a>, followed by the literal string "<code title="">charset=</code>", followed by the character encoding name of the <a href=#character-encoding-declaration>character encoding declaration</a>.</p> <p>A document must not contain both a <code><a href=#the-meta-element>meta</a></code> element with an <code title=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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a> and a <code><a href=#the-meta-element>meta</a></code> element with the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute present.</p> <p>The <a href=#attr-meta-http-equiv-content-type title=attr-meta-http-equiv-content-type>Encoding declaration state</a> may be used in <a href=#html-documents>HTML documents</a>, but elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in that state must not be used in <a href=#xml-documents>XML documents</a>.</p> </dd> <dt><dfn id=attr-meta-http-equiv-default-style title=attr-meta-http-equiv-default-style>Default style state</dfn> (<code title="">http-equiv="default-style"</code>) <dd> <p>This pragma sets the name of the default <a href=#alternative-style-sheet-sets title="alternative style sheet sets">alternative style sheet set</a>.</p> <div class=impl> <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that attribute's value is the empty string, then abort these steps.</li> <li><p>Set the <a href=#preferred-style-sheet-set>preferred style sheet set</a> to the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute. <a href=#refsCSSOM>[CSSOM]</a></li> </ol></div> </dd> <dt><dfn id=attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</dfn> (<code title="">http-equiv="refresh"</code>) <dd> <p>This pragma acts as timed redirect.</p> <div class=impl> <ol><!-- TESTS: http://www.hixie.ch/tests/adhoc/html/meta/refresh/ --><!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/734 --><li><p>If another <code><a href=#the-meta-element>meta</a></code> element with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the <a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a> has already been successfully processed (i.e. when it was inserted the user agent processed it and reached the last step of this list of steps), then abort these steps.</li> <li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that attribute's value is the empty string, then abort these steps.</li> <li><p>Let <var title="">input</var> be the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute.</li> <li><p>Let <var title="">position</var> point at the first character of <var title="">input</var>.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p><a href=#collect-a-sequence-of-characters title="collect a sequence of characters">Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and parse the resulting string using the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a>. If the sequence of characters collected is the empty string, then no number will have been parsed; abort these steps. Otherwise, let <var title="">time</var> be the parsed number.</li> <li><p><a href=#collect-a-sequence-of-characters title="collect a sequence of characters">Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) and U+002E FULL STOP (.). Ignore any collected characters.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>Let <var title="">url</var> be the address of the current page.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is a U+003B SEMICOLON ("<code title="">;</code>"), then advance <var title="">position</var> to the next character. Otherwise, jump to the last step.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is a U+0055 LATIN CAPITAL LETTER U character (U) or a U+0075 LATIN SMALL LETTER U character (u), then advance <var title="">position</var> to the next character. Otherwise, jump to the last step.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is a U+0052 LATIN CAPITAL LETTER R character (R) or a U+0072 LATIN SMALL LETTER R character (r), then advance <var title="">position</var> to the next character. Otherwise, jump to the last step.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is s U+004C LATIN CAPITAL LETTER L character (L) or a U+006C LATIN SMALL LETTER L character (l), then advance <var title="">position</var> to the next character. Otherwise, jump to the last step.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is a U+003D EQUALS SIGN ("<code title="">=</code>"), then advance <var title="">position</var> to the next character. Otherwise, jump to the last step.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If the character in <var title="">input</var> pointed to by <var title="">position</var> is either a U+0027 APOSTROPHE character (') or U+0022 QUOTATION MARK character ("), then let <var title="">quote</var> be that character, and advance <var title="">position</var> to the next character. Otherwise, let <var title="">quote</var> be the empty string.</li> <li><p>Let <var title="">url</var> be equal to the substring of <var title="">input</var> from the character at <var title="">position</var> to the end of the string.</li> <li><p>If <var title="">quote</var> is not the empty string, and there is a character in <var title="">url</var> equal to <var title="">quote</var>, then truncate <var title="">url</var> at that character, so that it and all subsequent characters are removed.</p> <li><p>Strip any trailing <a href=#space-character title="space character">space characters</a> from the end of <var title="">url</var>.</li> <li><p>Strip any U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), and U+000D CARRIAGE RETURN (CR) characters from <var title="">url</var>.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">url</var> value to an <a href=#absolute-url>absolute URL</a>, relative to the <code><a href=#the-meta-element>meta</a></code> element. If this fails, abort these steps.</li> <li> <p>Perform one or more of the following steps:</p> <ul><li> <p>After the refresh has come due (as defined below), if the user has not canceled the redirect and if the <code><a href=#the-meta-element>meta</a></code> element's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-automatic-features-browsing-context-flag>sandboxed automatic features browsing context flag</a> set when the <code><a href=#document>Document</a></code> was created, <a href=#navigate title=navigate>navigate</a><!--DONAV meta refresh--> the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> to <var title="">url</var>, with <a href=#replacement-enabled>replacement enabled</a>, and with the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> as the <a href=#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 title="">time</var> seconds have elapsed since the document has <a href=#completely-loaded>completely loaded</a>, adjusted to take into account user or user agent preferences.</li> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/774 --> <li>At least <var title="">time</var> seconds have elapsed since the <code><a href=#the-meta-element>meta</a></code> element was <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the <code>Document</code></a>, adjusted to take into account user or user agent preferences.</li> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/772 --> </ul></li> <li><p>Provide the user with an interface that, when selected, <a href=#navigate title=navigate>navigates</a><!--DONAV meta refresh--> a <a href=#browsing-context>browsing context</a> to <var title="">url</var>, with the document's browsing context as the <a href=#source-browsing-context>source browsing context</a>.</li> <li><p>Do nothing.</li> </ul><p>In addition, the user agent may, as with anything, inform the user of any and all aspects of its operation, including the state of any timers, the destinations of any timed redirects, and so forth.</p> </li> </ol></div> <p>For <code><a href=#the-meta-element>meta</a></code> elements with an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute in the <a href=#attr-meta-http-equiv-refresh title=attr-meta-http-equiv-refresh>Refresh state</a>, the <code title=attr-meta-content><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>valid non-negative integer</a>, or</li> <li>a <a href=#valid-non-negative-integer>valid non-negative integer</a>, followed by a U+003B SEMICOLON character (;), followed by one or more <a href=#space-character title="space character">space characters</a>, followed by a substring that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">URL</code>", followed by a U+003D EQUALS SIGN character (=), followed by a <a href=#valid-url>valid URL</a> that does not start with a literal U+0027 APOSTROPHE (') or U+0022 QUOTATION MARK (") character.</li> </ul><p>In the former case, the integer represents a number of seconds before the page is to be reloaded; in the latter case the integer represents a number of seconds before the page is to be replaced by the page at the given <a href=#url>URL</a>.</p> <div class=example> <p>A news organization's front page could include the following markup in the page's <code><a href=#the-head-element>head</a></code> element, to ensure that the page automatically reloads from the server every five minutes:</p> <pre><meta http-equiv="Refresh" content="300"></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><meta http-equiv="Refresh" content="20; URL=page4.html"></pre> </div> </dd> <dt class=impl><dfn id=attr-meta-http-equiv-set-cookie title=attr-meta-http-equiv-set-cookie>Cookie setter</dfn> (<code title="">http-equiv="set-cookie"</code>) <dd class=impl> <p>This pragma sets an HTTP cookie. <a href=#refsCOOKIES>[COOKIES]</a></p> <p>It is non-conforming. Real HTTP headers should be used instead.</p> <ol><li><p>If the <code><a href=#the-meta-element>meta</a></code> element has no <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, or if that attribute's value is the empty string, then abort these steps.</li> <li><p><a href=#obtain-the-storage-mutex>Obtain the storage mutex</a>.</li> <li><p>Act as if <a href=#receives-a-set-cookie-string title="receives a set-cookie-string">receiving a set-cookie-string</a> for <a href="#the-document's-address">the document's address</a> via a "non-HTTP" API, consisting of the value of the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute encoded as UTF-8. <a href=#refsCOOKIES>[COOKIES]</a> <a href=#refsRFC3629>[RFC3629]</a></li> </ol></dd> </dl><p>There must not be more than one <code><a href=#the-meta-element>meta</a></code> element with any particular state in the document at a time.</p> <h5 id=other-pragma-directives><span class=secno>4.2.5.4 </span>Other pragma directives</h5> <p><dfn id=concept-http-equiv-extensions title=concept-http-equiv-extensions>Extensions to the predefined set of pragma directives</dfn> may, under certain conditions, be registered in the <a href=http://wiki.whatwg.org/wiki/PragmaExtensions>WHATWG Wiki PragmaExtensions page</a>. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a></p> <p>Such extensions must use a name that is identical to an HTTP header registered in the Permanent Message Header Field Registry, and must have behavior identical to that described for the HTTP header. <a href=#refsIANAPERMHEADERS>[IANAPERMHEADERS]</a></p> <p>Pragma directives corresponding to headers describing metadata, or not requiring specific user agent processing, must not be registered; instead, use <a href=#concept-meta-extensions title=concept-meta-extensions>metadata names</a>. Pragma directives corresponding to headers that affect the HTTP processing model (e.g. caching) must not be registered, as they would result in HTTP-level behavior being different for user agents that implement HTML than for user agents that do not.</p> <p>Anyone is free to edit the WHATWG Wiki PragmaExtensions page at any time to add a pragma directive satisfying these conditions. Such registrations must specify the following information:</p> <dl><dt>Keyword</dt> <dd><p>The actual name being defined. The name must match a previously-registered HTTP name with the same requirements.</dd> <dt>Brief description</dt> <dd><p>A short non-normative description of the purpose of the pragma directive.</dd> <dt>Specification</dt> <dd>A link to the specification defining the corresponding HTTP header.</dd> </dl><div class=impl> <p>Conformance checkers must use the information given on the WHATWG Wiki PragmaExtensions page to establish if a value is allowed or not: values defined in this specification or listed on the aforementioned page must be accepted, whereas values 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> </div> <h5 id=charset><span class=secno>4.2.5.5 </span>Specifying the document's character encoding</h5> <!-- READ ME WHEN EDITING: if we ever move this to the "writing HTML" section, then we have to duplicate the requirements in the parsing section for conformance checkers, and we have to make sure that the requirements for charset="" apply even in XML, for the polyglot hack. --> <p>A <dfn id=character-encoding-declaration>character encoding declaration</dfn> is a mechanism by which the character encoding used to store or transmit a document is specified.</p> <p>The following restrictions apply to character encoding declarations:</p> <ul><li>The character encoding name given must be the name of the character encoding used to serialize the file.</li> <li>The value must be a valid character encoding name, and must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the <a href=#preferred-mime-name>preferred MIME name</a> for that encoding. <a href=#refsIANACHARSET>[IANACHARSET]</a></li> <li>The character encoding declaration must be serialized without the use of <a href=#syntax-charref title=syntax-charref>character references</a> or character escapes of any kind.</li> <li id=charset1024><span id=charset512 title="">The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.</span></li> <!-- span is for historical reasons, to keep an old ID alive --> </ul><p>In addition, due to a number of restrictions on <code><a href=#the-meta-element>meta</a></code> elements, there can only be one <code><a href=#the-meta-element>meta</a></code>-based character encoding declaration per document.</p> <!-- conformance criteria for this one are given in the XML spec, the <meta> section just after defining charset="", and the character encoding pragma section. Note that you _can_ have two character encoding declaration per document, if the document is an XML document and one is an XML declaration, the other is <meta charset>, and the encoding is UTF-8. --> <p>If an <a href=#html-documents title="HTML documents">HTML document</a> does not start with a BOM, and if its encoding is not explicitly given by <a href=#content-type title=Content-Type>Content-Type metadata</a>, and the document is not <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, then the character encoding used must be an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>, and, in addition, if that encoding isn't US-ASCII itself, then the encoding must be specified using a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a <code><a href=#the-meta-element>meta</a></code> element with an <code title=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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>.</p> <p>If the document is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, the document must not have a <a href=#character-encoding-declaration>character encoding declaration</a>. (In this case, the source is already decoded, since it is part of the document that contained the <code><a href=#the-iframe-element>iframe</a></code>.)</p> <p>If an <a href=#html-documents title="HTML documents">HTML document</a> contains a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute or a <code><a href=#the-meta-element>meta</a></code> element with an <code title=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 title=attr-meta-http-equiv-content-type>Encoding declaration state</a>, then the character encoding used must be an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>.</p> <p>Authors are encouraged to use UTF-8. Conformance checkers may advise authors against using legacy encodings. <a href=#refsRFC3629>[RFC3629]</a></p> <div class=impl> <p>Authoring tools should default to using UTF-8 for newly-created documents. <a href=#refsRFC3629>[RFC3629]</a></p> </div> <p>Encodings in which a series of bytes in the range 0x20 to 0x7E can encode characters other than the corresponding characters in the range U+0020 to U+007E represent a potential security vulnerability: a user agent that does not support the encoding (or does not support the label used to declare the encoding, or does not use the same mechanism to detect the encoding of unlabelled content as another user agent) might end up interpreting technically benign plain text content as HTML tags and JavaScript. For example, this applies to encodings in which the bytes corresponding to "<code title=""><script></code>" in ASCII can encode a different string. Authors should not use such encodings, which are known to include JIS_C6226-1983<!-- aka JIS-X-0208, x-JIS0208 -->, JIS_X0212-1990<!-- aka JIS-X-0212 -->, HZ-GB-2312<!-- has crazy handling of ASCII "~" -->, JOHAB <!-- a supplementary encoding in KS C 5601-1992 Annex 3 (= KS X 1001:1998 Annex 3) --> (Windows code page 1361), encodings based on ISO-2022<!-- http://krijnhoetmer.nl/irc-logs/whatwg/20090628#l-422 and http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-October/023797.html -->, and encodings based on EBCDIC. Furthermore, authors must not use the CESU-8, UTF-7, BOCU-1 and SCSU encodings, which also fall into this category, because these encodings were never intended for use for Web content. <a href=#refsRFC1345>[RFC1345]</a><!-- for the JIS types --> <a href=#refsRFC1842>[RFC1842]</a><!-- HZ-GB-2312 --> <a href=#refsRFC1468>[RFC1468]</a><!-- ISO-2022-JP --> <a href=#refsRFC2237>[RFC2237]</a><!-- ISO-2022-JP-1 --> <a href=#refsRFC1554>[RFC1554]</a><!-- ISO-2022-JP-2 --> <a href=#refsCP50220>[CP50220]</a><!-- CP50220, the compatibility replacement for ISO-2022-JP --> <a href=#refsRFC1922>[RFC1922]</a><!-- ISO-2022-CN and ISO-2022-CN-EXT --> <a href=#refsRFC1557>[RFC1557]</a><!-- ISO-2022-KR --> <a href=#refsCESU8>[CESU8]</a> <a href=#refsUTF7>[UTF7]</a> <a href=#refsBOCU1>[BOCU1]</a> <a href=#refsSCSU>[SCSU]</a> <!-- no idea what to reference for JOHAB or EBCDIC, so... --> </p> <p>Authors should not use UTF-32, as the encoding detection algorithms described in this specification intentionally do not distinguish it from UTF-16. <a href=#refsUNICODE>[UNICODE]</a></p> <p class=note>Using non-UTF-8 encodings can have unexpected results on form submission and URL encodings, which use the <a href="#document's-character-encoding">document's character encoding</a> by default.</p> <p>In XHTML, 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 UTF-8, the author could include the following markup near the top of the document (in the <code><a href=#the-head-element>head</a></code> element):</p> <pre><meta charset="utf-8"></pre> <p>In XML, the XML declaration would be used instead, at the very top of the markup:</p> <pre><?xml version="1.0" encoding="utf-8"?></pre> </div> <h4 id=the-style-element><span class=secno>4.2.6 </span>The <dfn><code>style</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: <a href=#flow-content>flow content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: where <a href=#metadata-content>metadata content</a> is expected.</dd> <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is absent: in a <code><a href=#the-noscript-element>noscript</a></code> element that is a child of a <code><a href=#the-head-element>head</a></code> element.</dd> <dd>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present: where <a href=#flow-content>flow content</a> is expected, but before any other <a href=#flow-content>flow content</a> other than <a href=#inter-element-whitespace>inter-element whitespace</a>, and not as the child of an element whose content model is <a href=#transparent>transparent</a>.</dd> <dt>Content model:</dt> <dd>Depends on the value of the <code title=attr-style-type><a href=#attr-style-type>type</a></code> attribute, but must match requirements described in prose below.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-style-media><a href=#attr-style-media>media</a></code></dd> <dd><code title=attr-style-type><a href=#attr-style-type>type</a></code></dd> <dd><code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code></dd> <dd>Also, the <code title=attr-style-title><a href=#attr-style-title>title</a></code> attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlstyleelement>HTMLStyleElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-style-disabled title=dom-style-disabled>disabled</a>; attribute DOMString <a href=#dom-style-media title=dom-style-media>media</a>; attribute DOMString <a href=#dom-style-type title=dom-style-type>type</a>; attribute boolean <a href=#dom-style-scoped title=dom-style-scoped>scoped</a>; }; <a href=#htmlstyleelement>HTMLStyleElement</a> implements <a href=#linkstyle>LinkStyle</a>;</pre> </dd> </dl><p>The <code><a href=#the-style-element>style</a></code> element allows authors to embed style information in their documents. The <code><a href=#the-style-element>style</a></code> element is one of several inputs to the <a href=#styling>styling processing model</a>. The element does not <a href=#represents title=represents>represent</a> content for the user.</p> <p>The <dfn id=attr-style-type title=attr-style-type><code>type</code></dfn> attribute gives the styling language. If the attribute is present, its value must be a <a href=#valid-mime-type>valid MIME type</a> that designates a styling language. The <code title="">charset</code> parameter must not be specified. The default value for the <code title=attr-style-type><a href=#attr-style-type>type</a></code> attribute, which is used if the attribute is absent, is "<code title="">text/css</code>". <a href=#refsRFC2318>[RFC2318]</a></p> <div class=impl> <!-- this paragraph is also present in the <script> section --> <p>When examining types to determine if they support the language, user agents must not ignore unknown MIME parameters — types with unknown parameters must be assumed to be unsupported. The <code title="">charset</code> parameter must be treated as an unknown parameter for the purpose of comparing <a href=#mime-type title="MIME type">MIME types</a> here.</p> </div> <p>The <dfn id=attr-style-media title=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>valid media query</a>. <span class=impl>The user agent must apply the styles when the <code title=attr-style-media><a href=#attr-style-media>media</a></code> attribute's value <a href=#matches-the-environment>matches the environment</a> and the other relevant conditions apply, and must not apply them otherwise.</span></p><!-- note similar text in <link> section --> <div class=impl> <p class=note>The styles might be further limited in scope, e.g. in CSS with the use of <code title="">@media</code> blocks. This specification does not override such further restrictions or requirements.</p><!-- note similar text in <link> section --> </div> <p id=style-default-media>The default, if the <code title=attr-style-media><a href=#attr-style-media>media</a></code> attribute is omitted, is "<code title="">all</code>", meaning that by default styles apply to all media.</p> <p>The <dfn id=attr-style-scoped title=attr-style-scoped><code>scoped</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. If present, it indicates that the styles are intended just for the subtree rooted at the <code><a href=#the-style-element>style</a></code> element's parent element, as opposed to the whole <code><a href=#document>Document</a></code>.</p> <p>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present and the element has a parent element, then the <code><a href=#the-style-element>style</a></code> element must be the first node of <a href=#flow-content>flow content</a> in its parent element other than <a href=#inter-element-whitespace>inter-element whitespace</a>, and the parent element's content model must not have a <a href=#transparent>transparent</a> component.</p> <p class=note>This implies that only one scoped <code><a href=#the-style-element>style</a></code> element is allowed at a time, and that such elements cannot be children of, e.g., <code><a href=#the-a-element>a</a></code> or <code><a href=#the-ins-element>ins</a></code> elements, even when those are used as <a href=#flow-content>flow content</a> containers.</p> <div class=impl> <p>If the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present, then the user agent must apply the specified style information only to the <code><a href=#the-style-element>style</a></code> element's parent element (if any), and that element's descendants. Otherwise, the specified styles must, if applied, be applied to the entire document.</p> <p>For scoped CSS resources, the effect of @-rules must be scoped to the scoped sheet and its subresources, even if the @-rule in question would ordinarily apply to all style sheets that affect the <code><a href=#document>Document</a></code>. Any '@page' rules in scoped CSS resources must be ignored.</p> <p class=example>For example, an '@font-face' rule defined in a scoped style sheet would only define the font for the purposes of font rules in the scoped section; style sheets outside the scoped section using the same font name would not end up using that embedded font.</p> </div> <p id=title-on-style>The <dfn id=attr-style-title title=attr-style-title><code>title</code></dfn> attribute on <code><a href=#the-style-element>style</a></code> elements defines <a href=#alternative-style-sheet-sets>alternative style sheet sets</a>. If the <code><a href=#the-style-element>style</a></code> element has no <code title=attr-style-title><a href=#attr-style-title>title</a></code> attribute, then it has no title; the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of ancestors does not apply to the <code><a href=#the-style-element>style</a></code> element. <a href=#refsCSSOM>[CSSOM]</a></p> <p class=note>The <code title=attr-style-title><a href=#attr-style-title>title</a></code> attribute on <code><a href=#the-style-element>style</a></code> elements, like the <code title=attr-link-title><a href=#attr-link-title>title</a></code> attribute on <code><a href=#the-link-element>link</a></code> elements, differs from the global <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute in that a <code><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 <code><a href=#textcontent>textContent</a></code> of a <code><a href=#the-style-element>style</a></code> element must match the <code title="">style</code> production in the following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p> <pre>style = no-c-start *( c-start no-c-end c-end no-c-start ) no-c-start = <any string that doesn't contain a substring that matches c-start > c-start = "<!--" no-c-end = <any string that doesn't contain a substring that matches c-end > c-end = "-->"</pre> <!-- Unmatched comment-like syntax is invalid on a temporary basis, waiting for IE, WebKit, and Opera to fix their parsing bug whereby such comments trigger a weird escape in which </style> is ignored. Otherwise, parsing behaviour in those browsers could differ substantially from the parsing behaviour of HTML5. Once everyone follows the HTML5 spec, we can drop this requirement. --> <div class=impl> <p>All descendant elements must be processed, according to their semantics, before the <code><a href=#the-style-element>style</a></code> element itself is evaluated. For styling languages that consist of pure text (as opposed to XML), user agents must evaluate <code><a href=#the-style-element>style</a></code> elements by passing the concatenation of the contents of all the <a href=#text-node title="text node">text nodes</a> that are children of the <code><a href=#the-style-element>style</a></code> element (not any other nodes such as comments or elements), in <a href=#tree-order>tree order</a>, to the style system. For XML-based styling languages, user agents must pass all the child nodes of the <code><a href=#the-style-element>style</a></code> element to the style system.</p> <p>All <a href=#url title=URL>URLs</a> found by the styling language's processor must be <a href=#resolve-a-url title="resolve a url">resolved</a>, relative to the element (or as defined by the styling language), when the processor is invoked.<!-- so dynamic changes to the base URL don't affect the CSS --></p> <!-- the next few paragraph are similar to text in the <style> section --> <p>Once the attempts to obtain the style sheet's <a href=#critical-subresources>critical subresources</a>, if any, are complete, or, if the style sheet has no <a href=#critical-subresources>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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-style-element>style</a></code> element, or, if one of the style sheet's <a href=#critical-subresources>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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><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>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the element's document until all the attempts to obtain the style sheet's <a href=#critical-subresources>critical subresources</a>, if any, are complete.</p> </div> <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> <div class=impl> <p>The <dfn id=dom-style-media title=dom-style-media><code>media</code></dfn>, <dfn id=dom-style-type title=dom-style-type><code>type</code></dfn> and <dfn id=dom-style-scoped title=dom-style-scoped><code>scoped</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <p>The <dfn id=dom-style-disabled title=dom-style-disabled><code>disabled</code></dfn> IDL attribute behaves as defined <a href=#dom-linkstyle-disabled title=dom-linkstyle-disabled>for the alternative style sheets DOM</a>.</p> <p>The <code><a href=#linkstyle>LinkStyle</a></code> interface is also implemented by this element; the <a href=#styling>styling processing model</a> defines how. <a href=#refsCSSOM>[CSSOM]</a></p> <div class=example> <p>The following document has its 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><!DOCTYPE html> <html lang="en-US"> <head> <title>My favorite book</title> <style> body { color: black; background: white; } em { font-style: normal; color: red; } </style> </head> <body> <p>My <em>favorite</em> book of all time has <em>got</em> to be <cite>A Cat's Life</cite>. It is a book by P. Rahmel that talks about the <i lang="la">Felis Catus</i> in modern human society.</p> </body> </html></pre> </div> <h4 id=styling><span class=secno>4.2.7 </span><dfn title="styling processing model">Styling</dfn></h4> <p>The <code><a href=#the-link-element>link</a></code> and <code><a href=#the-style-element>style</a></code> elements can provide styling information for the user agent to use when rendering the document. The CSS and CSSOM specifications specify what styling information is to be used by the user agent and how it is to be used. <a href=#refsCSS>[CSS]</a> <a href=#refsCSSOM>[CSSOM]</a></p> <p>The <code><a href=#the-style-element>style</a></code> and <code><a href=#the-link-element>link</a></code> elements implement the <code><a href=#linkstyle>LinkStyle</a></code> interface. <a href=#refsCSSOM>[CSSOM]</a></p> <div class=impl> <p>For <code><a href=#the-style-element>style</a></code> elements, if the user agent does not support the specified styling language, then the <code title=dom-LinkStyle-sheet><a href=#dom-linkstyle-sheet>sheet</a></code> attribute of the element's <code><a href=#linkstyle>LinkStyle</a></code> interface must return null. Similarly, <code><a href=#the-link-element>link</a></code> elements that do not represent <a href=#link-type-stylesheet title=rel-stylesheet>external resource links that contribute to the styling processing model</a> (i.e. that do not have a <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> keyword in their <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute), or for which <a href=#the-link-is-an-alternative-stylesheet>the link is an alternative stylesheet</a> but whose <code title=dom-title><a href=#dom-title>title</a></code> content attribute is absent or empty, must have their <code><a href=#linkstyle>LinkStyle</a></code> interface's <code title=dom-LinkStyle-sheet><a href=#dom-linkstyle-sheet>sheet</a></code> attribute return null.</p> <p>Otherwise, the <code><a href=#linkstyle>LinkStyle</a></code> interface's <code title=dom-LinkStyle-sheet><a href=#dom-linkstyle-sheet>sheet</a></code> attribute must return a <code><a href=#stylesheet>StyleSheet</a></code> object with the following properties: <a href=#refsCSSOM>[CSSOM]</a></p> <dl><dt>The style sheet type</dt> <dd><p>The style sheet type must be the same as the style's specified type. For <code><a href=#the-style-element>style</a></code> elements, this is the same as the <code title=attr-style-type><a href=#attr-style-type>type</a></code> content attribute's value, or <code title="">text/css</code> if that is omitted. For <code><a href=#the-link-element>link</a></code> elements, this is the <a href=#content-type title=Content-Type>Content-Type metadata of the specified resource</a>.</dd> <dt>The style sheet location</dt> <dd><p>For <code><a href=#the-link-element>link</a></code> elements, the location must be the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> given by the element's <code title=attr-link-href><a href=#attr-link-href>href</a></code> content attribute, relative to the element, or the empty string if that fails. For <code><a href=#the-style-element>style</a></code> elements, there is no location.</dd> <!-- note that this might not match the style sheet URL, if the base URL has changed for instance --> <dt>The style sheet media</dt> <dd><p>The media must be the same as the value of the element's <code title="">media</code> content attribute, or the empty string, if the attribute is omitted.</dd> <dt>The style sheet title</dt> <dd><p>The title must be the same as the value of the element's <code title=dom-title><a href=#dom-title>title</a></code> content attribute, if the attribute is present and has a non-empty value. If the attribute is absent or its value is the empty string, then the style sheet does not have a title (it is the empty string). The title is used for defining <a href=#alternative-style-sheet-sets>alternative style sheet sets</a>.</dd> <dt>The style sheet alternate flag</dt> <dd><p>For <code><a href=#the-link-element>link</a></code> elements, true if <a href=#the-link-is-an-alternative-stylesheet>the link is an alternative stylesheet</a>. In all other cases, false.</dd> <!-- <dt>The style sheet disabled flag</dt> (not included, because I assume CSSOM will change to not require this spec to initialise the value, but will instead initialise it based on the other values) --> </dl><p>The same object must be returned each time.</p> <p>The <dfn id=dom-linkstyle-disabled title=dom-LinkStyle-disabled><code>disabled</code></dfn> IDL attribute on <code><a href=#the-link-element>link</a></code> and <code><a href=#the-style-element>style</a></code> elements must return false and do nothing on setting, if the <code title=dom-linkstyle-sheet><a href=#dom-linkstyle-sheet>sheet</a></code> attribute of their <code><a href=#linkstyle>LinkStyle</a></code> interface is null. Otherwise, it must return the value of the <code><a href=#stylesheet>StyleSheet</a></code> interface's <code title=dom-stylesheet-disabled><a href=#dom-stylesheet-disabled>disabled</a></code> attribute on getting, and forward the new value to that same attribute on setting.</p> <!-- [CSSOM] covers the following: the term "alternative style sheet sets", the term "default style sheet set", preferred stylesheets, alternative stylesheets, persistent stylesheets, ordering of stylesheets, dynamic additions/removals, window.styleSheets, style sheets given by HTTP Link: headers, and the alternative style sheet API --> <p id=alternate-style-sheets>The rules for handling alternative style sheets are defined in the CSS object model specification. <a href=#refsCSSOM>[CSSOM]</a></p> <hr><p>Style sheets, whether added by a <code><a href=#the-link-element>link</a></code> element, a <code><a href=#the-style-element>style</a></code> element, an <code><?xml-stylesheet></code> PI, an HTTP <code title=http-link>Link:</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>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><a href=#the-style-element>style</a></code> element with no <code title="">@import</code> rules), then the style rules must be synchronously made available to script; otherwise, the style rules must only be made available to script once the <a href=#event-loop>event loop</a> reaches its "update the rendering" step.</p> <p>A style sheet in the context of the <code><a href=#document>Document</a></code> of an <a href=#html-parser>HTML parser</a> or <a href=#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 the element was created by that <code><a href=#document>Document</a></code>'s parser, and the element is either a <code><a href=#the-style-element>style</a></code> element or a <code><a href=#the-link-element>link</a></code> element that was an <a href=#link-type-stylesheet title=rel-stylesheet>external resource link that contributes to the styling processing model</a> when the element was created by the parser, and the element's style sheet was enabled when the element was created by the parser, and the element's <a href=#style-sheet-ready>style sheet ready</a> flag is not yet set, and, the last time the <a href=#event-loop>event loop</a> reached step 1, the element was <a href=#in-a-document title="in a document">in that <code>Document</code></a>, and 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.</p> <p class=note>Giving up on a style sheet before the style sheet loads, if the style sheet eventually does still load, means that the script might end up operating with incorrect information. For example, if a style sheet sets the color of an element to green, but a script that inspects the resulting style is executed before the sheet is loaded, the script will find that the element is black (or whatever the default color is), and might thus make poor choices (e.g. deciding to use black as the color elsewhere on the page, instead of green). 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><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>a style sheet that is blocking scripts</a> in the context of that <code><a href=#document>Document</a></code>, or if that <code><a href=#document>Document</a></code> is in a <a href=#browsing-context>browsing context</a> that has a <a href=#parent-browsing-context>parent browsing context</a>, and the <a href=#active-document>active document</a> of that <a href=#parent-browsing-context>parent browsing context</a> itself <a href=#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking scripts</a>.</p> <p>A <code><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 title="has a style sheet that is blocking scripts">have a style sheet that is blocking scripts</a> as defined in the previous paragraph.</p> </div> <h3 id=scripting-1><span class=secno>4.3 </span>Scripting</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><a href=#the-details-element>details</a></code> element could be used.</p> </div> <p>Authors are also encouraged to make their applications degrade gracefully in the absence of scripting support.</p> <div class=example> <p>For example, if an author provides a link in a table header to dynamically resort the table, the link could also be made to function without scripts by requesting the sorted table from the server.</p> </div> <h4 id=the-script-element><span class=secno>4.3.1 </span>The <dfn id=script><code>script</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>If there is no <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, depends on the value of the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, but must match <a href=#restrictions-for-contents-of-script-elements>script content restrictions</a>.</dd> <dd>If there <em>is</em> a <code title=attr-script-src><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>script documentation</a> that also matches <a href=#restrictions-for-contents-of-script-elements>script content restrictions</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-script-src><a href=#attr-script-src>src</a></code></dd> <dd><code title=attr-script-async><a href=#attr-script-async>async</a></code></dd> <dd><code title=attr-script-defer><a href=#attr-script-defer>defer</a></code></dd> <dd><code title=attr-script-type><a href=#attr-script-type>type</a></code></dd> <dd><code title=attr-script-charset><a href=#attr-script-charset>charset</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlscriptelement>HTMLScriptElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-script-src title=dom-script-src>src</a>; attribute boolean <a href=#dom-script-async title=dom-script-async>async</a>; attribute boolean <a href=#dom-script-defer title=dom-script-defer>defer</a>; attribute DOMString <a href=#dom-script-type title=dom-script-type>type</a>; attribute DOMString <a href=#dom-script-charset title=dom-script-charset>charset</a>; attribute DOMString <a href=#dom-script-text title=dom-script-text>text</a>; };</pre> </dd> </dl><p>The <code><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 title=represents>represent</a> content for the user.</p> <p>When used to include dynamic scripts, the scripts may either be embedded inline or may be imported from an external file using the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute. If the language is not that described by "<code title="">text/javascript</code>", then the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must be present, as described below. Whatever language is used, the contents of the <code><a href=#the-script-element>script</a></code> element must conform with the requirements of that language's specification.</p> <p>When used to include data blocks (as opposed to scripts), the data must be embedded inline, the format of the data must be given using the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute must not be specified, and the contents of the <code><a href=#the-script-element>script</a></code> element must conform to the requirements defined for the format used.</p> <p>The <dfn id=attr-script-type title=attr-script-type><code>type</code></dfn> attribute gives the language of the script or format of the data. If the attribute is present, its value must be a <a href=#valid-mime-type>valid MIME type</a>. The <code title="">charset</code> parameter must not be specified. The default, which is used if the attribute is absent, is "<code title="">text/javascript</code>".</p> <p>The <dfn id=attr-script-src title=attr-script-src><code>src</code></dfn> attribute, if specified, gives the address of the external script resource to use. The value of the attribute must be a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by spaces</a> identifying a script resource of the type given by the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, if the attribute is present, or of the type "<code title="">text/javascript</code>", if the attribute is absent. A resource is a script resource of a given type if that type identifies a scripting language and the resource conforms with the requirements of that language's specification.</p> <p>The <dfn id=attr-script-charset title=attr-script-charset><code>charset</code></dfn> attribute gives the character encoding of the external script resource. The attribute must not be specified if the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is not present. If the attribute is set, its value must be a valid character encoding name, must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the <a href=#preferred-mime-name>preferred MIME name</a> for that encoding, and must match the encoding given in the <code title="">charset</code> parameter of the <a href=#content-type title=Content-Type>Content-Type metadata</a> of the external file, if any. <a href=#refsIANACHARSET>[IANACHARSET]</a></p> <p>The <dfn id=attr-script-async title=attr-script-async><code>async</code></dfn> and <dfn id=attr-script-defer title=attr-script-defer><code>defer</code></dfn> attributes are <a href=#boolean-attribute title="boolean attribute">boolean attributes</a> that indicate how the script should be executed. The <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> and <code title=attr-script-async><a href=#attr-script-async>async</a></code> attributes must not be specified if the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is not present.</p> <p>There are three possible modes that can be selected using these attributes. If the <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute is present, then the script will be executed asynchronously, as soon as it is available. If the <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute is not present but the <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> attribute is present, then the script is executed when the page has finished parsing. If neither attribute is present, then the script is fetched and executed immediately, before the user agent continues parsing the page.</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><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 title=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 title=attr-script-defer><a href=#attr-script-defer>defer</a></code> attribute may be specified even if the <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute is specified, to cause legacy Web browsers that only support <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> (and not <code title=attr-script-async><a href=#attr-script-async>async</a></code>) to fall back to the <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> behavior instead of the synchronous blocking behavior that is the default.</p> <p>Changing the <code title=attr-script-src><a href=#attr-script-src>src</a></code>, <code title=attr-script-type><a href=#attr-script-type>type</a></code>, <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code>, <code title=attr-script-async><a href=#attr-script-async>async</a></code>, and <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> attributes dynamically has no direct effect; these attribute are only used at specific times described below.</p> <!-- by implication, changes to the base URL also have no effect --> <div class=impl> <p>A <code><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><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=#concept-node-clone-ext title=concept-node-clone-ext>cloning steps</a> for <code><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 id=parser-inserted>"parser-inserted"</dfn>. Initially, <code><a href=#the-script-element>script</a></code> elements must have this flag unset. It is set by the <a href=#html-parser>HTML parser</a> and the <a href=#xml-parser>XML parser</a> on <code><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 <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#the-script-element>script</a></code> elements must have this flag set. It is unset by the <a href=#html-parser>HTML parser</a> and the <a href=#xml-parser>XML parser</a> on <code><a href=#the-script-element>script</a></code> elements they insert. In addition, whenever a <code><a href=#the-script-element>script</a></code> element whose <a href=#force-async>"force-async"</a> flag is set has a <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute added, the element's <a href=#force-async>"force-async"</a> flag must be unset.</p> <!-- there's no need to unset it when the attribute is removed since you can't have the attribute and the flag set at once. --> <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><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>"parser-inserted"</a>, to let the parser know when to execute the script.</p> <p>The last few pieces of state are <dfn id="the-script-block's-type"><var>the script block's type</var></dfn>, <dfn id="the-script-block's-character-encoding"><var>the script block's character encoding</var></dfn>, and <dfn id="the-script-block's-fallback-character-encoding"><var>the script block's fallback character encoding</var></dfn>. They are determined when the script is prepared, based on the attributes on the element at that time, and the <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code> element.</p> <p>When a <code><a href=#the-script-element>script</a></code> element that is not marked as being <a href=#parser-inserted>"parser-inserted"</a> experiences one of the events listed in the following list, the user agent must synchronously <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#the-script-element>script</a></code> element:</p> <ul><li>The <code><a href=#the-script-element>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a document</a>.</li> <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a <code>Document</code></a> and its child nodes are changed.</li> <li>The <code><a href=#the-script-element>script</a></code> element is <a href=#in-a-document>in a <code>Document</code></a> and has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute set where previously the element had no such attribute.</li> </ul><p>To <dfn id=prepare-a-script title="prepare a script">prepare a script</dfn>, the user agent must act as follows:</p> <ol><li> <p>If the <code><a href=#the-script-element>script</a></code> element is marked as having <a href=#already-started>"already started"</a>, then the user agent must abort these steps at this point. The script is not executed.</p> </li> <li> <p>If the element has its <a href=#parser-inserted>"parser-inserted"</a> flag set, then set <var title="">was-parser-inserted</var> to true and unset the element's <a href=#parser-inserted>"parser-inserted"</a> flag. Otherwise, set <var title="">was-parser-inserted</var> to false.</p> <p class=note>This is done so that if parser-inserted <code><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> <!-- q.v. http://hsivonen.iki.fi/test/moz/script-setting-src-on-parser-inserted-script.html --> </li> <li> <p>If <var title="">was-parser-inserted</var> is true and the element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, then set the element's <a href=#force-async>"force-async"</a> flag to true.</p> <p class=note>This is done so that if a parser-inserted <code><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 asynchronously even if the <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute isn't set.</p> </li> <li id=script-processing-empty> <p>If the element has no <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and its child nodes, if any, consist only of comment nodes and empty <a href=#text-node title="text node">text nodes</a>, then the user agent must abort these steps at this point. The script is not executed.</p> </li> <li> <p>If the element is not <a href=#in-a-document>in a <code>Document</code></a>, then the user agent must abort these steps at this point. The script is not executed.</p> </li> <li id=script-processing-prepare> <p>If either:</p> <ul class=brief><li>the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute and its value is the empty string, or</li> <li>the <code><a href=#the-script-element>script</a></code> element has no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute but it has a <code title=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> <li>the <code><a href=#the-script-element>script</a></code> element has neither a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute nor a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute, then</li> </ul><p>...let <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element be "<code title="">text/javascript</code>".</p> <p>Otherwise, if the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute, let <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element be the value of that attribute with any leading or trailing sequences of <a href=#space-character title="space character">space characters</a> removed.</p> <!-- <span>Strip leading and trailing whitespace</span> from... --> <p>Otherwise, the element has a non-empty <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute; let <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element be the concatenation of the string "<code title="">text/</code>" followed by the value of the <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute.</p> <!-- user agents already support, e.g., type="text/javascript1.3", so we don't have to support that separately. --> <p class=note>The <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute is never conforming, and is always ignored if there is a <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute present.</p> </li> <li> <p>If the user agent does not <a href=#support-the-scripting-language>support the scripting language</a> given by <var><a href="#the-script-block's-type">the script block's type</a></var> for this <code><a href=#the-script-element>script</a></code> element, then the user agent must abort these steps at this point. The script is not executed.</p> </li> <li> <p>If <var title="">was-parser-inserted</var> is true, then flag the element as <a href=#parser-inserted>"parser-inserted"</a> again, and set the element's <a href=#force-async>"force-async"</a> flag to false.</p> </li> <li id=script-processing-start> <p>The user agent must set the element's <a href=#already-started>"already started"</a> flag.</p> <p class=note>The state of the element at this moment <a href=#establish-script-block-source>is later used</a> to determine the script source.</p> </li> <li> <p>If the element is flagged as <a href=#parser-inserted>"parser-inserted"</a>, but the element's <code><a href=#document>Document</a></code> is not the <code><a href=#document>Document</a></code> of the parser that created the element, then abort these steps.</p> </li> <li id=script-processing-noscript> <p>If <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the <code><a href=#the-script-element>script</a></code> element, then the user agent must abort these steps at this point. The script is not executed.</p> <p class=note>The definition of <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> means that, amongst others, the following scripts will not execute: scripts in <code>XMLHttpRequest</code>'s <code title=dom-XMLHttpRequest-responseXML>responseXML</code> documents, scripts in <code>DOMParser</code>-created documents, scripts in documents created by <code>XSLTProcessor</code>'s <code title=dom-XSLTProcessor-transformToDocument>transformToDocument</code> feature, and scripts that are first inserted by a script into a <code><a href=#document>Document</a></code> that was created using the <code title=dom-DOMImplementation-createDocument><a href=#dom-domimplementation-createdocument>createDocument()</a></code> API. <a href=#refsXHR>[XHR]</a> <a href=#refsDOMPARSING>[DOMPARSING]</a> <!--<a href="#refsXSLTP">[XSLTP]</a>--> <a href=#refsDOMCORE>[DOMCORE]</a></p> </li> <li id=script-processing-for> <p>If the <code><a href=#the-script-element>script</a></code> element has an <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute and a <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute, then run these substeps:</p> <ol><li><p>Let <var title="">for</var> be the value of the <code title=attr-script-for><a href=#attr-script-for>for</a></code> attribute.</li> <li><p>Let <var title="">event</var> be the value of the <code title=attr-script-event><a href=#attr-script-event>event</a></code> attribute.</li> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from <var title="">event</var> and <var title="">for</var>.</li> <li><p>If <var title="">for</var> is not an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">window</code>", then the user agent must abort these steps at this point. The script is not executed.</li> <li><p>If <var title="">event</var> is not an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for either the string "<code title="">onload</code>" or the string "<code title="">onload()</code>", then the user agent must abort these steps at this point. The script is not executed.</li> </ol></li> <li id=script-processing-encoding> <p>If the <code><a href=#the-script-element>script</a></code> element has a <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute, then let <var><a href="#the-script-block's-character-encoding">the script block's character encoding</a></var> for this <code><a href=#the-script-element>script</a></code> element be the encoding given by the <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code> attribute.</p> <p>Otherwise, let <var><a href="#the-script-block's-fallback-character-encoding">the script block's fallback character encoding</a></var> for this <code><a href=#the-script-element>script</a></code> element be the same as <a href="#document's-character-encoding" title="document's character encoding">the encoding of the document itself</a>.</p> <p class=note>Only one of these two pieces of state is set.</p> </li> <li id=script-processing-src-prepare> <p>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute whose value is not the empty string, then the value of that attribute must be <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element, and if that is successful, the specified resource must then be <a href=#fetch title=fetch>fetched</a>, from the <a href=#origin>origin</a> of the element's <code><a href=#document>Document</a></code>.</p> <!-- not http-origin privacy sensitive --> <p>If the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute's value is the empty string or if it could not be resolved, then the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the element, and abort these steps.</p> <p>For historical reasons, if the <a href=#url>URL</a> is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>, then the user agent must not, despite the requirements in the definition of the <a href=#fetch title=fetch>fetching</a> algorithm, actually execute the script in the URL; instead the user agent must act as if it had received an empty HTTP 400 response.</p> <p>For performance reasons, user agents may start fetching the script as soon as the attribute is set, instead, in the hope that the element will be inserted into the document. Either way, once the element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the document</a>, the load must have started. If the UA performs such prefetching, but the element is never inserted in the document, or the <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is dynamically changed,<!-- or the base URL is dynamically changed,--> then the user agent will not execute the script, and the fetching process will have been effectively wasted.</p> </li> <!-- at this point if the element is "parser-inserted" then we know it is not "force-async". --> <li> <p>Then, the first of the following options that describes the situation must be followed:</p> <dl class=switch><dt id=script-processing-defer>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and the element has a <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> attribute, and the element has been flagged as <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt> <dd> <p>The element must be added 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><a href=#document>Document</a></code> of the parser that created the element.</p> <p>The <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a> has completed must set the element's <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will handle executing the script.</p> </dd> <dt id=script-processing-parser-inserted>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and the element has been flagged as <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt> <dd> <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a> of the <code><a href=#document>Document</a></code> of the parser that created the element. (There can only be one such script per <code><a href=#document>Document</a></code> at a time.)</p> <p>The <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a> has completed must set the element's <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will handle executing the script.</p> </dd> <dt id=script-processing-style-delayed>If the element does not have a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, and the element has been flagged as <a href=#parser-inserted>"parser-inserted"</a>, and the <code><a href=#document>Document</a></code> of the <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a> that created the <code><a href=#the-script-element>script</a></code> element <a href=#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking scripts</a></dt> <dd> <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a> of the <code><a href=#document>Document</a></code> of the parser that created the element. (There can only be one such script per <code><a href=#document>Document</a></code> at a time.)</p> <p>Set the element's <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will handle executing the script.</p> </dd> <dt id=script-processing-src-sync>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, and does not have the <a href=#force-async>"force-async"</a> flag set</dt> <dd> <p>The element must be added 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 <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code> element at the time the <a href=#prepare-a-script>prepare a script</a> algorithm started.</p> <p>The <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a> has completed must 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>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 abort these steps without executing the script yet.</li> <li><p><i>Execution</i>: <a href=#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>list of scripts that will execute in order as soon as possible</a>.</li> <li><p>Remove the first element from this <a href=#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>.</li> <li><p>If this <a href=#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> is still not empty and the first entry has already been marked as ready, then jump back to the step labeled <i>execution</i>.</li> </ol></dd> <dt id=script-processing-src>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute</dt> <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 <code><a href=#document>Document</a></code> of the <code><a href=#the-script-element>script</a></code> element at the time the <a href=#prepare-a-script>prepare a script</a> algorithm started.</p> <p>The <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a> has completed must <a href=#execute-the-script-block>execute the script block</a> and then remove the element from the <a href=#set-of-scripts-that-will-execute-as-soon-as-possible>set of scripts that will execute as soon as possible</a>.</p> </dd> <dt id=script-processing-inline>Otherwise</dt> <dd>The user agent must immediately <a href=#execute-the-script-block>execute the script block</a>, even if other scripts are already executing.</dd> </dl></li> </ol><!-- similar text in various places --><p>Fetching an external script must <a href=#delay-the-load-event>delay the load event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> (defined above) has been run.</p> <p>The <dfn id=pending-parsing-blocking-script>pending parsing-blocking script</dfn> of a <code><a href=#document>Document</a></code> is used by the <code><a href=#document>Document</a></code>'s parser(s).</p> <p class=note>If a <code><a href=#the-script-element>script</a></code> element that blocks a parser gets moved to another <code><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>pending parsing-blocking script</a> because there was <a href=#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><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> <!-- also (and this would be worth testing): the way the spec is written, if you do not have a style sheet that is blocking scripts, then you parse a <script src>, then while waiting for the script to load you insert an external style sheet, the script will delay until the sheet is loaded, because there's just a binary "are style sheets blocking scripts" state, things aren't defined in terms of which style sheets are blocking which scripts --> <p>When the user agent is required to <dfn id=execute-the-script-block title="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>"parser-inserted"</a>, but the element's <code><a href=#document>Document</a></code> is not the <code><a href=#document>Document</a></code> of the parser that created the element, then abort these steps.</p> </li> <li> <p>Jump to the appropriate set of steps from the list below:</p> <dl class=switch><dt>If the load resulted in an error (for example a DNS error, or an HTTP 404 error)</dt> <dd><p>Executing the script block must just consist of <a href=#fire-a-simple-event title="fire a simple event">firing a simple event</a> named <code title=event-error>error</code> at the element.</dd> <dt>If the load was successful</dt> <!-- SCRIPT EXEC --> <dd> <p>Executing the script block must consist of running the following steps. For the purposes of these steps, the script is considered to be from an <i>external file</i> if, while the <a href=#prepare-a-script>prepare a script</a> algorithm above was running for this script, the <code><a href=#the-script-element>script</a></code> element had a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute specified.</p> <ol><li id=establish-script-block-source> <p>Initialize <dfn id="the-script-block's-source"><var>the script block's source</var></dfn> as follows:</p> <dl class=switch><dt>If the script is from an external file and <var><a href="#the-script-block's-type">the script block's type</a></var> is a text-based language</dt> <dd> <p>The contents of that file, interpreted as a Unicode string, are the script source.</p> <p>To obtain the Unicode string, the user agent run the following steps:</p> <ol><li><p>If the resource's <a href=#content-type title=Content-Type>Content Type metadata</a>, if any, specifies a character encoding, and the user agent supports that encoding, then let <var title="">character encoding</var> be that encoding, and jump to the bottom step in this series of steps.</li> <li><p>If the algorithm above set <var><a href="#the-script-block's-character-encoding">the script block's character encoding</a></var>, then let <var title="">character encoding</var> be that encoding, and jump to the bottom step in this series of steps.</li> <li><p>For each of the rows in the following table, starting with the first one and going down, if the file has as many or more bytes available than the number of bytes in the first column, and the first bytes of the file match the bytes given in the first column, then set <var title="">character encoding</var> to the encoding given in the cell in the second column of that row, and jump to the bottom step in this series of steps:</p> <!-- this table is present in several forms in this file; keep them in sync --> <table id=table-script-bom><thead><tr><th>Bytes in Hexadecimal <th>Encoding <tbody><!-- nobody uses this <tr> <td>00 00 FE FF <td>UTF-32BE <tr> <td>FF FE 00 00 <td>UTF-32LE --><tr><td>FE FF <td>Big-endian UTF-16 <tr><td>FF FE <td>Little-endian UTF-16 <tr><td>EF BB BF <td>UTF-8 <!-- nobody uses this <tr> <td>DD 73 66 73 <td>UTF-EBCDIC --> </table><p class=note>This step looks for Unicode Byte Order Marks (BOMs).</p> </li> <li><p>Let <var title="">character encoding</var> be <var><a href="#the-script-block's-fallback-character-encoding">the script block's fallback character encoding</a></var>.</li> <li><p>Convert the file to Unicode using <var>character encoding</var>, following the rules for doing so given by the specification for <var><a href="#the-script-block's-type">the script block's type</a></var>.</li> </ol></dd> <dt>If the script is from an external file and <var><a href="#the-script-block's-type">the script block's type</a></var> is an XML-based language</dt> <dd> <p>The external file is the script source. When it is later executed, it must be interpreted in a manner consistent with the specification defining the language given by <var><a href="#the-script-block's-type">the script block's type</a></var>.</p> </dd> <dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's type</a></var> is a text-based language</dt> <dd> <p>The value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code> IDL attribute at the time the element's <a href=#already-started>"already started"</a> flag was last set is the script source.</p> </dd> <dt>If the script is inline and <var><a href="#the-script-block's-type">the script block's type</a></var> is an XML-based language</dt> <dd> <p>The child nodes of the <code><a href=#the-script-element>script</a></code> element at the time the element's <a href=#already-started>"already started"</a> flag was last set are the script source.</p> </dd> </dl></li> <li> <p>If the script is from an external file, then increment the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the <code><a href=#the-script-element>script</a></code> element's <code><a href=#document>Document</a></code>. Let <var title="">neutralized doc</var> be that <code><a href=#document>Document</a></code>.</p> </li> <li> <p><a href=#create-a-script-from-a-node title="create a script from a node">Create a script</a> from the <code><a href=#the-script-element>script</a></code> element node, using <var><a href="#the-script-block's-source">the script block's source</a></var> and <var><a href="#the-script-block's-type">the script block's type</a></var>.</p> <p class=note>This is where the script is compiled and actually executed.</p> </li> <li> <p>Decrement the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of <var title="">neutralized doc</var>, if it was incremented in the earlier step.</p> </li> <li> <p>If the script is from an external file, <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-script-element>script</a></code> element.</p> <p>Otherwise, the script is internal; <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-script-element>script</a></code> element.</p> </li> </ol></dd> </dl></li> </ol><p>The IDL attributes <dfn id=dom-script-src title=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type title=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-charset title=dom-script-charset><code>charset</code></dfn>, and <dfn id=dom-script-defer title=dom-script-defer><code>defer</code></dfn>, each must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-script-async title=dom-script-async><code>async</code></dfn> IDL attribute controls whether the element will execute asynchronously or not. If the element's <a href=#force-async>"force-async"</a> flag is set, then, on getting, the <code title=dom-script-async><a href=#dom-script-async>async</a></code> IDL attribute must return true, and on setting, the <a href=#force-async>"force-async"</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=#force-async>"force-async"</a> flag is <em>not</em> set, the IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute.</p> </div> <dl class=domintro><dt><var title="">script</var> . <code title=dom-script-text><a href=#dom-script-text>text</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the contents of the element, ignoring child nodes that aren't <a href=#text-node title="text node">text nodes</a>.</p> <p>Can be set, to replace the element's children with the given value.</p> </dd> </dl><div class=impl> <p>The IDL attribute <dfn id=dom-script-text title=dom-script-text><code>text</code></dfn> must return a concatenation of the contents of all the <a href=#text-node title="text node">text nodes</a> that are children of the <code><a href=#the-script-element>script</a></code> element (ignoring any other nodes such as comments or elements), in tree order. On setting, it must act the same way as the <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> </div> <p class=note>When inserted using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method, <code><a href=#the-script-element>script</a></code> elements execute (typically synchronously), but when inserted using <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> and <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attributes, they do not execute at all.</p> <div class=example> <p>In this example, two <code><a href=#the-script-element>script</a></code> elements are used. One embeds an external script, and the other includes some data.</p> <pre><script src="game-engine.js"></script> <script type="text/x-game-map"> ........U.........e o............A....e .....A.....AAA....e .A..AAA...AAAAA...e </script></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 script element can be used to define a function that is then used by other parts of the document. It also shows how a <code><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><script> function calculate(form) { var price = 52000; if (form.elements.brakes.checked) price += 1000; if (form.elements.radio.checked) price += 2500; if (form.elements.turbo.checked) price += 5000; if (form.elements.sticker.checked) price += 250; form.elements.result.value = price; } </script> <form name="pricecalc" onsubmit="return false" onchange="calculate(this)"> <fieldset> <legend>Work out the price of your car</legend> <p>Base cost: £52000.</p> <p>Select additional options:</p> <ul> <li><label><input type=checkbox name=brakes> Ceramic brakes (£1000)</label></li> <li><label><input type=checkbox name=radio> Satellite radio (£2500)</label></li> <li><label><input type=checkbox name=turbo> Turbo charger (£5000)</label></li> <li><label><input type=checkbox name=sticker> "XZ" sticker (£250)</label></li> </ul> <p>Total: £<output name=result></output></p> </fieldset> <script> calculate(document.forms.pricecalc); </script> </form></pre> </div> <h5 id=scriptingLanguages><span class=secno>4.3.1.1 </span>Scripting languages</h5> <div class=impl> <p>A user agent is said to <dfn id=support-the-scripting-language>support the scripting language</dfn> if <var><a href="#the-script-block's-type">the script block's type</a></var> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the <a href=#mime-type>MIME type</a> string of a scripting language that the user agent implements.</p> </div> <p>The following lists some <a href=#mime-type>MIME type</a> strings and the languages to which they refer:</p> <dl><dt>"<code>application/ecmascript</code>"</dt> <dt>"<code>application/javascript</code>"</dt> <dt>"<code>application/x-ecmascript</code>"</dt> <dt>"<code>application/x-javascript</code>"</dt> <dt>"<code>text/ecmascript</code>"</dt> <dt>"<code>text/javascript</code>"</dt> <dt>"<code>text/javascript1.0</code>"</dt> <dt>"<code>text/javascript1.1</code>"</dt> <dt>"<code>text/javascript1.2</code>"</dt> <dt>"<code>text/javascript1.3</code>"</dt> <dt>"<code>text/javascript1.4</code>"</dt> <dt>"<code>text/javascript1.5</code>"</dt> <dt>"<code>text/jscript</code>"</dt> <dt>"<code>text/livescript</code>"</dt> <dt>"<code>text/x-ecmascript</code>"</dt> <dt>"<code>text/x-javascript</code>"</dt> <dd>JavaScript. <a href=#refsECMA262>[ECMA262]</a></dd> <dt>"<code>text/javascript;e4x=1</code>"</dt> <dd>JavaScript with ECMAScript for XML. <a href=#refsECMA357>[ECMA357]</a></dd> </dl><div class=impl> <p>User agents may support other <a href=#mime-type title="MIME type">MIME types</a> and other languages.</p> <p>The following <a href=#mime-type title="MIME type">MIME types</a> must not be interpreted as scripting languages:</p> <ul class=brief><li>"<code>text/plain</code>" <li>"<code>text/xml</code>" <!--<li>"<code>text/html</code>"--> <li>"<code>application/octet-stream</code>" <li>"<code>application/xml</code>" <!--<li>"<code>application/xhtml+xml</code>"--> <!--<li>"<code>image/svg+xml</code>"--> <!-- the commented-out ones aren't listed here because they couldn't sanely be interpreted as a scripting language anyway: they're defined to be something else. I just don't want this to devolve into a list of every non-scripting type in existence. --> </ul><p class=note>These types are explicitly listed here because they are poorly-defined types that are nonetheless likely to be used as formats for data blocks, and it would be problematic if they were suddenly to be interpreted as script by a user agent.</p> <!-- this paragraph is also present in the <style> section --> <p>When examining types to determine if they support the language, user agents must not ignore unknown MIME parameters — types with unknown parameters must be assumed to be unsupported. The <code title="">charset</code> parameter must be treated as an unknown parameter for the purpose of comparing <a href=#mime-type title="MIME type">MIME types</a> here.</p> </div> <h5 id=restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span><dfn title="script content restrictions">Restrictions for contents of <code>script</code> elements</dfn></h5> <p>The <code><a href=#textcontent>textContent</a></code> of a <code><a href=#the-script-element>script</a></code> element must match the <code title="">script</code> production in the following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p> <pre>script = data1 *( escape [ script-start data3 ] "-->" data1 ) [ escape ] escape = "<!--" data2 *( script-start data3 script-end data2 ) data1 = <any string that doesn't contain a substring that matches not-data1> not-data1 = <!-- script-end / -->"<!--" <!-- the script-end is redundant here since it would close the element --> data2 = <any string that doesn't contain a substring that matches not-data2> not-data2 = <!-- script-end / -->script-start / "-->" <!-- the script-end is redundant here since it would close the element --> data3 = <any string that doesn't contain a substring that matches not-data3> not-data3 = script-end / "-->" script-start = lt s c r i p t tag-end script-end = lt slash s c r i p t tag-end lt = %x003C ; U+003C LESS-THAN SIGN character (<) slash = %x002F ; U+002F SOLIDUS character (/) s = %x0053 ; U+0053 LATIN CAPITAL LETTER S s =/ %x0073 ; U+0073 LATIN SMALL LETTER S c = %x0043 ; U+0043 LATIN CAPITAL LETTER C c =/ %x0063 ; U+0063 LATIN SMALL LETTER C r = %x0052 ; U+0052 LATIN CAPITAL LETTER R r =/ %x0072 ; U+0072 LATIN SMALL LETTER R i = %x0049 ; U+0049 LATIN CAPITAL LETTER I i =/ %x0069 ; U+0069 LATIN SMALL LETTER I p = %x0050 ; U+0050 LATIN CAPITAL LETTER P p =/ %x0070 ; U+0070 LATIN SMALL LETTER P t = %x0054 ; U+0054 LATIN CAPITAL LETTER T t =/ %x0074 ; U+0074 LATIN SMALL LETTER T tag-end = %x0009 ; U+0009 CHARACTER TABULATION (tab) tag-end =/ %x000A ; U+000A LINE FEED (LF) tag-end =/ %x000C ; U+000C FORM FEED (FF) tag-end =/ %x0020 ; U+0020 SPACE tag-end =/ %x002F ; U+002F SOLIDUS (/) tag-end =/ %x003E ; U+003E GREATER-THAN SIGN (>)</pre> <p>When a <code><a href=#the-script-element>script</a></code> element contains <a href=#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> <h5 id=inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span><dfn title="script documentation">Inline documentation for external scripts</dfn></h5> <p>If a <code><a href=#the-script-element>script</a></code> element's <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is specified, then the contents of the <code><a href=#the-script-element>script</a></code> element, if any, must be such that the value of the <code title=dom-script-text><a href=#dom-script-text>text</a></code> IDL attribute, which is derived from the element's contents, matches the <code title="">documentation</code> production in the following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p> <pre>documentation = *( *( space / tab / comment ) [ line-comment ] newline ) comment = slash star *( not-star / star not-slash ) 1*star slash line-comment = slash slash *not-newline ; characters tab = %x0009 ; U+0009 CHARACTER TABULATION (tab) newline = %x000A ; U+000A LINE FEED (LF) space = %x0020 ; U+0020 SPACE star = %x002A ; U+002A ASTERISK (*) slash = %x002F ; U+002F SOLIDUS (/) not-newline = %x0000-0009 / %x000B-10FFFF ; a <a href=#unicode-character>Unicode character</a> other than U+000A LINE FEED (LF) not-star = %x0000-0029 / %x002B-10FFFF ; a <a href=#unicode-character>Unicode character</a> other than U+002A ASTERISK (*) not-slash = %x0000-002E / %x0030-10FFFF ; a <a href=#unicode-character>Unicode character</a> other than U+002F SOLIDUS (/)</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><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 title=attr-script-src><a href=#attr-script-src>src</a></code> attribute.</p> <pre><script src="cool-effects.js"> // create new instances using: // var e = new Effect(); // start the effect using .play, stop using .stop: // e.play(); // e.stop(); </script></pre> </div> <div class=impl> <h5 id=scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code><a href=#the-script-element>script</a></code> elements and XSLT</h5> <p><i>This section is non-normative.</i></p> <p>This specification does not define how XSLT interacts with the <code><a href=#the-script-element>script</a></code> element (or, indeed, how XSLT processing triggers the <a href=#stop-parsing>stop parsing</a> steps, how it interacts with the <a href=#navigate title=navigate>navigation</a> algorithm, or how it fits in with the <a href=#event-loop>event loop</a>). However, in the absence of another specification actually defining this, here are some guidelines for implementors, based on existing implementations:</p> <ul><li><p>When an XSLT transformation program is triggered by an <code title=""><?xml-stylesheet?></code> processing instruction and the browser implements a direct-to-DOM transformation, <code><a href=#the-script-element>script</a></code> elements created by the XSLT processor need to be marked <a href=#parser-inserted>"parser-inserted"</a> and run in document order (modulo scripts marked <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code> or <code title=attr-script-async><a href=#attr-script-async>async</a></code>), asynchronously while the transformation is occurring.</li> <li><p>The <code title=dom-XSLTProcessor-transformToDocument>XSLTProcessor.transformToDocument()</code> method adds elements to a <code><a href=#document>Document</a></code> that is not in a <a href=#browsing-context>browsing context</a>, and, accordingly, any <code><a href=#the-script-element>script</a></code> elements they create need to have their <a href=#already-started>"already started"</a> flag set in the <a href=#prepare-a-script>prepare a script</a> algorithm and never get executed (<a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a>). Such <code><a href=#the-script-element>script</a></code> elements still need to be marked <a href=#parser-inserted>"parser-inserted"</a>, though, such that their <code title=dom-script-async><a href=#dom-script-async>async</a></code> IDL attribute will return false in the absence of an <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute.</li> <li><p>The <code title=dom-XSLTProcessor-transformToFragment>XSLTProcessor.transformToFragment()</code> method needs to create a fragment that is equivalent to one built manually by creating the elements using <code title=dom-document-createElementNS><a href=#dom-document-createelementns>document.createElementNS()</a></code>. For instance, it needs to create <code><a href=#the-script-element>script</a></code> elements that aren't <a href=#parser-inserted>"parser-inserted"</a> and that don't have their <a href=#already-started>"already started"</a> flag set, so that they will execute when the fragment is inserted into a document.</li> </ul><p>The main distinction between the first two cases and the last case is that the first two operate on <code><a href=#document>Document</a></code>s and the last operates on a fragment.</p> </div> <h4 id=the-noscript-element><span class=secno>4.3.2 </span>The <dfn><code>noscript</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>In a <code><a href=#the-head-element>head</a></code> element of an <a href=#html-documents title="HTML documents">HTML document</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected in <a href=#html-documents>HTML documents</a>, if there are no ancestor <code><a href=#the-noscript-element>noscript</a></code> elements.</dd> <dt>Content model:</dt> <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, in a <code><a href=#the-head-element>head</a></code> element: in any order, zero or more <code><a href=#the-link-element>link</a></code> elements, zero or more <code><a href=#the-style-element>style</a></code> elements, and zero or more <code><a href=#the-meta-element>meta</a></code> elements.</dd> <dd>When <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a>, not in a <code><a href=#the-head-element>head</a></code> element: <a href=#transparent>transparent</a>, but there must be no <code><a href=#the-noscript-element>noscript</a></code> element descendants.</dd> <dd>Otherwise: text that conforms to the requirements given in the prose.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-noscript-element>noscript</a></code> element <a href=#represents>represents</a> nothing if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a>, and <a href=#represents>represents</a> its children if <a href=#concept-n-noscript title=concept-n-noscript>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 href=#html-documents>HTML documents</a>, the allowed content model is as follows:</p> <dl><dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the <code><a href=#the-noscript-element>noscript</a></code> element</dt> <dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-meta-element>meta</a></code> elements.</dd> <dt>In a <code><a href=#the-head-element>head</a></code> element, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the <code><a href=#the-noscript-element>noscript</a></code> element</dt> <dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element must contain only text, except that invoking the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a> <!-- (which disables <script> execution) --> with the <code><a href=#the-noscript-element>noscript</a></code> element as the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element and the text contents as the <var title="">input</var> must result in a list of nodes that consists only of <code><a href=#the-link-element>link</a></code>, <code><a href=#the-style-element>style</a></code>, and <code><a href=#the-meta-element>meta</a></code> elements that would be conforming if they were children of the <code><a href=#the-noscript-element>noscript</a></code> element, and no <a href=#parse-error title="parse error">parse errors</a>.</dd> <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the <code><a href=#the-noscript-element>noscript</a></code> element</dt> <dd><p>The <code><a href=#the-noscript-element>noscript</a></code> element's content model is <a href=#transparent>transparent</a>, with the additional restriction that a <code><a href=#the-noscript-element>noscript</a></code> element must not have a <code><a href=#the-noscript-element>noscript</a></code> element as an ancestor (that is, <code><a href=#the-noscript-element>noscript</a></code> can't be nested).</dd> <dt>Outside of <code><a href=#the-head-element>head</a></code> elements, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the <code><a href=#the-noscript-element>noscript</a></code> element</dt> <dd> <p>The <code><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><a href=#the-noscript-element>noscript</a></code> elements and no <code><a href=#the-script-element>script</a></code> elements, and such that no step in the algorithm causes an <a href=#html-parser>HTML parser</a> to flag a <a href=#parse-error>parse error</a>:</p> <ol><li>Remove every <code><a href=#the-script-element>script</a></code> element from the document.</li> <li>Make a list of every <code><a href=#the-noscript-element>noscript</a></code> element in the document. For every <code><a href=#the-noscript-element>noscript</a></code> element in that list, perform the following steps: <ol><li>Let the <var title="">parent element</var> be the parent element of the <code><a href=#the-noscript-element>noscript</a></code> element.</li> <li>Take all the children of the <var title="">parent element</var> that come before the <code><a href=#the-noscript-element>noscript</a></code> element, and call these elements <var title="">the before children</var>.</li> <li>Take all the children of the <var title="">parent element</var> that come <em>after</em> the <code><a href=#the-noscript-element>noscript</a></code> element, and call these elements <var title="">the after children</var>.</li> <li>Let <var title="">s</var> be the concatenation of all the <a href=#text-node>text node</a> children of the <code><a href=#the-noscript-element>noscript</a></code> element.</li> <li>Set the <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> attribute of the <var title="">parent element</var> to the value of <var title="">s</var>. (This, as a side-effect, causes the <code><a href=#the-noscript-element>noscript</a></code> element to be removed from the document.)</li> <li>Insert <var title="">the before children</var> at the start of the <var title="">parent element</var>, preserving their original relative order.</li> <li>Insert <var title="">the after children</var> at the end of the <var title="">parent element</var>, preserving their original relative order.</li> </ol></li> </ol></dd> </dl><p class=note>All these contortions are required because, for historical reasons, the <code><a href=#the-noscript-element>noscript</a></code> element is handled differently by the <a href=#html-parser>HTML parser</a> based on whether <a href=#scripting-flag title="scripting flag">scripting was enabled or not</a> when the parser was invoked.</p> <p>The <code><a href=#the-noscript-element>noscript</a></code> element must not be used in <a href=#xml-documents>XML documents</a>.</p> <p class=note>The <code><a href=#the-noscript-element>noscript</a></code> element is only effective in <a href=#syntax>the HTML syntax</a>, it has no effect in <a href=#the-xhtml-syntax>the XHTML 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> <div class=impl> <p>The <code><a href=#the-noscript-element>noscript</a></code> element has no other requirements. In particular, children of the <code><a href=#the-noscript-element>noscript</a></code> element are not exempt from <a href=#form-submission>form submission</a>, scripting, and so forth, even when <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the element.</p> </div> <div class=example> <p>In the following example, a <code><a href=#the-noscript-element>noscript</a></code> element is used to provide fallback for a script.</p> <pre><form action="calcSquare.php"> <p> <label for=x>Number</label>: <input id="x" name="x" type="number"> </p> <script> var x = document.getElementById('x'); var output = document.createElement('p'); output.textContent = 'Type a number; it will be squared right then!'; x.form.appendChild(output); x.form.onsubmit = function () { return false; } x.oninput = function () { var v = x.valueAsNumber; output.textContent = v + ' squared is ' + v * v; }; </script> <noscript> <input type=submit value="Calculate Square"> </noscript> </form></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><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><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><form action="calcSquare.php"> <p> <label for=x>Number</label>: <input id="x" name="x" type="number"> </p> <strong><input id="submit" type=submit value="Calculate Square"></strong> <script> var x = document.getElementById('x'); var output = document.createElement('p'); output.textContent = 'Type a number; it will be squared right then!'; x.form.appendChild(output); x.form.onsubmit = function () { return false; } x.oninput = function () { var v = x.valueAsNumber; output.textContent = v + ' squared is ' + v * v; }; <strong> var submit = document.getElementById('submit'); submit.parentNode.removeChild(submit);</strong> </script> </form></pre> <p>The above technique is also useful in XHTML, since <code><a href=#the-noscript-element>noscript</a></code> is not supported in <a href=#the-xhtml-syntax>the XHTML syntax</a>.</p> </div> <h3 id=sections><span class=secno>4.4 </span>Sections</h3> <h4 id=the-body-element><span class=secno>4.4.1 </span>The <dfn><code>body</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the second element in an <code><a href=#the-html-element>html</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code></dd> <dd><code title=handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>onbeforeprint</a></code></dd> <dd><code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code></dd> <dd><code title=handler-window-onblur><a href=#handler-window-onblur>onblur</a></code></dd> <dd><code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code></dd> <dd><code title=handler-window-onfocus><a href=#handler-window-onfocus>onfocus</a></code></dd> <dd><code title=handler-window-onhashchange><a href=#handler-window-onhashchange>onhashchange</a></code></dd> <dd><code title=handler-window-onload><a href=#handler-window-onload>onload</a></code></dd> <dd><code title=handler-window-onmessage><a href=#handler-window-onmessage>onmessage</a></code></dd> <dd><code title=handler-window-onoffline><a href=#handler-window-onoffline>onoffline</a></code></dd> <dd><code title=handler-window-ononline><a href=#handler-window-ononline>ononline</a></code></dd> <dd><code title=handler-window-onpagehide><a href=#handler-window-onpagehide>onpagehide</a></code></dd> <dd><code title=handler-window-onpageshow><a href=#handler-window-onpageshow>onpageshow</a></code></dd> <dd><code title=handler-window-onpopstate><a href=#handler-window-onpopstate>onpopstate</a></code></dd> <dd><code title=handler-window-onresize><a href=#handler-window-onresize>onresize</a></code></dd> <dd><code title=handler-window-onscroll><a href=#handler-window-onscroll>onscroll</a></code></dd> <dd><code title=handler-window-onstorage><a href=#handler-window-onstorage>onstorage</a></code></dd> <dd><code title=handler-window-onunload><a href=#handler-window-onunload>onunload</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlbodyelement>HTMLBodyElement</dfn> : <a href=#htmlelement>HTMLElement</a> { [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onafterprint title=handler-window-onafterprint>onafterprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeprint title=handler-window-onbeforeprint>onbeforeprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onblur title=handler-window-onblur>onblur</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onerror title=handler-window-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onfocus title=handler-window-onfocus>onfocus</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onhashchange title=handler-window-onhashchange>onhashchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onload title=handler-window-onload>onload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onmessage title=handler-window-onmessage>onmessage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onoffline title=handler-window-onoffline>onoffline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-ononline title=handler-window-ononline>ononline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpopstate title=handler-window-onpopstate>onpopstate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpagehide title=handler-window-onpagehide>onpagehide</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpageshow title=handler-window-onpageshow>onpageshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onresize title=handler-window-onresize>onresize</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onscroll title=handler-window-onscroll>onscroll</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onstorage title=handler-window-onstorage>onstorage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onunload title=handler-window-onunload>onunload</a>; };</pre> </dd> </dl><p>The <code><a href=#the-body-element>body</a></code> element <a href=#represents>represents</a> the main content of the document.</p> <p>In conforming documents, there is only one <code><a href=#the-body-element>body</a></code> element. The <code title=dom-document-body><a href=#dom-document-body>document.body</a></code> IDL attribute provides scripts with easy access to a document's <code><a href=#the-body-element>body</a></code> element.</p> <div class=impl> <p class=note>Some DOM operations (for example, parts of the <a href=#dnd>drag and drop</a> model) are defined in terms of "<a href=#the-body-element-0>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><a href=#the-body-element>body</a></code> element.</p> </div> <p>The <code><a href=#the-body-element>body</a></code> element exposes as <a href=#event-handler-content-attributes>event handler content attributes</a> a number of the <a href=#event-handlers>event handlers</a> of the <code><a href=#window>Window</a></code> object. It also mirrors their <a href=#event-handler-idl-attributes>event handler IDL attributes</a>.</p> <p>The <code title=handler-window-onblur><a href=#handler-window-onblur>onblur</a></code>, <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code>, <code title=handler-window-onfocus><a href=#handler-window-onfocus>onfocus</a></code>, <code title=handler-window-onload><a href=#handler-window-onload>onload</a></code>, and <code title=handler-window-onscroll><a href=#handler-window-onscroll>onscroll</a></code> <a href=#event-handlers>event handlers</a> of the <code><a href=#window>Window</a></code> object, exposed on the <code><a href=#the-body-element>body</a></code> element, shadow the generic <a href=#event-handlers>event handlers</a> with the same names normally supported by <a href=#html-elements>HTML elements</a>.</p> <p class=example>Thus, for example, a bubbling <code title=event-error>error</code> event dispatched on a child of <a href=#the-body-element-0>the body element</a> of a <code><a href=#document>Document</a></code> would first trigger the <code title=handler-onerror><a href=#handler-onerror>onerror</a></code> <a href=#event-handler-content-attributes>event handler content attributes</a> of that element, then that of the root <code><a href=#the-html-element>html</a></code> element, and only <em>then</em> would it trigger the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a> on the <code><a href=#the-body-element>body</a></code> element. This is because the event would bubble from the target, to the <code><a href=#the-body-element>body</a></code>, to the <code><a href=#the-html-element>html</a></code>, to the <code><a href=#document>Document</a></code>, to the <code><a href=#window>Window</a></code>, and the <a href=#event-handlers title="event handlers">event handler</a> on the <code><a href=#the-body-element>body</a></code> is watching the <code><a href=#window>Window</a></code> not the <code><a href=#the-body-element>body</a></code>. A regular event listener attached to the <code><a href=#the-body-element>body</a></code> using <code title="">addEventListener()</code>, however, would be run when the event bubbled through the <code><a href=#the-body-element>body</a></code> and not when it reaches the <code><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><!DOCTYPE HTML> <html> <head> <title>Online or offline?</title> <script> function update(online) { document.getElementById('status').textContent = online ? 'Online' : 'Offline'; } </script> </head> <body ononline="update(true)" onoffline="update(false)" onload="update(navigator.onLine)"> <p>You are: <span id="status">(Unknown)</span></p> </body> </html></pre> </div> <h4 id=the-section-element><span class=secno>4.4.2 </span>The <dfn><code>section</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-content>Sectioning content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-section-element>section</a></code> element <a href=#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><a href=#the-article-element>article</a></code> element instead of the <code><a href=#the-section-element>section</a></code> element when it would make sense to syndicate the contents of the element.</p> <p class=note id=use-div-for-wrappers>The <code><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><a href=#the-div-element>div</a></code> element instead. A general rule is that the <code><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>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><article> <hgroup> <h1>Apples</h1> <h2>Tasty, delicious fruit!</h2> </hgroup> <p>The apple is the pomaceous fruit of the apple tree.</p> <section> <h1>Red Delicious</h1> <p>These bright red apples are the most common found in many supermarkets.</p> </section> <section> <h1>Granny Smith</h1> <p>These juicy, green apples make a great filling for apple pies.</p> </section> </article></pre> <p>Notice how the use of <code><a href=#the-section-element>section</a></code> means that the author can use <code><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.</p> <pre><!DOCTYPE Html> <Html ><Head ><Title >Graduation Ceremony Summer 2022</Title ></Head ><Body ><H1 >Graduation</H1 ><Section ><H1 >Ceremony</H1 ><P >Opening Procession</P ><P >Speech by Validactorian</P ><P >Speech by Class President</P ><P >Presentation of Diplomas</P ><P >Closing Speech by Headmaster</P ></Section ><Section ><H1 >Graduates</H1 ><Ul ><Li >Molly Carpenter</Li ><Li >Anastasia Luccio</Li ><Li >Ebenezar McCoy</Li ><Li >Karrin Murphy</Li ><Li >Thomas Raith</Li ><Li >Susan Rodriguez</Li ></Ul ></Section ></Body ></Html></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. The whole book is wrapped in an <code><a href=#the-article-element>article</a></code> element as part of an even larger document containing other books.</p> <pre><article class="book"> <style> section { border: double medium; margin: 2em; } section.chapter h1 { font: 2em Roboto, Helvetica Neue, sans-serif; } section.appendix h1 { font: small-caps 2em Roboto, Helvetica Neue, sans-serif; } </style> <header> <hgroup> <h1>My Book</h1> <h2>A sample with not much content</h2> </hgroup> <p><small>Published by Dummy Publicorp Ltd.</small></p> </header> <section class="chapter"> <h1>My First Chapter</h1> <p>This is the first of my chapters. It doesn't say much.</p> <p>But it has two paragraphs!</p> </section> <section class="chapter"> <h1>It Continutes: The Second Chapter</h1> <p>Bla dee bla, dee bla dee bla. Boom.</p> </section> <section class="chapter"> <h1>Chapter Three: A Further Example</h1> <p>It's not like a battle between brightness and earthtones would go unnoticed.</p> <p>But it might ruin my story.</p> </section> <section class="appendix"> <h1>Appendix A: Overview of Examples</h1> <p>These are demonstrations.</p> </section> <section class="appendix"> <h1>Appendix B: Some Closing Remarks</h1> <p>Hopefully this long example shows that you <em>can</em> style sections, so long as they are used to indicate actual sections.</p> </section> </article></pre> </div> <h4 id=the-nav-element><span class=secno>4.4.3 </span>The <dfn><code>nav</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-content>Sectioning content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-nav-element>nav</a></code> element <a href=#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><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><a href=#the-footer-element>footer</a></code> element alone is sufficient for such cases; while a <code><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 and/or provide on request.</p> <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><body itemscope itemtype="http://schema.org/Blog"> <header> <h1>Wake up sheeple!</h1> <p><a href="news.html">News</a> - <a href="blog.html">Blog</a> - <a href="forums.html">Forums</a></p> <p>Last Modified: <span itemprop="dateModified">2009-04-01</span></p> <nav> <h1>Navigation</h1> <ul> <li><a href="articles.html">Index of all articles</a></li> <li><a href="today.html">Things sheeple need to wake up for today</a></li> <li><a href="successes.html">Sheeple we have managed to wake</a></li> </ul> </nav> </header> <div> <article itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting"> <header> <h1 itemprop="headline">My Day at the Beach</h1> </header> <div itemprop="articleBody"> <p>Today I went to the beach and had a lot of fun.</p> <em>...more content...</em> </div> <footer> <p>Posted <data itemprop="datePublished" value="2009-10-10">Thursday</data>.</p> </footer> </article> <em>...more blog posts...</em> </div> <footer> <p>Copyright © <span itemprop="copyrightYear">2010</span> <span itemprop="copyrightHolder">The Example Company</span> </p> <p><a href="about.html">About</a> - <a href="policy.html">Privacy Policy</a> - <a href="contact.html">Contact Us</a></p> </footer> </body></pre> <p>Notice the <code><a href=#the-div-element>div</a></code> elements being used to wrap all the contents of the page other than the header and footer, and all the contents of the blog entry other than its header and footer.</p> <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>In the following example, there are two <code><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><body> <h1>The Wiki Center Of Exampland</h1> <nav> <ul> <li><a href="/">Home</a></li> <li><a href="/events">Current Events</a></li> <em>...more...</em> </ul> </nav> <article> <header> <h1>Demos in Exampland</h1> <p>Written by A. N. Other.</p> </header> <nav> <ul> <li><a href="#public">Public demonstrations</a></li> <li><a href="#destroy">Demolitions</a></li> <em>...more...</em> </ul> </nav> <div> <section id="public"> <h1>Public demonstrations</h1> <p><em>...more...</em></p> </section> <section id="destroy"> <h1>Demolitions</h1> <p><em>...more...</em></p> </section> <em>...more...</em> </div> <footer> <p><a href="?edit">Edit</a> | <a href="?delete">Delete</a> | <a href="?Rename">Rename</a></p> </footer> </article> <footer> <p><small>© copyright 1998 Exampland Emperor</small></p> </footer> </body></pre> </div> <div class=example> <p>A <code><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><nav> <h1>Navigation</h1> <p>You are on my home page. To the north lies <a href="/blog">my blog</a>, from whence the sounds of battle can be heard. To the east you can see a large mountain, upon which many <a href="/school">school papers</a> are littered. Far up thus mountain you can spy a little figure who appears to be me, desperately scribbling a <a href="/school/thesis">thesis</a>.</p> <p>To the west are several exits. One fun-looking exit is labeled <a href="http://games.example.com/">"games"</a>. Another more boring-looking exit is labeled <a href="http://isp.example.net/">ISP™</a>.</p> <p>To the south lies a dark and dank <a href="/about">contacts page</a>. Cobwebs cover its disused entrance, and at one point you see a rat run quickly out of the page.</p> </nav></pre> </div> <h4 id=the-article-element><span class=secno>4.4.4 </span>The <dfn><code>article</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-content>Sectioning content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-article-element>article</a></code> element <a href=#represents>represents</a> a 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><a href=#the-article-element>article</a></code> elements are nested, the inner <code><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><a href=#the-article-element>article</a></code> elements nested within the <code><a href=#the-article-element>article</a></code> element for the blog entry.</p> <p>Author information associated with an <code><a href=#the-article-element>article</a></code> element (q.v. the <code><a href=#the-address-element>address</a></code> element) does not apply to nested <code><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><a href=#the-article-element>article</a></code> element is similar in purpose to the <code title="">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><a href=#the-article-element>article</a></code> element, using one of the CreativeWork subtypes.</p> <div class=example id=article-example> <p>This example shows a blog post using the <code><a href=#the-article-element>article</a></code> element, with some schema.org annotations:</p> <pre><article itemscope itemtype="http://schema.org/BlogPosting"> <header> <h1 itemprop="headline">The Very First Rule of Life</h1> <p><data itemprop="datePublished" value="2009-10-09">3 days ago</data></p> <link itemprop="url" href="?comments=0"> </header>[ <p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.</p> <p><em>...</em></p> <footer> <a itemprop="discussionUrl" href="?comments=1">Show comments...</a> </footer> </article></pre> <p>Here is that same blog post, but showing some of the comments:</p> <pre><article itemscope itemtype="http://schema.org/BlogPosting"> <header> <h1 itemprop="headline">The Very First Rule of Life</h1> <p><data itemprop="datePublished" value="2009-10-09">3 days ago</data></p> <link itemprop="url" href="?comments=0"> </header> <p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.</p> <p><em>...</em></p> <section> <h1>Comments</h1> <article itemprop="comment" itemscope itemtype="http://schema.org/UserComments" id="c1"> <link itemprop="url" href="#c1"> <footer> <p>Posted by: <span itemprop="creator" itemscope itemtype="http://schema.org/Person"> <span itemprop="name">George Washington</span> </span></p> <p><data itemprop="commentTime" value="2009-10-10">15 minutes ago</data></p> </footer> <p>Yeah! Especially when talking about your lobbyist friends!</p> </article> <article itemprop="comment" itemscope itemtype="http://schema.org/UserComments" id="c2"> <link itemprop="url" href="#c2"> <footer> <p>Posted by: <span itemprop="creator" itemscope itemtype="http://schema.org/Person"> <span itemprop="name">George Hammond</span> </span></p> <p><data itemprop="commentTime" value="2009-10-10">5 minutes ago</data></p> </footer> <p>Hey, you have the same first name as me.</p> </article> </section> </article></pre> <p>Notice the use of <code><a href=#the-footer-element>footer</a></code> to give the information for each comment (such as who wrote it and when): the <code><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><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> <h4 id=the-aside-element><span class=secno>4.4.5 </span>The <dfn><code>aside</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-content>Sectioning content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-aside-element>aside</a></code> element <a href=#represents>represents</a> a section of a page that consists of content that is tangentially related to the content around the <code><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><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><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><aside> <h1>Switzerland</h1> <p>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.</p> </aside></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>... <p>He later joined a large company, continuing on the same work. <q>I love my job. People ask me what I do for fun when I'm not at work. But I'm paid to do my hobby, so I never know what to answer. Some people wonder what they would do if they didn't have to work... but I know what I would do, because I was unemployed for a year, and I filled that time doing exactly what I do now.</q></p> <aside> <q> People ask me what I do for fun when I'm not at work. But I'm paid to do my hobby, so I never know what to answer. </q> </aside> <p>Of course his work — or should that be hobby? — isn't his only passion. He also enjoys other pleasures.</p> ...</pre> </div> <div class=example> <p>The following extract shows how <code><a href=#the-aside-element>aside</a></code> can be used for blogrolls and other side content on a blog:</p> <pre><body> <header> <h1>My wonderful blog</h1> <p>My tagline</p> </header> <aside> <!-- <em>this aside contains two sections that are tangentially related to the page, namely, links to other blogs, and links to blog posts from this blog</em> --> <nav> <h1>My blogroll</h1> <ul> <li><a href="http://blog.example.com/">Example Blog</a> </ul> </nav> <nav> <h1>Archives</h1> <ol reversed> <li><a href="/last-post">My last post</a> <li><a href="/first-post">My first post</a> </ol> </nav> </aside> <aside> <!-- <em>this aside is tangentially related to the page also, it contains twitter messages from the blog author</em> --> <h1>Twitter Feed</h1> <blockquote cite="http://twitter.example.net/t31351234"> I'm on vacation, writing my blog. </blockquote> <blockquote cite="http://twitter.example.net/t31219752"> I'm going to go on vacation soon. </blockquote> </aside> <article> <!-- <em>this is a blog post</em> --> <h1>My last post</h1> <p>This is my last post.</p> <footer> <p><a href="/last-post" rel=bookmark>Permalink</a> </footer> </article> <article> <!-- <em>this is also a blog post</em> --> <h1>My first post</h1> <p>This is my first post.</p> <aside> <!-- <em>this aside is about the blog post, since it's inside the <article> element; it would be wrong, for instance, to put the blogroll here, since the blogroll isn't really related to this post specifically, only to the page as a whole</em> --> <h1>Posting</h1> <p>While I'm thinking about it, I wanted to say something about posting. Posting is fun!</p> </aside> <footer> <p><a href="/first-post" rel=bookmark>Permalink</a> </footer> </article> <footer> <nav> <a href="/archives">Archives</a> — <a href="/about">About me</a> — <a href="/copyright">Copyright</a> </nav> </footer> </body></pre> </div> <h4 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><span class=secno>4.4.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</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#heading-content>Heading content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of an <code><a href=#the-hgroup-element>hgroup</a></code> element.</dd> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlheadingelement>HTMLHeadingElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>These elements <a href=#represents title=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>headings and sections</a>.</p> <p>These elements have a <dfn id=rank>rank</dfn> given by the number in their name. The <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element is said to have the highest rank, the <code><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>These two snippets are equivalent:</p> <pre><body> <h1>Let's call it a draw(ing surface)</h1> <h2>Diving in</h2> <h2>Simple shapes</h2> <h2>Canvas coordinates</h2> <h3>Canvas coordinates diagram</h3> <h2>Paths</h2> </body></pre> <pre><body> <h1>Let's call it a draw(ing surface)</h1> <section> <h1>Diving in</h1> </section> <section> <h1>Simple shapes</h1> </section> <section> <h1>Canvas coordinates</h1> <section> <h1>Canvas coordinates diagram</h1> </section> </section> <section> <h1>Paths</h1> </section> </body></pre> </div> <h4 id=the-hgroup-element><span class=secno>4.4.7 </span>The <dfn><code>hgroup</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#heading-content>Heading content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and/or <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-hgroup-element>hgroup</a></code> element <a href=#represents>represents</a> the heading of a section. The element is used to group a set of <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><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>For the purposes of document summaries, outlines, and the like, the text of <code><a href=#the-hgroup-element>hgroup</a></code> elements is defined to be the text of the highest <a href=#rank title=rank>ranked</a> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> element descendant of the <code><a href=#the-hgroup-element>hgroup</a></code> element, if there are any such elements, and the first such element if there are multiple elements with that <a href=#rank>rank</a>. If there are no such elements, then the text of the <code><a href=#the-hgroup-element>hgroup</a></code> element is the empty string.</p> <p>Other elements of <a href=#heading-content>heading content</a> in the <code><a href=#the-hgroup-element>hgroup</a></code> element indicate subheadings or subtitles.</p> <p>The <a href=#rank>rank</a> of an <code><a href=#the-hgroup-element>hgroup</a></code> element is the rank of the highest-ranked <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> element descendant of the <code><a href=#the-hgroup-element>hgroup</a></code> element, if there are any such elements, or otherwise the same as for an <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element (the highest rank).</p> <p>The section on <a href=#headings-and-sections>headings and sections</a> defines how <code><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. In each case, the emphasized text represents the text that would be used as the heading in an application extracting heading data and ignoring subheadings.</p> <pre><hgroup> <h1><strong>The reality dysfunction</strong></h1> <h2>Space is not the only void</h2> </hgroup></pre> <pre><hgroup> <h1><strong>Dr. Strangelove</strong></h1> <h2>Or: How I Learned to Stop Worrying and Love the Bomb</h2> </hgroup></pre> <p>The point of using <code><a href=#the-hgroup-element>hgroup</a></code> in these examples is to mask the <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element (which acts as a secondary title) from the <a href=#outline>outline</a> algorithm.</p><!-- http://www.brucelawson.co.uk/2009/html-5-is-a-mess/#comment-618895 --> </div> <h4 id=the-header-element><span class=secno>4.4.8 </span>The <dfn><code>header</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code> or <code><a href=#the-footer-element>footer</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-header-element>header</a></code> element <a href=#represents>represents</a> a group of introductory or navigational aids.</p> <p class=note>A <code><a href=#the-header-element>header</a></code> element is intended to usually contain the section's heading (an <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> element or an <code><a href=#the-hgroup-element>hgroup</a></code> element), but this is not required. The <code><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><header> <p>Welcome to...</p> <h1>Voidwars!</h1> </header></pre> <p>The following snippet shows how the element can be used to mark up a specification's header:</p> <pre><header> <hgroup> <h1>Scalable Vector Graphics (SVG) 1.2</h1> <h2>W3C Working Draft 27 October 2004</h2> </hgroup> <dl> <dt>This version:</dt> <dd><a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/">http://www.w3.org/TR/2004/WD-SVG12-20041027/</a></dd> <dt>Previous version:</dt> <dd><a href="http://www.w3.org/TR/2004/WD-SVG12-20040510/">http://www.w3.org/TR/2004/WD-SVG12-20040510/</a></dd> <dt>Latest version of SVG 1.2:</dt> <dd><a href="http://www.w3.org/TR/SVG12/">http://www.w3.org/TR/SVG12/</a></dd> <dt>Latest SVG Recommendation:</dt> <dd><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></dd> <dt>Editor:</dt> <dd>Dean Jackson, W3C, <a href="mailto:dean@w3.org">dean@w3.org</a></dd> <dt>Authors:</dt> <dd>See <a href="#authors">Author List</a></dd> </dl> <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notic <em>...</em> </header></pre> </div> <p class=note>The <code><a href=#the-header-element>header</a></code> element is not <a href=#sectioning-content>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><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element, and two subsections whose headings are given by <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> elements. The content after the <code><a href=#the-header-element>header</a></code> element is still part of the last subsection started in the <code><a href=#the-header-element>header</a></code> element, because the <code><a href=#the-header-element>header</a></code> element doesn't take part in the <a href=#outline>outline</a> algorithm.</p> <pre><body> <header> <h1>Little Green Guys With Guns</h1> <nav> <ul> <li><a href="/games">Games</a> <li><a href="/forum">Forum</a> <li><a href="/download">Download</a> </ul> </nav> <h2>Important News</h2> <!-- this starts a second subsection --> <!-- this is part of the subsection entitled "Important News" --> <p>To play today's games you will need to update your client.</p> <h2>Games</h2> <!-- this starts a third subsection --> </header> <p>You have three active games:</p> <!-- this is still part of the subsection entitled "Games" --> ...</pre> </div> <h4 id=the-footer-element><span class=secno>4.4.9 </span>The <dfn><code>footer</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code> or <code><a href=#the-footer-element>footer</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-footer-element>footer</a></code> element <a href=#represents>represents</a> a footer for its nearest ancestor <a href=#sectioning-content>sectioning content</a> or <a href=#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><a href=#the-footer-element>footer</a></code> element contains entire sections, they <a href=#represents title=represents>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><a href=#the-address-element>address</a></code> element, possibly itself inside a <code><a href=#the-footer-element>footer</a></code>.</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>sectioning content</a> or <a href=#sectioning-root>sectioning root</a> element is <a href=#the-body-element-0>the body element</a>, then it applies to the whole page.</p> <p class=note>The <code><a href=#the-footer-element>footer</a></code> element is not <a href=#sectioning-content>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><body> <footer><a href="../">Back to index...</a></footer> <hgroup> <h1>Lorem ipsum</h1> <h2>The ipsum of all lorems</h2> </hgroup> <p>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.</p> <footer><a href="../">Back to index...</a></footer> </body></pre> </div> <div class=example> <p>Here is an example which shows the <code><a href=#the-footer-element>footer</a></code> element being used both for a site-wide footer and for a section footer.</p> <pre><!DOCTYPE HTML> <HTML><HEAD> <TITLE>The Ramblings of a Scientist</TITLE> <BODY> <H1>The Ramblings of a Scientist</H1> <ARTICLE> <H1>Episode 15</H1> <VIDEO SRC="/fm/015.ogv" CONTROLS PRELOAD> <P><A HREF="/fm/015.ogv">Download video</A>.</P> </VIDEO> <FOOTER> <!-- footer for article --> <P>Published <DATA VALUE="2009-10-21T18:26-07:00">on 2009/10/21 at 6:26pm</DATA></P> </FOOTER> </ARTICLE> <ARTICLE> <H1>My Favorite Trains</H1> <P>I love my trains. My favorite train of all time is a Köf.</P> <P>It is fun to see them pull some coal cars because they look so dwarfed in comparison.</P> <FOOTER> <!-- footer for article --> <P>Published <DATA VALUE="2009-09-15T14:54-07:00">on 2009/09/15 at 2:54pm</DATA></P> </FOOTER> </ARTICLE> <FOOTER> <!-- site wide footer --> <NAV> <P><A HREF="/credits.html">Credits</A> — <A HREF="/tos.html">Terms of Service</A> — <A HREF="/index.html">Blog Index</A></P> </NAV> <P>Copyright © 2009 Gordon Freeman</P> </FOOTER> </BODY> </HTML></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>... <footer> <nav> <section> <h1>Articles</h1> <p><img src="images/somersaults.jpeg" alt=""> Go to the gym with our somersaults class! Our teacher Jim takes you through the paces in this two-part article. <a href="articles/somersaults/1">Part 1</a> · <a href="articles/somersaults/1">Part 2</a></p> <p><img src="images/kindplus.jpeg"> Tired of walking on the edge of a clif<!-- sic -->? Our guest writer Lara shows you how to bumble your way through the bars. <a href="articles/kindplus/1">Read more...</a></p> <p><img src="images/crisps.jpeg"> The chips are down, now all that's left is a potato. What can you do with it? <a href="articles/crisps/1">Read more...</a></p> </section> <ul> <li> <a href="/about">About us...</a> <li> <a href="/feedback">Send feedback!</a> <li> <a href="/sitemap">Sitemap</a> </ul> </nav> <p><small>Copyright © 2015 The Snacker — <a href="/tos">Terms of Service</a></small></p> </footer> </body></pre> </div> <h4 id=the-address-element><span class=secno>4.4.10 </span>The <dfn><code>address</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <a href=#heading-content>heading content</a> descendants, no <a href=#sectioning-content>sectioning content</a> descendants, and no <code><a href=#the-header-element>header</a></code>, <code><a href=#the-footer-element>footer</a></code>, or <code><a href=#the-address-element>address</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-address-element>address</a></code> element <a href=#represents>represents</a> the contact information for its nearest <code><a href=#the-article-element>article</a></code> or <code><a href=#the-body-element>body</a></code> element ancestor. If that is <a href=#the-body-element-0>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><ADDRESS> <A href="../People/Raggett/">Dave Raggett</A>, <A href="../People/Arnaud/">Arnaud Le Hors</A>, contact persons for the <A href="Activity">W3C HTML Activity</A> </ADDRESS></pre> </div> <p>The <code><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><a href=#the-p-element>p</a></code> element is the appropriate element for marking up postal addresses in general.)</p> <p>The <code><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><a href=#the-address-element>address</a></code> element:</p> <pre class=bad><ADDRESS>Last Modified: 1999/12/24 23:37:50</ADDRESS></pre> </div> <p>Typically, the <code><a href=#the-address-element>address</a></code> element would be included along with other information in a <code><a href=#the-footer-element>footer</a></code> element.</p> <div class=impl> <p>The contact information for a node <var title="">node</var> is a collection of <code><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 title="">node</var> is an <code><a href=#the-article-element>article</a></code> element</dt> <dt>If <var title="">node</var> is a <code><a href=#the-body-element>body</a></code> element</dt> <dd> <p>The contact information consists of all the <code><a href=#the-address-element>address</a></code> elements that have <var title="">node</var> as an ancestor and do not have another <code><a href=#the-body-element>body</a></code> or <code><a href=#the-article-element>article</a></code> element ancestor that is a descendant of <var title="">node</var>.</p> </dd> <dt>If <var title="">node</var> has an ancestor element that is an <code><a href=#the-article-element>article</a></code> element</dt> <dt>If <var title="">node</var> has an ancestor element that is a <code><a href=#the-body-element>body</a></code> element</dt> <dd> <p>The contact information of <var title="">node</var> is the same as the contact information of the nearest <code><a href=#the-article-element>article</a></code> or <code><a href=#the-body-element>body</a></code> element ancestor, whichever is nearest.</p> </dd> <dt>If <var title="">node</var>'s <code><a href=#document>Document</a></code> has <a href=#the-body-element-0 title="the body element">a body element</a></dt> <dd> <p>The contact information of <var title="">node</var> is the same as the contact information of <a href=#the-body-element-0>the body element</a> of the <code><a href=#document>Document</a></code>.</p> </dd> <dt>Otherwise</dt> <dd> <p>There is no contact information for <var title="">node</var>.</p> </dd> </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> <div class=example> <p>In this example the footer contains contact information and a copyright notice.</p> <pre><footer> <address> For more details, contact <a href="mailto:js@example.com">John Smith</a>. </address> <p><small>© copyright 2038 Example Corp.</small></p> </footer></pre> </div> <h4 id=headings-and-sections><span class=secno>4.4.11 </span><dfn>Headings and sections</dfn></h4> <p>The <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements and the <code><a href=#the-hgroup-element>hgroup</a></code> element are headings.</p> <p>The first element of <a href=#heading-content>heading content</a> in an element of <a href=#sectioning-content>sectioning content</a> <a href=#represents>represents</a> the heading for that section. Subsequent headings of equal or higher <a href=#rank>rank</a> start new (implied) sections, headings of lower <a href=#rank>rank</a> start implied subsections that are part of the previous one. In both cases, the element <a href=#represents>represents</a> the heading of the implied section.</p> <p>Certain elements are said to be <dfn id=sectioning-root title="sectioning root">sectioning roots</dfn>, including <code><a href=#the-blockquote-element>blockquote</a></code> and <code><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> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-blockquote-element>blockquote</a></code></li> <li><code><a href=#the-body-element>body</a></code></li> <li><code><a href=#the-details-element>details</a></code></li> <li><code><a href=#the-fieldset-element>fieldset</a></code></li> <li><code><a href=#the-figure-element>figure</a></code></li> <li><code><a href=#the-td-element>td</a></code></li> </ul><!-- a root element isn't a sectioning root. This means, for instance, that you don't get an outline if you just have a random XML file with <html:h1> elements in it. Other vocabs need to define what their sectioning root is. --><p><a href=#sectioning-content>Sectioning content</a> elements are always considered subsections of their nearest ancestor <a href=#sectioning-root>sectioning root</a> or their nearest ancestor element of <a href=#sectioning-content>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><body> <h1>Foo</h1> <h2>Bar</h2> <blockquote> <h3>Bla</h3> </blockquote> <p>Baz</p> <h2>Quux</h2> <section> <h3>Thud</h3> </section> <p>Grunt</p> </body></pre> <p>...the structure would be:</p> <ol><li> Foo (heading of explicit <code><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> <li> Quux (heading starting implied section with no content other than the heading itself) </li> <li> Thud (heading of explicit <code><a href=#the-section-element>section</a></code> section) </li> </ol></li> </ol><p>Notice how the <code><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>rank</a>, but authors are strongly encouraged to either use only <code><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>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>sectioning content</a>, instead of relying on the implicit sections generated by having multiple headings in one element of <a href=#sectioning-content>sectioning content</a>.</p> <div class=example> <p>For example, the following is correct:</p> <pre><body> <h4>Apples</h4> <p>Apples are fruit.</p> <section> <h2>Taste</h2> <p>They taste lovely.</p> <h6>Sweet</h6> <p>Red apples are sweeter than green ones.</p> <h1>Color</h1> <p>Apples come in various colors.</p> </section> </body></pre> <p>However, the same document would be more clearly expressed as:</p> <pre><body> <h1>Apples</h1> <p>Apples are fruit.</p> <section> <h2>Taste</h2> <p>They taste lovely.</p> <section> <h3>Sweet</h3> <p>Red apples are sweeter than green ones.</p> </section> </section> <section> <h2>Color</h2> <p>Apples come in various colors.</p> </section> </body></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><body> <h1>Apples</h1> <p>Apples are fruit.</p> <section> <h1>Taste</h1> <p>They taste lovely.</p> <section> <h1>Sweet</h1> <p>Red apples are sweeter than green ones.</p> </section> </section> <section> <h1>Color</h1> <p>Apples come in various colors.</p> </section> </body></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.4.11.1 </span>Creating an outline</h5> <div class=impl> <!-- v2 idea: It would be nice if there was a way to use this to autogenerate a table of contents or some such --> <p>This section defines an algorithm for creating an outline for a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element. It is defined in terms of a walk over the nodes of a DOM tree, in tree order, with each node being visited when it is <i>entered</i> and when it is <i>exited</i> during the walk.</p> </div> <p>The <dfn id=outline>outline</dfn> for a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element consists of a list of one or more potentially nested <a href=#concept-section title=concept-section>sections</a>. A <dfn id=concept-section title=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. <span class=impl>The algorithm for the outline also associates each node in the DOM tree with a particular section and potentially a heading.</span> (The sections in the outline aren't <code><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><body> <h1>A</h1> <p>B</p> <h2>C</h2> <p>D</p> <h2>E</h2> <p>F</p> </body></pre> <p>...results in the following outline being created for the <code><a href=#the-body-element>body</a></code> node (and thus the entire document):</p> <ol class=brief><li> <p>Section created for <code><a href=#the-body-element>body</a></code> node.</p> <p>Associated with heading "A".</p> <p>Also associated with paragraph "B".</p> <p>Nested sections:</p> <ol class=brief><li> <p>Section implied for first <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element.</p> <p>Associated with heading "C".</p> <p>Also associated with paragraph "D".</p> <p>No nested sections.</p> </li> <li> <p>Section implied for second <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element.</p> <p>Associated with heading "E".</p> <p>Also associated with paragraph "F".</p> <p>No nested sections.</p> </li> </ol></li> </ol></div> <div class=impl> <p>The algorithm that must be followed during a walk of a DOM subtree rooted at a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element to determine that element's <a href=#outline>outline</a> is as follows:</p> <ol><li><p>Let <var title="">current outlinee</var> be null. (It holds the element whose <a href=#outline>outline</a> is being created.)</li> <li><p>Let <var title="">current section</var> be null. (It holds a pointer to a <a href=#concept-section title=concept-section>section</a>, so that elements in the DOM can all be associated with a section.)</li> <li><p>Create a stack to hold elements, which is used to handle nesting. Initialize this stack to empty.</li> <li> <p>As you walk over the DOM in <a href=#tree-order>tree order</a>, starting with the <a href=#sectioning-content>sectioning content</a> element or <a href=#sectioning-root>sectioning root</a> element at the root of the subtree for which an outline is to be created, trigger the first relevant step below for each element as you enter and exit it.</p> <dl class=switch><dt>If you are exiting an element and that element is the element at the top of the stack</dt> <dd> <p class=note>The element being exited is a <a href=#heading-content>heading content</a> element.</p> <p>Pop that element from the stack.</p> </dd> <dt>If the top of the stack is a <a href=#heading-content>heading content</a> element</dt> <dd><p>Do nothing.</dd> <dt>When entering a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element</dt> <dd> <p>If <var title="">current outlinee</var> is not null, and the <var title="">current section</var> has no heading, create an implied heading and let that be the heading for the <var title="">current section</var>.</p> <p>If <var title="">current outlinee</var> is not null, push <var title="">current outlinee</var> onto the stack.</p> <p>Let <var title="">current outlinee</var> be the element that is being entered.</p> <p>Let <var title="">current section</var> be a newly created <a href=#concept-section title=concept-section>section</a> for the <var title="">current outlinee</var> element.</p> <p>Associate <var title="">current outlinee</var> with <var title="">current section</var>.</p> <p>Let there be a new <a href=#outline>outline</a> for the new <var title="">current outlinee</var>, initialized with just the new <var title="">current section</var> as the only <a href=#concept-section title=concept-section>section</a> in the outline.</p> </dd> <dt>When exiting a <a href=#sectioning-content>sectioning content</a> element, if the stack is not empty</dt> <dd> <p>Pop the top element from the stack, and let the <var title="">current outlinee</var> be that element.</p> <p>Let <var title="">current section</var> be the last section in the <a href=#outline>outline</a> of the <var title="">current outlinee</var> element.</p> <p>Append the <a href=#outline>outline</a> of the <a href=#sectioning-content>sectioning content</a> element being exited to the <var title="">current section</var>. (This does not change which section is the last section in the <a href=#outline>outline</a>.)</p> </dd> <dt>When exiting a <a href=#sectioning-root>sectioning root</a> element, if the stack is not empty</dt> <dd> <p>Run these steps:</p> <ol><li><p>Pop the top element from the stack, and let the <var title="">current outlinee</var> be that element.</li> <li><p>Let <var title="">current section</var> be the last section in the <a href=#outline>outline</a> of the <var title="">current outlinee</var> element.</li> <li><p><i>Finding the deepest child</i>: If <var title="">current section</var> has no child sections, stop these steps.</li> <li><p>Let <var title="">current section</var> be the last child <a href=#concept-section title=concept-section>section</a> of the current <var title="">current section</var>.</li> <li><p>Go back to the substep labeled <i>finding the deepest child</i>.</li> </ol></dd> <dt>When exiting a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element</dt> <dd> <p class=note>The <var title="">current outlinee</var> is the element being exited, and it is the <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element at the root of the subtree for which an outline is being generated.</p> <p>Let <var title="">current section</var> be the first <a href=#concept-section title=concept-section>section</a> in the <a href=#outline>outline</a> of the <var title="">current outlinee</var> element.</p> <p>Skip to the next step in the overall set of steps. (The walk is over.)</p> </dd> <dt>When entering a <a href=#heading-content>heading content</a> element</dt> <dd> <p>If the <var title="">current section</var> has no heading, let the element being entered be the heading for the <var title="">current section</var>.</p> <p>Otherwise, if the element being entered has a <a href=#rank>rank</a> equal to or greater than the heading of the last section of the <a href=#outline>outline</a> of the <var title="">current outlinee</var>, then create a new <a href=#concept-section title=concept-section>section</a> and append it to the <a href=#outline>outline</a> of the <var title="">current outlinee</var> element, so that this new section is the new last section of that outline. Let <var title="">current section</var> be that new section. Let the element being entered be the new heading for the <var title="">current section</var>.</p> <p>Otherwise, run these substeps:</p> <ol><li><p>Let <var title="">candidate section</var> be <var title="">current section</var>.</li> <li><p>If the element being entered has a <a href=#rank>rank</a> lower than the <a href=#rank>rank</a> of the heading of the <var title="">candidate section</var>, then create a new <a href=#concept-section title=concept-section>section</a>, and append it to <var title="">candidate section</var>. (This does not change which section is the last section in the outline.) Let <var title="">current section</var> be this new section. Let the element being entered be the new heading for the <var title="">current section</var>. Abort these substeps.</p> <li><p>Let <var title="">new candidate section</var> be the <a href=#concept-section title=concept-section>section</a> that contains <var title="">candidate section</var> in the <a href=#outline>outline</a> of <var title="">current outlinee</var>.</li> <li><p>Let <var title="">candidate section</var> be <var title="">new candidate section</var>.</li> <li><p>Return to step 2.</li> </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><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> has the <em>highest</em> rank, and <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> has the lowest rank.</p> </dd> <dt>Otherwise</dt> <dd><p>Do nothing.</dd> </dl><p id=associatedSection>In addition, whenever you exit a node, after doing the steps above, if the node is not associated with a <a href=#concept-section title=concept-section>section</a> yet, associate the node with the <a href=#concept-section title=concept-section>section</a> <var title="">current section</var>.</p> </li> <li><p>Associate all nodes with the heading of the <a href=#concept-section title=concept-section>section</a> with which they are associated, if any.</li> </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-0>the body element</a> of a <code><a href=#document>Document</a></code> is the <a href=#outline>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>sectioning content</a> element, if the <a href=#concept-section title=concept-section>section</a> was created for a real element in the original document, or to the relevant <a href=#heading-content>heading content</a> element, if the <a href=#concept-section title=concept-section>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 title=concept-section>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><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>heading content</a> element associated with a <a href=#concept-section title=concept-section>section</a> <var title="">section</var> is the number of <a href=#concept-section title=concept-section>sections</a> that are ancestors of <var title="">section</var> in the <a href=#outline>outline</a> that <var title="">section</var> finds itself in when the <a href=#outline title=outline>outlines</a> of its <code><a href=#document>Document</a></code>'s elements are created, plus 1. The <a href=#outline-depth>outline depth</a> of a <a href=#heading-content>heading content</a> element not associated with a <a href=#concept-section title=concept-section>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><body> <nav> <p><a href="/">Home</a></p> </nav> <p>Hello world.</p> <aside> <p>My cat is cute.</p> </aside> </body></pre> <p>Although it contains no headings, this snippet has three sections: a document (the <code><a href=#the-body-element>body</a></code>) with two subsections (a <code><a href=#the-nav-element>nav</a></code> and an <code><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> <li>Sidebar</li> </ol></li> </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 implementor's preferences, etc.</p> </div> <div class=note> <p>The following JavaScript function shows how the tree walk could be implemented. The <var title="">root</var> argument is the root of the tree to walk (either a <a href=#sectioning-content>sectioning content</a> element or a <a href=#sectioning-root>sectioning root</a> element), and the <var title="">enter</var> and <var title="">exit</var> arguments are callbacks that are called with the nodes as they are entered and exited. <a href=#refsECMA262>[ECMA262]</a></p> <pre>function (root, enter, exit) { var node = root; start: while (node) { enter(node); if (node.firstChild) { node = node.firstChild; continue start; } while (node) { exit(node); if (node == root) { node = null; } else if (node.nextSibling) { node = node.nextSibling; continue start; } else { node = node.parentNode; } } } }</pre> </div> </div> <h3 id=grouping-content><span class=secno>4.5 </span>Grouping content</h3> <h4 id=the-p-element><span class=secno>4.5.1 </span>The <dfn><code>p</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlparagraphelement>HTMLParagraphElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-p-element>p</a></code> element <a href=#represents>represents</a> a <a href=#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><p>The little kitten gently seated himself on a piece of carpet. Later in his life, this would be referred to as the time the cat sat on the mat.</p></pre> <pre><fieldset> <legend>Personal information</legend> <p> <label>Name: <input name="n"></label> <label><input name="anon" type="checkbox"> Hide from other users</label> </p> <p><label>Address: <textarea name="a"></textarea></label></p> </fieldset></pre> <pre><p>There was once an example from Femley,<br> Whose markup was of dubious quality.<br> The validator complained,<br> So the author was pained,<br> To move the error from the markup to the rhyming.</p></pre> </div> <p>The <code><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><section> <!-- ... --> <p>Last modified: 2001-04-23</p> <p>Author: fred@example.com</p> </section></pre> <p>However, it would be better marked-up as:</p> <pre><section> <!-- ... --> <footer>Last modified: 2001-04-23</footer> <address>Author: fred@example.com</address> </section></pre> <p>Or:</p> <pre><section> <!-- ... --> <footer> <p>Last modified: 2001-04-23</p> <address>Author: fred@example.com</address> </footer> </section></pre> </div> <h4 id=the-hr-element><span class=secno>4.5.2 </span>The <dfn><code>hr</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlhrelement>HTMLHRElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-hr-element>hr</a></code> element <a href=#represents>represents</a> a <a href=#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><a href=#the-hr-element>hr</a></code> element to separate topics within the section.</p> <pre><section> <h1>Communication</h1> <p>There are various methods of communication. This section covers a few of the important ones used by the project.</p> <strong><hr></strong> <p>Communication stones seem to come in pairs and have mysterious properties:</p> <ul> <li>They can transfer thoughts in two directions once activated if used alone.</li> <li>If used with another device, they can transfer one's consciousness to another body.</li> <li>If both stones are used with another device, the consciousnesses switch bodies.</li> </ul> <strong><hr></strong> <p>Radios use the electromagnetic spectrum in the meter range and longer.</p> <strong><hr></strong> <p>Signal flares use the electromagnetic spectrum in the nanometer range.</p> </section> <section> <h1>Food</h1> <p>All food at the project is rationed:</p> <dl> <dt>Potatoes</dt> <dd>Two per day</dd> <dt>Soup</dt> <dd>One bowl per day</dd> </dl> <strong><hr></strong> <p>Cooking is done by the chefs on a set rotation.</p> </section></pre> <p>There is no need for an <code><a href=#the-hr-element>hr</a></code> element between the sections themselves, since the <code><a href=#the-section-element>section</a></code> elements and the <code><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><a href=#the-hr-element>hr</a></code> element.</p> <!-- ISBN 1-4050-0020-1; bottom of page 14 --> <pre lang=en-GB><p>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.</p> <p><i>Maybe it won't be that bad</i>, he told himself. The lie was comforting enough to get him through the rest of the night's shift.</p> <strong><hr></strong> <p>The Carlton AllLander drove Dudley home just after dawn. Like the astronomer, the vehicle was old and worn, but perfectly capable of doing its job. It had a cheap diesel engine, common enough on a semi-frontier world like Gralmond, although its drive array was a thoroughly modern photoneural processor. With its high suspension and deep-tread tyres it could plough along the dirt track to the observatory in all weather and seasons, including the metre-deep snow of Gralmond's winters.</p></pre> </div> <p class=note>The <code><a href=#the-hr-element>hr</a></code> element does not affect the document's <a href=#outline>outline</a>.</p> <h4 id=the-pre-element><span class=secno>4.5.3 </span>The <dfn><code>pre</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlpreelement>HTMLPreElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-pre-element>pre</a></code> element <a href=#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>the HTML syntax</a>, a leading newline character immediately following the <code><a href=#the-pre-element>pre</a></code> element start tag is stripped.</p> <p>Some examples of cases where the <code><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> <li>Including fragments of computer code, with structure indicated according to the conventions of that language.</li> <li>Displaying ASCII art.</li> </ul><p class=note>Authors are encouraged to consider how preformatted text will be experienced when the formatting is lost, as will be the case for users of speech synthesizers, braille displays, and the like. For cases like ASCII art, it is likely that an alternative presentation, such as a textual description, would be more universally accessible to the readers of the document.</p> <p>To represent a block of computer code, the <code><a href=#the-pre-element>pre</a></code> element can be used with a <code><a href=#the-code-element>code</a></code> element; to represent a block of computer output the <code><a href=#the-pre-element>pre</a></code> element can be used with a <code><a href=#the-samp-element>samp</a></code> element. Similarly, the <code><a href=#the-kbd-element>kbd</a></code> element can be used within a <code><a href=#the-pre-element>pre</a></code> element to indicate text that the user is to enter.</p> <div class=impl> <p>A newline in a <code><a href=#the-pre-element>pre</a></code> element should separate paragraphs for the purposes of the Unicode bidirectional algorithm. This requirement may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements by implementing the CSS 'unicode-bidi' property. <a href=#refsBIDI>[BIDI]</a> <a href=#refsCSS>[CSS]</a></p> </div> <div class=example> <p>In the following snippet, a sample of computer code is presented.</p> <pre><p>This is the <code>Panel</code> constructor:</p> <pre><code>function Panel(element, canClose, closeHandler) { this.element = element; this.canClose = canClose; this.closeHandler = function () { if (closeHandler) closeHandler() }; }</code></pre></pre> </div> <div class=example> <p>In the following snippet, <code><a href=#the-samp-element>samp</a></code> and <code><a href=#the-kbd-element>kbd</a></code> elements are mixed in the contents of a <code><a href=#the-pre-element>pre</a></code> element to show a session of Zork I.</p> <pre><pre><samp>You are in an open field west of a big white house with a boarded front door. There is a small mailbox here. ></samp> <kbd>open mailbox</kbd> <samp>Opening the mailbox reveals: A leaflet. ></samp></pre></pre> </div> <div class=example> <p>The following shows a contemporary poem that uses the <code><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><pre> 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</pre></pre> </div> <h4 id=the-blockquote-element><span class=secno>4.5.4 </span>The <dfn><code>blockquote</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-blockquote-cite><a href=#attr-blockquote-cite>cite</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlquoteelement>HTMLQuoteElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-quote-cite title=dom-quote-cite>cite</a>; };</pre> <p class=note>The <code><a href=#htmlquoteelement>HTMLQuoteElement</a></code> interface is also used by the <code><a href=#the-q-element>q</a></code> element.</p> </dd> </dl><p>The <code><a href=#the-blockquote-element>blockquote</a></code> element <a href=#represents>represents</a> a section that is quoted from another source.</p> <p>Content inside a <code><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 title=attr-blockquote-cite><code>cite</code></dfn> attribute.</p> <p>If the <code title=attr-blockquote-cite><a href=#attr-blockquote-cite>cite</a></code> attribute is present, it must be a <a href=#valid-url-potentially-surrounded-by-spaces>valid URL potentially surrounded by spaces</a>. <span class=impl>To obtain the corresponding citation link, the value of the attribute must be <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element. User agents should allow users to follow such citation links.</span></p> <div class=impl> <p>The <dfn id=dom-quote-cite title=dom-quote-cite><code>cite</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the element's <code title="">cite</code> content attribute.</p> </div> <div class=example> <p>Here a <code><a href=#the-blockquote-element>blockquote</a></code> element is used in conjunction with a <code><a href=#the-figure-element>figure</a></code> element and its <code><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><a href=#the-blockquote-element>blockquote</a></code> itself):</p> <pre><figure> <blockquote> <p>The truth may be puzzling. It may take some work to grapple with. It may be counterintuitive. It may contradict deeply held prejudices. It may not be consonant with what we desperately want to be true. But our preferences do not determine what's true. We have a method, and that method helps us to reach not absolute truth, only asymptotic approaches to the truth — never there, just closer and closer, always finding vast new oceans of undiscovered possibilities. Cleverly designed experiments are the key.</p> </blockquote> <figcaption>Carl Sagan, in "<cite>Wonder and Skepticism</cite>", from the <cite>Skeptical Enquirer</cite> Volume 19, Issue 1 (January-February 1995)</cite></figcaption> </figure></pre> </div> <div class=example> <p>This next example shows the use of <code><a href=#the-cite-element>cite</a></code> alongside <code><a href=#the-blockquote-element>blockquote</a></code>:</p> <pre><p>His next piece was the aptly named <cite>Sonnet 130</cite>:</p> <blockquote cite="http://quotes.example.org/s/sonnet130.html"> <p>My mistress' eyes are nothing like the sun,<br> Coral is far more red, than her lips red,<br> ...</pre> </div> <div class=example> <p>This example shows how a forum post could use <code><a href=#the-blockquote-element>blockquote</a></code> to show what post a user is replying to. The <code><a href=#the-article-element>article</a></code> element is used for each post, to mark up the threading.</p> <pre><article> <h1><a href="http://bacon.example.com/?blog=109431">Bacon on a crowbar</a></h1> <article> <header><strong>t3yw</strong> 12 points 1 hour ago</header> <p>I bet a narwhal would love that.</p> <footer><a href="?pid=29578">permalink</a></footer> <article> <header><strong>greg</strong> 8 points 1 hour ago</header> <blockquote><p>I bet a narwhal would love that.</p></blockquote> <p>Dude narwhals don't eat bacon.</p> <footer><a href="?pid=29579">permalink</a></footer> <article> <header><strong>t3yw</strong> 15 points 1 hour ago</header> <blockquote> <blockquote><p>I bet a narwhal would love that.</p></blockquote> <p>Dude narwhals don't eat bacon.</p> </blockquote> <p>Next thing you'll be saying they don't get capes and wizard hats either!</p> <footer><a href="?pid=29580">permalink</a></footer> <article> <article> <header><strong>boing</strong> -5 points 1 hour ago</header> <p>narwhals are worse than ceiling cat</p> <footer><a href="?pid=29581">permalink</a></footer> </article> </article> </article> </article> <article> <header><strong>fred</strong> 1 points 23 minutes ago</header> <blockquote><p>I bet a narwhal would love that.</p></blockquote> <p>I bet they'd love to peel a banana too.</p> <footer><a href="?pid=29582">permalink</a></footer> </article> </article> </article></pre> </div> <div class=example> <p>This example shows the use of a <code><a href=#the-blockquote-element>blockquote</a></code> for short snippets, demonstrating that one does not have to use <code><a href=#the-p-element>p</a></code> elements inside <code><a href=#the-blockquote-element>blockquote</a></code> elements:</p> <pre><p>He began his list of "lessons" with the following:</p> <blockquote>One should never assume that his side of the issue will be recognized, let alone that it will be conceded to have merits.</blockquote> <p>He continued with a number of similar points, ending with:</p> <blockquote>Finally, one should be prepared for the threat of breakdown in negotiations at any given moment and not be cowed by the possiblity.</blockquote> <p>We shall now discuss these points...</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><a href=#the-cite-element>cite</a></code> and <code><a href=#the-blockquote-element>blockquote</a></code> elements for this purpose.</p> <h4 id=the-ol-element><span class=secno>4.5.5 </span>The <dfn><code>ol</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>If the element's children include at least one <code><a href=#the-li-element>li</a></code> element: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code></dd> <dd><code title=attr-ol-start><a href=#attr-ol-start>start</a></code></dd> <dd><code title=attr-ol-type><a href=#attr-ol-type>type</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlolistelement>HTMLOListElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-ol-reversed title=dom-ol-reversed>reversed</a>; attribute long <a href=#dom-ol-start title=dom-ol-start>start</a>; attribute DOMString <a href=#dom-ol-type title=dom-ol-type>type</a>; };</pre> </dd> </dl><p>The <code><a href=#the-ol-element>ol</a></code> element <a href=#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><a href=#the-li-element>li</a></code> element child nodes of the <code><a href=#the-ol-element>ol</a></code> element, in <a href=#tree-order>tree order</a>.</p> <p>The <dfn id=attr-ol-reversed title=attr-ol-reversed><code>reversed</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. If present, it indicates that the list is a descending list (..., 3, 2, 1). If the attribute is omitted, the list is an ascending list (1, 2, 3, ...).</p> <p>The <dfn id=attr-ol-start title=attr-ol-start><code>start</code></dfn> attribute, if present, must be a <a href=#valid-integer>valid integer</a> giving the <a href=#ordinal-value>ordinal value</a> of the first list item.</p> <div class=impl> <p>If the <code title=attr-ol-start><a href=#attr-ol-start>start</a></code> attribute is present, user agents must <a href=#rules-for-parsing-integers title="rules for parsing integers">parse it as an integer</a>, in order to determine the attribute's value. The default value, used if the attribute is missing or if the value cannot be converted to a number according to the referenced algorithm, is 1 if the element has no <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code> attribute, and is the number of child <code><a href=#the-li-element>li</a></code> elements otherwise.</p> <p>The first item in the list has the <a href=#ordinal-value>ordinal value</a> given by the <code><a href=#the-ol-element>ol</a></code> element's <code title=attr-ol-start><a href=#attr-ol-start>start</a></code> attribute, unless that <code><a href=#the-li-element>li</a></code> element has a <code title=attr-li-value><a href=#attr-li-value>value</a></code> attribute with a value that can be successfully parsed, in which case it has the <a href=#ordinal-value>ordinal value</a> given by that <code title=attr-li-value><a href=#attr-li-value>value</a></code> attribute.</p> <p>Each subsequent item in the list has the <a href=#ordinal-value>ordinal value</a> given by its <code title=attr-li-value><a href=#attr-li-value>value</a></code> attribute, if it has one, or, if it doesn't, the <a href=#ordinal-value>ordinal value</a> of the previous item, plus one if the <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code> is absent, or minus one if it is present.</p> </div> <p>The <dfn id=attr-ol-type title=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 referenced by their number/letter). The attribute, if specified, must have a value that is a <a href=#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. <span class=impl>The <code title=attr-ol-type><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 title=attr-ol-type-state-decimal>decimal</a> state.</span></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 title=attr-ol-type-keyword-decimal><code>1</code></dfn> (U+0031) <td><dfn id=attr-ol-type-state-decimal title=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 title=attr-ol-type-keyword-lower-alpha><code>a</code></dfn> (U+0061) <td><dfn id=attr-ol-type-state-lower-alpha title=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 title=attr-ol-type-keyword-upper-alpha><code>A</code></dfn> (U+0041) <td><dfn id=attr-ol-type-state-upper-alpha title=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 title=attr-ol-type-keyword-lower-roman><code>i</code></dfn> (U+0069) <td><dfn id=attr-ol-type-state-lower-roman title=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 title=attr-ol-type-keyword-upper-roman><code>I</code></dfn> (U+0049) <td><dfn id=attr-ol-type-state-upper-roman title=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><div class=impl> <p>User agents should render the items of the list in a manner consistent with the state of the <code title=attr-ol-type><a href=#attr-ol-type>type</a></code> attribute of the <code><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 title=attr-ol-type><a href=#attr-ol-type>type</a></code> attribute.</p> <p class=note>For CSS user agents, a mapping for this attribute to the 'list-style-type' 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> </div> <!-- v2: resuming numbering of lists from previous lists? --> <div class=impl> <p>The <dfn id=dom-ol-reversed title=dom-ol-reversed><code>reversed</code></dfn>, <dfn id=dom-ol-start title=dom-ol-start><code>start</code></dfn>, and <dfn id=dom-ol-type title=dom-ol-type><code>type</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <code title=dom-ol-start><a href=#dom-ol-start>start</a></code> IDL attribute has the same default as its content attribute.</p> </div> <div class=example> <p>The following markup shows a list where the order matters, and where the <code><a href=#the-ol-element>ol</a></code> element is therefore appropriate. Compare this list to the equivalent list in the <code><a href=#the-ul-element>ul</a></code> section to see an example of the same items using the <code><a href=#the-ul-element>ul</a></code> element.</p> <pre><p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>Switzerland <li>United Kingdom <li>United States <li>Norway </ol></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><p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>United Kingdom <li>Switzerland <li>United States <li>Norway </ol></pre> </div> <h4 id=the-ul-element><span class=secno>4.5.6 </span>The <dfn><code>ul</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>If the element's children include at least one <code><a href=#the-li-element>li</a></code> element: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlulistelement>HTMLUListElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-ul-element>ul</a></code> element <a href=#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><a href=#the-li-element>li</a></code> element child nodes of the <code><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><a href=#the-ul-element>ul</a></code> element is therefore appropriate. Compare this list to the equivalent list in the <code><a href=#the-ol-element>ol</a></code> section to see an example of the same items using the <code><a href=#the-ol-element>ol</a></code> element.</p> <pre><p>I have lived in the following countries:</p> <ul> <li>Norway <li>Switzerland <li>United Kingdom <li>United States </ul></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><p>I have lived in the following countries:</p> <ul> <li>Switzerland <li>Norway <li>United Kingdom <li>United States </ul></pre> </div> <h4 id=the-li-element><span class=secno>4.5.7 </span>The <dfn><code>li</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Inside <code><a href=#the-ol-element>ol</a></code> elements.</dd> <dd>Inside <code><a href=#the-ul-element>ul</a></code> elements.</dd> <dd>Inside <code><a href=#the-menu-element>menu</a></code> elements.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd>If the element is a child of an <code><a href=#the-ol-element>ol</a></code> element: <code title=attr-li-value><a href=#attr-li-value>value</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmllielement>HTMLLIElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute long <a href=#dom-li-value title=dom-li-value>value</a>; };</pre> </dd> </dl><p>The <code><a href=#the-li-element>li</a></code> element <a href=#represents>represents</a> a list item. If its parent element is an <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-ul-element>ul</a></code>, or <code><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><a href=#the-li-element>li</a></code> element.</p> <p>If the parent element is an <code><a href=#the-ol-element>ol</a></code> element, then the <code><a href=#the-li-element>li</a></code> element has an <dfn id=ordinal-value>ordinal value</dfn>.</p> <p>The <dfn id=attr-li-value title=attr-li-value><code>value</code></dfn> attribute, if present, must be a <a href=#valid-integer>valid integer</a> giving the <a href=#ordinal-value>ordinal value</a> of the list item.</p> <div class=impl> <p>If the <code title=attr-li-value><a href=#attr-li-value>value</a></code> attribute is present, user agents must <a href=#rules-for-parsing-integers title="rules for parsing integers">parse it as an integer</a>, in order to determine the attribute's value. If the attribute's value cannot be converted to a number, the attribute must be treated as if it was absent. The attribute has no default value.</p> <p>The <code title=attr-li-value><a href=#attr-li-value>value</a></code> attribute is processed relative to the element's parent <code><a href=#the-ol-element>ol</a></code> element (q.v.), if there is one. If there is not, the attribute has no effect.</p> <p>The <dfn id=dom-li-value title=dom-li-value><code>value</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the value of the <code title=dom-li-value><a href=#dom-li-value>value</a></code> content attribute.</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><a href=#the-figure-element>figure</a></code> element and its <code><a href=#the-figcaption-element>figcaption</a></code> element.</p> <pre><figure> <figcaption>The top 10 movies of all time</figcaption> <ol> <li value="10"><cite>Josie and the Pussycats</cite>, 2001</li> <li value="9"><cite lang="sh">Црна мачка, бели мачор</cite>, 1998</li> <li value="8"><cite>A Bug's Life</cite>, 1998</li> <li value="7"><cite>Toy Story</cite>, 1995</li> <li value="6"><cite>Monsters, Inc</cite>, 2001</li> <li value="5"><cite>Cars</cite>, 2006</li> <li value="4"><cite>Toy Story 2</cite>, 1999</li> <li value="3"><cite>Finding Nemo</cite>, 2003</li> <li value="2"><cite>The Incredibles</cite>, 2004</li> <li value="1"><cite>Ratatouille</cite>, 2007</li> </ol> </figure></pre> <p>The markup could also be written as follows, using the <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code> attribute on the <code><a href=#the-ol-element>ol</a></code> element:</p> <pre><figure> <figcaption>The top 10 movies of all time</figcaption> <ol reversed> <li><cite>Josie and the Pussycats</cite>, 2001</li> <li><cite lang="sh">Црна мачка, бели мачор</cite>, 1998</li> <li><cite>A Bug's Life</cite>, 1998</li> <li><cite>Toy Story</cite>, 1995</li> <li><cite>Monsters, Inc</cite>, 2001</li> <li><cite>Cars</cite>, 2006</li> <li><cite>Toy Story 2</cite>, 1999</li> <li><cite>Finding Nemo</cite>, 2003</li> <li><cite>The Incredibles</cite>, 2004</li> <li><cite>Ratatouille</cite>, 2007</li> </ol> </figure></pre> </div> <p class=note>If the <code><a href=#the-li-element>li</a></code> element is the child of a <code><a href=#the-menu-element>menu</a></code> element and itself has a child that defines a <a href=#concept-command title=concept-command>command</a>, then the <code><a href=#the-li-element>li</a></code> element will match the <code title=selector-enabled><a href=#selector-enabled>:enabled</a></code> and <code title=selector-disabled><a href=#selector-disabled>:disabled</a></code> pseudo-classes in the same way as the first such child element does.</p> <h4 id=the-dl-element><span class=secno>4.5.8 </span>The <dfn><code>dl</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>If the element's children include at least one name-value group: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Zero or more groups each consisting of one or more <code><a href=#the-dt-element>dt</a></code> elements followed by one or more <code><a href=#the-dd-element>dd</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmldlistelement>HTMLDListElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-dl-element>dl</a></code> element <a href=#represents>represents</a> an association list consisting of zero or more name-value groups (a description list). Each group must consist of one or more names (<code><a href=#the-dt-element>dt</a></code> elements) followed by one or more values (<code><a href=#the-dd-element>dd</a></code> elements). Within a single <code><a href=#the-dl-element>dl</a></code> element, there should not be more than one <code><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><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> <div class=impl> <p>If a <code><a href=#the-dl-element>dl</a></code> element is empty, it contains no groups.</p> <p>If a <code><a href=#the-dl-element>dl</a></code> element has one or more non-<a href=#inter-element-whitespace title="inter-element whitespace">whitespace</a> <a href=#text-node>text node</a> children, or has child elements that are neither <code><a href=#the-dt-element>dt</a></code> nor <code><a href=#the-dd-element>dd</a></code> elements, all such <a href=#text-node title="text node">text nodes</a> and elements, as well as their descendants (including any <code><a href=#the-dt-element>dt</a></code> or <code><a href=#the-dd-element>dd</a></code> elements), do not form part of any groups in that <code><a href=#the-dl-element>dl</a></code>.</p> <p>If a <code><a href=#the-dl-element>dl</a></code> element has one or more <code><a href=#the-dt-element>dt</a></code> element children but no <code><a href=#the-dd-element>dd</a></code> element children, then it consists of one group with names but no values.</p> <p>If a <code><a href=#the-dl-element>dl</a></code> element has one or more <code><a href=#the-dd-element>dd</a></code> element children but no <code><a href=#the-dt-element>dt</a></code> element children, then it consists of one group with values but no names.</p> <p>If a <code><a href=#the-dl-element>dl</a></code> element's first <code><a href=#the-dt-element>dt</a></code> or <code><a href=#the-dd-element>dd</a></code> element child is a <code><a href=#the-dd-element>dd</a></code> element, then the first group has no associated name.</p> <p>If a <code><a href=#the-dl-element>dl</a></code> element's last <code><a href=#the-dt-element>dt</a></code> or <code><a href=#the-dd-element>dd</a></code> element child is a <code><a href=#the-dt-element>dt</a></code> element, then the last group has no associated value.</p> <p class=note>When a <code><a href=#the-dl-element>dl</a></code> element doesn't match its content model, it is often due to accidentally using <code><a href=#the-dd-element>dd</a></code> elements in the place of <code><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> <div class=example> <p>In the following example, one entry ("Authors") is linked to two values ("John" and "Luke").</p> <pre><dl> <dt> Authors <dd> John <dd> Luke <dt> Editor <dd> Frank </dl></pre> </div> <div class=example> <p>In the following example, one definition is linked to two terms.</p> <pre><dl> <dt lang="en-US"> <dfn>color</dfn> </dt> <dt lang="en-GB"> <dfn>colour</dfn> </dt> <dd> 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. </dd> </dl></pre> </div> <div class=example> <p>The following example illustrates the use of the <code><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").</p> <pre><dl> <dt> Last modified time </dt> <dd> 2004-12-23T23:33Z </dd> <dt> Recommended update interval </dt> <dd> 60s </dd> <dt> Authors </dt> <dt> Editors </dt> <dd> Robert Rothman </dd> <dd> Daniel Jackson </dd> </dl></pre> </div> <div class=example> <p>The following example shows the <code><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><p>Determine the victory points as follows (use the first matching case):</p> <dl> <dt> If you have exactly five gold coins </dt> <dd> You get five victory points </dd> <dt> If you have one or more gold coins, and you have one or more silver coins </dt> <dd> You get two victory points </dd> <dt> If you have one or more silver coins </dt> <dd> You get one victory point </dd> <dt> Otherwise </dt> <dd> You get no victory points </dd> </dl></pre> </div> <div class=example> <p>The following snippet shows a <code><a href=#the-dl-element>dl</a></code> element being used as a glossary. Note the use of <code><a href=#the-dfn-element>dfn</a></code> to indicate the word being defined.</p> <pre><dl> <dt><dfn>Apartment</dfn>, n.</dt> <dd>An execution context grouping one or more threads with one or more COM objects.</dd> <dt><dfn>Flat</dfn>, n.</dt> <dd>A deflated tire.</dd> <dt><dfn>Home</dfn>, n.</dt> <dd>The user's login directory.</dd> </dl></pre> </div> <p class=note>The <code><a href=#the-dl-element>dl</a></code> element is inappropriate for marking up dialogue. <a href=#conversations>Examples of how to mark up dialogue</a> are shown below.</p> <h4 id=the-dt-element><span class=secno>4.5.9 </span>The <dfn><code>dt</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Before <code><a href=#the-dd-element>dd</a></code> or <code><a href=#the-dt-element>dt</a></code> elements inside <code><a href=#the-dl-element>dl</a></code> elements.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code>, <code><a href=#the-footer-element>footer</a></code>, <a href=#sectioning-content>sectioning content</a>, or <a href=#heading-content>heading content</a> descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-dt-element>dt</a></code> element <a href=#represents>represents</a> the term, or name, part of a term-description group in a description list (<code><a href=#the-dl-element>dl</a></code> element).</p> <p class=note>The <code><a href=#the-dt-element>dt</a></code> element itself, when used in a <code><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><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><a href=#the-dt-element>dt</a></code> element for questions and the <code><a href=#the-dd-element>dd</a></code> element for answers.</p> <pre><article> <h1>FAQ</h1> <dl> <dt>What do we want?</dt> <dd>Our data.</dd> <dt>When do we want it?</dt> <dd>Now.</dd> <dt>Where is it?</dt> <dd>We are not sure.</dd> </dl> </article></pre> </div> <h4 id=the-dd-element><span class=secno>4.5.10 </span>The <dfn><code>dd</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>After <code><a href=#the-dt-element>dt</a></code> or <code><a href=#the-dd-element>dd</a></code> elements inside <code><a href=#the-dl-element>dl</a></code> elements.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-dd-element>dd</a></code> element <a href=#represents>represents</a> the description, definition, or value, part of a term-description group in a description list (<code><a href=#the-dl-element>dl</a></code> element).</p> <div class=example> <p>A <code><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><a href=#the-dt-element>dt</a></code> with a <code><a href=#the-dfn-element>dfn</a></code>, has several <code><a href=#the-dd-element>dd</a></code>s, showing the various parts of the definition.</p> <!-- the actual pronunciations below are nonsense. --> <pre><dl> <dt><dfn>happiness</dfn></dt> <dd class="pronunciation">/'hæ p. nes/</dd> <dd class="part-of-speech"><i><abbr>n.</abbr></i></dd> <dd>The state of being happy.</dd> <dd>Good fortune; success. <q>Oh <b>happiness</b>! It worked!</q></dd> <dt><dfn>rejoice</dfn></dt> <dd class="pronunciation">/ri jois'/</dd> <dd><i class="part-of-speech"><abbr>v.intr.</abbr></i> To be delighted oneself.</dd> <dd><i class="part-of-speech"><abbr>v.tr.</abbr></i> To cause one to be delighted.</dd> </dl></pre> </div> <h4 id=the-figure-element><span class=secno>4.5.11 </span>The <dfn><code>figure</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Either: One <code><a href=#the-figcaption-element>figcaption</a></code> element followed by <a href=#flow-content>flow content</a>.</dd> <dd>Or: <a href=#flow-content>Flow content</a> followed by one <code><a href=#the-figcaption-element>figcaption</a></code> element.</dd> <dd>Or: <a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><!-- v2: Add a <credit> element for photo credits --><p>The <code><a href=#the-figure-element>figure</a></code> element <a href=#represents>represents</a> some <a href=#flow-content>flow content</a>, optionally with a caption, that is self-contained and is typically referenced as a single unit from the main flow of the document.</p> <p>The element can thus be used to annotate illustrations, diagrams, photos, code listings, etc, that are referred to from the main content of the document, but that could, without affecting the flow of the document, be moved away from that primary content, e.g. to the side of the page, to dedicated pages, or to an appendix.</p> <p>The <span class=impl>first</span> <code><a href=#the-figcaption-element>figcaption</a></code> element child of the element, if any, represents the caption of the <code><a href=#the-figure-element>figure</a></code> element's contents. If there is no child <code><a href=#the-figcaption-element>figcaption</a></code> element, then there is no caption.</p> <div class=example> <p>This example shows the <code><a href=#the-figure-element>figure</a></code> element to mark up a code listing.</p> <pre><p>In <a href="#l4">listing 4</a> we see the primary core interface API declaration.</p> <figure id="l4"> <figcaption>Listing 4. The primary core interface API declaration.</figcaption> <pre><code>interface PrimaryCore { boolean verifyDataLine(); void sendData(in sequence&lt;byte> data); void initSelfDestruct(); }</code></pre> </figure> <p>The API is designed to use UTF-8.</p></pre> </div> <div class=example> <p>Here we see a <code><a href=#the-figure-element>figure</a></code> element to mark up a photo.</p> <pre><figure> <img src="bubbles-work.jpeg" alt="Bubbles, sitting in his office chair, works on his latest project intently."> <figcaption>Bubbles at work</figcaption> </figure></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.</p> <pre><h2>Malinko's comics</h2> <p>This case centered on some sort of "intellectual property" infringement related to a comic (see Exhibit A). The suit started after a trailer ending with these words: <blockquote> <img src="promblem-packed-action.png" alt="ROUGH COPY! Promblem-Packed Action!"> </blockquote> <p>...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. <figure> <img src="ex-a.png" alt="Two squiggles on a dirty piece of paper."> <figcaption>Exhibit A. The alleged <cite>rough copy</cite> comic.</figcaption> </figure> <figure> <video src="ex-b.mov"></video> <figcaption>Exhibit B. The <cite>Rough Copy</cite> trailer.</figcaption> </figure> <p>The case was resolved out of court.</pre> </div> <div class=example> <p>Here, a part of a poem is marked up using <code><a href=#the-figure-element>figure</a></code>.</p> <pre><figure> <p>'Twas brillig, and the slithy toves<br> Did gyre and gimble in the wabe;<br> All mimsy were the borogoves,<br> And the mome raths outgrabe.</p> <figcaption><cite>Jabberwocky</cite> (first verse). Lewis Carroll, 1832-98</figcaption> </figure></pre> </div> <div class=example> <p>In this example, which could be part of a much larger work discussing a castle, the figure has three images in it.</p> <pre><figure> <img src="castle1423.jpeg" title="Etching. Anonymous, ca. 1423." alt="The castle has one tower, and a tall wall around it."> <img src="castle1858.jpeg" title="Oil-based paint on canvas. Maria Towle, 1858." alt="The castle now has two towers and two walls."> <img src="castle1999.jpeg" title="Film photograph. Peter Jankle, 1999." alt="The castle lies in ruins, the original tower all that remains in one piece."> <figcaption>The castle through the ages: 1423, 1858, and 1999 respectively.</figcaption> </figure></pre> </div> <h4 id=the-figcaption-element><span class=secno>4.5.12 </span>The <dfn><code>figcaption</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the first or last child of a <code><a href=#the-figure-element>figure</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-figcaption-element>figcaption</a></code> element <a href=#represents>represents</a> a caption or legend for the rest of the contents of the <code><a href=#the-figcaption-element>figcaption</a></code> element's parent <code><a href=#the-figure-element>figure</a></code> element<span class=impl>, if any</span>.</p> <h4 id=the-div-element><span class=secno>4.5.13 </span>The <dfn><code>div</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmldivelement>HTMLDivElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-div-element>div</a></code> element has no special meaning at all. It <a href=#represents>represents</a> its children. It can be used with the <code title=attr-class><a href=#classes>class</a></code>, <code title=attr-lang><a href=#attr-lang>lang</a></code>, and <code title=attr-title><a href=#the-title-attribute>title</a></code> attributes to mark up semantics common to a group of consecutive elements.</p> <p class=note>Authors are strongly encouraged to view the <code><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><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><a href=#the-article-element>article</a></code>, a chapter using <code><a href=#the-section-element>section</a></code>, a page's navigation aids using <code><a href=#the-nav-element>nav</a></code>, and a group of form controls using <code><a href=#the-fieldset-element>fieldset</a></code>.</p> <p>On the other hand, <code><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><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><article lang="en-US"> <h1>My use of language and my cats</h1> <p>My cat's behavior hasn't changed much since her absence, except that she plays her new physique to the neighbors regularly, in an attempt to get pets.</p> <div lang="en-GB"> <p>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.</p> <p>Hm, I just noticed that in the last paragraph I used British English. But I'm supposed to write in American English. So I shouldn't say "pavement" or "flat" or "colour"...</p> </div> <p>I should say "sidewalk" and "apartment" and "color"!</p> </article></pre> </div> <h3 id=text-level-semantics><span class=secno>4.6 </span>Text-level semantics</h3> <h4 id=the-a-element><span class=secno>4.6.1 </span>The <dfn><code>a</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: <a href=#phrasing-content>phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dd>Otherwise: where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#transparent>Transparent</a>, but there must be no <a href=#interactive-content>interactive content</a> descendant.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code></dd> <dd><code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code></dd> <!--DOWNLOAD--><!--PING--> <dd><code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code></dd> <dd><code title=attr-hyperlink-ping><a href=#ping>ping</a></code></dd> <!--DOWNLOAD--><!--PING--> <dd><code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code></dd> <dd><code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code></dd> <dd><code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code></dd> <dd><code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlanchorelement>HTMLAnchorElement</dfn> : <a href=#htmlelement>HTMLElement</a> { stringifier attribute DOMString <a href=#dom-a-href title=dom-a-href>href</a>; attribute DOMString <a href=#dom-a-target title=dom-a-target>target</a>; <!--DOWNLOAD--><!--PING--> attribute DOMString <a href=#dom-a-download title=dom-a-download>download</a>; attribute DOMString <a href=#dom-a-ping title=dom-a-ping>ping</a>; <!--DOWNLOAD--><!--PING--> attribute DOMString <a href=#dom-a-rel title=dom-a-rel>rel</a>; readonly attribute <a href=#domtokenlist>DOMTokenList</a> <a href=#dom-a-rellist title=dom-a-relList>relList</a>; attribute DOMString <a href=#dom-a-media title=dom-a-media>media</a>; attribute DOMString <a href=#dom-a-hreflang title=dom-a-hreflang>hreflang</a>; attribute DOMString <a href=#dom-a-type title=dom-a-type>type</a>; attribute DOMString <a href=#dom-a-text title=dom-a-text>text</a>; // <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> attribute DOMString <a href=#dom-a-protocol title=dom-a-protocol>protocol</a>; attribute DOMString <a href=#dom-a-host title=dom-a-host>host</a>; attribute DOMString <a href=#dom-a-hostname title=dom-a-hostname>hostname</a>; attribute DOMString <a href=#dom-a-port title=dom-a-port>port</a>; attribute DOMString <a href=#dom-a-pathname title=dom-a-pathname>pathname</a>; attribute DOMString <a href=#dom-a-search title=dom-a-search>search</a>; attribute DOMString <a href=#dom-a-hash title=dom-a-hash>hash</a>; };</pre> </dd> </dl><p>If the <code><a href=#the-a-element>a</a></code> element has an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then it <a href=#represents>represents</a> a <a href=#hyperlink>hyperlink</a> (a hypertext anchor).</p> <!-- v2: Eric Meyer requests the ability to nest links so that a big hyperlink, e.g. representing a calendar event, can be clickable, while within it there are subareas that represent links to distinct areas, e.g. a link to see photos of the event, or to edit the event, or some such. --> <p>If the <code><a href=#the-a-element>a</a></code> element has no <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then the element <a href=#represents>represents</a> a placeholder for where a link might otherwise have been placed, if it had been relevant.</p> <p>The <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>, <code title=attr-hyperlink-ping><a href=#ping>ping</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>, <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attributes must be omitted if the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute is not present.</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><a href=#the-a-element>a</a></code> element:</p> <pre><nav> <ul> <li> <a href="/">Home</a> </li> <li> <a href="/news">News</a> </li> <li> <a>Examples</a> </li> <li> <a href="/legal">Legal</a> </li> </ul> </nav></pre> </div> <div class=impl> <p>The <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>, <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>, and <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> <!--DOWNLOAD--><!--PING--> attributes affect what happens when users <a href=#following-hyperlinks title="following hyperlinks">follow hyperlinks</a> <!--DOWNLOAD--> or <a href=#downloading-hyperlinks title="downloading hyperlinks">download hyperlinks</a> <!--DOWNLOAD--> created using the <code><a href=#the-a-element>a</a></code> element. The <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>, <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><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 href=#activation-behavior>activation behavior</a> of <code><a href=#the-a-element>a</a></code> elements that create <a href=#hyperlink title=hyperlink>hyperlinks</a> is to run the following steps:</p> <ol><li><p>If the algorithm is not <a href=#allowed-to-show-a-pop-up>allowed to show a pop-up</a> and either the <code><a href=#the-a-element>a</a></code> <!--DOWNLOAD--> element has a <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute or the <!--DOWNLOAD--> element's <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute is present and applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a>, using the value of the <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute as the browsing context name, would result in there not being a chosen browsing context, then throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these steps.</li> <li><p>If the target of the <code title=event-click><a href=#event-click>click</a></code> event is an <code><a href=#the-img-element>img</a></code> element with an <code title=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><!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A...%3Ca%20href%3D%22%23%22%3E%3Cimg%20ismap%20usemap%3D%22%23a%22%20src%3D/resources/images/smallcats%3E%3C/a%3E%0A%3Cmap%20name%3Da%3E%3Carea%20shape%3Drect%20coords%3D0%2C0%2C50%2C50%20href%3Db%3E%3C/map%3E --><li>If the <code title=event-click><a href=#event-click>click</a></code> event was a real pointing-device-triggered <code title=event-click><a href=#event-click>click</a></code> event on the <code><a href=#the-img-element>img</a></code> element, then let <var title="">x</var> be the distance in CSS pixels from the left edge of the image's left border, if it has one, or the left edge of the image otherwise, to the location of the click, and let <var title="">y</var> be the distance in CSS pixels from the top edge of the image's top border, if it has one, or the top edge of the image otherwise, to the location of the click. Otherwise, let <var title="">x</var> and <var title="">y</var> be zero.</li> <li>Let the <dfn id=hyperlink-suffix><var>hyperlink suffix</var></dfn> be a U+003F QUESTION MARK character, the value of <var title="">x</var> expressed as a base-ten integer using ASCII digits, a U+002C COMMA character (,), and the value of <var title="">y</var> expressed as a base-ten integer using ASCII digits. ASCII digits are the characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol></li> <li><p>Finally, the user agent must <a href=#following-hyperlinks title="following hyperlinks">follow the hyperlink</a> <!--DOWNLOAD--> or <a href=#downloading-hyperlinks title="downloading hyperlinks">download the hyperlink</a> <!--DOWNLOAD--> created by the <code><a href=#the-a-element>a</a></code> element, as determined by <!--DOWNLOAD--> the <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute and <!--DOWNLOAD--> any expressed user preference. If the steps above defined a <var><a href=#hyperlink-suffix>hyperlink suffix</a></var>, then take that into account when following or downloading the hyperlink.</li> </ol></div> <dl class=domintro><dt><var title="">a</var> . <code title=dom-a-text><a href=#dom-a-text>text</a></code></dt> <dd> <p>Same as <code><a href=#textcontent>textContent</a></code>.</p> </dd> </dl><div class=impl> <p>The IDL attributes <dfn id=dom-a-href title=dom-a-href><code>href</code></dfn>, <!--DOWNLOAD--><!--PING--> <dfn id=dom-a-download title=dom-a-download><code>download</code></dfn>, <dfn id=dom-a-ping title=dom-a-ping><code>ping</code></dfn>, <!--DOWNLOAD--><!--PING--> <dfn id=dom-a-target title=dom-a-target><code>target</code></dfn>, <dfn id=dom-a-rel title=dom-a-rel><code>rel</code></dfn>, <dfn id=dom-a-media title=dom-a-media><code>media</code></dfn>, <dfn id=dom-a-hreflang title=dom-a-hreflang><code>hreflang</code></dfn>, and <dfn id=dom-a-type title=dom-a-type><code>type</code></dfn>, must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The IDL attribute <dfn id=dom-a-rellist title=dom-a-rellist><code>relList</code></dfn> must <a href=#reflect>reflect</a> the <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> content attribute.</p> <p>The <dfn id=dom-a-text title=dom-a-text><code>text</code></dfn> IDL attribute, on getting, must return the same value as the <code><a href=#textcontent>textContent</a></code> IDL attribute on the element, and on setting, must act as if the <code><a href=#textcontent>textContent</a></code> IDL attribute on the element had been set to the new value.</p> <p>The <code><a href=#the-a-element>a</a></code> element also supports the complement of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, <dfn id=dom-a-protocol title=dom-a-protocol><code>protocol</code></dfn>, <dfn id=dom-a-host title=dom-a-host><code>host</code></dfn>, <dfn id=dom-a-port title=dom-a-port><code>port</code></dfn>, <dfn id=dom-a-hostname title=dom-a-hostname><code>hostname</code></dfn>, <dfn id=dom-a-pathname title=dom-a-pathname><code>pathname</code></dfn>, <dfn id=dom-a-search title=dom-a-search><code>search</code></dfn>, and <dfn id=dom-a-hash title=dom-a-hash><code>hash</code></dfn>. These must follow the rules given for <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, with the <a href=#concept-uda-input title=concept-uda-input>input</a> being the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute relative to the element, if there is such an attribute and resolving it is successful, or the empty string otherwise; and the <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> being the same as setting the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute to the new output value.</p> </div> <div class=example> <p>The <code><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><aside class="advertising"> <h1>Advertising</h1> <a href="http://ad.example.com/?adid=1929&amp;pubid=1422"> <section> <h1>Mellblomatic 9000!</h1> <p>Turn all your widgets into mellbloms!</p> <p>Only $9.99 plus shipping and handling.</p> </section> </a> <a href="http://ad.example.com/?adid=375&amp;pubid=1422"> <section> <h1>The Mellblom Browser</h1> <p>Web browsing at the speed of light.</p> <p>No other browser goes faster!</p> </section> </a> </aside></pre> </div> <h4 id=the-em-element><span class=secno>4.6.2 </span>The <dfn><code>em</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-em-element>em</a></code> element <a href=#represents>represents</a> stress emphasis of its contents.</p> <p>The level of emphasis that a particular piece of content has is given by its number of ancestor <code><a href=#the-em-element>em</a></code> elements.</p> <p>The placement of emphasis changes the meaning of the sentence. The element thus forms an integral part of the content. The precise way in which emphasis is used in this way depends on the language.</p> <div class=example> <p>These examples show how changing the emphasis changes the meaning. First, a general statement of fact, with no emphasis:</p> <pre><p>Cats are cute animals.</p></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><p><em>Cats</em> are cute animals.</p></pre> <p>Moving the emphasis 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><p>Cats <em>are</em> cute animals.</p></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><p>Cats are <em>cute</em> animals.</p></pre> <p>Similarly, if someone asserted that cats were vegetables, someone correcting this might emphasize the last word:</p> <pre><p>Cats are cute <em>animals</em>.</p></pre> <p>By emphasizing the entire sentence, it becomes clear that the speaker is fighting hard to get the point across. This kind of emphasis also typically affects the punctuation, hence the exclamation mark here.</p> <pre><p><em>Cats are cute animals!</em></p></pre> <p>Anger mixed with emphasizing the cuteness could lead to markup such as:</p> <pre><p><em>Cats are <em>cute</em> animals!</em></p></pre> </div> <div class=note> <p>The <code><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><a href=#the-i-element>i</a></code> element is more appropriate.</p> <p>The <code><a href=#the-em-element>em</a></code> element also isn't intended to convey importance; for that purpose, the <code><a href=#the-strong-element>strong</a></code> element is more appropriate.</p> <!-- Thus the following is a bad use of <em>: <p><em>Note</em>: ...</p> You should use <strong> or <i> for this instead (depending on exactly what you're doing). --> </div> <h4 id=the-strong-element><span class=secno>4.6.3 </span>The <dfn><code>strong</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-strong-element>strong</a></code> element <a href=#represents>represents</a> strong importance for its contents.</p> <p>The relative level of importance of a piece of content is given by its number of ancestor <code><a href=#the-strong-element>strong</a></code> elements; each <code><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><a href=#the-strong-element>strong</a></code> element does not change the meaning of the sentence.</p> <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> <!-- DO NOT REFLOW THIS EXAMPLE it has been carefully balanced --> <pre><p><strong>Warning.</strong> This dungeon is dangerous. <strong>Avoid the ducks.</strong> Take any gold you find. <strong><strong>Do not take any of the diamonds</strong>, they are explosive and <strong>will destroy anything within ten meters.</strong></strong> You have been warned.</p></pre> </div> <h4 id=the-small-element><span class=secno>4.6.4 </span>The <dfn><code>small</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-small-element>small</a></code> element <a href=#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><a href=#the-small-element>small</a></code> element does not "de-emphasize" or lower the importance of text emphasized by the <code><a href=#the-em-element>em</a></code> element or marked as important with the <code><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><a href=#the-em-element>em</a></code> or <code><a href=#the-strong-element>strong</a></code> elements respectively.</p> <p>The <code><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><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> <div class=example> <p>In this example, the <code><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><dl> <dt>Single room <dd>199 € <small>breakfast included, VAT not included</small> <dt>Double room <dd>239 € <small>breakfast included, VAT not included</small> </dl></pre> </div> <div class=example> <p>In this second example, the <code><a href=#the-small-element>small</a></code> element is used for a side comment in an article.</p> <pre><p>Example Corp today announced record profits for the second quarter <small>(Full Disclosure: Foo News is a subsidiary of Example Corp)</small>, leading to speculation about a third quarter merger with Demo Group.</p></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><aside> <h1>Example Corp</h1> <p>This company mostly creates small software and Web sites.</p> <p>The Example Corp company mission is "To provide entertainment and news on a sample basis".</p> <p><small>Information obtained from <a href="http://example.com/about.html">example.com</a> home page.</small></p> </aside></pre> </div> <div class=example> <p>In this last example, the <code><a href=#the-small-element>small</a></code> element is marked as being <em>important</em> small print.</p> <pre><p><strong><small>Continued use of this service will result in a kiss.</small></strong></p></pre> </div> <h4 id=the-s-element><span class=secno>4.6.5 </span>The <dfn><code>s</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-s-element>s</a></code> element <a href=#represents>represents</a> contents that are no longer accurate or no longer relevant.</p> <p class=note>The <code><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><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><p>Buy our Iced Tea and Lemonade!</p> <p><s>Recommended retail price: $3.99 per bottle</s></p> <p><strong>Now selling for just $2.99 a bottle!</strong></p></pre> </div> <h4 id=the-cite-element><span class=secno>4.6.6 </span>The <dfn><code>cite</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-cite-element>cite</a></code> element <a href=#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, etc). This can be a work that is being quoted or referenced 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><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><a href=#the-span-element>span</a></code> element can be used.)</p> <!--(some people argue a ship is a work) <p>A ship is similarly not a work, and the element must not be used to mark up ship names (the <code>i</code> element can be used for that purpose).</p> --> <div class=example> <p>This next example shows a typical use of the <code><a href=#the-cite-element>cite</a></code> element:</p> <pre><p>My favorite book is <cite>The Reality Dysfunction</cite> by Peter F. Hamilton. My favorite comic is <cite>Pearls Before Swine</cite> by Stephan Pastis. My favorite track is <cite>Jive Samba</cite> by the Cannonball Adderley Sextet.</p></pre> </div> <div class=example> <p>This is correct usage:</p> <pre><p>According to the Wikipedia article <cite>HTML</cite>, as it stood in mid-February 2008, leaving attribute values unquoted is unsafe. This is obviously an over-simplification.</p></pre> <p>The following, however, is incorrect usage, as the <code><a href=#the-cite-element>cite</a></code> element here is containing far more than the title of the work:</p> <pre class=bad><!-- do not copy this example, it is an example of bad usage! --> <p>According to <cite>the Wikipedia article on HTML</cite>, as it stood in mid-February 2008, leaving attribute values unquoted is unsafe. This is obviously an over-simplification.</p></pre> </div> <div class=example> <p>The <code><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><p><cite>Universal Declaration of Human Rights</cite>, United Nations, December 1948. Adopted by General Assembly resolution 217 A (III).</p></pre> </div> <p class=note>A <em>citation</em> is not a <em>quote</em> (for which the <code><a href=#the-q-element>q</a></code> element is appropriate).</p> <div class=example> <p>This is incorrect usage, because <code><a href=#the-cite-element>cite</a></code> is not for quotes:</p> <pre class=bad><p><cite>This is wrong!</cite>, said Ian.</p></pre> <p>This is also incorrect usage, because a person is not a work:</p> <pre class=bad><p><q>This is still wrong!</q>, said <cite>Ian</cite>.</p></pre> <p>The correct usage does not use a <code><a href=#the-cite-element>cite</a></code> element:</p> <pre><p><q>This is correct</q>, said Ian.</p></pre> <p>As mentioned above, the <code><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><p>And then <b>Ian</b> said <q>this might be right, in a gossip column, maybe!</q>.</p></pre> </div> <h4 id=the-q-element><span class=secno>4.6.7 </span>The <dfn><code>q</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-q-cite><a href=#attr-q-cite>cite</a></code></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlquoteelement>HTMLQuoteElement</a></code>.</dd> </dl><p>The <code><a href=#the-q-element>q</a></code> element <a href=#represents>represents</a> some <a href=#phrasing-content title="phrasing content">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><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><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 title=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 title=attr-q-cite><a href=#attr-q-cite>cite</a></code> attribute is present, it must be a <a href=#valid-url-potentially-surrounded-by-spaces>valid URL potentially surrounded by spaces</a>. <span class=impl>To obtain the corresponding citation link, the value of the attribute must be <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element. User agents should allow users to follow such citation links.</span></p> <p>The <code><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><a href=#the-q-element>q</a></code> element for marking up sarcastic statements.</p> <p>The use of <code><a href=#the-q-element>q</a></code> elements to mark up quotations is entirely optional; using explicit quotation punctuation without <code><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><a href=#the-q-element>q</a></code> element:</p> <pre><p>The man said <q>Things that are impossible just take longer</q>. I disagreed with him.</p></pre> </div> <div class=example> <p>Here is an example with both an explicit citation link in the <code><a href=#the-q-element>q</a></code> element, and an explicit citation outside:</p> <pre><p>The W3C page <cite>About W3C</cite> says the W3C's mission is <q cite="http://www.w3.org/Consortium/">To lead the World Wide Web to its full potential by developing protocols and guidelines that ensure long-term growth for the Web</q>. I disagree with this mission.</p></pre> </div> <div class=example> <p>In the following example, the quotation itself contains a quotation:</p> <pre><p>In <cite>Example One</cite>, he writes <q>The man said <q>Things that are impossible just take longer</q>. I disagreed with him</q>. Well, I disagree even more!</p></pre> </div> <div class=example> <p>In the following example, quotation marks are used instead of the <code><a href=#the-q-element>q</a></code> element:</p> <pre><p>His best argument was ❝I disagree❞, which I thought was laughable.</p></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><a href=#the-q-element>q</a></code> element in this case would be inappropriate.</p> <pre><p>The word "ineffable" could have been used to describe the disaster resulting from the campaign's mismanagement.</p></pre> </div> <h4 id=the-dfn-element><span class=secno>4.6.8 </span>The <dfn><code>dfn</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>, but there must be no <code><a href=#the-dfn-element>dfn</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd>Also, the <code title=attr-dfn-title><a href=#attr-dfn-title>title</a></code> attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-dfn-element>dfn</a></code> element <a href=#represents>represents</a> the defining instance of a term. The <a href=#paragraph title=paragraph>paragraph</a>, <a href=#the-dl-element title=dl>description list group</a>, or <a href=#sectioning-content title="sectioning content">section</a> that is the nearest ancestor of the <code><a href=#the-dfn-element>dfn</a></code> element must also contain the definition(s) for the <a href=#defining-term title="defining term">term</a> given by the <code><a href=#the-dfn-element>dfn</a></code> element.</p> <p><dfn id=defining-term>Defining term</dfn>: If the <code><a href=#the-dfn-element>dfn</a></code> element has a <dfn id=attr-dfn-title title=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 <a href=#text-node title="text node">text nodes</a>, and that child element is an <code><a href=#the-abbr-element>abbr</a></code> element with a <code title=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><a href=#textcontent>textContent</a></code> of the <code><a href=#the-dfn-element>dfn</a></code> element that gives the term being defined.</p> <!-- note that this means <dfn>x \n x</dfn> won't match <span>x x</span> --> <p>If the <code title=attr-dfn-title><a href=#attr-dfn-title>title</a></code> attribute of the <code><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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute of ancestor elements does not affect <code><a href=#the-dfn-element>dfn</a></code> elements.</p> <p>An <code><a href=#the-a-element>a</a></code> element that links to a <code><a href=#the-dfn-element>dfn</a></code> element represents an instance of the term defined by the <code><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><p>The <strong><dfn><abbr title="Garage Door Opener">GDO</abbr></dfn></strong> is a device that allows off-world teams to open the iris.</p> <!-- ... later in the document: --> <p>Teal'c activated his <strong><abbr title="Garage Door Opener">GDO</abbr></strong> and so Hammond ordered the iris to be opened.</p></pre> <p>With the addition of an <code><a href=#the-a-element>a</a></code> element, the reference can be made explicit:</p> <pre><p>The <dfn <strong>id=gdo</strong>><abbr title="Garage Door Opener">GDO</abbr></dfn> is a device that allows off-world teams to open the iris.</p> <!-- ... later in the document: --> <p>Teal'c activated his <strong><a href=#gdo></strong><abbr title="Garage Door Opener">GDO</abbr><strong></a></strong> and so Hammond ordered the iris to be opened.</p></pre> </div> <h4 id=the-abbr-element><span class=secno>4.6.9 </span>The <dfn><code>abbr</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd>Also, the <code title=attr-abbr-title><a href=#attr-abbr-title>title</a></code> attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-abbr-element>abbr</a></code> element <a href=#represents>represents</a> an abbreviation or acronym, optionally with its expansion. The <dfn id=attr-abbr-title title=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><a href=#the-abbr-element>abbr</a></code> element. This paragraph <a href=#defining-term title="defining term">defines the term</a> "Web Hypertext Application Technology Working Group".</p> <pre><p>The <dfn id=whatwg><abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr></dfn> 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.</p></pre> <p>An alternative way to write this would be:</p> <pre><p>The <dfn id=whatwg>Web Hypertext Application Technology Working Group</dfn> (<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>) 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.</p></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><a href=#the-abbr-element>abbr</a></code> element.</p> <pre><p>The <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> started working on HTML5 in 2004.</p></pre> </div> <div class=example> <p>This paragraph links an abbreviation to its definition.</p> <pre><p>The <a href="#whatwg"><abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr></a> community does not have much representation from Asia.</p></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><p>Philip` and Dashiva both denied that they were going to get the issue counts from past revisions of the specification to backfill the <abbr>WHATWG</abbr> issue graph.</p></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><p>Two <abbr title="Working Group">WG</abbr>s worked on this specification: the <abbr>WHATWG</abbr> and the <abbr>HTMLWG</abbr>.</p></pre> <p>Here the plural is inside the element, so the expansion is in the plural:</p> <pre><p>Two <abbr title="Working Groups">WGs</abbr> worked on this specification: the <abbr>WHATWG</abbr> and the <abbr>HTMLWG</abbr>.</p></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><a href=#the-abbr-element>abbr</a></code> element with a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute is an alternative to including the expansion inline (e.g. in parentheses).</li> <li>Abbreviations that are likely to be unfamiliar to the document's readers, for which authors are encouraged to either mark up the abbreviation using an <code><a href=#the-abbr-element>abbr</a></code> element with a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute or include the expansion inline in the text the first time the abbreviation is used.</li> <li>Abbreviations whose presence needs to be semantically annotated, e.g. so that they can be identified from a style sheet and given specific styles, for which the <code><a href=#the-abbr-element>abbr</a></code> element can be used without a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute.</li> </ul><p title=note>Providing an expansion in a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute once will not necessarily cause other <code><a href=#the-abbr-element>abbr</a></code> elements in the same document with the same contents but without a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute to behave as if they had the same expansion. Every <code><a href=#the-abbr-element>abbr</a></code> element is independent.</p> <h4 id=the-data-element><span class=secno>4.6.10 </span>The <dfn><code>data</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-data-value><a href=#attr-data-value>value</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmldataelement>HTMLDataElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-data-value title=dom-data-value>value</a>; };</pre> </dd> </dl><p>The <code><a href=#the-data-element>data</a></code> element <a href=#represents>represents</a> its contents, along with a machine-readable form of those contents in the <code title=attr-data-value><a href=#attr-data-value>value</a></code> attribute.</p> <p>The <dfn id=attr-data-value title=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>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 title=attr-data-value><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 title=attr-data-*><a href=#attr-data-*>data-*</a></code> attributes can also be useful in such situations.)</p> <div class=impl> <p>The <dfn id=dom-data-value title=dom-data-value><code>value</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <div class=example> <p>The <code><a href=#the-data-element>data</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><a href=#the-data-element>data</a></code> element:</p> <pre><div class="vevent"> <a class="url" href="http://www.web2con.com/">http://www.web2con.com/</a> <span class="summary">Web 2.0 Conference</span>: <data class="dtstart" value="2007-10-05">October 5</data> - <data class="dtend" value="2007-10-20">19</data>, at the <span class="location">Argent Hotel, San Francisco, CA</span> </div></pre> <p>(The end date is encoded as one day after the last date of the event because in the iCalendar format, end dates are <em>exclusive</em>, not inclusive.)</p> </div> <div class=example> <p>In this example, an article's publication date is marked up using <code><a href=#the-data-element>data</a></code> and the schema.org microdata vocabulary:</p> <pre><article itemscope itemtype="http://schema.org/BlogPosting"> <h1 itemprop="headline">Small tasks</h1> <footer>Published <data itemprop="datePublished" value="2009-08-30">yesterday</data>.</footer> <p itemprop="articleBody">I put a bike bell on his bike.</p> </article></pre> </div> <div class=example> <p>In the following snippet, the <code><a href=#the-data-element>data</a></code> element is used to encode a date in the ISO8601 format, for later processing by a script:</p> <pre><p>Our first date was <data value="2006-09-23">a Saturday</data>.</p></pre> <p>In this second snippet, the value includes a time:</p> <pre><p>We stopped talking at <data value="2006-09-24T05:00-07:00">5am the next morning</data>.</p></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><a href=#the-data-element>data</a></code> element) could scan through the page and look at all the <code><a href=#the-data-element>data</a></code> elements therein to create an index of dates and times.</p> </div> <div class=example> <p>Here, a short table has its numeric values encoded using <code><a href=#the-data-element>data</a></code> so that a script 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><table class="sortable"> <!-- class used by script to find tables to which to add sorting controls --> <thead> <tr> <th> Game <th> Corporations <th> Map Size <tbody> <tr> <td> 1830 <td> <data value="8">Eight</data> <td> <data value="93">19+74 hexes (93 total)</data> <tr> <td> 1856 <td> <data value="11">Eleven</data> <td> <data value="99">12+87 hexes (99 total)</data> <tr> <td> 1870 <td> <data value="10">Ten</data> <td> <data value="149">4+145 hexes (149 total)</data> </table></pre> </div> <h4 id=the-code-element><span class=secno>4.6.11 </span>The <dfn><code>code</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-code-element>code</a></code> element <a href=#represents>represents</a> a fragment of computer code. This could be an XML element name, a filename, a computer program, or any other string that a computer would recognize.</p> <p>Although there is no formal way to indicate the language of computer code being marked up, authors who wish to mark <code><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, may do so by adding a class prefixed with "<code title="">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><p>The <code>code</code> element represents a fragment of computer code.</p> <p>When you call the <code>activate()</code> method on the <code>robotSnowman</code> object, the eyes glow.</p> <p>The example below uses the <code>begin</code> keyword to indicate the start of a statement block. It is paired with an <code>end</code> keyword, which is followed by the <code>.</code> punctuation character (full stop) to indicate the end of the program.</p></pre> </div> <div class=example> <p>The following example shows how a block of code could be marked up using the <code><a href=#the-pre-element>pre</a></code> and <code><a href=#the-code-element>code</a></code> elements.</p> <pre><pre><code class="language-pascal">var i: Integer; begin i := 1; end.</code></pre></pre> <p>A class is used in that example to indicate the language used.</p> </div> <p class=note>See the <code><a href=#the-pre-element>pre</a></code> element for more details.</p> <h4 id=the-var-element><span class=secno>4.6.12 </span>The <dfn><code>var</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-var-element>var</a></code> element <a href=#represents>represents</a> a variable. This could be an actual variable in a mathematical expression or programming context, an identifier representing a constant, 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><p>If there are <var>n</var> pipes leading to the ice cream factory then I expect at <em>least</em> <var>n</var> flavors of ice cream to be available for purchase!</p></pre> </div> <p>For mathematics, in particular for anything beyond the simplest of expressions, MathML is more appropriate. However, the <code><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><a href=#the-var-element>var</a></code>.</p> <pre><figure> <math> <mi>a</mi> <mo>=</mo> <msqrt> <msup><mi>b</mi><mn>2</mn></msup> <mi>+</mi> <msup><mi>c</mi><mn>2</mn></msup> </msqrt> </math> <figcaption> Using Pythagoras' theorem to solve for the hypotenuse <var>a</var> of a triangle with sides <var>b</var> and <var>c</var> </figcaption> </figure></pre> </div> <div class=example> <p>Here, the equation describing mass-energy equivalence is used in a sentence, and the <code><a href=#the-var-element>var</a></code> element is used to mark the variables and constants in that equation:</p> <pre><p>Then he turned to the blackboard and picked up the chalk. After a few moment's thought, he wrote <var>E</var> = <var>m</var> <var>c</var><sup>2</sup>. The teacher looked pleased.</p></pre> </div> <h4 id=the-samp-element><span class=secno>4.6.13 </span>The <dfn><code>samp</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-samp-element>samp</a></code> element <a href=#represents>represents</a> (sample) output from a program or computing system.</p> <p class=note>See the <code><a href=#the-pre-element>pre</a></code> and <code><a href=#the-kbd-element>kbd</a></code> elements for more details.</p> <div class=example> <p>This example shows the <code><a href=#the-samp-element>samp</a></code> element being used inline:</p> <pre><p>The computer said <samp>Too much cheese in tray two</samp> but I didn't know what that meant.</p></pre> <p>This second example shows a block of sample output. Nested <code><a href=#the-samp-element>samp</a></code> and <code><a href=#the-kbd-element>kbd</a></code> elements allow for the styling of specific elements of the sample output using a style sheet.</p> <pre><pre><samp><span class="prompt">jdoe@mowmow:~$</span> <kbd>ssh demo.example.com</kbd> 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 <span class="prompt">jdoe@demo:~$</span> <span class="cursor">_</span></samp></pre></pre> </div> <h4 id=the-kbd-element><span class=secno>4.6.14 </span>The <dfn><code>kbd</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-kbd-element>kbd</a></code> element <a href=#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><a href=#the-kbd-element>kbd</a></code> element is nested inside a <code><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><a href=#the-kbd-element>kbd</a></code> element <em>contains</em> a <code><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><a href=#the-kbd-element>kbd</a></code> element is nested inside another <code><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><a href=#the-kbd-element>kbd</a></code> element is used to indicate keys to press:</p> <pre><p>To make George eat an apple, press <kbd><kbd>Shift</kbd>+<kbd>F3</kbd></kbd></p></pre> <p>In this second example, the user is told to pick a particular menu item. The outer <code><a href=#the-kbd-element>kbd</a></code> element marks up a block of input, with the inner <code><a href=#the-kbd-element>kbd</a></code> elements representing each individual step of the input, and the <code><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><p>To make George eat an apple, select <kbd><kbd><samp>File</samp></kbd>|<kbd><samp>Eat Apple...</samp></kbd></kbd> </p></pre> <p>Such precision isn't necessary; the following is equally fine:</p> <pre><p>To make George eat an apple, select <kbd>File | Eat Apple...</kbd></p></pre> </div> <h4 id=the-sub-and-sup-elements><span class=secno>4.6.15 </span>The <dfn id=the-sub-element><code>sub</code></dfn> and <dfn id=the-sup-element><code>sup</code></dfn> elements</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Use <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-sub-and-sup-elements>sup</a></code> element <a href=#represents>represents</a> a superscript and the <code><a href=#the-sub-and-sup-elements>sub</a></code> element <a href=#represents>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><a href=#the-sub-and-sup-elements>sub</a></code> and <code><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><p>The most beautiful women are <span lang="fr"><abbr>M<sup>lle</sup></abbr> Gwendoline</span> and <span lang="fr"><abbr>M<sup>me</sup></abbr> Denise</span>.</p></pre> </div> <p>The <code><a href=#the-sub-and-sup-elements>sub</a></code> element can be used inside a <code><a href=#the-var-element>var</a></code> element, for variables that have subscripts.</p> <div class=example> <p>Here, the <code><a href=#the-sub-and-sup-elements>sub</a></code> element is used to represents the subscript that identifies the variable in a family of variables:</p> <pre><p>The coordinate of the <var>i</var>th point is (<var>x<sub><var>i</var></sub></var>, <var>y<sub><var>i</var></sub></var>). For example, the 10th point has coordinate (<var>x<sub>10</sub></var>, <var>y<sub>10</sub></var>).</p></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><a href=#the-sub-and-sup-elements>sub</a></code> and <code><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><var>E</var>=<var>m</var><var>c</var><sup>2</sup></pre> <pre>f(<var>x</var>, <var>n</var>) = log<sub>4</sub><var>x</var><sup><var>n</var></sup></pre> </div> <h4 id=the-i-element><span class=secno>4.6.16 </span>The <dfn><code>i</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-i-element>i</a></code> element <a href=#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, a thought, or a ship name in Western texts.</p> <p>Terms in languages different from the main text should be annotated with <code title=attr-lang><a href=#attr-lang>lang</a></code> attributes (or, in XML, <a href=#attr-xml-lang title=attr-xml-lang><code title="">lang</code> attributes in the <span>XML namespace</span></a>).</p> <div class=example> <p>The examples below show uses of the <code><a href=#the-i-element>i</a></code> element:</p> <pre><p>The <i class="taxonomy">Felis silvestris catus</i> is cute.</p> <p>The term <i>prose content</i> is defined above.</p> <p>There is a certain <i lang="fr">je ne sais quoi</i> in the air.</p></pre> <p>In the following example, a dream sequence is marked up using <code><a href=#the-i-element>i</a></code> elements.</p> <pre><p>Raymond tried to sleep.</p> <p><i>The ship sailed away on Thursday</i>, he dreamt. <i>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.</i></p> <p><i>Finally one night he picked up the courage to speak with her—</i></p> <p>Raymond woke with a start as the fire alarm rang out.</p></pre> </div> <p>Authors can use the <code title=attr-class><a href=#classes>class</a></code> attribute on the <code><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><a href=#the-i-element>i</a></code> element, for instance the <code><a href=#the-em-element>em</a></code> element for marking up stress emphasis, or the <code><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><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><a href=#the-i-element>i</a></code> elements will necessarily be italicized.</p> <h4 id=the-b-element><span class=secno>4.6.17 </span>The <dfn><code>b</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-b-element>b</a></code> element <a href=#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><a href=#the-b-element>b</a></code> element to highlight key words without marking them up as important:</p> <pre><p>The <b>frobonitor</b> and <b>barbinator</b> components are fried.</p></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><a href=#the-b-element>b</a></code> element.</p> <pre><p>You enter a small room. Your <b>sword</b> glows brighter. A <b>rat</b> scurries past the corner wall.</p></pre> </div> <div class=example> <p>Another case where the <code><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><article> <h2>Kittens 'adopted' by pet rabbit</h2> <p><b class="lede">Six abandoned kittens have found an unexpected new mother figure — a pet rabbit.</b></p> <p>Veterinary nurse Melanie Humble took the three-week-old kittens to her Aberdeen home.</p> <i>[...]</i></pre> </div> <p>As with the <code><a href=#the-i-element>i</a></code> element, authors can use the <code title=attr-class><a href=#classes>class</a></code> attribute on the <code><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><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><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> to <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements, stress emphasis should use the <code><a href=#the-em-element>em</a></code> element, importance should be denoted with the <code><a href=#the-strong-element>strong</a></code> element, and text marked or highlighted should use the <code><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><p><b>WARNING!</b> Do not frob the barbinator!</p></pre> <p>In the previous example, the correct element to use would have been <code><a href=#the-strong-element>strong</a></code>, not <code><a href=#the-b-element>b</a></code>.</p> </div> <p class=note>Style sheets can be used to format <code><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><a href=#the-b-element>b</a></code> elements will necessarily be boldened.</p> <h4 id=the-u-element><span class=secno>4.6.18 </span>The <dfn><code>u</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-u-element>u</a></code> element <a href=#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><a href=#the-em-element>em</a></code> element should be used; for marking key words or phrases either the <code><a href=#the-b-element>b</a></code> element or the <code><a href=#the-mark-element>mark</a></code> element should be used, depending on the context; for marking book titles, the <code><a href=#the-cite-element>cite</a></code> element should be used<!-- even for the Chinese wavy underline 'book title mark' -->; for labeling text with explicit textual annotations, the <code><a href=#the-ruby-element>ruby</a></code> element should be used; for labeling ship names in Western texts, the <code><a href=#the-i-element>i</a></code> element should be used.</p> <p class=note>The default rendering of the <code><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><a href=#the-u-element>u</a></code> element where it could be confused for a hyperlink.</p> <h4 id=the-mark-element><span class=secno>4.6.19 </span>The <dfn><code>mark</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><!-- v2: attribute that means "highlight this on the scrollbar" --><p>The <code><a href=#the-mark-element>mark</a></code> element <a href=#represents>represents</a> a run of text in one document marked or highlighted for reference 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><a href=#the-mark-element>mark</a></code> element can be used to bring attention to a particular part of a quotation:</p> <pre><p lang="en-US">Consider the following quote:</p> <blockquote lang="en-GB"> <p>Look around and you will find, no-one's really <mark>colour</mark> blind.</p> </blockquote> <p lang="en-US">As we can tell from the <em>spelling</em> of the word, the person writing this quote is clearly not American.</p></pre> <p>(If the goal was to mark the element as misspelt, however, the <code><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><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><p>I also have some <mark>kitten</mark>s who are visiting me these days. They're really cute. I think they like my garden! Maybe I should adopt a <mark>kitten</mark>.</p></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><p>The highlighted part below is where the error lies:</p> <pre><code>var i: Integer; begin i := <mark>1.1</mark>; end.</code></pre></pre> <p>This is separate from <em>syntax highlighting</em>, for which <code><a href=#the-span-element>span</a></code> is more appropriate. Combining both, one would get:</p> <pre><p>The highlighted part below is where the error lies:</p> <pre><code><span class=keyword>var</span> <span class=ident>i</span>: <span class=type>Integer</span>; <span class=keyword>begin</span> <span class=ident>i</span> := <span class=literal><mark>1.1</mark></span>; <span class=keyword>end</span>.</code></pre></pre> </div> <div class=example> <p>This is another example showing the use of <code><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><a href=#the-mark-element>mark</a></code> elements in quotes to render in italics.</p> <pre><article> <style scoped> blockquote mark, q mark { font: inherit; font-style: italic; text-decoration: none; background: transparent; color: inherit; } .bubble em { font: inherit; font-size: larger; text-decoration: underline; } </style> <h1>She knew</h1> <p>Did you notice the subtle joke in the joke on panel 4?</p> <blockquote> <p class="bubble">I didn't <em>want</em> to believe. <mark>Of course on some level I realized it was a known-plaintext attack.</mark> But I couldn't admit it until I saw for myself.</p> </blockquote> <p>(Emphasis mine.) I thought that was great. It's so pedantic, yet it explains everything neatly.</p> </article></pre> <p>Note, incidentally, the distinction between the <code><a href=#the-em-element>em</a></code> element in this example, which is part of the original text being quoted, and the <code><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><a href=#the-strong-element>strong</a></code>) as opposed to denoting the <em>relevance</em> of a span of text (<code><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><h3>Wormhole Physics Introduction</h3> <p><mark>A wormhole in normal conditions can be held open for a maximum of just under 39 minutes.</mark> 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).</p> <p><mark>Momentum is preserved across the wormhole. Electromagnetic radiation can travel in both directions through a wormhole, but matter cannot.</mark></p> <p>When a wormhole is created, a vortex normally forms. <strong>Warning: The vortex caused by the wormhole opening will annihilate anything in its path.</strong> Vortexes can be avoided when using sufficiently advanced dialing technology.</p> <p><mark>An obstruction in a gate will prevent it from accepting a wormhole connection.</mark></p></pre> </div> <h4 id=the-ruby-element><span class=secno>4.6.20 </span>The <dfn><code>ruby</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>One or more groups of: <a href=#phrasing-content>phrasing content</a> followed either by a single <code><a href=#the-rt-element>rt</a></code> element, or an <code><a href=#the-rp-element>rp</a></code> element, an <code><a href=#the-rt-element>rt</a></code> element, and another <code><a href=#the-rp-element>rp</a></code> element.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><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>A <code><a href=#the-ruby-element>ruby</a></code> element <a href=#represents>represents</a> the spans of phrasing content it contains, ignoring all the child <code><a href=#the-rt-element>rt</a></code> and <code><a href=#the-rp-element>rp</a></code> elements and their descendants. Those spans of phrasing content have associated annotations created using the <code><a href=#the-rt-element>rt</a></code> element.</p> <div class=example> <!-- this is the hiragana for the word "kanji" ("chinese character") in japanese --> <!-- in japanese, ruby-like typography is called "furigana" --> <p>In this example, each ideograph in the Japanese text <span lang=ja title="">漢字</span> is annotated with its reading in hiragana.</p> <pre lang=ja>... <ruby>漢<rt>かん</rt>字<rt>じ</rt></ruby> ...</pre> <p>This might be rendered as:</p> <p><img alt="The two main ideographs, each with its annotation in hiragana rendered in a smaller font above it." height=78 src=http://images.whatwg.org/sample-ruby-ja.png width=171></p> </div> <div class=example> <!-- this is the bopomofo for the word "hanzi" ("chinese character") in traditional chinese, as used in taiwan --> <p>In this example, each ideograph in the traditional Chinese text <span lang=zh-TW title="">漢字</span> is annotated with its bopomofo reading.</p> <pre lang=zh-TW><ruby>漢<rt>ㄏㄢˋ</rt>字<rt>ㄗˋ</rt></ruby></pre> <p>This might be rendered as:</p> <p><img alt="The two main ideographs, each with its bopomofo annotation rendered in a smaller font next to it." height=100 src=http://images.whatwg.org/sample-ruby-bopomofo.png width=78></p> </div> <div class=example> <!-- this is the pinyin for the word "hanzi" ("chinese character") in simplified chinese, as used in mainland china --> <p>In this example, each ideograph in the simplified Chinese text <span lang=zh-CN title="">汉字</span> is annotated with its pinyin reading.</p> <pre lang=zh-CN>...<ruby>汉<rt>hàn</rt>字<rt>zì</rt></ruby>...</pre> <p>This might be rendered as:</p> <p><img alt="The two main ideographs, each with its pinyin annotation rendered in a smaller font above it." height=79 src=http://images.whatwg.org/sample-ruby-pinyin.png width=173></p> </div> <!-- Note: Examples are 32px/16px Stone Sans Sem ITC TT --> <h4 id=the-rt-element><span class=secno>4.6.21 </span>The <dfn><code>rt</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-ruby-element>ruby</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-rt-element>rt</a></code> element marks the ruby text component of a ruby annotation.</p> <p>An <code><a href=#the-rt-element>rt</a></code> element <span class=impl>that is a child of a <code><a href=#the-ruby-element>ruby</a></code> element</span> <a href=#represents>represents</a> an annotation (given by its children) for the zero or more nodes of phrasing content that immediately precedes it in the <code><a href=#the-ruby-element>ruby</a></code> element, ignoring <code><a href=#the-rp-element>rp</a></code> elements.</p> <div class=impl> <p>An <code><a href=#the-rt-element>rt</a></code> element that is not a child of a <code><a href=#the-ruby-element>ruby</a></code> element represents the same thing as its children.</p> </div> <h4 id=the-rp-element><span class=secno>4.6.22 </span>The <dfn><code>rp</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-ruby-element>ruby</a></code> element, either immediately before or immediately after an <code><a href=#the-rt-element>rt</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <!-- <dd>If the <code>rp</code> element is immediately after an <code>rt</code> element that is immediately preceded by another <code>rp</code> element: a single character from Unicode character class Pe.</dd> <dd>Otherwise: a single character from Unicode character class Ps.</dd> --> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-rp-element>rp</a></code> element can be used to provide parentheses 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><a href=#the-rp-element>rp</a></code> element <span class=impl>that is a child of a <code><a href=#the-ruby-element>ruby</a></code> element</span> <a href=#represents>represents</a> nothing<span class=impl> and its contents must be ignored</span>. <span class=impl>An <code><a href=#the-rp-element>rp</a></code> element whose parent element is not a <code><a href=#the-ruby-element>ruby</a></code> element <a href=#represents>represents</a> its children.</span></p> <div class=example> <p>The example above, in which each ideograph in the text <span lang=ja title="">漢字</span> is annotated with its phonetic reading, could be expanded to use <code><a href=#the-rp-element>rp</a></code> so that in legacy user agents the readings are in parentheses:</p> <pre lang=ja>... <ruby> 漢 <rp>(</rp><rt>かん</rt><rp>)</rp> 字 <rp>(</rp><rt>じ</rt><rp>)</rp> </ruby> ...</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> <h4 id=the-bdi-element><span class=secno>4.6.23 </span>The <dfn><code>bdi</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd>Also, the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> global attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-bdi-element>bdi</a></code> element <a href=#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 title=attr-dir><a href=#the-dir-attribute>dir</a></code> global attribute defaults to <code title=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> <div class=impl> <p>For the purposes of applying the bidirectional algorithm to the contents of a <code><a href=#the-bdi-element>bdi</a></code> element, user agents must treat the element as a paragraph-level container.</p> <p>For the purposes of applying the bidirectional algorithm to the paragraph-level container that a <code><a href=#the-bdi-element>bdi</a></code> element finds itself within, the <code><a href=#the-bdi-element>bdi</a></code> element must be treated like a U+FFFC OBJECT REPLACEMENT CHARACTER (in the same manner that an image or other inline object is handled).</p> <p>The requirements on handling the <code><a href=#the-bdi-element>bdi</a></code> element for the bidirectional algorithm may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements by implementing the CSS 'unicode-bidi' property. <a href=#refsCSS>[CSS]</a></p> </div> <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><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><ul> <li>User <bdi>jcranmer</bdi>: 12 posts. <li>User <bdi>hober</bdi>: 5 posts. <li>User <bdi><bdo dir=rtl>إيان</bdo></bdi>: 3 posts. </ul></pre> </div> <h4 id=the-bdo-element><span class=secno>4.6.24 </span>The <dfn><code>bdo</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd>Also, the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> global attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-bdo-element>bdo</a></code> element <a href=#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 title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute on this element, with the value <code>ltr</code> to specify a left-to-right override and with the value <code>rtl</code> to specify a right-to-left override.</p> <div class=impl> <p>If the element's <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <i title=attr-dir-rtl-state><a href=#attr-dir-rtl-state>rtl</a></i> state, then for the purposes of the bidirectional algorithm, the user agent must act as if there was a U+202D LEFT-TO-RIGHT OVERRIDE character at the start of the element, and a U+202C POP DIRECTIONAL FORMATTING at the end of the element.</p> <p>If the element's <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute is in the <i title=attr-dir-ltr-state><a href=#attr-dir-ltr-state>ltr</a></i>, then for the purposes of the bidirectional algorithm, the user agent must act as if there was a U+202E RIGHT-TO-LEFT OVERRIDE character at the start of the element, and a U+202C POP DIRECTIONAL FORMATTING at the end of the element.</p> <p>The requirements on handling the <code><a href=#the-bdo-element>bdo</a></code> element for the bidirectional algorithm may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements by implementing the CSS 'unicode-bidi' property. <a href=#refsCSS>[CSS]</a></p> </div> <h4 id=the-span-element><span class=secno>4.6.25 </span>The <dfn><code>span</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlspanelement>HTMLSpanElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><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>global attributes</a>, e.g. <code title=attr-class><a href=#classes>class</a></code>, <code title=attr-lang><a href=#attr-lang>lang</a></code>, or <code title=attr-dir><a href=#the-dir-attribute>dir</a></code>. It <a href=#represents>represents</a> its children.</p> <div class=example> <p>In this example, a code fragment is marked up using <code><a href=#the-span-element>span</a></code> elements and <code title=attr-class><a href=#classes>class</a></code> attributes so that its keywords and identifiers can be color-coded from CSS:</p> <!-- extract from http://www.cs.cmu.edu/~dst/DeCSS/Gallery/vlc-dvd_css-c.txt --> <pre><pre><code class="lang-c"><span class="keyword">for</span> (<span class="ident">j</span> = 0; <span class="ident">j</span> &lt; 256; <span class="ident">j</span>++) { <span class="ident">i_t3</span> = (<span class="ident">i_t3</span> & 0x1ffff) | (<span class="ident">j</span> &lt;&lt; 17); <span class="ident">i_t6</span> = (((((((<span class="ident">i_t3</span> >> 3) ^ <span class="ident">i_t3</span>) >> 1) ^ <span class="ident">i_t3</span>) >> 8) ^ <span class="ident">i_t3</span>) >> 5) & 0xff; <span class="keyword">if</span> (<span class="ident">i_t6</span> == <span class="ident">i_t1</span>) <span class="keyword">break</span>; }</code></pre></pre> </div> <h4 id=the-br-element><span class=secno>4.6.26 </span>The <dfn><code>br</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlbrelement>HTMLBRElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-br-element>br</a></code> element <a href=#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><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><a href=#the-br-element>br</a></code> element:</p> <pre><p>P. Sherman<br> 42 Wallaby Way<br> Sydney</p></pre> </div> <p><code><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><a href=#the-br-element>br</a></code> element:</p> <pre><p><a ...>34 comments.</a><br> <a ...>Add a comment.</a></p></pre> <pre><p><label>Name: <input name="name"></label><br> <label>Address: <input name="address"></label></p></pre> <p>Here are alternatives to the above, which are correct:</p> <pre><p><a ...>34 comments.</a></p> <p><a ...>Add a comment.</a></p></pre> <pre><p><label>Name: <input name="name"></label></p> <p><label>Address: <input name="address"></label></p></pre> </div> <p>If a <a href=#paragraph>paragraph</a> consists of nothing but a single <code><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> <div class=impl> <p>Any content inside <code><a href=#the-br-element>br</a></code> elements must not be considered part of the surrounding text.</p> <p>A <code><a href=#the-br-element>br</a></code> element should separate paragraphs for the purposes of the Unicode bidirectional algorithm. This requirement may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements by implementing the CSS 'unicode-bidi' property. <a href=#refsBIDI>[BIDI]</a> <a href=#refsCSS>[CSS]</a></p> </div> <h4 id=the-wbr-element><span class=secno>4.6.27 </span>The <dfn><code>wbr</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-wbr-element>wbr</a></code> element <a href=#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><a href=#the-wbr-element>wbr</a></code> element.</p> <pre><p>So then he pointed at the tiger and screamed "there<wbr>is<wbr>no<wbr>way<wbr>you<wbr>are<wbr>ever<wbr>going<wbr>to<wbr>catch<wbr>me"!</p></pre> </div> <div class=example> <p>Here, especially long lines of code in a program listing have suggested wrapping points given using <code><a href=#the-wbr-element>wbr</a></code> elements.</p> <pre><pre>... Heading heading = Helm.HeadingFactory(HeadingCoordinates[1], <wbr>HeadingCoordinates[2], <wbr>HeadingCoordinates[3], <wbr>HeadingCoordinates[4]); Course course = Helm.CourseFactory(Heading, <wbr>Maps.MapFactoryFromHeading(heading), <wbr>Speeds.GetMaximumSpeed().ConvertToWarp()); ...</pre></pre> </div> <div class=impl> <p>Any content inside <code><a href=#the-wbr-element>wbr</a></code> elements must not be considered part of the surrounding text.</p> </div> <h4 id=usage-summary><span class=secno>4.6.28 </span>Usage summary</h4> <p><i>This section is non-normative.</i></p> <table><thead><tr><th>Element <th>Purpose <th>Example <tbody><tr><td><code><a href=#the-a-element>a</a></code> <td>Hyperlinks <td><pre class=example>Visit my <strong><a href="drinks.html">drinks</a></strong> page.</pre> <tr><td><code><a href=#the-em-element>em</a></code> <td>Stress emphasis <td><pre class=example>I must say I <strong><em>adore</em></strong> lemonade.</pre> <tr><td><code><a href=#the-strong-element>strong</a></code> <td>Importance <td><pre class=example>This tea is <strong><strong>very hot</strong></strong>.</pre> <tr><td><code><a href=#the-small-element>small</a></code> <td>Side comments <td><pre class=example>These grapes are made into wine. <strong><small>Alcohol is addictive.</small></strong></pre> <tr><td><code><a href=#the-s-element>s</a></code> <td>Inaccurate text <td><pre class=example>Price: <strong><s>£4.50</s></strong> £2.00!</pre> <tr><td><code><a href=#the-cite-element>cite</a></code> <td>Titles of works <td><pre class=example>The case <strong><cite>Hugo v. Danielle</cite></strong> is relevant here.</pre> <tr><td><code><a href=#the-q-element>q</a></code> <td>Quotations <td><pre class=example>The judge said <strong><q>You can drink water from the fish tank</q></strong> but advised against it.</pre> <tr><td><code><a href=#the-dfn-element>dfn</a></code> <td>Defining instance <td><pre class=example>The term <strong><dfn>organic food</dfn></strong> refers to food produced without synthetic chemicals.</pre> <tr><td><code><a href=#the-abbr-element>abbr</a></code> <td>Abbreviations <td><pre class=example>Organic food in Ireland is certified by the <strong><abbr title="Irish Organic Farmers and Growers Association">IOFGA</abbr></strong>.</pre> <tr><td><code><a href=#the-data-element>data</a></code> <td>Machine-readable equivalent <td><pre class=example>Available starting today! <strong><data value="UPC:022014640201">North Coast Organic Apple Cider</data></strong></pre> <tr><td><code><a href=#the-code-element>code</a></code> <td>Computer code <td><pre class=example>The <strong><code>fruitdb</code></strong> program can be used for tracking fruit production.</pre> <tr><td><code><a href=#the-var-element>var</a></code> <td>Variables <td><pre class=example>If there are <strong><var>n</var></strong> fruit in the bowl, at least <strong><var>n</var></strong>÷2 will be ripe.</pre> <tr><td><code><a href=#the-samp-element>samp</a></code> <td>Computer output <td><pre class=example>The computer said <strong><samp>Unknown error -3</samp></strong>.</pre> <tr><td><code><a href=#the-kbd-element>kbd</a></code> <td>User input <td><pre class=example>Hit <strong><kbd>F1</kbd></strong> to continue.</pre> <tr><td><code><a href=#the-sub-and-sup-elements>sub</a></code> <td>Subscripts <td><pre class=example>Water is H<strong><sub>2</sub></strong>O.</pre> <tr><td><code><a href=#the-sub-and-sup-elements>sup</a></code> <td>Superscripts <td><pre class=example>The Hydrogen in heavy water is usually <strong><sup>2</sup></strong>H.</pre> <tr><td><code><a href=#the-i-element>i</a></code> <td>Alternative voice <td><pre class=example>Lemonade consists primarily of <strong><i>Citrus limon</i></strong>.</pre> <tr><td><code><a href=#the-b-element>b</a></code> <td>Keywords <td><pre class=example>Take a <strong><b>lemon</b></strong> and squeeze it with a <strong><b>juicer</b></strong>.</pre> <tr><td><code><a href=#the-u-element>u</a></code> <td>Annotations <td><pre class=example>The mixture of apple juice and <u class="spelling">eldeflower</u> juice is very pleasant.</pre> <tr><td><code><a href=#the-mark-element>mark</a></code> <td>Highlight <td><pre class=example>Elderflower cordial, with one <strong><mark>part</mark></strong> cordial to ten <strong><mark>part</mark></strong>s water, stands a<strong><mark>part</mark></strong> from the rest.</pre> <tr><td><code><a href=#the-ruby-element>ruby</a></code>, <code><a href=#the-rt-element>rt</a></code>, <code><a href=#the-rp-element>rp</a></code> <td>Ruby annotations <td><pre class=example><strong><ruby> OJ <rp>(<rt>Orange Juice<rp>)</ruby></strong></pre> <tr><td><code><a href=#the-bdi-element>bdi</a></code> <td>Text directionality isolation <td><pre class=example>The recommended restaurant is <strong><bdi lang="">My Juice Café (At The Beach)</bdi></strong>.</pre> <tr><td><code><a href=#the-bdo-element>bdo</a></code> <td>Text directionality formatting <td><pre class=example>The proposal is to write English, but in reverse order. "Juice" would become "<strong><bdo dir=rtl>Juice</bdo></strong>"</pre> <tr><td><code><a href=#the-span-element>span</a></code> <td>Other <td><pre class=example>In French we call it <strong><span lang="fr">sirop de sureau</span></strong>.</pre> <tr><td><code><a href=#the-br-element>br</a></code> <td>Line break <td><pre class=example>Simply Orange Juice Company<strong><br></strong>Apopka, FL 32703<strong><br></strong>U.S.A.</pre> <tr><td><code><a href=#the-wbr-element>wbr</a></code> <td>Line breaking opportunity <td><pre class=example>www.simply<strong><wbr></strong>orange<strong><wbr></strong>juice.com</pre> </table><h3 id=edits><span class=secno>4.7 </span>Edits</h3> <p>The <code><a href=#the-ins-element>ins</a></code> and <code><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</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: <a href=#phrasing-content>phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dd>Otherwise: where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#transparent>Transparent</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-mod-cite><a href=#attr-mod-cite>cite</a></code></dd> <dd><code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code></dd> <dt>DOM interface:</dt> <dd>Uses the <code><a href=#htmlmodelement>HTMLModElement</a></code> interface.</dd> </dl><p>The <code><a href=#the-ins-element>ins</a></code> element <a href=#represents>represents</a> an addition to the document.</p> <div class=example> <p>The following represents the addition of a single paragraph:</p> <pre><aside> <ins> <p> I like fruit. </p> </ins> </aside></pre> <p>As does this, because everything in the <code><a href=#the-aside-element>aside</a></code> element here counts as <a href=#phrasing-content>phrasing content</a> and therefore there is just one <a href=#paragraph>paragraph</a>:</p> <pre><aside> <ins> Apples are <em>tasty</em>. </ins> <ins> So are pears. </ins> </aside></pre> </div> <p><code><a href=#the-ins-element>ins</a></code> elements should not cross <a href=#paragraph title=paragraph>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><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><aside> <!-- don't do this --> <ins datetime="2005-03-16T00:00Z"> <p> I like fruit. </p> Apples are <em>tasty</em>. </ins> <ins datetime="2007-12-19T00:00Z"> So are pears. </ins> </aside></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><aside> <ins datetime="2005-03-16T00:00Z"> <p> I like fruit. </p> </ins> <ins datetime="2005-03-16T00:00Z"> Apples are <em>tasty</em>. </ins> <ins datetime="2007-12-19T00:00Z"> So are pears. </ins> </aside></pre> <!-- Those dates aren't random. They're the start and end of something. Can you guess what? --> </div> <h4 id=the-del-element><span class=secno>4.7.2 </span>The <dfn><code>del</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: <a href=#phrasing-content>phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dd>Otherwise: where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#transparent>Transparent</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-mod-cite><a href=#attr-mod-cite>cite</a></code></dd> <dd><code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code></dd> <dt>DOM interface:</dt> <dd>Uses the <code><a href=#htmlmodelement>HTMLModElement</a></code> interface.</dd> </dl><p>The <code><a href=#the-del-element>del</a></code> element <a href=#represents>represents</a> a removal from the document.</p> <p><code><a href=#the-del-element>del</a></code> elements should not cross <a href=#paragraph title=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><h1>To Do</h1> <ul> <li>Empty the dishwasher</li> <li><del datetime="2009-10-11T01:25-07:00">Watch Walter Lewin's lectures</del></li> <li><del datetime="2009-10-10T23:38-07:00">Download more tracks</del></li> <li>Buy a printer</li> </ul></pre> </div> <h4 id=attributes-common-to-ins-and-del-elements><span class=secno>4.7.3 </span>Attributes common to <code><a href=#the-ins-element>ins</a></code> and <code><a href=#the-del-element>del</a></code> elements</h4> <p>The <dfn id=attr-mod-cite title=attr-mod-cite><code>cite</code></dfn> attribute may be used to specify the address 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 fragment identifier pointing to the specific part of that document that discusses the change.</p> <p>If the <code title=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>valid URL potentially surrounded by spaces</a> that explains the change. <span class=impl>To obtain the corresponding citation link, the value of the attribute must be <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element. User agents should allow users to follow such citation links.</span></p> <p>The <dfn id=attr-mod-datetime title=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 title=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>valid date string with optional time</a>.</p> <div class=impl> <p>User agents must parse the <code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code> attribute according to the <a href=#parse-a-date-or-time-string>parse a date or time string</a> algorithm. If that doesn't return a <a href=#concept-date title=concept-date>date</a> or a <a href=#concept-datetime title=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>valid date string with optional time</a>). Otherwise, the modification is marked as having been made at the given <a href=#concept-date title=concept-date>date</a> or <a href=#concept-datetime title=concept-datetime>global date and time</a>. If the given value is a <a href=#concept-datetime title=concept-datetime>global date and time</a> then user agents should use the associated time-zone offset information to determine which time zone to present the given datetime in.</p> </div> <p>The <code><a href=#the-ins-element>ins</a></code> and <code><a href=#the-del-element>del</a></code> elements <span class=impl>must</span> implement the <code><a href=#htmlmodelement>HTMLModElement</a></code> interface:</p> <pre class=idl>interface <dfn id=htmlmodelement>HTMLModElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-mod-cite title=dom-mod-cite>cite</a>; attribute DOMString <a href=#dom-mod-datetime title=dom-mod-datetime>dateTime</a>; };</pre> <div class=impl> <p>The <dfn id=dom-mod-cite title=dom-mod-cite><code>cite</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the element's <code title=attr-mod-cite><a href=#attr-mod-cite>cite</a></code> content attribute. The <dfn id=dom-mod-datetime title=dom-mod-datetime><code>dateTime</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the element's <code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code> content attribute.</p> </div> <h4 id=edits-and-paragraphs><span class=secno>4.7.4 </span>Edits and paragraphs</h4> <p><i>This section is non-normative.</i></p> <p>Since the <code><a href=#the-ins-element>ins</a></code> and <code><a href=#the-del-element>del</a></code> elements do not affect <a href=#paragraph title=paragraph>paragraphing</a>, it is possible, in some cases where paragraphs are <a href=#paragraph title=paragraph>implied</a> (without explicit <code><a href=#the-p-element>p</a></code> elements), for an <code><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> element to span both an entire paragraph or other non-<a href=#phrasing-content>phrasing content</a> elements and part of another paragraph. For example:</p> <pre><section> <ins> <p> This is a paragraph that was inserted. </p> This is another paragraph whose first sentence was inserted at the same time as the paragraph above. </ins> This is a second sentence, which was there all along. </section></pre> <p>By only wrapping some paragraphs in <code><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><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> element (though this is very confusing, and not considered good practice):</p> <pre class=bad><section> This is the first paragraph. <ins>This sentence was inserted. <p>This second paragraph was inserted.</p> This sentence was inserted too.</ins> This is the third paragraph in this example. <!-- (don't do this) --> </section></pre> <p>However, due to the way <a href=#paragraph title=paragraph>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><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> element. You instead have to use one (or two) <code><a href=#the-p-element>p</a></code> element(s) and two <code><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> elements, as for example:</p> <pre><section> <p>This is the first paragraph. <del>This sentence was deleted.</del></p> <p><del>This sentence was deleted too.</del> That sentence needed a separate &lt;del&gt; element.</p> </section></pre> <p>Partly because of the confusion described above, authors are strongly encouraged to always mark up all paragraphs with the <code><a href=#the-p-element>p</a></code> element, instead of having <code><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> elements that cross <a href=#paragraph title=paragraph>implied paragraphs</a> boundaries.</p> <h4 id=edits-and-lists><span class=secno>4.7.5 </span>Edits and lists</h4> <p><i>This section is non-normative.</i></p> <p>The content models of the <code><a href=#the-ol-element>ol</a></code> and <code><a href=#the-ul-element>ul</a></code> elements do not allow <code><a href=#the-ins-element>ins</a></code> and <code><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><a href=#the-ins-element>ins</a></code> or <code><a href=#the-del-element>del</a></code> element can be wrapped around the contents of the <code><a href=#the-li-element>li</a></code> element. To indicate that an item has been replaced by another, a single <code><a href=#the-li-element>li</a></code> element can have one or more <code><a href=#the-del-element>del</a></code> elements followed by one or more <code><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><h1>Stop-ship bugs</h1> <ol> <li><ins datetime="2008-02-12T15:20Z"><em>Bug 225: Rain detector doesn't work in snow</em></ins></li> <li><del datetime="2008-03-01T20:22Z"><ins datetime="2008-02-14T12:02Z">Bug 228: Water buffer overflows in April</ins></del></li> <li><ins datetime="2008-02-16T13:50Z"><em>Bug 230: Water heater doesn't use renewable fuels</em></ins></li> <li><del datetime="2008-02-20T21:15Z"><ins datetime="2008-02-16T14:25Z">Bug 232: Carbon dioxide emissions detected after startup</ins></del></li> </ol></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><h1>List of <del>fruits</del><ins>colors</ins></h1> <ul> <li><del>Lime</del><ins>Green</ins></li> <li><del>Apple</del></li> <li>Orange</li> <li><del>Pear</del></li> <li><ins>Teal</ins></li> <li><del>Lemon</del><ins>Yellow</ins></li> <li>Olive</li> <li><ins>Purple</ins></li> </ul></pre> </div> <h4 id=edits-and-tables><span class=secno>4.7.6 </span>Edits and tables</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><a href=#the-ins-element>ins</a></code> and <code><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><a href=#the-ins-element>ins</a></code> or <code><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><table> <thead> <tr> <th> Game name <th> Game publisher <th> Verdict <tbody> <tr> <td> Diablo 2 <td> Blizzard <td> 8/10 <tr> <td> Portal <td> Valve <td> 10/10 <strong> <tr> <td> <ins>Portal 2</ins> <td> <ins>Valve</ins> <td> <ins>10/10</ins></strong> </table></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><table> <thead> <tr> <th> Game name <th> Game publisher <th> <strong><del cite="/edits/r192" datetime="2011-05-02T14:23Z">Verdict</del></strong> <tbody> <tr> <td> Diablo 2 <td> Blizzard <td> <strong><del cite="/edits/r192" datetime="2011-05-02T14:23Z">8/10</del></strong> <tr> <td> Portal <td> Valve <td> <strong><del cite="/edits/r192" datetime="2011-05-02T14:23Z">10/10</del></strong> <tr> <td> Portal 2 <td> Valve <td> <strong><del cite="/edits/r192" datetime="2011-05-02T14:23Z">10/10</del></strong> </table></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-1><span class=secno>4.8 </span>Embedded content</h3> <h4 id=the-img-element><span class=secno>4.8.1 </span>The <dfn><code>img</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd>If the element has a <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute: <a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-img-alt><a href=#attr-img-alt>alt</a></code></dd> <dd><code title=attr-img-src><a href=#attr-img-src>src</a></code></dd> <dd><code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code></dd> <dd><code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code></dd> <dd><code title=attr-img-ismap><a href=#attr-img-ismap>ismap</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>[NamedConstructor=<a href=#dom-image title=dom-image>Image</a>(), NamedConstructor=<a href=#dom-image-w title=dom-image-w>Image</a>(unsigned long width), NamedConstructor=<a href=#dom-image-wh title=dom-image-wh>Image</a>(unsigned long width, unsigned long height)] interface <dfn id=htmlimageelement>HTMLImageElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-img-alt title=dom-img-alt>alt</a>; attribute DOMString <a href=#dom-img-src title=dom-img-src>src</a>; attribute DOMString <a href=#dom-img-crossorigin title=dom-img-crossOrigin>crossOrigin</a>; attribute DOMString <a href=#dom-img-usemap title=dom-img-useMap>useMap</a>; attribute boolean <a href=#dom-img-ismap title=dom-img-isMap>isMap</a>; attribute unsigned long <a href=#dom-img-width title=dom-img-width>width</a>; attribute unsigned long <a href=#dom-img-height title=dom-img-height>height</a>; readonly attribute unsigned long <a href=#dom-img-naturalwidth title=dom-img-naturalWidth>naturalWidth</a>; readonly attribute unsigned long <a href=#dom-img-naturalheight title=dom-img-naturalHeight>naturalHeight</a>; readonly attribute boolean <a href=#dom-img-complete title=dom-img-complete>complete</a>; };</pre> </dd> </dl><p>An <code><a href=#the-img-element>img</a></code> element represents an image.</p> <!-- v2 ideas for <img>: * Maps sites would like to know which images are already cached, so that they can use images that are vaguely suitable while they wait for the most appropriate image to download. Almost like lowsrc="", except that many images might be appropriate. Slight hitch: their images are at a different origin, and we don't want to allow arbitrary cross-origin inspection (privacy leak risk). So it will require them to do CORS opt-in. * See note at rel=noreferrer. --> <p>The image given by the <dfn id=attr-img-src title=attr-img-src><code>src</code></dfn> attribute is the embedded content; the value of the <dfn id=attr-img-alt title=attr-img-alt><code>alt</code></dfn> attribute provides equivalent content for those who cannot process images or who have image loading disabled<!-- --><!--FORK--><!-- --> (i.e. it is the <code><a href=#the-img-element>img</a></code> element's <a href=#fallback-content>fallback content</a>)<!-- --><!--FORK--><!-- -->.</p> <p>The <code title=attr-img-src><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>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>Images can thus be static bitmaps (e.g. PNGs, GIFs, JPEGs), single-page vector documents (single-page PDFs, XML files with an SVG root element), animated bitmaps (APNGs, animated GIFs), animated vector graphics (XML files with an SVG root element that use declarative SMIL animation), and so forth. However, this also precludes SVG files with script, multipage PDF files, interactive MNG files, HTML documents, plain text documents, and so forth.</p> <p>The requirements on the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute's value are described <a href=#alt>in the next section</a>.</p> <p>The <code><a href=#the-img-element>img</a></code> element must not be used as a layout tool. In particular, <code><a href=#the-img-element>img</a></code> elements should not be used to display transparent images, as they rarely convey meaning and rarely add anything useful to the document.</p> <p>The <dfn id=attr-img-crossorigin title=attr-img-crossorigin><code>crossorigin</code></dfn> attribute is a <a href=#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><a href=#the-canvas-element>canvas</a></code>.</p> <div class=impl> <hr><p>An <code><a href=#the-img-element>img</a></code> is always in one of the following states:</p> <dl><dt><dfn id=img-none title=img-none>Unavailable</dfn></dt> <dd>The user agent hasn't obtained any image data.</dd> <dt><dfn id=img-inc title=img-inc>Partially available</dfn></dt> <dd>The user agent has obtained some of the image data.</dd> <dt><dfn id=img-all title=img-all>Completely available</dfn></dt> <dd>The user agent has obtained all of the image data.</dd> <dt><dfn id=img-error title=img-error>Broken</dfn></dt> <dd>The user agent has obtained all of the image data that it can, but it cannot decode the image (e.g. the image is corrupted, or the format is not supported, or no data could be obtained).</dd> </dl><p>When an <code><a href=#the-img-element>img</a></code> element is either in the <a href=#img-inc title=img-inc>partially available</a> state or in the <a href=#img-all title=img-all>completely available</a> state, it is said to be <dfn id=img-yes title=img-yes>available</dfn>.</p> <p>An <code><a href=#the-img-element>img</a></code> element is initially <a href=#img-none title=img-none>unavailable</a>.</p> <p>When an <code><a href=#the-img-element>img</a></code> element is <a href=#img-yes title=img-yes>available</a>, it <a href=#provides-a-paint-source>provides a paint source</a> whose width is the image's intrinsic width, whose height is the image's intrinsic height, and whose appearance is the intrinsic appearance of the image.</p> <p>User agents may obtain images immediately or on demand.</p> <p>A user agent that obtains images immediately must synchronously <a href=#update-the-image-data>update the image data</a> of an <code><a href=#the-img-element>img</a></code> element whenever that element is either created with a <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute, or has its <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute set, changed, or removed, or has its <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> attribute set, changed, or removed.</p> <!-- Note how this does NOT happen when the base URL changes. --> <p>A user agent that obtains images on demand must <a href=#update-the-image-data>update the image data</a> of an <code><a href=#the-img-element>img</a></code> element whenever it needs the image data (i.e. on demand), but only if the <code><a href=#the-img-element>img</a></code> element has a <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute, and only if the <code><a href=#the-img-element>img</a></code> element is in the <a href=#img-none title=img-none>unavailable</a> state. When an <code><a href=#the-img-element>img</a></code> element's <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is changed or removed, and whenever the element's <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> attribute is set, changed, or removed, if the user agent only obtains images on demand, the <code><a href=#the-img-element>img</a></code> element must return to the <a href=#img-none title=img-none>unavailable</a> state.</p> <!-- Note how this does NOT happen when the base URL changes. --> <p>When the user agent is to <dfn id=update-the-image-data>update the image data</dfn> of an <code><a href=#the-img-element>img</a></code> element, it must run the following steps:</p> <ol><li><p>Return the <code><a href=#the-img-element>img</a></code> element to the <a href=#img-none title=img-none>unavailable</a> state.</p> <li><p>If an instance of the <a href=#fetch title=fetch>fetching</a> algorithm is still running for this element, then abort that algorithm, discarding any pending <a href=#concept-task title=concept-task>tasks</a> generated by that algorithm.</li> <li><p>Forget the <code><a href=#the-img-element>img</a></code> element's current image data, if any.</li> <li><p>If the user agent cannot support images, or its support for images has been disabled, then abort these steps.</li> <li><p>Asynchronously <a href=#await-a-stable-state>await a stable state</a>, allowing the <a href=#concept-task title=concept-task>task</a> that invoked this algorithm to continue. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm until the algorithm says the <a href=#synchronous-section>synchronous section</a> has ended. (Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked with ⌛.)</li> <li> <p>⌛ If another instance of this algorithm for this <code><a href=#the-img-element>img</a></code> element was started after this instance, then abort these steps. Only the last instance takes effect, to avoid multiple requests when the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is set multiple times in a row, or when the <code title=attr-img-src><a href=#attr-img-src>src</a></code> and <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> attributes are both set in succession.</p> </li> <li> <p>⌛ If the element's <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is missing or its value is the empty string, then set the element to the <a href=#img-error title=img-error>broken</a> state, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-img-element>img</a></code> element, and abort these steps.</p> </li> <li> <p>⌛ <a href=#resolve-a-url title="resolve a url">Resolve</a> the value of the element's <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute, relative to the element.</p> <p>If that is not successful, abort these steps.</p> <p>Otherwise, do a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the resulting <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being the state of the element's <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> content attribute, the <i title="">origin</i> being the <a href=#origin>origin</a> of the <code><a href=#the-img-element>img</a></code> element's <code><a href=#document>Document</a></code>, and the <i>default origin behaviour</i> set to <i>taint</i>.</p> <p>The resource obtained in this fashion, if any, is the <code><a href=#the-img-element>img</a></code> element's image data. It can be either <a href=#cors-same-origin>CORS-same-origin</a> or <a href=#cors-cross-origin>CORS-cross-origin</a>; this affects the <a href=#origin>origin</a> of the image itself (e.g. when used on a <code><a href=#the-canvas-element>canvas</a></code>).</p> <!-- same text in <input type=image> section and similar text elsewhere --> <p>Fetching the image must <a href=#delay-the-load-event>delay the load event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> (<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=#origin title=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>The first <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> while the image is being <a href=#fetch title=fetch>fetched</a> must set the <code><a href=#the-img-element>img</a></code> element's state to <a href=#img-inc title=img-inc>partially available</a>.</p> <p id=img-load>If the resource is in a supported image format, then each <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> while the image is being <a href=#fetch title=fetch>fetched</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); furthermore, the last <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> must act as appropriate given the following alternatives:</p> <dl class=switch><dt>If the download was successful</dt> <dd>Set the <code><a href=#the-img-element>img</a></code> element to the <a href=#img-all title=img-all>completely available</a> state, update the presentation of the image appropriately, and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-img-element>img</a></code> element.</dd> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1222 --> <dt>Otherwise</dt> <dd>Set the <code><a href=#the-img-element>img</a></code> element to the <a href=#img-error title=img-error>broken</a> state, and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-img-element>img</a></code> element.</dd> </dl><p>On the other hand, if the resource type is <code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code>, then each <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> while the image is being <a href=#fetch title=fetch>fetched</a> must also 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><a href=#the-img-element>img</a></code> element to the <a href=#img-all title=img-all>completely available</a> state and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-img-element>img</a></code> element.</p> <p>If at any point the user agent discovers that the image data is corrupted in some fatal way, or that the image data is not in a supported file format, then the user agent must set the <code><a href=#the-img-element>img</a></code> element to the <a href=#img-error title=img-error>broken</a> state. If the <a href=#fetch title=fetch>fetching</a> algorithm is still running for this element, then the user agent must also abort that algorithm, discarding any pending <a href=#concept-task title=concept-task>tasks</a> generated by that algorithm, and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-img-element>img</a></code> element.</p> </li> </ol><p>When an <code><a href=#the-img-element>img</a></code> element is in the <a href=#img-all title=img-all>completely available</a> state <em>and</em> the user agent can decode the media data without errors, then the <code><a href=#the-img-element>img</a></code> element is said to be <dfn id=img-good title=img-good>fully decodable</dfn>.</p> <p>Whether the image is fetched successfully or not (e.g. whether the response code was a 2xx code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</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>The user agents should apply the <a href=#content-type-sniffing:-image title="Content-Type sniffing: image">image sniffing rules</a> to determine the type of the image, with the image's <a href=#content-type title=Content-Type>associated Content-Type headers</a> giving the <var title="">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 title=Content-Type>associated Content-Type headers</a>.</p> <p>User agents must not support non-image resources with the <code><a href=#the-img-element>img</a></code> element (e.g. XML files whose root element 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 honor any animation in the resource.</p> <p>This specification does not specify which image types are to be supported.</p> <p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a task">queued</a> by algorithms in this section is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <hr><p>What an <code><a href=#the-img-element>img</a></code> element represents depends on the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute and the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute.</p> <dl class=switch><dt>If the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is set and the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is set to the empty string</dt> <dd> <p>The image is either decorative or supplemental to the rest of the content, redundant with some other information in the document.</p> <p>If the image is <a href=#img-yes title=img-yes>available</a> and the user agent is configured to display that image, then the element <a href=#represents>represents</a> the element's image data.</p> <p>Otherwise, the element <a href=#represents>represents</a> nothing, and may be omitted completely from the rendering. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.</p> </dd> <dt>If the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is set and the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is set to a value that isn't empty</dt> <dd> <p>The image is a key part of the content; the <code title=attr-img-alt><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-yes title=img-yes>available</a> and the user agent is configured to display that image, then the element <a href=#represents>represents</a> the element's image data.</p> <p>Otherwise, the element <a href=#represents>represents</a> the text given by the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.</p> </dd> <dt>If the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is set and the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is not</dt> <dd> <p>The image might be a key part of the content, and there is no textual equivalent of the image available.</p> <p class=note>In a conforming document, the absence of the <code title=attr-img-alt><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-yes title=img-yes>available</a> and the user agent is configured to display that image, then the element <a href=#represents>represents</a> the element's image data.</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><!-- when editing this list, search for the two other occurrences of 'critical-no-alt' --><li><p>If the image has a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute whose value is not the empty string, then the value of that attribute is the caption information; abort these steps.</li> <li><p>If the image is a descendant of a <code><a href=#the-figure-element>figure</a></code> element that has a child <code><a href=#the-figcaption-element>figcaption</a></code> element, and, ignoring the <code><a href=#the-figcaption-element>figcaption</a></code> element and its descendants, the <code><a href=#the-figure-element>figure</a></code> element has no text node descendants other than <a href=#inter-element-whitespace>inter-element whitespace</a>, and no <a href=#embedded-content>embedded content</a> descendant other than the <code><a href=#the-img-element>img</a></code> element, then the contents of the first such <code><a href=#the-figcaption-element>figcaption</a></code> element are the caption information; abort these steps.</li> </ol></dd> <dt>If the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is not set and either the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is set to the empty string or the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute is not set at all</dt> <dd> <p>The element <a href=#represents>represents</a> nothing.</p> </dd> <dt>Otherwise</dt> <dd> <p>The element <a href=#represents>represents</a> the text given by the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute.</p> </dd> </dl><p>The <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute does not represent advisory information. User agents must not present the contents of the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute in the same way as content of the <code title=attr-title><a href=#the-title-attribute>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. <!--POLITICS--><!--FORK--> 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. <!--POLITICS--><!--FORK--> </p> <p class=warning>While user agents are encouraged to repair cases of missing <code title=attr-img-alt><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><a href=#the-img-element>img</a></code> elements, if any, are ignored for the purposes of rendering.</p> </div> <hr><p>The <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute, if present, can indicate that the image has an associated <a href=#image-map>image map</a>.</p> <p>The <dfn id=attr-img-ismap title=attr-img-ismap><code>ismap</code></dfn> attribute, when used on an element that is a descendant of an <code><a href=#the-a-element>a</a></code> element with an <code title=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><a href=#the-a-element>a</a></code> element.</p> <p>The <code title=attr-img-ismap><a href=#attr-img-ismap>ismap</a></code> attribute is a <a href=#boolean-attribute>boolean attribute</a>. The attribute must not be specified on an element that does not have an ancestor <code><a href=#the-a-element>a</a></code> element with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute.</p> <p>The <code><a href=#the-img-element>img</a></code> element supports <a href=#dimension-attributes>dimension attributes</a>.</p> <div class=impl> <p>The <dfn id=dom-img-alt title=dom-img-alt><code>alt</code></dfn> and <dfn id=dom-img-src title=dom-img-src><code>src</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-img-crossorigin title=dom-img-crossOrigin><code>crossOrigin</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> content attribute.</p> <p>The <dfn id=dom-img-usemap title=dom-img-useMap><code>useMap</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-img-usemap>usemap</code> content attribute.</p> <p>The <dfn id=dom-img-ismap title=dom-img-isMap><code>isMap</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-img-ismap><a href=#attr-img-ismap>ismap</a></code> content attribute.</p> </div> <dl class=domintro><dt><var title="">image</var> . <code title=dom-img-width><a href=#dom-img-width>width</a></code> [ = <var title="">value</var> ]</dt> <dt><var title="">image</var> . <code title=dom-img-height><a href=#dom-img-height>height</a></code> [ = <var title="">value</var> ]</dt> <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> </dd> <dt><var title="">image</var> . <code title=dom-img-naturalWidth><a href=#dom-img-naturalwidth>naturalWidth</a></code></dt> <dt><var title="">image</var> . <code title=dom-img-naturalHeight><a href=#dom-img-naturalheight>naturalHeight</a></code></dt> <dd> <p>These attributes return the intrinsic dimensions of the image, or zero if the dimensions are not known.</p> </dd> <dt><var title="">image</var> . <code title=dom-img-complete><a href=#dom-img-complete>complete</a></code></dt> <dd> <p>Returns true if the image has been completely downloaded or if no image is specified; otherwise, returns false.</p> </dd> <dt><var title="">image</var> = new <code title=dom-image><a href=#dom-image>Image</a></code>( [ <var title="">width</var> [, <var title="">height</var> ] ] )</dt> <dd> <p>Returns a new <code><a href=#the-img-element>img</a></code> element, with the <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes set to the values passed in the relevant arguments, if applicable.</p> </dd> </dl><div class=impl> <p>The IDL attributes <dfn id=dom-img-width title=dom-img-width><code>width</code></dfn> and <dfn id=dom-img-height title=dom-img-height><code>height</code></dfn> must return the rendered width and height of the image, in CSS pixels, if the image is <a href=#being-rendered>being rendered</a>, and is being rendered to a visual medium; or else the intrinsic width and height of the image, in CSS pixels, if the image is <i title=img-available>available</i> but not being rendered to a visual medium; or else 0, if the image is not <i title=img-available>available</i>. <a href=#refsCSS>[CSS]</a></p> <p>On setting, they must act as if they <a href=#reflect title=reflect>reflected</a> the respective content attributes of the same name.</p> <p>The IDL attributes <dfn id=dom-img-naturalwidth title=dom-img-naturalWidth><code>naturalWidth</code></dfn> and <dfn id=dom-img-naturalheight title=dom-img-naturalHeight><code>naturalHeight</code></dfn> must return the intrinsic width and height of the image, in CSS pixels, if the image is <i title=img-available>available</i>, or else 0. <a href=#refsCSS>[CSS]</a></p> <p>The IDL attribute <dfn id=dom-img-complete title=dom-img-complete><code>complete</code></dfn> must return true if any of the following conditions is true:</p> <ul class=brief><li>The <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute is omitted. <li>The <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute's value is the empty string. <li>The final <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> has been <a href=#queue-a-task title="queue a task">queued</a>, but has not yet been run, and the <code><a href=#the-img-element>img</a></code> element is not in the <a href=#img-error title=img-error>broken</a> state. <li>The <code><a href=#the-img-element>img</a></code> element is <a href=#img-all title=img-all>completely available</a>. </ul><p>Otherwise, the attribute must return false.</p> <p class=note>The value of <code title=dom-img-complete><a href=#dom-img-complete>complete</a></code> can thus change while a <a href=#concept-script title=concept-script>script</a> is executing.</p> <p>Three constructors are provided for creating <code><a href=#htmlimageelement>HTMLImageElement</a></code> objects (in addition to the factory methods from DOM Core such as <code title="">createElement()</code>): <dfn id=dom-image title=dom-image><code>Image()</code></dfn>, <dfn id=dom-image-w title=dom-image-w><code>Image(<var title="">width</var>)</code></dfn>, and <dfn id=dom-image-wh title=dom-image-wh><code>Image(<var title="">width</var>, <var title="">height</var>)</code></dfn>. When invoked as constructors, these must return a new <code><a href=#htmlimageelement>HTMLImageElement</a></code> object (a new <code><a href=#the-img-element>img</a></code> element). If the <var title="">width</var> argument is present, the new object's <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> content attribute must be set to <var title="">width</var>. If the <var title="">height</var> argument is also present, the new object's <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> content attribute must be set to <var title="">height</var>. The element's document must be the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> of the <code><a href=#window>Window</a></code> object on which the interface object of the invoked constructor is found.</p> </div> <div class=example> <p>A single image can have different appropriate alternative text depending on the context.</p> <p>In each of the following cases, the same image is used, yet the <code title=attr-img-alt><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><p>I lived in <img src="carouge.svg" alt=""> Carouge.</p></pre> <p>Here it is used as an icon representing the town:</p> <pre><p>Home town: <img src="carouge.svg" alt="Carouge"></p></pre> <p>Here it is used as part of a text on the town:</p> <pre><p>Carouge has a coat of arms.</p> <p><img src="carouge.svg" alt="The coat of arms depicts a lion, sitting in front of a tree."></p> <p>It is used as decoration all over the town.</p></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><p>Carouge has a coat of arms.</p> <p><img src="carouge.svg" alt=""></p> <p>The coat of arms depicts a lion, sitting in front of a tree. It is used as decoration all over the town.</p></pre> <p>Here it is used as part of a story:</p> <pre><p>He picked up the folder and a piece of paper fell out.</p> <p><img src="carouge.svg" alt="Shaped like a shield, the paper had a red background, a green tree, and a yellow lion with its tongue hanging out and whose tail was shaped like an S."></p> <p>He stared at the folder. S! The answer he had been looking for all this time was simply the letter S! How had he not seen that before? It all came together now. The phone call where Hector had referred to a lion's tail, the time Marco had stuck his tongue out...</p></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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute:</p> <pre><p>The last user to have uploaded a coat of arms uploaded this one:</p> <p><img src="last-uploaded-coat-of-arms.cgi" title="User-uploaded coat of arms."></p></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><article> <h1>My cats</h1> <h2>Fluffy</h2> <p>Fluffy is my favorite.</p> <img src="fluffy.jpg" alt="She likes playing with a ball of yarn."> <p>She's just too cute.</p> <h2>Miles</h2> <p>My other cat, Miles just eats and sleeps.</p> </article></pre> <pre><article> <h1>Photography</h1> <h2>Shooting moving targets indoors</h2> <p>The trick here is to know how to anticipate; to know at what speed and what distance the subject will pass by.</p> <img src="fluffy.jpg" alt="A cat flying by, chasing a ball of yarn, can be photographed quite nicely using this technique."> <h2>Nature by night</h2> <p>To achieve this, you'll need either an extremely sensitive film, or immense flash lights.</p> </article></pre> <pre><article> <h1>About me</h1> <h2>My pets</h2> <p>I've got a cat named Fluffy and a dog named Miles.</p> <img src="fluffy.jpg" alt="Fluffy, my cat, tends to keep itself busy."> <p>My dog Miles and I like go on long walks together.</p> <h2>music</h2> <p>After our walks, having emptied my mind, I like listening to Bach.</p> </article></pre> <pre><article> <h1>Fluffy and the Yarn</h1> <p>Fluffy was a cat who liked to play with yarn. He also liked to jump.</p> <aside><img src="fluffy.jpg" alt="" title="Fluffy"></aside> <p>He would play in the morning, he would play in the evening.</p> </article></pre> </div> <h5 id=alt><span class=secno>4.8.1.1 </span>Requirements for providing text to act as an alternative for images</h5> <h6 id=general-guidelines><span class=secno>4.8.1.1.1 </span>General guidelines</h6> <p>Except where otherwise specified, the <code title=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 title=attr-img-alt><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 title=attr-img-alt><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 title=attr-img-alt><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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute can be used for supplemental information.</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.1.1.2 </span>A link or button containing nothing but the image</h6> <p>When an <a href=#the-a-element>a</a> element that creates a <a href=#hyperlink>hyperlink</a>, or a <code><a href=#the-button-element>button</a></code> element, has no textual content but contains one or more images, the <code title=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 his 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><h1>Pick your color</h1> <ul> <li><a href="green.html"><strong><img src="green.jpeg" alt="Green"></strong></a></li> <li><a href="blue.html"><strong><img src="blue.jpeg" alt="Blue"></strong></a></li> <li><a href="red.html"><strong><img src="red.jpeg" alt="Red"></strong></a></li> </ul></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><button name="rgb"><strong><img src="red" alt="RGB"><img src="green" alt=""><img src="blue" alt=""></strong></button> <button name="cmyk"><strong><img src="cyan" alt="CMYK"><img src="magenta" alt=""><img src="yellow" alt=""><img src="black" alt=""></strong></button></pre> <p>Since each image represents one part of the text, it could also be written like this:</p> <pre><button name="rgb"><strong><img src="red" alt="R"><img src="green" alt="G"><img src="blue" alt="B"></strong></button> <button name="cmyk"><strong><img src="cyan" alt="C"><img src="magenta" alt="M"><img src="yellow" alt="Y"><img src="black" alt="K"></strong></button></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><button name="rgb"><strong><img src="red" alt="sRGB profile"><img src="green" alt=""><img src="blue" alt=""></strong></button> <button name="cmyk"><strong><img src="cyan" alt="CMYK profile"><img src="magenta" alt=""><img src="yellow" alt=""><img src="black" alt=""></strong></button></pre> </div> <h6 id=a-phrase-or-paragraph-with-an-alternative-graphical-representation:-charts,-diagrams,-graphs,-maps,-illustrations><span class=secno>4.8.1.1.3 </span>A phrase or paragraph with an alternative graphical representation: charts, diagrams, graphs, maps, illustrations</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><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 title=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 title=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.png>a flowchart</a> in image form, with text in the <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute rephrasing the flowchart in prose form:</p> <pre><p>In the common case, the data handled by the tokenization stage comes from the network, but it can also come from script.</p> <p><strong><img src="images/parsing-model-overview.png" alt="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."></strong></p></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><!-- This is the correct way to do things. --> <p> You are standing in an open field west of a house. <strong><img src="house.jpeg" alt="The house is white, with a boarded front door."></strong> There is a small mailbox here. </p></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><!-- <em>This is the wrong way to do things.</em> --> <p> You are standing in an open field west of a house. <img src="house.jpeg" alt="A white house, with a boarded front door."> There is a small mailbox here. </p></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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute or in the <code><a href=#the-figcaption-element>figcaption</a></code> element of a <code><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.1.1.4 </span>A short phrase or label with an alternative graphical representation: icons, logos</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 title=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 title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute:</p> <pre><nav> <p><a href="/help/"><strong><img src="/icons/help.png" alt=""></strong> Help</a></p> <p><a href="/configure/"><strong><img src="/icons/configuration.png" alt=""></strong> Configuration Tools</a></p> </nav></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 title=attr-img-alt><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><body> <article> <header> <h1>Ratatouille wins <i>Best Movie of the Year</i> award</h1> <p><strong><img src="movies.png" alt="Movies"></strong></p> </header> <p>Pixar has won yet another <i>Best Movie of the Year</i> award, making this its 8th win in the last 12 years.</p> </article> <article> <header> <h1>Latest TWiT episode is online</h1> <p><strong><img src="podcasts.png" alt="Podcasts"></strong></p> </header> <p>The latest TWiT episode has been posted, in which we hear several tech news stories as well as learning much more about the iPhone. This week, the panelists compare how reflective their iPhones' Apple logos are.</p> </article> </body></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 title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute must contain the name of the entity being represented by the logo. The <code title=attr-img-alt><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 title=attr-img-alt><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><h1><strong><img src="XYZ.gif" alt="The XYZ company"></strong></h1></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><article> <h2>News</h2> <p>We have recently been looking at buying the <strong><img src="alpha.gif" alt=""> ΑΒΓ company</strong>, a small Greek company specializing in our type of product.</p></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> <strong><aside><p><img src="alpha-large.gif" alt=""></p></aside></strong> <p>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.</p> </article></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><p>Consider for a moment their logo:</p> <strong><p><img src="/images/logo" alt="It consists of a green circle with a green question mark centered inside it."></p></strong> <p>How unoriginal can you get? I mean, oooooh, a question mark, how <em>revolutionary</em>, how utterly <em>ground-breaking</em>, I'm sure everyone will rush to adopt those specifications now! They could at least have tried for some sort of, I don't know, sequence of rounded squares with varying shades of green and bold white outlines, at least that would look good on the cover of a blue book.</p></pre> <p>This example shows how the alternative text should be written such that if the image isn't <i title=img-available>available</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.1.1.5 </span>Text that has been rendered to a graphic for typographical effect</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 title=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><h1><strong><img src="earthdayheading.png" alt="Earth Day"></strong></h1></pre> </div> <h6 id=a-graphical-representation-of-some-of-the-surrounding-text><span class=secno>4.8.1.1.6 </span>A graphical representation of some of the surrounding text</h6> <p>In many cases, the image is actually just supplementary, and its presence merely reinforces the surrounding text. In these cases, the <code title=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><p>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.</p> <strong><p><img src="images/parsing-model-overview.png" alt=""></p></strong></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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute can be used, or the <code><a href=#the-figure-element>figure</a></code> and <code><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><!-- Using the title="" attribute --> <p>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.</p> <p><strong><img src="images/parsing-model-overview.png" alt="" title="Flowchart representation of the parsing model."></strong></p></pre> <pre><!-- Using <figure> and <figcaption> --> <p>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.</p> <figure> <strong><img src="images/parsing-model-overview.png" alt="The Network leads to the Input Stream Preprocessor, which leads to the Tokenizer, which leads to the Tree Construction stage. The Tree Construction stage leads to two items. The first is Script Execution, which leads via document.write() back to the Tokenizer. The second item from which Tree Construction leads is the DOM. The DOM is related to the Script Execution."></strong> <figcaption>Flowchart representation of the parsing model.</figcaption> </figure></pre> <pre class=bad><!-- This is WRONG. Do not do this. Instead, do what the above examples do. --> <p>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.</p> <p><img src="images/parsing-model-overview.png" alt="Flowchart representation of the parsing model."></p> <!-- Never put the image's caption in the alt="" attribute! --></pre> </div> <div class=example> <p>A graph that repeats the previous paragraph in graphical form:</p> <pre><p>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.</p> <strong><p><img src="rendering-mode-pie-chart.png" alt=""></p></strong></pre> </div> <h6 id="a-purely-decorative-image-that-doesn't-add-any-information"><span class=secno>4.8.1.1.7 </span>A purely decorative image that doesn't add any information</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> <!-- The above paragraph is omitted in the WHATWG copy and replaced with the explicit requirement below because accessibility is better served by having authors get all their information from one place, instead of requiring them to read multiple (contradictory) documents. --> <!--FORK--> <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><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 title=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><h1>The Lady of Shalott</h1> <strong><p><img src="shalott.jpeg" alt=""></p></strong> <p>On either side the river lie<br> Long fields of barley and of rye,<br> That clothe the wold and meet the sky;<br> And through the field the road run by<br> To many-tower'd Camelot;<br> And up and down the people go,<br> Gazing where the lilies blow<br> Round an island there below,<br> The island of Shalott.</p></pre> </div> <!--FORK--> <h6 id=a-group-of-images-that-form-a-single-larger-picture-with-no-links><span class=secno>4.8.1.1.8 </span>A group of images that form a single larger picture with no links</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 title=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 title=attr-img-alt><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 title="">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><h1><strong><img src="logo1.png" alt="XYZ Corp"><img src="logo2.png" alt=""></strong></h1></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><p>Rating: <meter max=5 value=3><strong><img src="1" alt="3 out of 5" ><img src="1" alt=""><img src="1" alt=""><img src="0" alt="" ><img src="0" alt=""></strong></meter></p></pre> </div> <h6 id=a-group-of-images-that-form-a-single-larger-picture-with-links><span class=secno>4.8.1.1.9 </span>A group of images that form a single larger picture with links</h6> <p>Generally, <a href=#image-map title="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 title=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><h1>The Church</h1> <p>You come across a flying spaghetti monster. Which side of His Noodliness do you wish to reach out for?</p> <strong><p><a href="?go=left" ><img src="fsm-left.png" alt="Left side. "></a ><img src="fsm-middle.png" alt="" ><a href="?go=right"><img src="fsm-right.png" alt="Right side."></a></p></strong></pre> </div> <h6 id=a-key-part-of-the-content><span class=secno>4.8.1.1.10 </span>A key part of the content</h6> <p>In some cases, the image is a critical part of the content. This could be the case, for instance, on a page that is part of a photo gallery. The image is the whole <em>point</em> of the page containing it.</p> <p>How to provide alternative text for an image that is a key part of the content depends on the image's provenance.</p> <dl><dt>The general case</dt> <dd> <p>When it is possible for detailed alternative text to be provided, for example if the image is part of a series of screenshots in a magazine review, or part of a comic strip, or is a photograph in a blog entry about that photograph, text that can serve as a substitute for the image must be given as the contents of the <code title=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><figure> <strong><img src="KDE%20Light%20desktop.png" alt="The desktop is blue, with icons along the left hand side in two columns, reading System, Home, K-Mail, etc. A window is open showing that menus wrap to a second line if they cannot fit in the window. The window has a list of icons along the top, with an address bar below it, a list of icons for tabs along the left edge, a status bar on the bottom, and two panes in the middle. The desktop has a bar at the bottom of the screen with a few buttons, a pager, a list of open applications, and a clock."></strong> <figcaption>Screenshot of a KDE desktop.</figcaption> </figure></pre> </div> <div class=example> <p>A graph in a financial report:</p> <pre><strong><img src="sales.gif" title="Sales graph" alt="From 1998 to 2005, sales increased by the following percentages with each year: 624%, 75%, 138%, 40%, 35%, 9%, 21%"></strong></pre> <p>Note that "sales graph" would be inadequate alternative text for a sales graph. Text that would be a good <em>caption</em> is not generally suitable as replacement text.</p> </div> </dd> <dt>Images that defy a complete description</dt> <dd> <p>In certain cases, the nature of the image might be such that providing thorough alternative text is impractical. For example, the image could be indistinct, or could be a complex fractal, or could be a detailed topographical map.</p> <p>In these cases, the <code title=attr-img-alt><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><figure> <strong><img src="/commons/a/a7/Rorschach1.jpg" alt="A shape with left-right symmetry with indistinct edges, with a small gap in the center, two larger gaps offset slightly from the center, with two similar gaps under them. The outline is wider in the top half than the bottom half, with the sides extending upwards higher than the center, and the center extending below the sides."></strong> <figcaption>A black outline of the first of the ten cards in the Rorschach inkblot test.</figcaption> </figure></pre> <p>Note that the following would be a very bad use of alternative text:</p> <pre class=bad><!-- This example is wrong. Do not copy it. --> <figure> <img src="/commons/a/a7/Rorschach1.jpg" alt="A black outline of the first of the ten cards in the Rorschach inkblot test."> <figcaption>A black outline of the first of the ten cards in the Rorschach inkblot test.</figcaption> </figure></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><strong><img src="ms1.jpeg" alt="The Mandelbrot set appears as a cardioid with its cusp on the real axis in the positive direction, with a smaller bulb aligned along the same center line, touching it in the negative direction, and with these two shapes being surrounded by smaller bulbs of various sizes."></strong></pre> </div> </dd> <dt id=unknown-images>Images whose contents are not known</dt> <dd> <p>In some unfortunate cases, there might be no alternative text available at all, either because the image is obtained in some automated fashion without any associated alternative text (e.g. a Webcam), or because the page is being generated by a script using user-provided images where the user did not provide suitable or usable alternative text (e.g. photograph sharing sites), or because the author does not himself know what the images represent (e.g. a blind photographer sharing an image on his blog).</p> <p>In such cases, the <code title=attr-img-alt><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><!-- when editing this list, search for the two other occurrences of 'critical-no-alt' --><li>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute is present and has a non-empty value.</li> <li id=figcaption-as-alt-condition>The <code><a href=#the-img-element>img</a></code> element is in a <code><a href=#the-figure-element>figure</a></code> element that contains a <code><a href=#the-figcaption-element>figcaption</a></code> element that contains content other than <a href=#inter-element-whitespace>inter-element whitespace</a>, and, ignoring the <code><a href=#the-figcaption-element>figcaption</a></code> element and its descendants, the <code><a href=#the-figure-element>figure</a></code> element has no text node descendants other than <a href=#inter-element-whitespace>inter-element whitespace</a>, and no <a href=#embedded-content>embedded content</a> descendant other than the <code><a href=#the-img-element>img</a></code> element.</li> </ul><p class=note>Such cases are to be kept to an absolute minimum. If there is even the slightest possibility of the author having the ability to provide real alternative text, then it would not be acceptable to omit the <code title=attr-img-alt><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><figure> <strong><img src="1100670787_6a7c664aef.jpg"></strong> <figcaption>Bubbles traveled everywhere with us.</figcaption> </figure></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 he took shows:</p> <pre><article> <h1>I took a photo</h1> <p>I went out today and took a photo!</p> <figure> <strong><img src="photo2.jpeg"></strong> <figcaption>A photograph taken blindly from my front porch.</figcaption> </figure> </article></pre> <p>Eventually though, the user might obtain a description of the image from his friends and could then include alternative text:</p> <pre><article> <h1>I took a photo</h1> <p>I went out today and took a photo!</p> <figure> <strong><img src="photo2.jpeg" alt="The photograph shows my hummingbird feeder hanging from the edge of my roof. It is half full, but there are no birds around. In the background, out-of-focus trees fill the shot. The feeder is made of wood with a metal grate, and it contains peanuts. The edge of the roof is wooden too, and is painted white with light blue streaks."></strong> <figcaption>A photograph taken blindly from my front porch.</figcaption> </figure> </article></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 title=attr-title><a href=#the-title-attribute>title</a></code> attribute):</p> <pre><p><label>What does this image say? <strong><img src="captcha.cgi?id=8934" title="CAPTCHA"></strong> <input type=text name=captcha></label> (If you cannot see the image, you can use an <a href="?audio">audio</a> test instead.)</p></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><table> <thead> <tr> <th> Image <th> Description <tbody> <tr> <td> <strong><img src="2421.png" title="Image 640 by 100, filename 'banner.gif'"></strong> <td> <input name="alt2421"> <tr> <td> <strong><img src="2422.png" title="Image 200 by 480, filename 'ad3.gif'"></strong> <td> <input name="alt2422"> </table></pre> <p>Notice that even in this example, as much useful information as possible is still included in the <code title=attr-title><a href=#the-title-attribute>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 title=attr-img-alt><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 title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute.</p> </dd> </dl><h6 id=an-image-not-intended-for-the-user><span class=secno>4.8.1.1.11 </span>An image not intended for the user</h6> <p>Generally authors should avoid using <code><a href=#the-img-element>img</a></code> elements for purposes other than showing images.</p> <p>If an <code><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 title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute must be the empty string.</p> <p>In such cases, the <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes should both be set to zero.</p> <!--FORK--> <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.1.1.12 </span>An image in an e-mail or private document intended for a specific person who is known to be able to view images</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 title=attr-img-alt><a href=#attr-img-alt>alt</a></code> attribute may be omitted. However, even in such cases it is strongly recommended that alternative text be included (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> <!--FORK--> <div class=impl> <h6 id=guidance-for-markup-generators><span class=secno>4.8.1.1.13 </span>Guidance for markup generators</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>As a last resort, implementors should either set the <code title=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 title=attr-img-alt><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 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> </div> <div class=impl> <h6 id=guidance-for-conformance-checkers><span class=secno>4.8.1.1.14 </span>Guidance for conformance checkers</h6> <p>A conformance checker must report the lack of an <code title=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><!-- when editing this list, search for the two other occurrences of 'critical-no-alt' --><li>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute is present and has a non-empty value (as <a href=#unknown-images>described above</a>).</li> <li>The <code><a href=#the-img-element>img</a></code> element is in a <code><a href=#the-figure-element>figure</a></code> element that satisfies <a href=#figcaption-as-alt-condition>the conditions described above</a>.</li> <!-- the following are additional entries not included in the aforementioned list, as they apply only to conformance checkers --> <!--FORK--> <li>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> <!--FORK--> <li>The document has a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=meta-generator><a href=#meta-generator>generator</a></code>". (This case does not represent a case where the document is conforming, only that the generator could not determine appropriate alternative text — validators are required to not show an error in this case to discourage markup generators from including bogus alternative text purely in an attempt to silence validators.)</li> </ul></div> <h4 id=the-iframe-element><span class=secno>4.8.2 </span>The <dfn><code>iframe</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>Text that conforms to <a href=#iframe-content-model>the requirements given in the prose</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code></dd> <dd><code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code></dd> <dd><code title=attr-iframe-name><a href=#attr-iframe-name>name</a></code></dd> <dd><code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code></dd> <dd><code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmliframeelement>HTMLIFrameElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-iframe-src title=dom-iframe-src>src</a>; attribute DOMString <a href=#dom-iframe-srcdoc title=dom-iframe-srcdoc>srcdoc</a>; attribute DOMString <a href=#dom-iframe-name title=dom-iframe-name>name</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-iframe-sandbox title=dom-iframe-sandbox>sandbox</a>; attribute boolean <a href=#dom-iframe-seamless title=dom-iframe-seamless>seamless</a>; attribute DOMString <a href=#dom-dim-width title=dom-dim-width>width</a>; attribute DOMString <a href=#dom-dim-height title=dom-dim-height>height</a>; readonly attribute Document? <a href=#dom-iframe-contentdocument title=dom-iframe-contentDocument>contentDocument</a>; readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-iframe-contentwindow title=dom-iframe-contentWindow>contentWindow</a>; };</pre> </dd> </dl><p>The <code><a href=#the-iframe-element>iframe</a></code> element <a href=#represents>represents</a> a <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>The <dfn id=attr-iframe-src title=attr-iframe-src><code>src</code></dfn> attribute gives the address of a page that the <a href=#nested-browsing-context>nested browsing context</a> is to contain. The attribute, if present, must be a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by spaces</a>.</p> <p>The <dfn id=attr-iframe-srcdoc title=attr-iframe-srcdoc><code>srcdoc</code></dfn> attribute gives the content of the page that the <a href=#nested-browsing-context>nested browsing context</a> is to contain. The value of the attribute is the source of <dfn id=an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</dfn>.</p> <p>For <code><a href=#the-iframe-element>iframe</a></code> elements in <a href=#html-documents>HTML documents</a>, the attribute, if present, must have a value using <a href=#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 title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> <li>Optionally, a <a href=#syntax-doctype title=syntax-doctype>DOCTYPE</a>. <li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li> <li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> </ol><p>For <code><a href=#the-iframe-element>iframe</a></code> elements in <a href=#xml-documents>XML documents</a>, the attribute, if present, must have a value that matches the production labeled <code><a href=#document>document</a></code> in the XML specification. <a href=#refsXML>[XML]</a></p> <p>If the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute and the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute are both specified together, the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute takes priority. This allows authors to provide a fallback <a href=#url>URL</a> for legacy user agents that do not support the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute.</p> <div class=impl> <p>When an <code><a href=#the-iframe-element>iframe</a></code> element is first <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a document</a>, the user agent must create a <a href=#nested-browsing-context>nested browsing context</a>, and then <a href=#process-the-iframe-attributes>process the <code>iframe</code> attributes</a> for the first time.</p> <p>Whenever an <code><a href=#the-iframe-element>iframe</a></code> element with a <a href=#nested-browsing-context>nested browsing context</a> has its <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute set, changed, or removed, the user agent must <a href=#process-the-iframe-attributes>process the <code>iframe</code> attributes</a>.</p> <p>Similarly, whenever an <code><a href=#the-iframe-element>iframe</a></code> element with a <a href=#nested-browsing-context>nested browsing context</a> but with no <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute specified has its <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute set, changed, or removed, the user agent must <a href=#process-the-iframe-attributes>process the <code>iframe</code> attributes</a>.</p> <!-- It doesn't happen when the base URL is changed, though. --> <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 title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute is specified</dt> <dd><p><a href=#navigate>Navigate</a><!--DONAV iframe--> the element's <a href=#browsing-context>browsing context</a> to a resource whose <a href=#content-type>Content-Type</a> is <code><a href=#text/html>text/html</a></code>, whose <a href=#url>URL</a> is <code><a href=#about:srcdoc>about:srcdoc</a></code>, and whose data consists of the value of the attribute. The resulting <code><a href=#document>Document</a></code> must be considered <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>.</dd> <dt>If the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute is specified but the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute is not</dt> <dd> <ol><li><p>If the value of the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute is the empty string, jump to the <i title="">empty</i> step below.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the value of the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute, relative to the <code><a href=#the-iframe-element>iframe</a></code> element.</li> <li><p>If that is not successful, then jump to the <i title="">empty</i> step below.</li> <li><p>If the resulting <a href=#absolute-url>absolute URL</a> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code><a href=#about:blank>about:blank</a></code>", and the user agent is processing this <code><a href=#the-iframe-element>iframe</a></code>'s attributes for the first time, then jump to the <i title="">empty</i> step below. (In cases other than the first time, <code><a href=#about:blank>about:blank</a></code> is loaded normally.)</li> <li><p><a href=#navigate>Navigate</a><!--DONAV iframe--> the element's <a href=#browsing-context>browsing context</a> to the resulting <a href=#absolute-url>absolute URL</a>.</li> </ol><p><i>Empty</i>: When the steps above require the user agent to jump to the <i title="">empty</i> step, if the user agent is processing this <code><a href=#the-iframe-element>iframe</a></code>'s attributes for the first time, then the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-iframe-element>iframe</a></code> element. (After jumping to this step, the above steps are not resumed.) <span class=note>No <code title=event-load>load</code> event is fired at the <code><a href=#about:blank>about:blank</a></code> document itself.</span></p> </dd> <dt>Otherwise</dt> <dd> <p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-iframe-element>iframe</a></code> element.</p> </dd> </dl><p>Any <a href=#navigate title=navigate>navigation</a> required of the user agent in the <a href=#process-the-iframe-attributes>process the <code>iframe</code> attributes</a> algorithm must be completed with the <code><a href=#the-iframe-element>iframe</a></code> element's document's <a href=#browsing-context>browsing context</a> as the <a href=#source-browsing-context>source browsing context</a>.</p> <p>Furthermore, if the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> contained only one <code><a href=#document>Document</a></code> when the <a href=#process-the-iframe-attributes>process the <code>iframe</code> attributes</a> algorithm was invoked, and that was the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> created when the <a href=#browsing-context>browsing context</a> was created, then any <a href=#navigate title=navigate>navigation</a> required of the user agent in that algorithm must be completed with <a href=#replacement-enabled>replacement enabled</a>.</p> <!-- see also the note near similar text for the location.assign() method --> </div> <p class=note>If, when the element is created, the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute is not set, and the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute is either also not set or set but its value cannot be <a href=#resolve-a-url title="resolve a url">resolved</a>, the browsing context will remain at the initial <code><a href=#about:blank>about:blank</a></code> page.</p> <p class=note>If the user <a href=#navigate title=navigate>navigates</a> away from this page, the <code><a href=#the-iframe-element>iframe</a></code>'s corresponding <code><a href=#windowproxy>WindowProxy</a></code> object will proxy new <code><a href=#window>Window</a></code> objects for new <code><a href=#document>Document</a></code> objects, but the <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute will not change.</p> <div class=impl> <div class=note> <p><a href=#remove-an-element-from-a-document title="remove an element from a document">Removing</a> an <code><a href=#the-iframe-element>iframe</a></code> from a <code><a href=#document>Document</a></code> does not cause its <a href=#browsing-context>browsing context</a> to be discarded. Indeed, an <code><a href=#the-iframe-element>iframe</a></code>'s <a href=#browsing-context>browsing context</a> can survive its original parent <code><a href=#document>Document</a></code> if its <code><a href=#the-iframe-element>iframe</a></code> is moved to another <code><a href=#document>Document</a></code>.</p> <p>On the other hand, if an <code><a href=#the-iframe-element>iframe</a></code> is <a href=#remove-an-element-from-a-document title="remove an element from a document">removed</a> from a <code><a href=#document>Document</a></code> and is then subsequently garbage collected, this will likely mean (in the absence of other references) that the <a href=#child-browsing-context>child browsing context</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object will become eligble for garbage collection, which will then lead to that <a href=#browsing-context>browsing context</a> being <a href=#a-browsing-context-is-discarded title="a browsing context is discarded">discarded</a>, which will then lead to its <code><a href=#document>Document</a></code> being <a href=#discard-a-document title="discard a document">discarded</a> also. This happens without notice to any scripts running in that <code><a href=#document>Document</a></code>; for example, no <code title=event-unload>unload</code> events are fired (the "<a href=#unload-a-document>unload a document</a>" steps are not run).</p> </div> </div> <div class=example> <p>Here a blog uses the <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute in conjunction with the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> and <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code> attributes 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><article> <h1>I got my own magazine!</h1> <p>After much effort, I've finally found a publisher, and so now I have my own magazine! Isn't that awesome?! The first issue will come out in September, and we have articles about getting food, and about getting in boxes, it's going to be great!</p> <footer> <p>Written by <a href="/users/cap">cap</a>, 1 hour ago. </footer> <article> <footer> Thirteen minutes ago, <a href="/users/ch">ch</a> wrote: </footer> <iframe seamless sandbox srcdoc="<p>did you get a cover picture yet?"></iframe> </article> <article> <footer> Nine minutes ago, <a href="/users/cap">cap</a> wrote: </footer> <iframe seamless sandbox srcdoc="<p>Yeah, you can see it <a href=&quot;/gallery?mode=cover&amp;amp;page=1&quot;>in my gallery</a>."></iframe> </article> <article> <footer> Five minutes ago, <a href="/users/ch">ch</a> wrote: </footer> <iframe seamless sandbox srcdoc="<p>hey that's earl's table. <p>you should get earl&amp;amp;me on the next cover."></iframe> </article></pre> <p>Notice the way that quotes have to be escaped (otherwise the <code title=attr-iframe-srcdoc><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 title=attr-iframe-srcdoc><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> </div> <p class=note>In <a href=#syntax>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+0022 QUOTATION MARK (") and U+0026 AMPERSAND (&) characters, and to specify the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute, to ensure safe embedding of content.</p> <p class=note>Due to restrictions of <a href=#the-xhtml-syntax>the XHTML syntax</a>, in XML the U+003C LESS-THAN SIGN character (<) needs to be escaped as well. In order to prevent <a href=http://www.w3.org/TR/REC-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> <hr><p>The <dfn id=attr-iframe-name title=attr-iframe-name><code>name</code></dfn> attribute, if present, must be a <a href=#valid-browsing-context-name>valid browsing context name</a>. The given value is used to name the <a href=#nested-browsing-context>nested browsing context</a>. <span class=impl>When the browsing context is created, if the attribute is present, the <a href=#browsing-context-name>browsing context name</a> must be set to the value of this attribute; otherwise, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</span></p> <div class=impl> <p>Whenever the <code title=attr-iframe-name><a href=#attr-iframe-name>name</a></code> attribute is set, the nested <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-name title="browsing context name">name</a> must be changed to the new value. If the attribute is removed, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</p> <p>When content loads in an <code><a href=#the-iframe-element>iframe</a></code>, after any <code title=event-load>load</code> events are fired within the content itself, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-iframe-element>iframe</a></code> element. When content whose <a href=#url>URL</a> has the <a href=#same-origin>same origin</a> as the <code><a href=#the-iframe-element>iframe</a></code> element's <code><a href=#document>Document</a></code> fails to load (e.g. due to a DNS error, network error, or if the server returned a 4xx or 5xx status code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>), then the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the element instead. (This event does not fire for <a href=#parse-error title="parse error">parse errors</a>, script errors, or any errors for cross-origin resources.)</p> <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p class=note>A <code title=event-load>load</code> event is also fired at the <code><a href=#the-iframe-element>iframe</a></code> element when it is created if no other data is loaded in it.</p> <p>When there is an <a href=#active-parser>active parser</a> in the <code><a href=#the-iframe-element>iframe</a></code>, and when anything in the <code><a href=#the-iframe-element>iframe</a></code> is <a href=#delay-the-load-event title="delay the load event">delaying the load event</a> of the <code><a href=#the-iframe-element>iframe</a></code>'s <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>, the <code><a href=#the-iframe-element>iframe</a></code> must <a href=#delay-the-load-event>delay the load event</a> of its document.</p> <p class=note>If, during the handling of the <code title=event-load>load</code> event, the <a href=#browsing-context>browsing context</a> in the <code><a href=#the-iframe-element>iframe</a></code> is again <a href=#navigate title=navigate>navigated</a>, that will further <a href=#delay-the-load-event>delay the load event</a>.</p> </div> <hr><p>The <dfn id=attr-iframe-sandbox title=attr-iframe-sandbox><code>sandbox</code></dfn> attribute, when specified, enables a set of extra restrictions on any content hosted by the <code><a href=#the-iframe-element>iframe</a></code>. Its value must be an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of unique space-separated tokens</a> that are <a href=#ascii-case-insensitive>ASCII case-insensitive</a>. The allowed values are <code title=attr-iframe-sandbox-allow-forms><a href=#attr-iframe-sandbox-allow-forms>allow-forms</a></code>, <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code>, <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code>, and <code title=attr-iframe-sandbox-allow-top-navigation><a href=#attr-iframe-sandbox-allow-top-navigation>allow-top-navigation</a></code>. When the attribute is set, the content is treated as being from a unique <a href=#origin>origin</a>, forms and scripts are disabled, links are prevented from targeting other <a href=#browsing-context title="browsing context">browsing contexts</a>, and plugins are secured. The <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code> keyword allows the content to be treated as being from the same origin instead of forcing it into a unique origin, the <code title=attr-iframe-sandbox-allow-top-navigation><a href=#attr-iframe-sandbox-allow-top-navigation>allow-top-navigation</a></code> keyword allows the content to <a href=#navigate>navigate</a> its <a href=#top-level-browsing-context>top-level browsing context</a>, and the <code title=attr-iframe-sandbox-allow-forms><a href=#attr-iframe-sandbox-allow-forms>allow-forms</a></code> and <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> keywords re-enable forms and scripts respectively (though scripts are still prevented from creating popups).</p> <p class=warning>Setting both the <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> and <code title=attr-iframe-sandbox-allow-same-origin><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>same origin</a> as the page containing the <code><a href=#the-iframe-element>iframe</a></code> allows the embedded page to simply remove the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute.</p> <p class=warning>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><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.</p> <div class=impl> <!-- v2: Add a new attribute that enables new restrictions, e.g.: - disallow cross-origin loads of any kind (networking override that only allows same-origin URLs or about:, javascript:, data:) - block access to 'parent.frames' from sandbox --> <p>While the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute is specified, the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context>nested browsing context</a> must have the flags given in the following list set. In addition, any browsing contexts <a href=#nested-browsing-context title="nested browsing context">nested</a> within an <code><a href=#the-iframe-element>iframe</a></code>, either directly or indirectly, must have all the flags set on them as were set on the <code><a href=#the-iframe-element>iframe</a></code>'s <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> when the <code><a href=#the-iframe-element>iframe</a></code>'s <code><a href=#document>Document</a></code> was created.</p> <dl><dt>The <dfn id=sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</dfn></dt> <dd> <p>This flag <a href=#sandboxLinks>prevents content from navigating browsing contexts other than the sandboxed browsing context itself</a> (or browsing contexts further nested inside it), and the <a href=#top-level-browsing-context>top-level browsing context</a> (which is protected by the <a href=#sandboxed-top-level-navigation-browsing-context-flag>sandboxed top-level navigation browsing context flag</a> defined next).</p> <p>This flag also <a href=#sandboxWindowOpen>prevents content from creating new auxiliary browsing contexts</a>, e.g. using the <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute, the <code title=dom-open><a href=#dom-open>window.open()</a></code> method, or the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method.</p> </dd> <dt>The <dfn id=sandboxed-top-level-navigation-browsing-context-flag>sandboxed top-level navigation browsing context flag</dfn>, unless the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute's value, when <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>, is found to have the <dfn id=attr-iframe-sandbox-allow-top-navigation title=attr-iframe-sandbox-allow-top-navigation><code>allow-top-navigation</code></dfn> keyword set</dt> <dd> <p>This flag <a href=#sandboxLinks>prevents content from navigating their <span>top-level browsing context</span></a>.</p> <p>When the <code title=attr-iframe-sandbox-allow-top-navigation><a href=#attr-iframe-sandbox-allow-top-navigation>allow-top-navigation</a></code> is set, content can navigate its <a href=#top-level-browsing-context>top-level browsing context</a>, but other <a href=#browsing-context title="browsing context">browsing contexts</a> are still protected by the <a href=#sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> defined above.</p> </dd> <dt>The <dfn id=sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</dfn></dt> <dd> <p>This flag prevents content from instantiating <a href=#plugin title=plugin>plugins</a>, whether using <a href=#sandboxPluginEmbed>the <code>embed</code> element</a>, <a href=#sandboxPluginObject>the <code>object</code> element</a>, <a href=#sandboxPluginApplet>the <code>applet</code> element</a>, or through <a href=#sandboxPluginNavigate>navigation</a> of a <a href=#nested-browsing-context>nested browsing context</a>, unless those <a href=#plugin title=plugin>plugins</a> can be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a>.</p> </dd> <dt>The <dfn id=sandboxed-seamless-iframes-flag>sandboxed seamless iframes flag</dfn></dt> <dd> <p>This flag prevents content from using the <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code> attribute on descendant <code><a href=#the-iframe-element>iframe</a></code> elements.</p> <p class=note>This prevents a page inserted using the <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code> keyword from using a CSS-selector-based method of probing the DOM of other pages on the same site (in particular, pages that contain user-sensitive information).</p> <!-- http://lists.w3.org/Archives/Public/public-web-security/2009Dec/thread.html#msg51 --> </dd> <dt>The <dfn id=sandboxed-origin-browsing-context-flag>sandboxed origin browsing context flag</dfn>, unless the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute's value, when <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>, is found to have the <dfn id=attr-iframe-sandbox-allow-same-origin title=attr-iframe-sandbox-allow-same-origin><code>allow-same-origin</code></dfn> keyword set</dt> <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=#origin>origin</a>.</p> <p>This flag also <a href=#sandboxCookies>prevents script from reading from or writing to the <code title=dom-document-cookie>document.cookie</code> IDL attribute</a>, and blocks access to <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code>. </p> <div class=note> <p>The <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code> attribute 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 popup windows, etc, without preventing the embedded page from communicating back to its originating site, using the database APIs to store data, etc.</p> </div> </dd> <dt>The <dfn id=sandboxed-forms-browsing-context-flag>sandboxed forms browsing context flag</dfn>, unless the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute's value, when <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>, is found to have the <dfn id=attr-iframe-sandbox-allow-forms title=attr-iframe-sandbox-allow-forms><code>allow-forms</code></dfn> keyword set</dt> <dd> <p>This flag <a href=#sandboxSubmitBlocked>blocks form submission</a>.</p> </dd> <dt>The <dfn id=sandboxed-scripts-browsing-context-flag>sandboxed scripts browsing context flag</dfn>, unless the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute's value, when <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>, is found to have the <dfn id=attr-iframe-sandbox-allow-scripts title=attr-iframe-sandbox-allow-scripts><code>allow-scripts</code></dfn> keyword set</dt> <dd> <p>This flag <a href=#sandboxScriptBlocked>blocks script execution</a>.</p> </dd> <dt>The <dfn id=sandboxed-automatic-features-browsing-context-flag>sandboxed automatic features browsing context flag</dfn>, unless the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute's value, when <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>, is found to have the <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> keyword (defined above) set</dt> <dd> <p>This flag blocks features that trigger automatically, such as <a href=#attr-media-autoplay title=attr-media-autoplay>automatically playing a video</a> or <a href=#attr-fe-autofocus title=attr-fe-autofocus>automatically focusing a form control</a>. It is relaxed by the same flag 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> </dd> </dl><p>These flags must not be set unless the conditions listed above define them as being set.</p> <p class=warning>These flags only take effect when the <a href=#nested-browsing-context>nested browsing context</a> of the <code><a href=#the-iframe-element>iframe</a></code> is <a href=#navigate title=navigate>navigated</a>. Removing them, or removing the entire <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute, has no effect on an already-loaded page.</p> </div> <div class=example> <p>In this example, some completely-unknown, potentially hostile, user-provided HTML content is embedded in a page. Because it is served from a separate domain, it is affected by all the normal cross-site restrictions. In addition, the embedded page has scripting disabled, plugins disabled, forms disabled, and it cannot navigate any frames or windows other than itself (or any frames or windows it itself embeds).</p> <pre><p>We're not scared of you! Here is your content, unedited:</p> <iframe sandbox src="http://usercontent.example.net/getusercontent.cgi?id=12193"></iframe></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><iframe sandbox="allow-same-origin allow-forms allow-scripts" src="http://maps.example.com/embedded.html"></iframe></pre> </div> <div class=example> <p>Suppose a file A contained the following fragment:</p> <pre><iframe sandbox="allow-same-origin allow-forms" src=B></iframe></pre> <p>Suppose that file B contained an iframe also:</p> <pre><iframe sandbox="allow-scripts" src=C></iframe></pre> <p>Further, suppose that file C contained a link:</p> <pre><a href=D>Link</a></pre> <p>For this example, suppose all the files were served as <code><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><a href=#the-iframe-element>iframe</a></code> in A has scripts disabled, and this overrides the <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> keyword set on the <code><a href=#the-iframe-element>iframe</a></code> in B. Forms are also disabled, because the inner <code><a href=#the-iframe-element>iframe</a></code> (in B) does not have the <code title=attr-iframe-sandbox-allow-forms><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 title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attributes in A <!--grammar-check-override--> and B. This would change nothing immediately. If the user clicked the link in C, loading page D into the <code><a href=#the-iframe-element>iframe</a></code> in B, page D would now act as if the <code><a href=#the-iframe-element>iframe</a></code> in B had the <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code> and <code title=attr-iframe-sandbox-allow-forms><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>nested browsing context</a> in the <code><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 title=attr-iframe-sandbox><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> <p class=note>Potentially hostile files should not be served from the same server as the file containing the <code><a href=#the-iframe-element>iframe</a></code> element. 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 title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute.</p> <p class=warning>If the <code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> keyword is set along with <code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code> keyword, and the file is from the <a href=#same-origin>same origin</a> as the <code><a href=#the-iframe-element>iframe</a></code>'s <code><a href=#document>Document</a></code>, then a script in the "sandboxed" iframe could just reach out, remove the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute, and then reload itself, effectively breaking out of the sandbox altogether.</p> <hr><!-- v2: Might be interesting to have a value on seamless that allowed event propagation of some sort, maybe based on the WICD work: http://www.w3.org/TR/WICD/ --><p>The <dfn id=attr-iframe-seamless title=attr-iframe-seamless><code>seamless</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When specified, it indicates that the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#browsing-context>browsing context</a> is to be rendered in a manner that makes it appear to be part of the containing document (seamlessly included in the parent document). <span class=impl>Specifically, when the attribute is set on an <code><a href=#the-iframe-element>iframe</a></code> element whose owner <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-seamless-iframes-flag>sandboxed seamless iframes flag</a> set when that <code><a href=#document>Document</a></code> was created, and while either the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> has the <a href=#same-origin>same origin</a> as the <code><a href=#the-iframe-element>iframe</a></code> element's document, or the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>'s <em><a href="#the-document's-address" title="the document's address">address</a></em> has the <a href=#same-origin>same origin</a> as the <code><a href=#the-iframe-element>iframe</a></code> element's document, or the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, the following requirements apply:</span></p> <div class=impl> <ul><li><p>The user agent must set the <dfn id=seamless-browsing-context-flag>seamless browsing context flag</dfn> to true for that <a href=#browsing-context>browsing context</a>. This will <a href=#seamlessLinks>cause links to open in the parent browsing context</a> unless an <a href=#explicit-self-navigation-override>explicit self-navigation override</a> is used (<code title="">target="_self"</code>).</li> <li><p>In a CSS-supporting user agent: the user agent must add all the style sheets that apply to the <code><a href=#the-iframe-element>iframe</a></code> element to the cascade of the <a href=#active-document>active document</a> of the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>, at the appropriate cascade levels, before any style sheets specified by the document itself.</li> <li><p>In a CSS-supporting user agent: the user agent must, for the purpose of CSS property inheritance only, treat the root element of the <a href=#active-document>active document</a> of the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context>nested browsing context</a> as being a child of the <code><a href=#the-iframe-element>iframe</a></code> element. (Thus inherited properties on the root element of the document in the <code><a href=#the-iframe-element>iframe</a></code> will inherit the computed values of those properties on the <code><a href=#the-iframe-element>iframe</a></code> element instead of taking their initial values.)</li> <li><p>In visual media, in a CSS-supporting user agent: the user agent should set the intrinsic width of the <code><a href=#the-iframe-element>iframe</a></code> to the width that the element would have if it was a non-replaced block-level element with 'width: auto'.</li> <li><p>In visual media, in a CSS-supporting user agent: the user agent should set the intrinsic height of the <code><a href=#the-iframe-element>iframe</a></code> to the height of the bounding box around the content rendered in the <code><a href=#the-iframe-element>iframe</a></code> at its current width (as given in the previous bullet point), as it would be if the scrolling position was such that the top of the viewport for the content rendered in the <code><a href=#the-iframe-element>iframe</a></code> was aligned with the origin of that content's canvas.</li> <li> <p>In visual media, in a CSS-supporting user agent: the user agent must force the height of the initial containing block of the <a href=#active-document>active document</a> of the <a href=#nested-browsing-context>nested browsing context</a> of the <code><a href=#the-iframe-element>iframe</a></code> to zero.</p> <p class=note>This is intended to get around the otherwise circular dependency of percentage dimensions that depend on the height of the containing block, thus affecting the height of the document's bounding box, thus affecting the height of the viewport, thus affecting the size of the initial containing block.</p> </li> <li><p>In speech media, the user agent should render the <a href=#nested-browsing-context>nested browsing context</a> without announcing that it is a separate document.</li> <li> <p>User agents should, in general, act as if the <a href=#active-document>active document</a> of the <code><a href=#the-iframe-element>iframe</a></code>'s <a href=#nested-browsing-context>nested browsing context</a> was part of the document that the <code><a href=#the-iframe-element>iframe</a></code> is in, if any.</p> <p class=example>For example if the user agent supports listing all the links in a document, links in "seamlessly" nested documents would be included in that list without being significantly distinguished from links in the document itself.</p> </li> </ul><p>If the attribute is not specified, or if the <a href=#origin>origin</a> conditions listed above are not met, then the user agent should render the <a href=#nested-browsing-context>nested browsing context</a> in a manner that is clearly distinguishable as a separate <a href=#browsing-context>browsing context</a>, and the <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> must be set to false for that <a href=#browsing-context>browsing context</a>.</p> <p class=warning>It is important that user agents recheck the above conditions whenever the <a href=#active-document>active document</a> of the <a href=#nested-browsing-context>nested browsing context</a> of the <code><a href=#the-iframe-element>iframe</a></code> changes, such that the <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> gets unset if the <a href=#nested-browsing-context>nested browsing context</a> is <a href=#navigate title=navigate>navigated</a> to another origin.</p> </div> <p class=note>The attribute can be set or removed dynamically, with the rendering updating in tandem.</p> <div class=example> <p>In this example, the site's navigation is embedded using a client-side include using an <code><a href=#the-iframe-element>iframe</a></code>. Any links in the <code><a href=#the-iframe-element>iframe</a></code> will, in new user agents, be automatically opened in the <code><a href=#the-iframe-element>iframe</a></code>'s parent browsing context; for legacy user agents, the site could also include a <code><a href=#the-base-element>base</a></code> element with a <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute with the value <code title="">_parent</code>. Similarly, in new user agents the styles of the parent page will be automatically applied to the contents of the frame, but to support legacy user agents authors might wish to include the styles explicitly.</p> <pre><nav><iframe seamless src="nav.include.html"></iframe></nav></pre> </div> <hr><p>The <code><a href=#the-iframe-element>iframe</a></code> element supports <a href=#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><a href=#the-iframe-element>iframe</a></code> element never has <a href=#fallback-content>fallback content</a>, as it will always create a nested <a href=#browsing-context>browsing context</a>, regardless of whether the specified initial contents are successfully used.</p> <p>Descendants of <code><a href=#the-iframe-element>iframe</a></code> elements represent nothing. (In legacy user agents that do not support <code><a href=#the-iframe-element>iframe</a></code> elements, the contents would be parsed as markup that could act as fallback content.)</p> <p id=iframe-content-model>When used in <a href=#html-documents>HTML documents</a>, the allowed content model of <code><a href=#the-iframe-element>iframe</a></code> elements is text, except that invoking the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a> with the <code><a href=#the-iframe-element>iframe</a></code> element as the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element and the text contents as the <var title="">input</var> must result in a list of nodes that are all <a href=#phrasing-content>phrasing content</a>, with no <a href=#parse-error title="parse error">parse errors</a> having occurred, with no <code><a href=#the-script-element>script</a></code> elements being anywhere in the list or as descendants of elements in the list, and with all the elements in the list (including their descendants) being themselves conforming.</p> <p>The <code><a href=#the-iframe-element>iframe</a></code> element must be empty in <a href=#xml-documents>XML documents</a>.</p> <p class=note>The <a href=#html-parser>HTML parser</a> treats markup inside <code><a href=#the-iframe-element>iframe</a></code> elements as text.</p> <div class=impl> <p>The IDL attributes <dfn id=dom-iframe-src title=dom-iframe-src><code>src</code></dfn>, <dfn id=dom-iframe-srcdoc title=dom-iframe-srcdoc><code>srcdoc</code></dfn>, <dfn id=dom-iframe-name title=dom-iframe-name><code>name</code></dfn>, <dfn id=dom-iframe-sandbox title=dom-iframe-sandbox><code>sandbox</code></dfn>, and <dfn id=dom-iframe-seamless title=dom-iframe-seamless><code>seamless</code></dfn> must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-iframe-contentdocument title=dom-iframe-contentDocument><code>contentDocument</code></dfn> IDL attribute must return the <code><a href=#document>Document</a></code> object of the <a href=#active-document>active document</a> of the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>The <dfn id=dom-iframe-contentwindow title=dom-iframe-contentWindow><code>contentWindow</code></dfn> IDL attribute must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <code><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>.</p> </div> <div class=example> <p>Here is an example of a page using an <code><a href=#the-iframe-element>iframe</a></code> to include advertising from an advertising broker:</p> <pre><iframe src="http://ads.example.com/?customerid=923513721&amp;format=banner" width="468" height="60"></iframe></pre> </div> <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</code></dfn> element</h4> <!-- (v2?) we have all kinds of quirks we should define if they come up during testing, as e.g. shown in: http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsObjectFrame.cpp http://trac.webkit.org/browser/trunk/WebCore/html/HTMLEmbedElement.cpp http://trac.webkit.org/browser/trunk/WebCore/rendering/RenderPartObject.cpp (updateWidget) e.g. - 240x200 default - the attributes/params are sent in a name-value pair list as follows (for Gecko): + attributes of the element, in source order + a synthesised 'src' attribute, if there was no 'src' but there was a 'data', with the value of the 'data' attribute + the params, in source order (WebKit does something different still) - the HIDDEN attribute (might be moot now) --> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-embed-src><a href=#attr-embed-src>src</a></code></dd> <dd><code title=attr-embed-type><a href=#attr-embed-type>type</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dd>Any other attribute that has no namespace (see prose).</dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlembedelement>HTMLEmbedElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-embed-src title=dom-embed-src>src</a>; attribute DOMString <a href=#dom-embed-type title=dom-embed-type>type</a>; attribute DOMString <a href=#dom-dim-width title=dom-dim-width>width</a>; attribute DOMString <a href=#dom-dim-height title=dom-dim-height>height</a>; };</pre> <div class=impl> <p>Depending on the type of content instantiated by the <code><a href=#the-embed-element>embed</a></code> element, the node may also support other interfaces.</p> </div> </dd> </dl><p>The <code><a href=#the-embed-element>embed</a></code> element <a href=#represents>represents</a> an integration point for an external (typically non-HTML) application or interactive content.</p> <p>The <dfn id=attr-embed-src title=attr-embed-src><code>src</code></dfn> attribute gives the address of the resource being embedded. The attribute, if present, must contain a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by spaces</a>.</p> <p>The <dfn id=attr-embed-type title=attr-embed-type><code>type</code></dfn> attribute, if present, gives the <a href=#mime-type>MIME type</a> by which the plugin to instantiate is selected. The value must be a <a href=#valid-mime-type>valid MIME type</a>. If both the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute and the <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute are present, then the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute must specify the same type as the <a href=#content-type title=Content-Type>explicit Content-Type metadata</a> of the resource given by the <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute.</p> <div class=impl> <p>When the element is created with neither a <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute nor a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute, and when attributes are removed such that neither attribute is present on the element anymore, and when the element has a <a href=#media-element>media element</a> ancestor, and when the element has an ancestor <code><a href=#the-object-element>object</a></code> element that is <em>not</em> showing its <a href=#fallback-content>fallback content</a>, any plugins instantiated for the element must be removed, and the <code><a href=#the-embed-element>embed</a></code> element represents nothing.</p> <p>An <code><a href=#the-embed-element>embed</a></code> element is said to be <dfn id=concept-embed-active title=concept-embed-active>potentially active</dfn> when the following conditions are all met simultaneously:</p> <ul class=brief><li>The element is <a href=#in-a-document title="in a document">in a <code>Document</code></a>.</li> <li>The element's <code><a href=#document>Document</a></code> is <a href=#fully-active>fully active</a>.</li> <li>The element has either a <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute set or a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute set (or both).</li> <li>The element's <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute is either absent or its value is the empty string.</li> <li>The element is not a descendant of a <a href=#media-element>media element</a>.</li> <li>The element is not a descendant of an <code><a href=#the-object-element>object</a></code> element that is not showing its <a href=#fallback-content>fallback content</a>.</li> </ul><p>Whenever an <code><a href=#the-embed-element>embed</a></code> element that was not <a href=#concept-embed-active title=concept-embed-active>potentially active</a> becomes <a href=#concept-embed-active title=concept-embed-active>potentially active</a>, and whenever a <a href=#concept-embed-active title=concept-embed-active>potentially active</a> <code><a href=#the-embed-element>embed</a></code> element's <code title=attr-embed-type><a href=#attr-embed-type>src</a></code> attribute is set, changed, or removed, and whenever a <a href=#concept-embed-active title=concept-embed-active>potentially active</a> <code><a href=#the-embed-element>embed</a></code> element's <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute is set, changed, or removed, the appropriate set of steps from the following is then applied:</p> <dl class=switch><dt>If the element has a <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute set</dt> <dd> <p>The user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of the element's <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute, relative to the element. If that is successful, the user agent should <a href=#fetch>fetch</a> the resulting <a href=#absolute-url>absolute URL</a>, from the element's <a href=#browsing-context-scope-origin>browsing context scope origin</a> if it has one<!-- potentially http-origin privacy sensitive -->. The <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> must find and instantiate an appropriate <a href=#plugin>plugin</a> based on the <a href=#concept-embed-type title=concept-embed-type>content's type</a>, and hand that <a href=#plugin>plugin</a> the content of the resource, replacing any previously instantiated plugin for the element.</p> <!-- Note that this doesn't happen when the base URL changes. --> <p>Fetching the resource must <a href=#delay-the-load-event>delay the load event</a> of the element's document.</p> <!-- if we add load/error events, then replace the previous paragraph with the text one: --> <!-- similar text in various places --> <!--<p>Fetching the resource must <span>delay the load event</span> of the element's document until the final <span title="concept-task">task</span> that is <span title="queue a task">queued</span> by the <span>networking task source</span> once the resource has been <span title="fetch">fetched</span> has been run.</p>--> </dd> <dt>If the element has no <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute set</dt> <dd><p>The user agent should find and instantiate an appropriate <a href=#plugin>plugin</a> based on the value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute.</p> </dl><p>Whenever an <code><a href=#the-embed-element>embed</a></code> element that was <a href=#concept-embed-active title=concept-embed-active>potentially active</a> stops being <a href=#concept-embed-active title=concept-embed-active>potentially active</a>, any <a href=#plugin>plugin</a> that had been instantiated for that element must be unloaded.</p> <p id=sandboxPluginEmbed>When a <a href=#plugin>plugin</a> is to be instantiated but it cannot be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a> and the <a href=#sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> was set on the <a href=#browsing-context>browsing context</a> for which the <code><a href=#the-embed-element>embed</a></code> element's <code><a href=#document>Document</a></code> is the <a href=#active-document>active document</a> when that <code><a href=#document>Document</a></code> was created, then the user agent must not instantiate the <a href=#plugin>plugin</a>, and must instead render the <code><a href=#the-embed-element>embed</a></code> element in a manner that conveys that the <a href=#plugin>plugin</a> was disabled. The user agent may offer the user the option to override the sandbox and instantiate the <a href=#plugin>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 title=concept-plugin-secure>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 class=note>The <code><a href=#the-embed-element>embed</a></code> element is unaffected by the CSS 'display' property. The selected plugin is instantiated even if the element is hidden with a 'display:none' CSS style.</p> <p>The <dfn id=concept-embed-type title=concept-embed-type>type of the content</dfn> being embedded is defined as follows:</p> <ol><li><p>If the element has a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute, and that attribute's value is a type that a <a href=#plugin>plugin</a> supports, then the value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute is the <a href=#concept-embed-type title=concept-embed-type>content's type</a>.</li> <li> <!-- if we get to this point we know we can successfully parsed the URL, since this algorithm is only used after fetching the resource in the steps above --> <p>Otherwise, if the <a href=#url-path title=url-path><path></a> component of the <a href=#url>URL</a> of the specified resource (after any redirects) matches a pattern that a <a href=#plugin>plugin</a> supports, then the <a href=#concept-embed-type title=concept-embed-type>content's type</a> is 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=#url-path title=url-path><path></a> components that end with the four character string "<code title="">.swf</code>".</p> <!-- it's sad that we have to do extension sniffing. sigh. --> <!-- see also <object> which has a similar step --> </li> <li><p>Otherwise, if the specified resource has <a href=#content-type title=Content-Type>explicit Content-Type metadata</a>, then that is the <a href=#concept-embed-type title=concept-embed-type>content's type</a>.</li> <li><p>Otherwise, the content has no type and there can be no appropriate <a href=#plugin>plugin</a> for it.</li> <!-- This algorithm is a monument to bad design. Go legacy! --> </ol><p>The <code><a href=#the-embed-element>embed</a></code> element has no <a href=#fallback-content>fallback content</a>. If the user agent can't find a suitable plugin, then the user agent must use a default plugin. (This default could be as simple as saying "Unsupported Format".)</p> <p>Whether the resource is fetched successfully or not (e.g. whether the response code was a 2xx code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>) must be ignored when determining the resource's type and when handing the resource to the plugin.</p> <p class=note>This allows servers to return data for plugins even with error responses (e.g. HTTP 500 Internal Server Error codes can still contain plugin data).</p> </div> <p>Any namespace-less attribute other than <code title=attr-embed-name><a href=#attr-embed-name>name</a></code>, <code title=attr-embed-align><a href=#attr-embed-align>align</a></code>, <code title=attr-embed-hspace><a href=#attr-embed-hspace>hspace</a></code>, and <code title=attr-embed-vspace><a href=#attr-embed-vspace>vspace</a></code> <!-- when editing, see also note below --> may be specified on the <code><a href=#the-embed-element>embed</a></code> element, so long as its name is <a href=#xml-compatible>XML-compatible</a> and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z). These attributes are then passed as parameters to the <a href=#plugin>plugin</a>.</p> <p class=note>All attributes in <a href=#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>plugin</a>.</p> <div class=impl> <p>The user agent should pass the names and values of all the attributes of the <code><a href=#the-embed-element>embed</a></code> element that have no namespace to the <a href=#plugin>plugin</a> used, when it is instantiated.</p> <p>If the <a href=#plugin>plugin</a> instantiated for the <code><a href=#the-embed-element>embed</a></code> element supports a scriptable interface, the <code><a href=#htmlembedelement>HTMLEmbedElement</a></code> object representing the element should expose that interface while the element is instantiated.</p> </div> <p>The <code><a href=#the-embed-element>embed</a></code> element supports <a href=#dimension-attributes>dimension attributes</a>.</p> <div class=impl> <p>The IDL attributes <dfn id=dom-embed-src title=dom-embed-src><code>src</code></dfn> and <dfn id=dom-embed-type title=dom-embed-type><code>type</code></dfn> each must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <div class=example> <p>Here's a way to embed a resource that requires a proprietary plugin, like Flash:</p> <pre><embed src="catgame.swf"></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><embed src="catgame.swf" quality="high"></pre> <p>This would be equivalent to the following, when using an <code><a href=#the-object-element>object</a></code> element instead:</p> <pre><object data="catgame.swf"> <param name="quality" value="high"> </object></pre> </div> <h4 id=the-object-element><span class=secno>4.8.4 </span>The <dfn><code>object</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd>If the element has a <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute: <a href=#interactive-content>Interactive content</a>.</dd> <!-- also when showing a plugin or a nested browsing context, but checking that statically is hard...) --> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-submit title=category-submit>submittable</a>, <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-param-element>param</a></code> elements, then, <a href=#transparent>transparent</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-object-data><a href=#attr-object-data>data</a></code></dd> <dd><code title=attr-object-type><a href=#attr-object-type>type</a></code></dd> <dd><code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code></dd> <dd><code title=attr-object-name><a href=#attr-object-name>name</a></code></dd> <dd><code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlobjectelement>HTMLObjectElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-object-data title=dom-object-data>data</a>; attribute DOMString <a href=#dom-object-type title=dom-object-type>type</a>; attribute boolean <a href=#dom-object-typemustmatch title=dom-object-typeMustMatch>typeMustMatch</a>; attribute DOMString <a href=#dom-object-name title=dom-object-name>name</a>; attribute DOMString <a href=#dom-object-usemap title=dom-object-useMap>useMap</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-dim-width title=dom-dim-width>width</a>; attribute DOMString <a href=#dom-dim-height title=dom-dim-height>height</a>; readonly attribute Document? <a href=#dom-object-contentdocument title=dom-object-contentDocument>contentDocument</a>; readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-object-contentwindow title=dom-object-contentWindow>contentWindow</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); };</pre> <div class=impl> <p>Depending on the type of content instantiated by the <code><a href=#the-object-element>object</a></code> element, the node also supports other interfaces.</p> </div> </dd> </dl><p>The <code><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>nested browsing context</a>, or as an external resource to be processed by a <a href=#plugin>plugin</a>.</p> <p>The <dfn id=attr-object-data title=attr-object-data><code>data</code></dfn> attribute, if present, specifies the address of the resource. If present, the attribute must be a <a href=#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=#origin title=origin>origins</a> that they do not trust are urged to use the <code title=attr-object-typemustmatch><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> <!-- for example, if the user doesn't have flash installed but does have java installed, and the remote site unexpectedly returns java instead of flash, then java will run, and it will ignore the allowScriptAccess thing --> <p>The <dfn id=attr-object-type title=attr-object-type><code>type</code></dfn> attribute, if present, specifies the type of the resource. If present, the attribute must be a <a href=#valid-mime-type>valid MIME type</a>.</p> <p>At least one of either the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute or the <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute must be present.</p> <p>The <dfn id=attr-object-typemustmatch title=attr-object-typemustmatch><code>typemustmatch</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> whose presence indicates that the resource specified by the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute is only to be used if the value of the <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute and the <a href=#content-type>Content-Type</a> of the aforementioned resource match.</p> <p>The <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute must not be specified unless both the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute and the <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute are present.</p> <p>The <dfn id=attr-object-name title=attr-object-name><code>name</code></dfn> attribute, if present, must be a <a href=#valid-browsing-context-name>valid browsing context name</a>. The given value is used to name the <a href=#nested-browsing-context>nested browsing context</a>, if applicable.</p> <div class=impl> <p>When the element is created, when it is popped off the <a href=#stack-of-open-elements>stack of open elements</a> of an <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a>, and subsequently whenever the element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a document</a> or <a href=#remove-an-element-from-a-document title="remove an element from a document">removed from a document</a>; and whenever the element's <code><a href=#document>Document</a></code> changes whether it is <a href=#fully-active>fully active</a>; and whenever an ancestor <code><a href=#the-object-element>object</a></code> element changes to or from showing its <a href=#fallback-content>fallback content</a>; and whenever the element's <code title=attr-object-classid><a href=#attr-object-classid>classid</a></code> attribute is set, changed, or removed; and, when its <code title=attr-object-classid><a href=#attr-object-classid>classid</a></code> attribute is not present, whenever its <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute is set, changed, or removed; and, when neither its <code title=attr-object-classid><a href=#attr-object-classid>classid</a></code> attribute nor its <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute are present, whenever its <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute is set, changed, or removed: the user agent must <a href=#queue-a-task>queue a task</a> to run the following steps to (re)determine what the <code><a href=#the-object-element>object</a></code> element represents. The <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <!-- Changing the base URL doesn't trigger this. --> <ol><li> <p>If the user has indicated a preference that this <code><a href=#the-object-element>object</a></code> element's <a href=#fallback-content>fallback content</a> be shown instead of the element's usual behavior, then jump to the last step in the overall set of steps (fallback).</p> <p class=note>For example, a user could ask for the element's <a href=#fallback-content>fallback content</a> to be shown because that content uses a format that the user finds more accessible.</p> </li> <li> <p>If the element has an ancestor <a href=#media-element>media element</a>, or has an ancestor <code><a href=#the-object-element>object</a></code> element that is <em>not</em> showing its <a href=#fallback-content>fallback content</a>, or if the element is not <a href=#in-a-document title="in a document">in a <code>Document</code></a> with a <a href=#browsing-context>browsing context</a>, or if the element's <code><a href=#document>Document</a></code> is not <a href=#fully-active>fully active</a>, or if the element is still in the <a href=#stack-of-open-elements>stack of open elements</a> of an <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a>, then jump to the last step in the overall set of steps (fallback).</p> </li> <li> <!-- what if it's not in the document? if that should prevent plugin instantiation, then here just skip to the last step --> <p>If the <code title=attr-object-classid><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>plugin</a> suitable according to the value of the <code title=attr-object-classid><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>plugin</a> can be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a>, then that <a href=#plugin>plugin</a> <a href=#object-plugin>should be used</a>, and the value of the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute, if any, should be passed to the <a href=#plugin>plugin</a>. If no suitable <a href=#plugin>plugin</a> can be found, or if the <a href=#plugin>plugin</a> reports an error, jump to the last step in the overall set of steps (fallback).</p> <!-- case insensitive: is "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" -> application/x-shockwave-flash is "clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" -> audio/x-pn-realaudio-plugin is "clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" -> video/quicktime is "clsid:166b1bca-3f9c-11cf-8075-444553540000" -> application/x-director is "clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" -> application/x-mplayer2 starts with "java:" -> application/x-java-vm starts with "clsid:" -> application/x-oleobject --> </li> <!-- (v2?) we may have to define magic fallback to <param> if it turns out to be needed in testing: <hyatt> apparently your url can come from <param> <hyatt> not just the data attribute <hyatt> our code looks for params with "src", "movie", "code" and "url" <hyatt> and also tries to find the type on a param <Hixie> oh that's you trying to have hacky activex support <Hixie> opera does that too <hyatt> yeah we support activex versions of plugins that are common <hyatt> like flash and quicktime and realaudio <Hixie> that would be a step 1b. if no data attribute, then look for a <param> to get you a URL instead. <Hixie> and if you find one, carry on as if that was your data="". --> <li><p>If the <code title=attr-object-data><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 title=attr-object-type><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>plugin</a> for, then the user agent may jump to the last step in the overall set of steps (fallback) without fetching the content to examine its real type.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <a href=#url>URL</a> specified by the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute, relative to the element.</li> <li><p>If that failed, <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the element, then jump to the last step in the overall set of steps (fallback).</li> <li> <p><a href=#fetch>Fetch</a> the resulting <a href=#absolute-url>absolute URL</a>, from the element's <a href=#browsing-context-scope-origin>browsing context scope origin</a> if it has one<!-- potentially http-origin privacy sensitive -->.</p> <!-- similar text in various places --> <p>Fetching the resource must <a href=#delay-the-load-event>delay the load event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> (defined next) has been run.</p> <p>For the purposes of the <a href=#application-cache>application cache</a> networking model, this <a href=#fetch>fetch</a> operation is not for a <a href=#child-browsing-context>child browsing context</a> (though it might end up being used for one after all, as defined below).</p> </li> <li><p>If the resource is not yet available (e.g. because the resource was not available in the cache, so that loading the resource required making a request over the network), then jump to the last step in the overall set of steps (fallback). The <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>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> <li><p>If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the element, then jump to the last step in the overall set of steps (fallback).</li> <li id=object-type-detection> <p>Determine the <var title="">resource type</var>, as follows:</p> <!-- Hopefully this step is exactly equivalent to the following: START | V Is there a Content-Type and is the UA going to obey it blindly? | | | YES | NO | V YES | Is there a type="" attribute whose value is a plugin type? ============================================-. | | | | | NO | | V NO YES | | Is there a Content type? ========-> Is there a type="" attribute? ==========> Let TYPE be type="" | | | | attribute value | | | YES | NO | | V NO V | V | +-<============== Is it text/plain or application/octet-stream? `==> Let TYPE be =====>+ | | | | Sniffed type | | | | text/plain | octet-stream V | | V YES V Is TYPE | | Does the page sniff as binary? ======> Is there a type="" attribute? application/octet-stream? | | | | | | | | | | NO | YES | NO | YES | NO | | | | YES V V | | | | application/octet-stream? =====> Extension that is plugin type? | | | | | | | | | | | | NO | NO | YES | | | | V | | | | | | Type attribute is XML or YES V | | | | | doesn't start with image/* ======> FALLBACK | | | | | and is not a plugin type? | | | | | | | | | | | | NO | | V V V V V V Use Use Use Use it (will be Use Use type="" Content-Type text/plain bitmap or plugin) extension TYPE attribute | | | | | | | V V V V | `================->-+========================================>-+==============>-+-<============-+-<==============+-<======' | V Continue following rules in the spec, which might result in a plugin, a browsing context, an image, or using fallback, depending on the UA and the type. "Extension that is plugin type?" means "Is there an extension that matches one that a plugin supports?". Plugins are not allowed to register text/plain or application/octet-stream. --> <ol><li> <p>Let the <var title="">resource type</var> be unknown.</p> </li> <li> <p>If the <code><a href=#the-object-element>object</a></code> element has a <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute and a <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute, and the resource has <a href=#content-type title=Content-Type>associated Content-Type metadata</a>, and the type specified in <a href=#content-type title=Content-Type>the resource's Content-Type metadata</a> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the value of the element's <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute, then let <var title="">resource type</var> be that type and jump to the step below labeled <i>handler</i>.</p> <!-- do we need to <span>strip leading and trailing whitespace</span> from anything here? collapse sequences of spaces? drop parameters? --> </li> <li> <p>If the <code><a href=#the-object-element>object</a></code> element has a <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute, jump to the step below labeled <i>handler</i>.</p> </li> <li> <!-- by request: http://www.w3.org/Bugs/Public/show_bug.cgi?id=8479 --> <p>If the user agent is configured to strictly obey Content-Type headers for this resource, and the resource has <a href=#content-type title=Content-Type>associated Content-Type metadata</a>, then let the <var title="">resource type</var> be the type specified in <a href=#content-type title=Content-Type>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. <!-- e.g. the example given above, where the site is expecting Flash with allowScriptAccess=never, and instead gets back Java with its unrestricted DOM access --></p> </li> <li> <p>If there is a <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute present on the <code><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>plugin</a> supports, then let the <var title="">resource type</var> be the type specified in that <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute, and jump to the step below labeled <i>handler</i>.</p> </li> <li> <p>Run the approprate set of steps from the following list:</p> <dl class=switch><dt>The resource has <a href=#content-type title=Content-Type>associated Content-Type metadata</a></dt> <dd> <ol><li> <p>Let <var title="">binary</var> be false.</p> </li> <li> <p>If the type specified in <a href=#content-type title=Content-Type>the resource's Content-Type metadata</a> is "<code>text/plain</code>", and the result of applying the <a href=#content-type-sniffing:-text-or-binary title="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>text/plain</code>, then set <var title="">binary</var> to true.</p> </li> <li> <p>If the type specified in <a href=#content-type title=Content-Type>the resource's Content-Type metadata</a> is "<code>application/octet-stream</code>", then set <var title="">binary</var> to true.</p> </li> <li> <p>If <var title="">binary</var> is false, then let the <var title="">resource type</var> be the type specified in <a href=#content-type title=Content-Type>the resource's Content-Type metadata</a>, and jump to the step below labeled <i>handler</i>.</p> </li> <li> <p>If there is a <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute present on the <code><a href=#the-object-element>object</a></code> element, and its value is not <code>application/octet-stream</code>, then run the following steps:</p> <ol><li> <p>If the attribute's value is a type that a <a href=#plugin>plugin</a> supports, or the attribute's value is a type that starts with "<code>image/</code>" that is not also an <a href=#xml-mime-type>XML MIME type</a>, then let the <var title="">resource type</var> be the type specified in that <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute.</p> </li> <li> <p>Jump to the step below labeled <i>handler</i>.</p> </li> </ol></li> </ol></dd> <dt>The resource does not have <a href=#content-type title=Content-Type>associated Content-Type metadata</a></dt> <dd> <ol><li> <p>If there is a <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute present on the <code><a href=#the-object-element>object</a></code> element, then let the <var title="">tentative type</var> be the type specified in that <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute.</p> <p>Otherwise, let <var title="">tentative type</var> be the <a href=#content-type-sniffing-0 title="content-type sniffing">sniffed type of the resource</a>.</p> </li> <li> <p>If <var title="">tentative type</var> is <em>not</em> <code>application/octet-stream</code>, then let <var title="">resource type</var> be <var title="">tentative type</var> and jump to the step below labeled <i>handler</i>.</p> </li> </ol></dd> </dl></li> <li> <!-- if we get to this point we know we can successfully parsed the URL, since this algorithm is only used after fetching the resource in the steps above --> <p>If the <a href=#url-path title=url-path><path></a> component of the <a href=#url>URL</a> of the specified resource (after any redirects) matches a pattern that a <a href=#plugin>plugin</a> supports, then let <var title="">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=#url-path title=url-path><path></a> components that end with the four character string "<code title="">.swf</code>".</p> <!-- it's sad that we have to do extension sniffing. sigh. --> <!-- see also <embed> which has a similar step --> </li> </ol><p class=note>It is possible for this step to finish, or for one of the substeps above to jump straight to the next step, with <var title="">resource type</var> still being unknown. In both cases, the next step will trigger fallback.</p> </li> <li><p><i>Handler</i>: Handle the content as given by the first of the following cases that matches:</p> <dl class=switch><dt>If the <var title="">resource type</var> is not a type that the user agent supports, but it <em>is</em> a type that a <a href=#plugin>plugin</a> supports</dt> <dd> <p>If <a href=#sandboxPluginObject>plugins are being sandboxed</a> and the plugin that supports <var title="">resource type</var> cannot be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a>, jump to the last step in the overall set of steps (fallback).</p> <p>Otherwise, the user agent should <a href=#object-plugin>use the plugin that supports <var title="">resource type</var></a> and pass the content of the resource to that <a href=#plugin>plugin</a>. If the <a href=#plugin>plugin</a> reports an error, then jump to the last step in the overall set of steps (fallback).</p> </dd> <dt>If the <var title="">resource type</var> is an <a href=#xml-mime-type>XML MIME type</a>, or <!-- (redundant with the next one) if the <var title="">resource type</var> is HTML, or --> if the <var title="">resource type</var> does not start with "<code>image/</code>"</dt> <dd> <p>The <code><a href=#the-object-element>object</a></code> element must be associated with a newly created <a href=#nested-browsing-context>nested browsing context</a>, if it does not already have one.</p> <p>If the <a href=#url>URL</a> of the given resource is not <code><a href=#about:blank>about:blank</a></code>, the element's <a href=#nested-browsing-context>nested browsing context</a> must then be <a href=#navigate title=navigate>navigated</a><!--DONAV object--> to that resource, with <a href=#replacement-enabled>replacement enabled</a>, and with the <code><a href=#the-object-element>object</a></code> element's document's <a href=#browsing-context>browsing context</a> as the <a href=#source-browsing-context>source browsing context</a>. (The <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute of the <code><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 href=#url>URL</a> of the given resource <em>is</em> <code><a href=#about:blank>about:blank</a></code>, then, instead, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-object-element>object</a></code> element. <span class=note>No <code title=event-load>load</code> event is fired at the <code><a href=#about:blank>about:blank</a></code> document itself.</span></p> <p>The <code><a href=#the-object-element>object</a></code> element <a href=#represents>represents</a> the <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>If the <code title=attr-object-name><a href=#attr-object-name>name</a></code> attribute is present, the <a href=#browsing-context-name>browsing context name</a> must be set to the value of this attribute; otherwise, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</p> <p class=note>In certain situations, e.g. if the resource was <a href=#fetch title=fetch>fetched</a> from an <a href=#application-cache>application cache</a> but it is an HTML file with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute that points to a different <a href=#concept-appcache-manifest title=concept-appcache-manifest>application cache manifest</a>, the <a href=#navigate title=navigate>navigation</a> of the <a href=#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>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>nested browsing context</a>: only the <a href=#navigate>navigate</a> algorithm is restarted, not this <code><a href=#the-object-element>object</a></code> algorithm.</p> <!-- note that malformed XML files don't cause fallback --> </dd> <dt>If the <var title="">resource type</var> starts with "<code>image/</code>", and support for images has not been disabled</dt> <dd> <p>Apply the <a href=#content-type-sniffing:-image title="content-type sniffing: image">image sniffing</a> rules to determine the type of the image.</p> <p>The <code><a href=#the-object-element>object</a></code> element <a href=#represents>represents</a> the specified image. The image is not a <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>If the image cannot be rendered, e.g. because it is malformed or in an unsupported format, jump to the last step in the overall set of steps (fallback).</p> </dd> <dt>Otherwise</dt> <dd> <p>The given <var title="">resource type</var> is not supported. Jump to the last step in the overall set of steps (fallback).</p> <p class=note>If the previous step ended with the <var title="">resource type</var> being unknown, this is the case that is triggered.</p> </dd> </dl></li> <li><p>The element's contents are not part of what the <code><a href=#the-object-element>object</a></code> element represents.</p> <li> <p>Once the resource is completely loaded, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the element.</p> <p>The <a href=#task-source>task source</a> for this task<!--tasks mentioned in this section--> is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> </li> </ol></li> <li><p>If the <code title=attr-object-data><a href=#attr-object-data>data</a></code> attribute is absent but the <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute is present, and the user agent can find a <a href=#plugin>plugin</a> suitable according to the value of the <code title=attr-object-type><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>plugin</a> can be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a>, then that <a href=#plugin>plugin</a> <a href=#object-plugin>should be used</a>. If these conditions cannot be met, or if the <a href=#plugin>plugin</a> reports an error, jump to the next step (fallback).</li> <li><p>(Fallback.) The <code><a href=#the-object-element>object</a></code> element <a href=#represents>represents</a> the element's children, ignoring any leading <code><a href=#the-param-element>param</a></code> element children. This is the element's <a href=#fallback-content>fallback content</a>. If the element has an instantiated <a href=#plugin>plugin</a>, then unload it.</li> </ol><p id=object-plugin>When the algorithm above instantiates a <a href=#plugin>plugin</a>, the user agent should pass to the <a href=#plugin>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 title=concept-param-parameter>parameters</a> given by <code><a href=#the-param-element>param</a></code> elements that are children of the <code><a href=#the-object-element>object</a></code> element, in <a href=#tree-order>tree order</a>. If the <a href=#plugin>plugin</a> supports a scriptable interface, the <code><a href=#htmlobjectelement>HTMLObjectElement</a></code> object representing the element should expose that interface. The <code><a href=#the-object-element>object</a></code> element <a href=#represents>represents</a> the <a href=#plugin>plugin</a>. The <a href=#plugin>plugin</a> is not a nested <a href=#browsing-context>browsing context</a>.</p> <p id=sandboxPluginObject>Plugins are considered sandboxed for the purpose of an <code><a href=#the-object-element>object</a></code> element if the <a href=#sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> was set on the <code><a href=#the-object-element>object</a></code> element's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> when the <code><a href=#document>Document</a></code> was created.</p> <p class=note>The above algorithm is independent of CSS properties (including 'display', 'overflow', and 'visibility'). For example, it runs even if the element is hidden with a 'display:none' CSS style, and does not run <em>again</em> if the element's visibility changes.</p> <p>Due to the algorithm above, the contents of <code><a href=#the-object-element>object</a></code> elements act as <a href=#fallback-content>fallback content</a>, used only when referenced resources can't be shown (e.g. because it returned a 404 error). This allows multiple <code><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>Whenever the <code title=attr-object-name><a href=#attr-object-name>name</a></code> attribute is set, if the <code><a href=#the-object-element>object</a></code> element has a nested <a href=#browsing-context>browsing context</a>, its <a href=#browsing-context-name title="browsing context name">name</a> must be changed to the new value. If the attribute is removed, if the <code><a href=#the-object-element>object</a></code> element has a <a href=#browsing-context>browsing context</a>, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</p> </div> <p>The <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute, if present while the <code><a href=#the-object-element>object</a></code> element represents an image, can indicate that the object has an associated <a href=#image-map>image map</a>. <span class=impl>The attribute must be ignored if the <code><a href=#the-object-element>object</a></code> element doesn't represent an image.</span></p> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-object-element>object</a></code> element with its <a href=#form-owner>form owner</a>.</p> <div class=impl> <p><strong>Constraint validation</strong>: <code><a href=#the-object-element>object</a></code> elements are always <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <p>The <code><a href=#the-object-element>object</a></code> element supports <a href=#dimension-attributes>dimension attributes</a>.</p> <div class=impl> <p>The IDL attributes <dfn id=dom-object-data title=dom-object-data><code>data</code></dfn>, <dfn id=dom-object-type title=dom-object-type><code>type</code></dfn> and <dfn id=dom-object-name title=dom-object-name><code>name</code></dfn> each must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <dfn id=dom-object-typemustmatch title=dom-object-typeMustMatch><code>typeMustMatch</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code> content attribute. The <dfn id=dom-object-usemap title=dom-object-useMap><code>useMap</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-object-usemap>usemap</code> content attribute.</p> <p>The <dfn id=dom-object-contentdocument title=dom-object-contentDocument><code>contentDocument</code></dfn> IDL attribute must return the <code><a href=#document>Document</a></code> object of the <a href=#active-document>active document</a> of the <code><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>, if it has one; otherwise, it must return null.</p> <p>The <dfn id=dom-object-contentwindow title=dom-object-contentWindow><code>contentWindow</code></dfn> IDL attribute must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <code><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>, if it has one; otherwise, it must return null.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute is part of the element's forms API.</p> </div> <div class=example> <p>In the following example, a Java applet is embedded in a page using the <code><a href=#the-object-element>object</a></code> element. (Generally speaking, it is better to avoid using applets like these and instead use native JavaScript and HTML to provide the functionality, since that way the application will work on all Web browsers without requiring a third-party plugin. Many devices, especially embedded devices, do not support third-party technologies like Java.)</p> <pre><figure> <object type="application/x-java-applet"> <param name="code" value="MyJavaClass"> <p>You do not have Java available, or it is disabled.</p> </object> <figcaption>My Java Clock</figcaption> </figure></pre> </div> <div class=example> <p>In this example, an HTML page is embedded in another using the <code><a href=#the-object-element>object</a></code> element.</p> <pre><figure> <object data="clock.html"></object> <figcaption>My HTML Clock</figcaption> </figure></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><a href=#the-video-element>video</a></code> element to show the video for those using user agents that support <code><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><a href=#the-video-element>video</a></code>-capable browser.</p> <pre><p>Look at my video: <object type="application/x-shockwave-flash"> <param name=movie value="http://video.example.com/library/watch.swf"> <param name=allowfullscreen value=true> <param name=flashvars value="http://video.example.com/vids/315981"> <video controls src="http://video.example.com/vids/315981"> <a href="http://video.example.com/vids/315981">View video</a>. </video> </object> </p></pre> </div> <h4 id=the-param-element><span class=secno>4.8.5 </span>The <dfn><code>param</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of an <code><a href=#the-object-element>object</a></code> element, before any <a href=#flow-content>flow content</a>.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-param-name><a href=#attr-param-name>name</a></code></dd> <dd><code title=attr-param-value><a href=#attr-param-value>value</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlparamelement>HTMLParamElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-param-name title=dom-param-name>name</a>; attribute DOMString <a href=#dom-param-value title=dom-param-value>value</a>; };</pre> </dd> </dl><p>The <code><a href=#the-param-element>param</a></code> element defines parameters for plugins invoked by <code><a href=#the-object-element>object</a></code> elements. It does not <a href=#represents title=represents>represent</a> anything on its own.</p> <p>The <dfn id=attr-param-name title=attr-param-name><code>name</code></dfn> attribute gives the name of the parameter.</p> <p>The <dfn id=attr-param-value title=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> <div class=impl> <p>If both attributes are present, and if the parent element of the <code><a href=#the-param-element>param</a></code> is an <code><a href=#the-object-element>object</a></code> element, then the element defines a <dfn id=concept-param-parameter title=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 title=concept-param-parameter>parameter</a> defined by a <code><a href=#the-param-element>param</a></code> element that is the child of an <code><a href=#the-object-element>object</a></code> element that <a href=#represents>represents</a> an instantiated <a href=#plugin>plugin</a> changes, and if that <a href=#plugin>plugin</a> is communicating with the user agent using an API that features the ability to update the <a href=#plugin>plugin</a> when the name or value of a <a href=#concept-param-parameter title=concept-param-parameter>parameter</a> so changes, then the user agent must appropriately exercise that ability to notify the <a href=#plugin>plugin</a> of the change.</p> <p>The IDL attributes <dfn id=dom-param-name title=dom-param-name><code>name</code></dfn> and <dfn id=dom-param-value title=dom-param-value><code>value</code></dfn> must both <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <div class=example> <p>The following example shows how the <code><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><!DOCTYPE HTML> <html lang="en"> <head> <title>O3D Utah Teapot</title> </head> <body> <p> <object type="application/vnd.o3d.auto"> <strong><param name="o3d_features" value="FloatingPointTextures"></strong> <img src="o3d-teapot.png" title="3D Utah Teapot illustration rendered using O3D." alt="When O3D renders the Utah Teapot, it appears as a squat teapot with a shiny metallic finish on which the surroundings are reflected, with a faint shadow caused by the lighting."> <p>To see the teapot actually rendered by O3D on your computer, please download and install the <a href="http://code.google.com/apis/o3d/docs/gettingstarted.html#install">O3D plugin</a>.</p> </object> <script src="o3d-teapot.js"></script> </p> </body> </html></pre> </div> <h4 id=the-video-element><span class=secno>4.8.6 </span>The <dfn id=video><code>video</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd>If the element has a <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute: <a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>If the element has a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute: zero or more <code><a href=#the-track-element>track</a></code> elements, then <a href=#transparent>transparent</a>, but with no <a href=#media-element>media element</a> descendants.</dd> <dd>If the element does not have a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute: zero or more <code><a href=#the-source-element>source</a></code> elements, then zero or more <code><a href=#the-track-element>track</a></code> elements, then <a href=#transparent>transparent</a>, but with no <a href=#media-element>media element</a> descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-media-src><a href=#attr-media-src>src</a></code></dd> <dd><code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code></dd> <dd><code title=attr-video-poster><a href=#attr-video-poster>poster</a></code></dd> <dd><code title=attr-media-preload><a href=#attr-media-preload>preload</a></code></dd> <dd><code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code></dd> <dd><code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code></dd> <dd><code title=attr-media-loop><a href=#attr-media-loop>loop</a></code></dd> <dd><code title=attr-media-muted><a href=#attr-media-muted>muted</a></code></dd> <dd><code title=attr-media-controls><a href=#attr-media-controls>controls</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlvideoelement>HTMLVideoElement</dfn> : <a href=#htmlmediaelement>HTMLMediaElement</a> { attribute unsigned long <a href=#dom-dim-width title=dom-dim-width>width</a>; attribute unsigned long <a href=#dom-dim-height title=dom-dim-height>height</a>; readonly attribute unsigned long <a href=#dom-video-videowidth title=dom-video-videoWidth>videoWidth</a>; readonly attribute unsigned long <a href=#dom-video-videoheight title=dom-video-videoHeight>videoHeight</a>; attribute DOMString <a href=#dom-video-poster title=dom-video-poster>poster</a>; };</pre> </dd> </dl><p>A <code><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><a href=#the-video-element>video</a></code> element<span class=impl>. User agents should not show this content to the user</span>; it is intended for older Web browsers which do not support <code><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 blind, 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><a href=#the-track-element>track</a></code> element. Sign-language tracks can be provided, again either embedded in the video stream or by synchronizing multiple <code><a href=#the-video-element>video</a></code> elements using the <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute or a <code><a href=#mediacontroller>MediaController</a></code> object. Audio descriptions can be provided, either as a separate track embedded in the video stream, or a separate audio track in an <code><a href=#the-audio-element>audio</a></code> element <a href=#slaved-media-elements title="slaved media elements">slaved</a> to the same controller as the <code><a href=#the-video-element>video</a></code> element(s), or in text form using a <a href=#webvtt-file>WebVTT file</a> referenced using the <code><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><a href=#the-video-element>video</a></code> element.</p> <p>The <code><a href=#the-video-element>video</a></code> element is a <a href=#media-element>media element</a> whose <a href=#media-data>media data</a> is ostensibly video data, possibly with associated audio data.</p> <p>The <code title=attr-media-src><a href=#attr-media-src>src</a></code>, <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>, <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>, <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code>, <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code>, <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code>, and <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attributes are <a href=#media-element-attributes title="media element attributes">the attributes common to all media elements</a>.</p> <p>The <dfn id=attr-video-poster title=attr-video-poster><code>poster</code></dfn> attribute gives the address 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>valid non-empty URL potentially surrounded by spaces</a>.</p> <div class=impl> <p>If the specified resource is to be used, then, when the element is created or when the <code title=attr-video-poster><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>:</p> <!-- thus it is unaffected by changes to the base URL. --> <ol><li><p>If there is an existing instance of this algorithm running for this <code><a href=#the-video-element>video</a></code> element, abort that instance of this algorithm without changing the <a href=#poster-frame>poster frame</a>.</li> <li><p>If the <code title=attr-video-poster><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>poster frame</a>; abort these steps.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code> attribute's value relative to the element. If this fails, then there is no <a href=#poster-frame>poster frame</a>; abort these steps.</li> <li><p><a href=#fetch>Fetch</a> the resulting <a href=#absolute-url>absolute URL</a>, from the element's <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a>. This must <a href=#delay-the-load-event>delay the load event</a> of the element's document.</li> <!-- could define how to sniff for an image here --> <li><p>If an image is thus obtained, the <a href=#poster-frame>poster frame</a> is that image. Otherwise, there is no <a href=#poster-frame>poster frame</a>.</li> </ol></div> <p class=note>The image given by the <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code> attribute, the <i><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> <div class=impl> <hr><p>When no video data is available (the element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is either <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, or <code title=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 title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is any subsequent value but the <a href=#media-resource>media resource</a> does not have a video channel), the <code><a href=#the-video-element>video</a></code> element <a href=#represents>represents</a> the <a href=#poster-frame>poster frame</a>.</p> <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> and the <a href=#current-playback-position title="current playback position">current playback position</a> is the first frame of video, the element <a href=#represents>represents</a> the <a href=#poster-frame>poster frame</a>, unless a frame of video has already been shown, in which case the element <a href=#represents>represents</a> the frame of video corresponding to the <a href=#current-playback-position title="current playback position">current playback position</a>.</p> <p>When a <code><a href=#the-video-element>video</a></code> element is <a href=#dom-media-paused title=dom-media-paused>paused</a> at any other position, and the <a href=#media-resource>media resource</a> has a video channel, the element <a href=#represents>represents</a> the frame of video corresponding to the <a href=#current-playback-position title="current playback position">current playback position</a>, or, if that is not yet available (e.g. because the video is seeking or buffering), the last frame of the video to have been rendered.</p> <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media resource</a> has a video channel is <a href=#potentially-playing>potentially playing</a>, it <a href=#represents>represents</a> the frame of video at the continuously increasing <a href=#current-playback-position title="current playback position">"current" position</a>. When the <a href=#current-playback-position>current playback position</a> changes such that the last frame rendered is no longer the frame corresponding to the <a href=#current-playback-position>current playback position</a> in the video, the new frame must be rendered. Similarly, any audio associated with the <a href=#media-resource>media resource</a> must, if played, be played synchronized with the <a href=#current-playback-position>current playback position</a>, at the element's <a href=#effective-media-volume>effective media volume</a>.</p> <p>When a <code><a href=#the-video-element>video</a></code> element whose <a href=#media-resource>media resource</a> has a video channel is neither <a href=#potentially-playing>potentially playing</a> nor <a href=#dom-media-paused title=dom-media-paused>paused</a> (e.g. when seeking or stalled), the element <a href=#represents>represents</a> the last frame of the video to have been rendered.</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><a href=#the-video-element>video</a></code> element also <a href=#represents>represents</a> any <a href=#text-track-cue title="text track cue">text track cues</a> whose <a href=#text-track-cue-active-flag>text track cue active flag</a> is set and whose <a href=#text-track>text track</a> is in the <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> modes.</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 title=represents>represent</a> a link to an external video playback utility or to the video data itself.</p> <p>When a <code><a href=#the-video-element>video</a></code> element's <a href=#media-resource>media resource</a> has a video channel, the element <a href=#provides-a-paint-source>provides a paint source</a> whose width is the <a href=#media-resource>media resource</a>'s <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</a>, whose height is the <a href=#media-resource>media resource</a>'s <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</a>, and whose appearance is the frame of video corresponding to the <a href=#current-playback-position title="current playback position">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></div> <dl class=domintro><dt><var title="">video</var> . <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code></dt> <dt><var title="">video</var> . <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code></dt> <dd> <p>These attributes return the intrinsic dimensions of the video, or zero if the dimensions are not known.</p> </dd> </dl><div class=impl> <p>The <dfn id=concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</dfn> and <dfn id=concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</dfn> of the <a href=#media-resource>media resource</a> are the dimensions of the resource in CSS pixels 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 title=dom-video-videoWidth><code>videoWidth</code></dfn> IDL attribute must return the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</a> of the video in CSS pixels. The <dfn id=dom-video-videoheight title=dom-video-videoHeight><code>videoHeight</code></dfn> IDL attribute must return the <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</a> of the video in CSS pixels. If the element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then the attributes must return 0.</p> </div> <p>The <code><a href=#the-video-element>video</a></code> element supports <a href=#dimension-attributes>dimension attributes</a>.</p> <div class=impl> <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 intrinsic width of a <code><a href=#the-video-element>video</a></code> element's playback area is the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</a> of the video resource, if that is available; otherwise it is the intrinsic width of the <a href=#poster-frame>poster frame</a>, if that is available; otherwise it is 300 CSS pixels.</p> <p>The intrinsic height of a <code><a href=#the-video-element>video</a></code> element's playback area is the <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</a> of the video resource, if that is available; otherwise it is the intrinsic height of the <a href=#poster-frame>poster frame</a>, if that is available; otherwise it is 150 CSS pixels.</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 (e.g. full-screen or in an independent resizable window). As for 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 title="expose a user interface to the user">exposing a user interface</a>. In such an independent context, however, user agents may make full user interfaces visible, with, e.g., play, pause, seeking, and volume controls, even if the <code title=attr-media-controls><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 title=dom-video-poster><code>poster</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code> content attribute.</p> </div> <div class=example> <p>This example shows how to detect when a video has failed to play correctly:</p> <pre><script> function failed(e) { // video playback failed - show a message saying why switch (e.target.error.code) { case e.target.error.MEDIA_ERR_ABORTED: alert('You aborted the video playback.'); break; case e.target.error.MEDIA_ERR_NETWORK: alert('A network error caused the video download to fail part-way.'); break; case e.target.error.MEDIA_ERR_DECODE: alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.'); break; case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: alert('The video could not be loaded, either because the server or network failed or because the format is not supported.'); break; default: alert('An unknown error occurred.'); break; } } </script> <p><video src="tgif.vid" autoplay controls onerror="failed(event)"></video></p> <p><a href="tgif.vid">Download the video file</a>.</p></pre> </div> <!--CODECS <div class="impl"> <h5>Video and audio codecs for <code>video</code> elements</h5> <p>User agents may support any video and audio codecs and container formats.</p> <p class="note">Certain user agents might support no codecs at all, e.g. text browsers running over SSH connections.</p> <!- - similar note in audio codecs section - -> <p class="note">Implementations are free to implement support for video codecs either natively, or using platform-specific APIs, or using plugins: this specification does not specify how codecs are to be implemented.</p> </div> (when replacing this text, also fix "- -" nested comments)--> <h4 id=the-audio-element><span class=secno>4.8.7 </span>The <dfn id=audio><code>audio</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd>If the element has a <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute: <a href=#interactive-content>Interactive content</a>.</dd> <dd>If the element has a <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd>If the element has a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute: zero or more <code><a href=#the-track-element>track</a></code> elements, then <a href=#transparent>transparent</a>, but with no <a href=#media-element>media element</a> descendants.</dd> <dd>If the element does not have a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute: zero or more <code><a href=#the-source-element>source</a></code> elements, then zero or more <code><a href=#the-track-element>track</a></code> elements, then <a href=#transparent>transparent</a>, but with no <a href=#media-element>media element</a> descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-media-src><a href=#attr-media-src>src</a></code></dd> <dd><code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code></dd> <dd><code title=attr-media-preload><a href=#attr-media-preload>preload</a></code></dd> <dd><code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code></dd> <dd><code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code></dd> <dd><code title=attr-media-loop><a href=#attr-media-loop>loop</a></code></dd> <dd><code title=attr-media-muted><a href=#attr-media-muted>muted</a></code></dd> <dd><code title=attr-media-controls><a href=#attr-media-controls>controls</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>[NamedConstructor=<a href=#dom-audio title=dom-Audio>Audio</a>(), NamedConstructor=<a href=#dom-audio-s title=dom-Audio-s>Audio</a>(DOMString src)] interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediaelement>HTMLMediaElement</a> {};</pre> </dd> </dl><p>An <code><a href=#the-audio-element>audio</a></code> element <a href=#represents>represents</a> a sound or audio stream.</p> <!-- v2 (actually v3) suggestions: * Audio syntesis. Use cases from Charles Pritchard: > Use a sound of varying pitch to hint to a user the location of their > mouse (is it hovering over a button, is it x/y pixels away from the edge > of the screen, how close is it to the center). > > Alter the pitch of a sound to make a very cheap midi instrument. > > Pre-mix a few generated sounds, because the client processor is slow. > > Alter the pitch of an actual audio recording, and pre-mix it, to give > different sounding voices to pre-recorded readings of a single text. As > has been tried for "male" "female" sound fonts. > > Support very simple audio codecs, and programmable synthesizers. --> <p>Content may be provided inside the <code><a href=#the-audio-element>audio</a></code> element<span class=impl>. User agents should not show this content to the user</span>; it is intended for older Web browsers which do not support <code><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><a href=#the-video-element>video</a></code> element can be used instead of the <code><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><a href=#the-track-element>track</a></code> element and a WebVTT file. And, naturally, transcripts or other textual alternatives can be provided by simply linking to them in the prose near the <code><a href=#the-audio-element>audio</a></code> element.</p> <p>The <code><a href=#the-audio-element>audio</a></code> element is a <a href=#media-element>media element</a> whose <a href=#media-data>media data</a> is ostensibly audio data.</p> <p>The <code title=attr-media-src><a href=#attr-media-src>src</a></code>, <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>, <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>, <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code>, <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code>, <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code>, and <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attributes are <a href=#media-element-attributes title="media element attributes">the attributes common to all media elements</a>.</p> <div class=impl> <p>When an <code><a href=#the-audio-element>audio</a></code> element is <a href=#potentially-playing>potentially playing</a>, it must have its audio data played synchronized with the <a href=#current-playback-position>current playback position</a>, at the element's <a href=#effective-media-volume>effective media volume</a>.</p> <p>When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#potentially-playing>potentially playing</a>, audio must not play for the element.</p> </div> <dl class=domintro><dt><var title="">audio</var> = new <code title=dom-Audio><a href=#dom-audio>Audio</a></code>( [ <var title="">url</var> ] )</dt> <dd> <p>Returns a new <code><a href=#the-audio-element>audio</a></code> element, with the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute set to the value passed in the argument, if applicable.</p> </dd> </dl><div class=impl> <p>Two constructors are provided for creating <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> objects (in addition to the factory methods from DOM Core such as <code title="">createElement()</code>): <dfn id=dom-audio title=dom-Audio><code>Audio()</code></dfn> and <dfn id=dom-audio-s title=dom-Audio-s><code>Audio(<var title="">src</var>)</code></dfn>. When invoked as constructors, these must return a new <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> object (a new <code><a href=#the-audio-element>audio</a></code> element). The element must have its <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute set to the literal value "<code title=attr-media-preload-auto><a href=#attr-media-preload-auto>auto</a></code>". If the <var title="">src</var> argument is present, the object created must have its <code title=attr-media-src><a href=#attr-media-src>src</a></code> content attribute set to the provided value, and the user agent must invoke the object's <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> before returning. The element's document must be the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> of the <code><a href=#window>Window</a></code> object on which the interface object of the invoked constructor is found.</p> </div> <!--CODECS <div class="impl"> <h5>Audio codecs for <code>audio</code> elements</h5> <p>User agents may support any audio codecs and container formats.</p> <p>User agents must support the WAVE container format with audio encoded using the 16 bit PCM (LE) codec, at sampling frequencies of 11.025kHz, 22.050kHz, and 44.100kHz, and for both mono and stereo. <a href="#- -refsWAVE">[WAVE]</a></p> <!- - <dt id="- -refsWAVE">WAVE</dt> <dd>http://en.wikipedia.org/wiki/WAV? </dd> - -> <!- - similar note in video codecs section - -> <p class="note">Implementations are free to implement support for audio codecs either natively, or using platform-specific APIs, or using plugins: this specification does not specify how codecs are to be implemented.</p> </div> (when replacing this text, also fix "- -" nested comments)--> <h4 id=the-source-element><span class=secno>4.8.8 </span>The <dfn><code>source</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <a href=#media-element>media element</a>, before any <a href=#flow-content>flow content</a> or <code><a href=#the-track-element>track</a></code> elements.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-source-src><a href=#attr-source-src>src</a></code></dd> <dd><code title=attr-source-type><a href=#attr-source-type>type</a></code></dd> <dd><code title=attr-source-media><a href=#attr-source-media>media</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlsourceelement>HTMLSourceElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-source-src title=dom-source-src>src</a>; attribute DOMString <a href=#dom-source-type title=dom-source-type>type</a>; attribute DOMString <a href=#dom-source-media title=dom-source-media>media</a>; };</pre> </dd> </dl><p>The <code><a href=#the-source-element>source</a></code> element allows authors to specify multiple alternative <a href=#media-resource title="media resource">media resources</a> for <a href=#media-element title="media element">media elements</a>. It does not <a href=#represents title=represents>represent</a> anything on its own.</p> <p>The <dfn id=attr-source-src title=attr-source-src><code>src</code></dfn> attribute gives the address of the <a href=#media-resource>media resource</a>. The value must be a <a href=#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><a href=#the-source-element>source</a></code> element and its attribute when the element is already inserted in a <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code> element will have no effect. To change what is playing, just use the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute on the <a href=#media-element>media element</a> directly, possibly making use of the <code title=dom-navigator-canPlayType><a href=#dom-navigator-canplaytype>canPlayType()</a></code> method to pick from amongst available resources. Generally, manipulating <code><a href=#the-source-element>source</a></code> elements manually after the document has been parsed is an unncessarily complicated approach.</p> <p>The <dfn id=attr-source-type title=attr-source-type><code>type</code></dfn> attribute gives the type of the <a href=#media-resource>media resource</a>, to help the user agent determine if it can play this <a href=#media-resource>media resource</a> before fetching it. If specified, its value must be a <a href=#valid-mime-type>valid MIME type</a>. The <code title="">codecs</code> parameter, which certain MIME types define, might be necessary to specify exactly how the resource is encoded. <a href=#refsRFC4281>[RFC4281]</a></p> <div class=example> <p>The following list shows some examples of how to use the <code title="">codecs=</code> MIME parameter in the <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute.</p> <dl><dt>H.264 Constrained baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'></pre></dd> <dt>H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"'></pre></dd> <dt>H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'></pre></dd> <dt>H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="avc1.64001E, mp4a.40.2"'></pre></dd> <dt>MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="mp4v.20.8, mp4a.40.2"'></pre></dd> <dt>MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container</dt> <dd><pre><source src='video.mp4' type='video/mp4; codecs="mp4v.20.240, mp4a.40.2"'></pre></dd> <dt>MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container</dt> <dd><pre><source src='video.3gp' type='video/3gpp; codecs="mp4v.20.8, samr"'></pre></dd> <dt>Theora video and Vorbis audio in Ogg container</dt> <dd><pre><source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'></pre></dd> <dt>Theora video and Speex audio in Ogg container</dt> <dd><pre><source src='video.ogv' type='video/ogg; codecs="theora, speex"'></pre></dd> <dt>Vorbis audio alone in Ogg container</dt> <dd><pre><source src='audio.ogg' type='audio/ogg; codecs=vorbis'></pre></dd> <dt>Speex audio alone in Ogg container</dt> <dd><pre><source src='audio.spx' type='audio/ogg; codecs=speex'></pre></dd> <dt>FLAC audio alone in Ogg container</dt> <dd><pre><source src='audio.oga' type='audio/ogg; codecs=flac'></pre></dd> <dt>Dirac video and Vorbis audio in Ogg container</dt> <dd><pre><source src='video.ogv' type='video/ogg; codecs="dirac, vorbis"'></pre></dd> <!-- awaiting definition by the Matroska guys: <dt>Theora video and Vorbis audio in Matroska container</dt> <dd><pre><source src='video.mkv' type='video/x-matroska; codecs="theora, vorbis"'></pre></dd> --> <!-- awaiting definition by the Ogg or BBC guys: <dt>Dirac video and Vorbis audio in Matroska container</dt> <dd><pre><source src='video.mkv' type='video/x-matroska; codecs='></pre></dd> --> <!-- awaiting definition by the Microsoft guys: <dt>WMV9 video and WMA 2 audio in ASF container</dt> <dd><pre><source src='video.wmv' type='video/x-ms-wmv; codecs='></pre></dd> <dt>WMV8 video and WMA 2 audio in ASF container</dt> <dd><pre><source src='video.wmv' type='video/x-ms-wmv; codecs='></pre></dd> <dt>VC-1 video and WMA 10 Pro audio in ASF container</dt> <dd><pre><source src='video.wmv' type='video/x-ms-wmv; codecs='></pre></dd> <dt>XviD video and MP3 audio in AVI container</dt> <dd><pre><source src='video.avi' type='video/x-msvideo; codecs='></pre></dd> <dt>Motion-JPEG video and uncompressed PCM audio in AVI container</dt> <dd><pre><source src='video.avi' type='video/x-msvideo; codecs='></pre></dd> --> <!-- awaiting definition by Real: <dt>Real Video 10 video and High-Efficiency AAC audio in Real Media container</dt> <dd><pre><source src='video.rm' type='application/vnd.rn-realmedia; codecs='></pre></dd> --> <!-- undefined: <dt>MPEG-1 video and MPEG-1 Audio Layer II audio in MPEG-1 program stream</dt> <dd><pre><source src='video.mpg' type='video/mpeg; codecs='></pre></dd> --> </dl></div> <p>The <dfn id=attr-source-media title=attr-source-media><code>media</code></dfn> attribute gives the intended media type of the <a href=#media-resource>media resource</a>, to help the user agent determine if this <a href=#media-resource>media resource</a> is useful to the user before fetching it. Its value must be a <a href=#valid-media-query>valid media query</a>.</p> <p id=source-default-media>The default, if the <code title=attr-srouce-media>media</code> attribute is omitted, is "<code title="">all</code>", meaning that by default the <a href=#media-resource>media resource</a> is suitable for all media.</p> <div class=impl> <p>If a <code><a href=#the-source-element>source</a></code> element is inserted as a child of a <a href=#media-element>media element</a> that has no <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute and whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> has the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, the user agent must invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</p> <p>The IDL attributes <dfn id=dom-source-src title=dom-source-src><code>src</code></dfn>, <dfn id=dom-source-type title=dom-source-type><code>type</code></dfn>, and <dfn id=dom-source-media title=dom-source-media><code>media</code></dfn> must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <div class=example> <p>If the author isn't sure if the user agents will all be able to render the media resources provided, the author can listen to the <code title=event-error>error</code> event on the last <code><a href=#the-source-element>source</a></code> element and trigger fallback behavior:</p> <pre><script> function fallback(video) { // replace <video> with its contents while (video.hasChildNodes()) { if (video.firstChild instanceof HTMLSourceElement) video.removeChild(video.firstChild); else video.parentNode.insertBefore(video.firstChild, video); } video.parentNode.removeChild(video); } </script> <video controls autoplay> <source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> <source src='video.ogv' type='video/ogg; codecs="theora, vorbis"' onerror="fallback(parentNode)"> ... </video></pre> </div> <h4 id=the-track-element><span class=secno>4.8.9 </span>The <dfn><code>track</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <a href=#media-element>media element</a>, before any <a href=#flow-content>flow content</a>.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-track-kind><a href=#attr-track-kind>kind</a></code></dd> <dd><code title=attr-track-src><a href=#attr-track-src>src</a></code></dd> <dd><code title=attr-track-srclang><a href=#attr-track-srclang>srclang</a></code></dd> <dd><code title=attr-track-label><a href=#attr-track-label>label</a></code></dd> <dd><code title=attr-track-default><a href=#attr-track-default>default</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltrackelement>HTMLTrackElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-track-kind title=dom-track-kind>kind</a>; attribute DOMString <a href=#dom-track-src title=dom-track-src>src</a>; attribute DOMString <a href=#dom-track-srclang title=dom-track-srclang>srclang</a>; attribute DOMString <a href=#dom-track-label title=dom-track-label>label</a>; attribute boolean <a href=#dom-track-default title=dom-track-default>default</a>; const unsigned short <a href=#dom-track-none title=dom-track-NONE>NONE</a> = 0; const unsigned short <a href=#dom-track-loading title=dom-track-LOADING>LOADING</a> = 1; const unsigned short <a href=#dom-track-loaded title=dom-track-LOADED>LOADED</a> = 2; const unsigned short <a href=#dom-track-error title=dom-track-ERROR>ERROR</a> = 3; readonly attribute unsigned short <a href=#dom-track-readystate title=dom-track-readyState>readyState</a>; readonly attribute <a href=#texttrack>TextTrack</a> <a href=#dom-track-track title=dom-track-track>track</a>; };</pre> </dd> </dl><p>The <code><a href=#the-track-element>track</a></code> element allows authors to specify explicit external timed <a href=#text-track title="text track">text tracks</a> for <a href=#media-element title="media element">media elements</a>. It does not <a href=#represents title=represents>represent</a> anything on its own.</p> <p>The <dfn id=attr-track-kind title=attr-track-kind><code>kind</code></dfn> attribute is an <a href=#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 title=attr-track-kind-keyword-subtitles><code>subtitles</code></dfn> <td><dfn id=attr-track-kind-subtitles title=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>media resource</a>'s audio track). Overlaid on the video. <tr><td><dfn id=attr-track-kind-keyword-captions title=attr-track-kind-keyword-captions><code>captions</code></dfn> <td><dfn id=attr-track-kind-captions title=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 title=attr-track-kind-keyword-descriptions><code>descriptions</code></dfn> <td><dfn id=attr-track-kind-descriptions title=attr-track-kind-descriptions>Descriptions</dfn> <td> Textual descriptions of the video component of the <a href=#media-resource>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 title=attr-track-kind-keyword-chapters><code>chapters</code></dfn> <td><dfn id=attr-track-kind-chapters title=attr-track-kind-chapters>Chapters</dfn> <td> Chapter titles, intended to be used for navigating the <a href=#media-resource>media resource</a>. Displayed as an interactive (potentially nested) list in the user agent's interface. <tr><td><dfn id=attr-track-kind-keyword-metadata title=attr-track-kind-keyword-metadata><code>metadata</code></dfn> <td><dfn id=attr-track-kind-metadata title=attr-track-kind-metadata>Metadata</dfn> <td> Tracks intended for use from script. Not displayed by the user agent. </table><p>The attribute may be omitted. The <i>missing value default</i> is the <a href=#attr-track-kind-subtitles title=attr-track-kind-subtitles>subtitles</a> state.</p> <p>The <dfn id=attr-track-src title=attr-track-src><code>src</code></dfn> attribute gives the address of the text track data. The value must be a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by spaces</a>. This attribute must be present.</p> <div class=impl> <p>If the element has a <code title=attr-track-src><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=#resolve-a-url title="resolve a url">resolved</a> relative to the element, then the element's <dfn id=track-url>track URL</dfn> is the resulting <a href=#absolute-url>absolute URL</a>. Otherwise, the element's <a href=#track-url>track URL</a> is the empty string.</p> </div> <!--TTVTT--> <p>If the element's <a href=#track-url>track URL</a> identifies a <a href=#webvtt>WebVTT</a> resource, and the element's <code title=attr-track-kind><a href=#attr-track-kind>kind</a></code> attribute is not in the <a href=#attr-track-kind-metadata title=attr-track-kind-metadata>metadata</a> state, then the <a href=#webvtt>WebVTT</a> file must be a <a href=#webvtt-file-using-cue-text>WebVTT file using cue text</a>.</p> <p>Furthermore, if the element's <a href=#track-url>track URL</a> identifies a <a href=#webvtt>WebVTT</a> resource, and the element's <code title=attr-track-kind><a href=#attr-track-kind>kind</a></code> attribute is in the <a href=#attr-track-kind-chapters title=attr-track-kind-chapters>chapters</a> state, then the <a href=#webvtt>WebVTT</a> file must be both a <a href=#webvtt-file-using-chapter-title-text>WebVTT file using chapter title text</a> and a <a href=#webvtt-file-using-only-nested-cues>WebVTT file using only nested cues</a>.</p> <!--TTVTT--> <p>The <dfn id=attr-track-srclang title=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 title=attr-track-kind><a href=#attr-track-kind>kind</a></code> attribute is in the <a href=#attr-track-kind-subtitles title=attr-track-kind-subtitles>subtitles</a> state. <a href=#refsBCP47>[BCP47]</a></p> <div class=impl> <p>If the element has a <code title=attr-track-srclang><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>track language</a>.</p> </div> <p>The <dfn id=attr-track-label title=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 title=attr-track-kind-subtitles>subtitle</a>, <a href=#attr-track-kind-captions title=attr-track-kind-captions>caption</a>, and <a href=#attr-track-kind-descriptions title=attr-track-kind-descriptions>audio description</a> tracks in their user interface.</p> <p>The value of the <code title=attr-track-label><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><a href=#the-track-element>track</a></code> element children of the same <a href=#media-element>media element</a> whose <code title=attr-track-kind><a href=#attr-track-kind>kind</a></code> attributes are in the same state, whose <code title=attr-track-srclang><a href=#attr-track-srclang>srclang</a></code> attributes are both missing or have values that represent the same language, and whose <code title=attr-track-label><a href=#attr-track-label>label</a></code> attributes are again both missing or both have the same value.</p> <div class=impl> <p>If the element has a <code title=attr-track-label><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>track label</a> is a user-agent defined string (e.g. the string "untitled" in the user's locale, or a value automatically generated from the other attributes).</p> </div> <p>The <dfn id=attr-track-default title=attr-track-default><code>default</code></dfn> attribute, 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. There must not be more than one <code><a href=#the-track-element>track</a></code> element with the same parent node with the <code title=attr-track-default><a href=#attr-track-default>default</a></code> attribute specified.</p> <dl class=domintro><dt><var title="">track</var> . <code title=dom-track-readyState><a href=#dom-track-readystate>readyState</a></code></dt> <dd> <p>Returns the <a href=#text-track-readiness-state>text track readiness state</a>, represented by a number from the following list:</p> <dl><dt><var title="">track</var> . <code title=dom-track-NONE><a href=#dom-track-none>NONE</a></code> (0)</dt> <dd> <p>The <a href=#text-track-not-loaded>text track not loaded</a> state.</p> </dd> <dt><var title="">track</var> . <code title=dom-track-LOADING><a href=#dom-track-loading>LOADING</a></code> (1)</dt> <dd> <p>The <a href=#text-track-loading>text track loading</a> state.</p> </dd> <dt><var title="">track</var> . <code title=dom-track-LOADED><a href=#dom-track-loaded>LOADED</a></code> (2)</dt> <dd> <p>The <a href=#text-track-loaded>text track loaded</a> state.</p> </dd> <dt><var title="">track</var> . <code title=dom-track-ERROR><a href=#dom-track-error>ERROR</a></code> (3)</dt> <dd> <p>The <a href=#text-track-failed-to-load>text track failed to load</a> state.</p> </dd> </dl></dd> <dt><var title="">track</var> . <code title=dom-track-track><a href=#dom-track-track>track</a></code></dt> <dd> <p>Returns the <code><a href=#texttrack>TextTrack</a></code> object corresponding to the <a href=#text-track>text track</a> of the <code><a href=#the-track-element>track</a></code> element.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-track-readystate title=dom-track-readyState><code>readyState</code></dfn> attribute must return the numeric value corresponding to the <a href=#text-track-readiness-state>text track readiness state</a> of the <code><a href=#the-track-element>track</a></code> element's <a href=#text-track>text track</a>, as defined by the following list:</p> <dl><dt><dfn id=dom-track-none title=dom-track-NONE><code>NONE</code></dfn> (numeric value 0)</dt> <dd>The <a href=#text-track-not-loaded>text track not loaded</a> state.</dd> <dt><dfn id=dom-track-loading title=dom-track-LOADING><code>LOADING</code></dfn> (numeric value 1)</dt> <dd>The <a href=#text-track-loading>text track loading</a> state.</dd> <dt><dfn id=dom-track-loaded title=dom-track-LOADED><code>LOADED</code></dfn> (numeric value 2)</dt> <dd>The <a href=#text-track-loaded>text track loaded</a> state.</dd> <dt><dfn id=dom-track-error title=dom-track-ERROR><code>ERROR</code></dfn> (numeric value 3)</dt> <dd>The <a href=#text-track-failed-to-load>text track failed to load</a> state.</dd> </dl><p>The <dfn id=dom-track-track title=dom-track-track><code>track</code></dfn> IDL attribute must, on getting, return the <code><a href=#the-track-element>track</a></code> element's <a href=#text-track>text track</a>'s corresponding <code><a href=#texttrack>TextTrack</a></code> object.</p> <p>The <dfn id=dom-track-src title=dom-track-src><code>src</code></dfn>, <dfn id=dom-track-srclang title=dom-track-srclang><code>srclang</code></dfn>, <dfn id=dom-track-label title=dom-track-label><code>label</code></dfn>, and <dfn id=dom-track-default title=dom-track-default><code>default</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <dfn id=dom-track-kind title=dom-track-kind><code>kind</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> </div> <div class=example> <p>This video has subtitles in several languages:</p> <pre><video src="brave.webm"> <track kind=subtitles src=brave.en.vtt srclang=en label="English"> <track kind=captions src=brave.en.hoh.vtt srclang=en label="English for the Hard of Hearing"> <track kind=subtitles src=brave.fr.vtt srclang=fr lang=fr label="Français"> <track kind=subtitles src=brave.de.vtt srclang=de lang=de label="Deutsch"> </video></pre> </div> <h4 id=media-elements><span class=secno>4.8.10 </span>Media elements</h4> <p><dfn id=media-element title="media element">Media elements</dfn> (<code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code>, in this specification) implement the following interface:</p> <pre class=idl>interface <dfn id=htmlmediaelement>HTMLMediaElement</dfn> : <a href=#htmlelement>HTMLElement</a> { // error state readonly attribute <a href=#mediaerror>MediaError</a>? <a href=#dom-media-error title=dom-media-error>error</a>; // network state attribute DOMString <a href=#dom-media-src title=dom-media-src>src</a>; readonly attribute DOMString <a href=#dom-media-currentsrc title=dom-media-currentSrc>currentSrc</a>; attribute DOMString <a href=#dom-media-crossorigin title=dom-media-crossOrigin>crossOrigin</a>; const unsigned short <a href=#dom-media-network_empty title=dom-media-NETWORK_EMPTY>NETWORK_EMPTY</a> = 0; const unsigned short <a href=#dom-media-network_idle title=dom-media-NETWORK_IDLE>NETWORK_IDLE</a> = 1; const unsigned short <a href=#dom-media-network_loading title=dom-media-NETWORK_LOADING>NETWORK_LOADING</a> = 2; const unsigned short <a href=#dom-media-network_no_source title=dom-media-NETWORK_NO_SOURCE>NETWORK_NO_SOURCE</a> = 3; readonly attribute unsigned short <a href=#dom-media-networkstate title=dom-media-networkState>networkState</a>; attribute DOMString <a href=#dom-media-preload title=dom-media-preload>preload</a>; <!--v3BUF readonly attribute double <span title="dom-media-bufferingRate">bufferingRate</span>; readonly attribute boolean <span title="dom-media-bufferingThrottled">bufferingThrottled</span>; --> readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-media-buffered title=dom-media-buffered>buffered</a>; void <a href=#dom-media-load title=dom-media-load>load</a>(); DOMString <a href=#dom-navigator-canplaytype title=dom-navigator-canPlayType>canPlayType</a>(DOMString type); // ready state const unsigned short <a href=#dom-media-have_nothing title=dom-media-HAVE_NOTHING>HAVE_NOTHING</a> = 0; const unsigned short <a href=#dom-media-have_metadata title=dom-media-HAVE_METADATA>HAVE_METADATA</a> = 1; const unsigned short <a href=#dom-media-have_current_data title=dom-media-HAVE_CURRENT_DATA>HAVE_CURRENT_DATA</a> = 2; const unsigned short <a href=#dom-media-have_future_data title=dom-media-HAVE_FUTURE_DATA>HAVE_FUTURE_DATA</a> = 3; const unsigned short <a href=#dom-media-have_enough_data title=dom-media-HAVE_ENOUGH_DATA>HAVE_ENOUGH_DATA</a> = 4; readonly attribute unsigned short <a href=#dom-media-readystate title=dom-media-readyState>readyState</a>; readonly attribute boolean <a href=#dom-media-seeking title=dom-media-seeking>seeking</a>; // playback state attribute double <a href=#dom-media-currenttime title=dom-media-currentTime>currentTime</a>; readonly attribute double <a href=#dom-media-initialtime title=dom-media-initialTime>initialTime</a>; readonly attribute double <a href=#dom-media-duration title=dom-media-duration>duration</a>; readonly attribute <span>Date</span> <a href=#dom-media-startoffsettime title=dom-media-startOffsetTime>startOffsetTime</a>; readonly attribute boolean <a href=#dom-media-paused title=dom-media-paused>paused</a>; attribute double <a href=#dom-media-defaultplaybackrate title=dom-media-defaultPlaybackRate>defaultPlaybackRate</a>; attribute double <a href=#dom-media-playbackrate title=dom-media-playbackRate>playbackRate</a>; readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-media-played title=dom-media-played>played</a>; readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-media-seekable title=dom-media-seekable>seekable</a>; readonly attribute boolean <a href=#dom-media-ended title=dom-media-ended>ended</a>; attribute boolean <a href=#dom-media-autoplay title=dom-media-autoplay>autoplay</a>; attribute boolean <a href=#dom-media-loop title=dom-media-loop>loop</a>; void <a href=#dom-media-play title=dom-media-play>play</a>(); void <a href=#dom-media-pause title=dom-media-pause>pause</a>(); // media controller attribute <span>DOMString</span> <a href=#dom-media-mediagroup title=dom-media-mediaGroup>mediaGroup</a>; attribute <a href=#mediacontroller>MediaController</a>? <a href=#dom-media-controller title=dom-media-controller>controller</a>; // controls attribute boolean <a href=#dom-media-controls title=dom-media-controls>controls</a>; attribute double <a href=#dom-media-volume title=dom-media-volume>volume</a>; attribute boolean <a href=#dom-media-muted title=dom-media-muted>muted</a>; attribute boolean <a href=#dom-media-defaultmuted title=dom-media-defaultMuted>defaultMuted</a>; // tracks readonly attribute <a href=#audiotracklist>AudioTrackList</a> <a href=#dom-media-audiotracks title=dom-media-audioTracks>audioTracks</a>; readonly attribute <a href=#videotracklist>VideoTrackList</a> <a href=#dom-media-videotracks title=dom-media-videoTracks>videoTracks</a>; readonly attribute <a href=#texttracklist>TextTrackList</a> <a href=#dom-media-texttracks title=dom-media-textTracks>textTracks</a>; <a href=#texttrack>TextTrack</a> <a href=#dom-media-addtexttrack title=dom-media-addTextTrack>addTextTrack</a>(DOMString kind, optional DOMString label, optional DOMString language); };</pre> <p>The <dfn id=media-element-attributes>media element attributes</dfn>, <code title=attr-media-src><a href=#attr-media-src>src</a></code>, <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code>, <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>, <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>, <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code>, <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code>, <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code>, and <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code>, apply to all <a href=#media-element title="media element">media elements</a>. They are defined in this section.</p> <!-- proposed v2 (actually v3!) features: * frame forward / backwards / step(n) while paused * per-frame control: get current frame; set current frame * queue of content - pause current stream and insert content at front of queue to play immediately - pre-download another stream - add stream(s) to play at end of current stream - pause playback upon reaching a certain time - playlists, with the ability to get metadata out of them (e.g. xspf) * general meta data, implemented as getters (don't expose the whole thing) - getMetadata(key: string, language: string) => HTMLImageElement or string - onmetadatachanged (no context info) - general custom metadata store (ratings, etc.) * video: applying CSS filters * an event to notify people of when the video size changes (e.g. for chained Ogg streams of multiple independent videos) (or for when the current video track changes) * balance and 3D position audio * audio filters * audio synthesis (see <audio> section for use cases) * feedback to the script on how well the video is playing - frames per second? - skipped frames per second? - an event that reports playback difficulties? - an arbitrary quality metric? * bufferingRate/bufferingThrottled (see v3BUF) * events for when the user agent's controls get shown or hidden so that the author's controls can get away of the UA's --> <!-- v2 features that already have experimental implementations: * webkitPreservesPitch (for when playbackRate != 1.0) --> <p><a href=#media-element title="media element">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 title="media element">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>media resource</a> can have multiple audio and video tracks. For the purposes of a <a href=#media-element>media element</a>, the video data of the <a href=#media-resource>media resource</a> is only that of the currently selected track (if any) given by the element's <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> attribute, and the audio data of the <a href=#media-resource>media resource</a> is the result of mixing all the currently enabled tracks (if any) given by the element's <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> attribute.</p> <p class=note>Both <code><a href=#the-audio-element>audio</a></code> and <code><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><a href=#the-audio-element>audio</a></code> element has no playback area for visual content (such as video or captions), whereas the <code><a href=#the-video-element>video</a></code> element does.</p> <div class=impl> <p>Except where otherwise specified, the <a href=#task-source>task source</a> for all the tasks <a href=#queue-a-task title="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>.</p> </div> <h5 id=error-codes><span class=secno>4.8.10.1 </span>Error codes</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-error><a href=#dom-media-error>error</a></code></dt> <dd> <p>Returns a <code><a href=#mediaerror>MediaError</a></code> object representing the current error state of the element.</p> <p>Returns null if there is no error.</p> </dd> </dl><div class=impl> <p>All <a href=#media-element title="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 title=concept-media-load-algorithm>resource selection algorithm</a> was last invoked. The <dfn id=dom-media-error title=dom-media-error><code>error</code></dfn> attribute, on getting, must return the <code><a href=#mediaerror>MediaError</a></code> object created for this last error, or null if there has not been an error.</p> </div> <pre class=idl>interface <dfn id=mediaerror>MediaError</dfn> { const unsigned short <a href=#dom-mediaerror-media_err_aborted title=dom-MediaError-MEDIA_ERR_ABORTED>MEDIA_ERR_ABORTED</a> = 1; const unsigned short <a href=#dom-mediaerror-media_err_network title=dom-MediaError-MEDIA_ERR_NETWORK>MEDIA_ERR_NETWORK</a> = 2; const unsigned short <a href=#dom-mediaerror-media_err_decode title=dom-MediaError-MEDIA_ERR_DECODE>MEDIA_ERR_DECODE</a> = 3; const unsigned short <a href=#dom-mediaerror-media_err_src_not_supported title=dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED>MEDIA_ERR_SRC_NOT_SUPPORTED</a> = 4; readonly attribute unsigned short <a href=#dom-mediaerror-code title=dom-MediaError-code>code</a>; };</pre> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-error><a href=#dom-media-error>error</a></code> . <code title=dom-MediaError-code><a href=#dom-mediaerror-code>code</a></code></dt> <dd> <p>Returns the current error's error code, from the list below.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-mediaerror-code title=dom-MediaError-code><code>code</code></dfn> attribute of a <code><a href=#mediaerror>MediaError</a></code> object must return the code for the error, which must be one of the following:</p> </div> <dl><dt><dfn id=dom-mediaerror-media_err_aborted title=dom-MediaError-MEDIA_ERR_ABORTED><code>MEDIA_ERR_ABORTED</code></dfn> (numeric value 1)</dt> <dd>The fetching process for the <a href=#media-resource>media resource</a> was aborted by the user agent at the user's request.</dd> <dt><dfn id=dom-mediaerror-media_err_network title=dom-MediaError-MEDIA_ERR_NETWORK><code>MEDIA_ERR_NETWORK</code></dfn> (numeric value 2)</dt> <dd>A network error of some description caused the user agent to stop fetching the <a href=#media-resource>media resource</a>, after the resource was established to be usable.</dd> <dt><dfn id=dom-mediaerror-media_err_decode title=dom-MediaError-MEDIA_ERR_DECODE><code>MEDIA_ERR_DECODE</code></dfn> (numeric value 3)</dt> <dd>An error of some description occurred while decoding the <a href=#media-resource>media resource</a>, after the resource was established to be usable.</dd> <dt><dfn id=dom-mediaerror-media_err_src_not_supported title=dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED><code>MEDIA_ERR_SRC_NOT_SUPPORTED</code></dfn> (numeric value 4)</dt> <dd>The <a href=#media-resource>media resource</a> indicated by the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute was not suitable.</dd> </dl><h5 id=location-of-the-media-resource><span class=secno>4.8.10.2 </span>Location of the media resource</h5> <p>The <dfn id=attr-media-src title=attr-media-src><code>src</code></dfn> content attribute on <a href=#media-element title="media element">media elements</a> gives the address 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>valid non-empty URL potentially surrounded by spaces</a>.</p> <p>The <dfn id=attr-media-crossorigin title=attr-media-crossorigin><code>crossorigin</code></dfn> content attribute on <a href=#media-element title="media element">media elements</a> is a <a href=#cors-settings-attribute>CORS settings attribute</a>.</p> <div class=impl> <p>If a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute of a <a href=#media-element>media element</a> is set or changed, the user agent must invoke the <a href=#media-element>media element</a>'s <a href=#media-element-load-algorithm>media element load algorithm</a>. (<em>Removing</em> the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute does not do this, even if there are <code><a href=#the-source-element>source</a></code> elements present.)</p> <p>The <dfn id=dom-media-src title=dom-media-src><code>src</code></dfn> IDL attribute on <a href=#media-element title="media element">media elements</a> must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-media-crossorigin title=dom-media-crossOrigin><code>crossOrigin</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> content attribute.</p> </div> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-currentSrc><a href=#dom-media-currentsrc>currentSrc</a></code></dt> <dd> <p>Returns the address of the current <a href=#media-resource>media resource</a>.</p> <p>Returns the empty string when there is no <a href=#media-resource>media resource</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-currentsrc title=dom-media-currentSrc><code>currentSrc</code></dfn> IDL attribute is initially the empty string. Its value is changed by the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> defined below.</p> </div> <p class=note>There are two ways to specify a <a href=#media-resource>media resource</a>, the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute, or <code><a href=#the-source-element>source</a></code> elements. The attribute overrides the elements.</p> <h5 id=mime-types><span class=secno>4.8.10.3 </span>MIME types</h5> <p>A <a href=#media-resource>media resource</a> can be described in terms of its <em>type</em>, specifically a <a href=#mime-type>MIME type</a>, in some cases with a <code title="">codecs</code> parameter. (Whether the <code title="">codecs</code> parameter is allowed or not depends on the MIME type.) <a href=#refsRFC4281>[RFC4281]</a></p> <p>Types are usually somewhat incomplete descriptions; for example "<code title="">video/mpeg</code>" doesn't say anything except what the container type is, and even a type like "<code title="">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 href=#mime-type>MIME type</a> "<code>application/octet-stream</code>" with no parameters is never <a href=#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 title=Content-Type>Content-Type metadata</a> when it is used to label a potential <a href=#media-resource>media resource</a>.</p> <p class=note> <!--FORK--> Only the <a href=#mime-type>MIME type</a> <!-- the WG decision started with the next bit, which is not in the style of the spec --> <!--FORK--> "<code>application/octet-stream</code>" <!--FORK--> with no parameters <!--FORK--> is special-cased here; if any parameter appears with it, it <!--FORK--> will <!-- the WG decision that led to this text had a "should", but this is a non-normative section --> be treated just like any other <a href=#mime-type>MIME type</a>. This is a deviation from the rule <!-- in RFC 2046, section 1, paragraph 3 --> that unknown <a href=#mime-type>MIME type</a> parameters should be ignored. <!-- but not really a "willful violation" since it's not that the types are not being ignored, just that before the type is handled as a type, there's a special case for a particular set of strings --> </p> <dl class=domintro><dt><var title="">media</var> . <code title=dom-navigator-canPlayType><a href=#dom-navigator-canplaytype>canPlayType</a></code>(<var title="">type</var>)</dt> <dd> <p>Returns the empty string (a negative response), "maybe", or "probably" based on how confident the user agent is that it can play media resources of the given type.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-navigator-canplaytype title=dom-navigator-canPlayType><code>canPlayType(<var title="">type</var>)</code></dfn> method must return the empty string if <var title="">type</var> is <a href=#a-type-that-the-user-agent-knows-it-cannot-render>a type that the user agent knows it cannot render</a> or is the type "<code>application/octet-stream</code>"; it must return "<code title="">probably</code>" if the user agent is confident that the type represents a <a href=#media-resource>media resource</a> that it can render if used in with this <code><a href=#the-audio-element>audio</a></code> or <code><a href=#the-video-element>video</a></code> element; and it must return "<code title="">maybe</code>" otherwise. Implementors are encouraged to return "<code title="">maybe</code>" unless the type can be confidently established as being supported or not. Generally, a user agent should never return "<code title="">probably</code>" for a type that allows the <code title="">codecs</code> parameter if that parameter is not present.</p> </div> <div class=example> <p>This script tests to see if the user agent supports a (fictional) new format to dynamically decide whether to use a <code><a href=#the-video-element>video</a></code> element or a plugin:</p> <pre><section id="video"> <p><a href="playing-cats.nfv">Download video</a></p> </section> <script> var videoSection = document.getElementById('video'); var videoElement = document.createElement('video'); var support = videoElement.canPlayType('video/x-new-fictional-format;codecs="kittens,bunnies"'); if (support != "probably" && "New Fictional Video Plugin" in navigator.plugins) { // not confident of browser support // but we have a plugin // so use plugin instead videoElement = document.createElement("embed"); } else if (support == "") { // no support from browser and no plugin // do nothing videoElement = null; } if (videoElement) { while (videoSection.hasChildNodes()) videoSection.removeChild(videoSection.firstChild); videoElement.setAttribute("src", "playing-cats.nfv"); videoSection.appendChild(videoElement); } </script></pre> </div> <p class=note>The <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute of the <code><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.10.4 </span>Network states</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code></dt> <dd> <p>Returns the current state of network activity for the element, from the codes in the list below.</p> </dd> </dl><div class=impl> <p>As <a href=#media-element title="media element">media elements</a> interact with the network, their current network activity is represented by the <dfn id=dom-media-networkstate title=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> </div> <dl><dt><dfn id=dom-media-network_empty title=dom-media-NETWORK_EMPTY><code>NETWORK_EMPTY</code></dfn> (numeric value 0)</dt> <dd>The element has not yet been initialized. All attributes are in their initial states.</dd> <dt><dfn id=dom-media-network_idle title=dom-media-NETWORK_IDLE><code>NETWORK_IDLE</code></dfn> (numeric value 1)</dt> <dd>The element<span class=impl>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> is active and</span> has selected a <a href=#media-resource title="media resource">resource</a>, but it is not actually using the network at this time.</dd> <dt><dfn id=dom-media-network_loading title=dom-media-NETWORK_LOADING><code>NETWORK_LOADING</code></dfn> (numeric value 2)</dt> <dd>The user agent is actively trying to download data.</dd> <dt><dfn id=dom-media-network_no_source title=dom-media-NETWORK_NO_SOURCE><code>NETWORK_NO_SOURCE</code></dfn> (numeric value 3)</dt> <dd>The element<span class=impl>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> is active, but it</span> has not yet found a <a href=#media-resource title="media resource">resource</a> to use.</dd> </dl><div class=impl> <p>The <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> defined below describes exactly when the <code title=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> </div> <h5 id=loading-the-media-resource><span class=secno>4.8.10.5 </span>Loading the media resource</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-load><a href=#dom-media-load>load</a></code>()</dt> <dd> <p>Causes the element to reset and start selecting and loading a new <a href=#media-resource>media resource</a> from scratch.</p> </dd> </dl><div class=impl> <p>All <a href=#media-element title="media element">media elements</a> have an <dfn id=autoplaying-flag>autoplaying 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>delaying-the-load-event flag</a> is true, the element must <a href=#delay-the-load-event>delay the load event</a> of its document.</p> <p>When the <dfn id=dom-media-load title=dom-media-load><code>load()</code></dfn> method on a <a href=#media-element>media element</a> is invoked, the user agent must run the <a href=#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 title=concept-media-load-algorithm>resource selection algorithm</a> for this element.</li> <li> <p>If there are any <a href=#concept-task title=concept-task>tasks</a> from the <a href=#media-element>media element</a>'s <a href=#media-element-event-task-source>media element event task source</a> in one of the <a href=#task-queue title="task queue">task queues</a>, then remove those tasks.</p> <p class=note>Basically, pending events and callbacks for the media element are discarded when the media element starts loading a new resource.</p> </li> <li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is set to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code> or <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-abort><a href=#event-media-abort>abort</a></code> at the <a href=#media-element>media element</a>.</li> <li> <p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is not set to <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then run these substeps:</p> <ol><li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-emptied><a href=#event-media-emptied>emptied</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>If a fetching process is in progress for the <a href=#media-element>media element</a>, the user agent should stop it.</li> <li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>.</li> <li><p><a href="#forget-the-media-element's-media-resource-specific-text-tracks">Forget the media element's media-resource-specific text tracks</a>.</li> <li><p>If <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is not set to <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then set it to that state. <!-- this can do the "report the controller state" thing --> </li> <li><p>If the <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, then set it to true.</li> <li><p>If <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> is true, set it to false.</li> <li> <p>Set the <a href=#current-playback-position>current playback position</a> to 0.</p> <p>Set the <a href=#official-playback-position>official playback position</a> to 0.</p> <p>If this changed the <a href=#official-playback-position>official playback position</a>, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the <a href=#media-element>media element</a>.</p> </li> <li><p>Set the <a href=#initial-playback-position>initial playback position</a> to 0.</li> <li><p>Set the <a href=#timeline-offset>timeline offset</a> to Not-a-Number (NaN).</li> <li> <p>Update the <code title=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 title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> event for this particular change of the duration.</p> </li> </ol></li> <li><p>Set the <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code> attribute to the value of the <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> attribute.</li> <li><p>Set the <code title=dom-media-error><a href=#dom-media-error>error</a></code> attribute to null and the <a href=#autoplaying-flag>autoplaying flag</a> to true.</li> <li><p>Invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> <li> <p class=note>Playback of any previously playing <a href=#media-resource>media resource</a> for this element stops.</p> </li> </ol><p>The <dfn id=concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</dfn> for a <a href=#media-element>media element</a> is as follows. This algorithm is always invoked synchronously, but one of the first steps in the algorithm is to return and continue running the remaining steps asynchronously, meaning that it runs in the background with scripts and other <a href=#concept-task title=concept-task>tasks</a> running in parallel. In addition, this algorithm interacts closely with the <a href=#event-loop>event loop</a> mechanism; in particular, it has <a href=#synchronous-section title="synchronous section">synchronous sections</a> (which are triggered as part of the <a href=#event-loop>event loop</a> algorithm). Steps in such sections are marked with ⌛.</p> <ol><!-- precondition: networkState == NETWORK_EMPTY at this point --><li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_NO_SOURCE><a href=#dom-media-network_no_source>NETWORK_NO_SOURCE</a></code>.</li> <li><p>Asynchronously <a href=#await-a-stable-state>await a stable state</a>, allowing the <a href=#concept-task title=concept-task>task</a> that invoked this algorithm to continue. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm until the algorithm says the <a href=#synchronous-section>synchronous section</a> has ended. (Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked with ⌛.)</li> <li> <p>⌛ If the <a href=#media-element>media element</a> has a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute, then let <var title="">mode</var> be <i title="">attribute</i>.</p> <p>⌛ Otherwise, if the <a href=#media-element>media element</a> does not have a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute but has a <code><a href=#the-source-element>source</a></code> element child, then let <var title="">mode</var> be <i title="">children</i> and let <var title="">candidate</var> be the first such <code><a href=#the-source-element>source</a></code> element child in <a href=#tree-order>tree order</a>.</p> <p>⌛ Otherwise the <a href=#media-element>media element</a> has neither a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute nor a <code><a href=#the-source-element>source</a></code> element child: set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, and abort these steps; the <a href=#synchronous-section>synchronous section</a> ends.</p> </li> <li><p>⌛ Set the <a href=#media-element>media element</a>'s <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to true (this <a href=#delay-the-load-event title="delay the load event">delays the load event</a>), and set its <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li> <li><p>⌛ <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-loadstart><a href=#event-media-loadstart>loadstart</a></code> at the <a href=#media-element>media element</a>.</li> <li> <p>If <var title="">mode</var> is <i title="">attribute</i>, then run these substeps:</p> <ol><li><p>⌛ <i>Process candidate</i>: If the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute's value is the empty string, then end the <a href=#synchronous-section>synchronous section</a>, and jump down to the <i title="">failed</i> step below.</li> <li><p>⌛ Let <var title="">absolute URL</var> be the <a href=#absolute-url>absolute URL</a> that would have resulted from <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> specified by the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute's value relative to the <a href=#media-element>media element</a> when the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute was last changed.</p> <!-- i.e. changing xml:base or <base> after src="" has no effect --> <li><p>⌛ If <var title="">absolute URL</var> was obtained successfully, set the <code title=dom-media-currentSrc><a href=#dom-media-currentsrc>currentSrc</a></code> attribute to <var title="">absolute URL</var>.</li> <li><p>End the <a href=#synchronous-section>synchronous section</a>, continuing the remaining steps asynchronously.</li> <li><p>If <var title="">absolute URL</var> was obtained successfully, run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource fetch algorithm</a> with <var title="">absolute URL</var>. If that algorithm returns without aborting <em>this</em> one, then the load failed.</li> <li> <p><i>Failed</i>: Reaching this step indicates that the media resource failed to load or that the given <a href=#url>URL</a> could not be <a href=#resolve-a-url title="resolve a url">resolved</a>. In one atomic operation, run the following steps:</p> <ol><li><p>Set the <code title=dom-media-error><a href=#dom-media-error>error</a></code> attribute to a new <code><a href=#mediaerror>MediaError</a></code> object whose <code title=dom-MediaError-code><a href=#dom-mediaerror-code>code</a></code> attribute is set to <code title=dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED><a href=#dom-mediaerror-media_err_src_not_supported>MEDIA_ERR_SRC_NOT_SUPPORTED</a></code>.</li> <li><p><a href="#forget-the-media-element's-media-resource-specific-text-tracks">Forget the media element's media-resource-specific text tracks</a>.</li> <li><p>Set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <a href=#dom-media-network_no_source title=dom-media-NETWORK_NO_SOURCE>NETWORK_NO_SOURCE</a> value.</li> </ol></li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-error><a href=#event-media-error>error</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">delaying the load event</a>.</li> <li><p>Abort these steps. Until the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method is invoked or the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute is changed, the element won't attempt to load another resource.</li> <!-- it took its ball and went home, sulking. --> </ol><p>Otherwise, the <code><a href=#the-source-element>source</a></code> elements will be used; run these substeps:</p> <ol><li> <p>⌛ Let <var title="">pointer</var> be a position defined by two adjacent nodes in the <a href=#media-element>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 title="">pointer</var>, and the other node is the node after <var title="">pointer</var>. Initially, let <var title="">pointer</var> be the position between the <var title="">candidate</var> node and the next node, if there are any, or the end of the list, if it is the last node.</p> <p>As nodes are inserted and removed into the <a href=#media-element>media element</a>, <var title="">pointer</var> must be updated as follows:</p> <dl><dt>If a new node is inserted between the two nodes that define <var title="">pointer</var></dt> <dd>Let <var title="">pointer</var> be the point between the node before <var title="">pointer</var> and the new node. In other words, insertions at <var title="">pointer</var> go after <var title="">pointer</var>.</dd> <dt>If the node before <var title="">pointer</var> is removed</dt> <dd>Let <var title="">pointer</var> be the point between the node after <var title="">pointer</var> and the node before the node after <var title="">pointer</var>. In other words, <var title="">pointer</var> doesn't move relative to the remaining nodes.</dd> <dt>If the node after <var title="">pointer</var> is removed</dt> <dd>Let <var title="">pointer</var> be the point between the node before <var title="">pointer</var> and the node after the node before <var title="">pointer</var>. Just as with the previous case, <var title="">pointer</var> doesn't move relative to the remaining nodes.</dd> </dl><p>Other changes don't affect <var title="">pointer</var>.</p> </li> <li><p>⌛ <i>Process candidate</i>: If <var title="">candidate</var> does not have a <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute, or if its <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute's value is the empty string, then end the <a href=#synchronous-section>synchronous section</a>, and jump down to the <i title="">failed</i> step below.</li> <li><p>⌛ Let <var title="">absolute URL</var> be the <a href=#absolute-url>absolute URL</a> that would have resulted from <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> specified by <var title="">candidate</var>'s <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute's value relative to the <var title="">candidate</var> when the <code title=attr-source-src><a href=#attr-source-src>src</a></code> attribute was last changed.</p> <!-- i.e. changing xml:base or <base> after src="" has no effect --> <li><p>⌛ If <var title="">absolute URL</var> was not obtained successfully, then end the <a href=#synchronous-section>synchronous section</a>, and jump down to the <i title="">failed</i> step below.</li> <li><p>⌛ If <var title="">candidate</var> has a <code title=attr-source-type><a href=#attr-source-type>type</a></code> attribute whose value, when parsed as a <a href=#mime-type>MIME type</a> (including any codecs described by the <code title="">codecs</code> parameter, for types that define that parameter), represents <a href=#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>synchronous section</a>, and jump down to the <i title="">failed</i> step below.</li> <li><p>⌛ If <var title="">candidate</var> has a <code title=attr-source-media><a href=#attr-source-media>media</a></code> attribute whose value does not <a href=#matches-the-environment title="matches the environment">match the environment</a>, then end the <a href=#synchronous-section>synchronous section</a>, and jump down to the <i title="">failed</i> step below.</li> <li><p>⌛ Set the <code title=dom-media-currentSrc><a href=#dom-media-currentsrc>currentSrc</a></code> attribute to <var title="">absolute URL</var>.</li> <li><p>End the <a href=#synchronous-section>synchronous section</a>, continuing the remaining steps asynchronously.</li> <li><p>Run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource fetch algorithm</a> with <var title="">absolute URL</var>. If that algorithm returns without aborting <em>this</em> one, then the load failed.</li> <li><p><i title="">Failed</i>: <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <var title="">candidate</var> element, in the context of the <a href=#fetch title=fetch>fetching process</a> that was used to try to obtain <var title="">candidate</var>'s corresponding <a href=#media-resource>media resource</a> in the <a href=#concept-media-load-resource title=concept-media-load-resource>resource fetch algorithm</a>.</li> <li><p>Asynchronously <a href=#await-a-stable-state>await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm until the algorithm says the <a href=#synchronous-section>synchronous section</a> has ended. (Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked with ⌛.)</li> <li><p>⌛ <a href="#forget-the-media-element's-media-resource-specific-text-tracks">Forget the media element's media-resource-specific text tracks</a>.</li> <li><p>⌛ <i title="">Find next candidate</i>: Let <var title="">candidate</var> be null.</li> <li><p>⌛ <i title="">Search loop</i>: If the node after <var title="">pointer</var> is the end of the list, then jump to the <i title="">waiting</i> step below.</li> <li><p>⌛ If the node after <var title="">pointer</var> is a <code><a href=#the-source-element>source</a></code> element, let <var title="">candidate</var> be that element.</li> <li><p>⌛ Advance <var title="">pointer</var> so that the node before <var title="">pointer</var> is now the node that was after <var title="">pointer</var>, and the node after <var title="">pointer</var> is the node after the node that used to be after <var title="">pointer</var>, if any.</li> <li><p>⌛ If <var title="">candidate</var> is null, jump back to the <i title="">search loop</i> step. Otherwise, jump back to the <i title="">process candidate</i> step.</li> <li><p>⌛ <i title="">Waiting</i>: Set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <a href=#dom-media-network_no_source title=dom-media-NETWORK_NO_SOURCE>NETWORK_NO_SOURCE</a> value.</li> <li><p>⌛ Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">delaying the load event</a>.</li> <li><p>End the <a href=#synchronous-section>synchronous section</a>, continuing the remaining steps asynchronously.</li> <li><p>Wait until the node after <var title="">pointer</var> is a node other than the end of the list. (This step might wait forever.)</li> <li><p>Asynchronously <a href=#await-a-stable-state>await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm until the algorithm says the <a href=#synchronous-section>synchronous section</a> has ended. (Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked with ⌛.)</li> <li><p>⌛ Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> back to true (this <a href=#delay-the-load-event title="delay the load event">delays the load event</a> again, in case it hasn't been fired yet).</p> <li><p>⌛ Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> back to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li> <li><p>⌛ Jump back to the <i title="">find next candidate</i> step above.</li> </ol></li> </ol><p>The <dfn id=concept-media-load-resource title=concept-media-load-resource>resource fetch algorithm</dfn> for a <a href=#media-element>media element</a> and a given <a href=#absolute-url>absolute URL</a> is as follows:</p> <ol><li><p>Let the <var title="">current media resource</var> be the resource given by the <a href=#absolute-url>absolute URL</a> passed to this algorithm. This is now the element's <a href=#media-resource>media resource</a>.</li> <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 use requests it explicitly (e.g. as a way to implement the <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute's <code title=attr-media-preload-none><a href=#attr-media-preload-none>none</a></code> keyword).</p> <ol><li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code>.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-suspend><a href=#event-media-suspend>suspend</a></code> at the element.</li> <li><p>Wait for the task to be run.</li> <li><p>Wait for an implementation-defined event (e.g. the user requesting that the media element begin playback).</li> <li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li> </ol></li> <li> <p>Perform a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the <var title="">current media resource</var>'s <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being the state of the <a href=#media-element>media element</a>'s <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> content attribute, the <i title="">origin</i> being the <a href=#origin>origin</a> of the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code>, and the <i>default origin behaviour</i> set to <i>taint</i>.</p> <p>The resource obtained in this fashion, if any, contains the <a href=#media-data>media data</a>. It can be <a href=#cors-same-origin>CORS-same-origin</a> or <a href=#cors-cross-origin>CORS-cross-origin</a>; this affects whether subtitles referenced in the <a href=#media-data>media data</a> are exposed in the API and, for <code><a href=#the-video-element>video</a></code> elements, whether a <code><a href=#the-canvas-element>canvas</a></code> gets tainted when the video is drawn on it.</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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-progress><a href=#event-media-progress>progress</a></code> at the element.</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>media element</a> that is actively attempting to obtain <a href=#media-data>media data</a> has failed to receive any data for a duration equal to the <a href=#stall-timeout>stall timeout</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=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>media data</a> downloads. When a <a href=#media-element>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, or while waiting for user input in an interactive resource. When a <a href=#media-element>media element</a>'s download has been suspended, the user agent must <a href=#queue-a-task>queue a task</a> to set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-suspend><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>queue a task</a> to set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>. Between the queuing of these tasks, the load is suspended (so <code title=event-media-progress><a href=#event-media-progress>progress</a></code> events don't fire, as described above).</p> <p class=note>The <code title=attr-media-preload><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 title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code> attribute.</p> <p>When a user agent decides to completely stall a download, e.g. if it is waiting until the user starts playback before downloading any further content, the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> must be set to false. This stops <a href=#delay-the-load-event title="delay the load event">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>The <a href=#networking-task-source>networking task source</a> <a href=#concept-task title=concept-task>tasks</a> to process the data as it is being fetched must, when appropriate, include the relevant substeps from the following list:</p> <dl class=switch><dt>If the <a href=#media-data>media data</a> cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource</dt> <dt>If the <a href=#media-resource>media resource</a> is found to have <a href=#content-type title=Content-Type>Content-Type metadata</a> that, when parsed as a <a href=#mime-type>MIME type</a> (including any codecs described by the <code title="">codecs</code> parameter, if the parameter is defined for that type), represents <a href=#a-type-that-the-user-agent-knows-it-cannot-render>a type that the user agent knows it cannot render</a> (even if the actual <a href=#media-data>media data</a> is in a supported format)</dt> <dt>If the <a href=#media-data>media data</a> can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all</dt> <dd> <p>DNS errors, HTTP 4xx and 5xx errors (and equivalents in other protocols), and other fatal network errors that occur before the user agent has established whether the <var title="">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> <li><p>Abort this subalgorithm, returning to the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</p> </ol></dd> <!-- insert content sniffing here if we want to define that --> <!-- (in practice I don't think that's necessary since it's not like you can do anything with the resource if you sniff it as the wrong type) --> <dt id=found-another-audio-track>If the <a href=#media-resource>media resource</a> is found to have an audio track</dt> <dd> <ol><li><p>Create an <code><a href=#audiotrack>AudioTrack</a></code> object to represent the audio track.</li> <li><p>Update the <a href=#media-element>media element</a>'s <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> attribute's <code><a href=#audiotracklist>AudioTrackList</a></code> object with the new <code><a href=#audiotrack>AudioTrack</a></code> object.</li> <li><p>Fire an event with the name <code title=event-addtrack>addtrack</code>, that does not bubble and is not cancelable, and that uses the <code><a href=#trackevent>TrackEvent</a></code> interface, with the <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code> attribute initialized to the new <code><a href=#audiotrack>AudioTrack</a></code> object, at this <code><a href=#audiotracklist>AudioTrackList</a></code> object.</li> </ol></dd> <dt id=found-another-video-track>If the <a href=#media-resource>media resource</a> is found to have a video track</dt> <dd> <ol><li><p>Create a <code><a href=#videotrack>VideoTrack</a></code> object to represent the video track.</li> <li><p>Update the <a href=#media-element>media element</a>'s <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> attribute's <code><a href=#videotracklist>VideoTrackList</a></code> object with the new <code><a href=#videotrack>VideoTrack</a></code> object.</li> <li><p>Fire an event with the name <code title=event-addtrack>addtrack</code>, that does not bubble and is not cancelable, and that uses the <code><a href=#trackevent>TrackEvent</a></code> interface, with the <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code> attribute initialized to the new <code><a href=#videotrack>VideoTrack</a></code> object, at this <code><a href=#videotracklist>VideoTrackList</a></code> object.</li> </ol></dd> <dt id=getting-media-metadata>Once enough of the <a href=#media-data>media data</a> has been fetched to determine the duration of the <a href=#media-resource>media resource</a>, its dimensions, and other metadata</dt> <dd> <p>This indicates that the resource is usable. The user agent must follow these substeps:</p> <ol><li> <p><a href=#defineTimeline>Establish the media timeline</a> for the purposes of the <a href=#current-playback-position>current playback position</a>, the <a href=#earliest-possible-position>earliest possible position</a>, and the <a href=#initial-playback-position>initial playback position</a>, based on the <a href=#media-data>media data</a>.</p> </li> <li> <p>Update the <a href=#timeline-offset>timeline offset</a> to the date and time that corresponds to the zero time in the <a href=#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>media resource</a>, the <a href=#timeline-offset>timeline offset</a> must be set to Not-a-Number (NaN).</p> </li> <li><p>Set the <a href=#current-playback-position>current playback position</a> and the <a href=#official-playback-position>official playback position</a> to the <a href=#earliest-possible-position>earliest possible position</a>.</li> <li> <p>Update the <code title=dom-media-duration><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>media timeline</a> established above. If it is not known (e.g. a stream that is in principle infinite), update the <code title=dom-media-duration><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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> at the element at this point.</p> </li> <li><p>For <code><a href=#the-video-element>video</a></code> elements, set the <code title=dom-video-videoWidth><a href=#dom-video-videowidth>videoWidth</a></code> and <code title=dom-video-videoHeight><a href=#dom-video-videoheight>videoHeight</a></code> attributes.</li> <li> <p>Set the <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute to <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code>.</p> <p class=note>A <code title=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 title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute to a new value.</p> <!-- this can also do the "report the controller state" thing --> </li> <li><p>Let <var title="">jumped</var> be false.</li> <li><p>If the <a href=#media-element>media element</a>'s <a href=#default-playback-start-position>default playback start position</a> is greater than zero, then <a href=#dom-media-seek title=dom-media-seek>seek</a> to that time, and let <var title="">jumped</var> be true.</li> <li><p>Let the <a href=#media-element>media element</a>'s <a href=#default-playback-start-position>default playback start position</a> be zero.</li> <li> <p>If either the <a href=#media-resource>media resource</a> or the address of the <var title="">current media resource</var> indicate a particular start time, then set the <a href=#initial-playback-position>initial playback position</a> to that time and, if <var title="">jumped</var> is still false, <a href=#dom-media-seek title=dom-media-seek>seek</a> to that time and let <var title="">jumped</var> be true.</p> <p class=example>For example, with media formats that support the <cite>Media Fragments URI</cite> fragment identifier syntax, the fragment identifier can be used to indicate a start position. <a href=#refsMEDIAFRAG>[MEDIAFRAG]</a></p> </li> <li> <p>If either the <a href=#media-resource>media resource</a> or the address of the <var title="">current media resource</var> indicate a particular set of audio or video tracks to enable, then the selected audio tracks must be enabled in the element's <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> object, and, of the selected video tracks, the one that is listed first in the element's <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> object must be selected.</p> </li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then: if <var title="">jumped</var> is true and the <a href=#initial-playback-position>initial playback position</a>, relative to the <a href=#current-media-controller>current media controller</a>'s timeline, is greater than the <a href=#current-media-controller>current media controller</a>'s <a href=#media-controller-position>media controller position</a>, then <a href=#seek-the-media-controller>seek the media controller</a> to the <a href=#media-element>media element</a>'s <a href=#initial-playback-position>initial playback position</a>, relative to the <a href=#current-media-controller>current media controller</a>'s timeline; otherwise, <a href=#dom-media-seek title=dom-media-seek>seek</a> the <a href=#media-element>media element</a> to the <a href=#media-controller-position>media controller position</a>, relative to the <a href=#media-element>media element</a>'s timeline.</li> <!-- i.e. "bring the media element up to speed with its new media controller" --> <!-- we do this because otherwise the fragment identifier initial position is lost. Basically this means that if you are attached to a media controller when you load your resource, and you have a fragment identifier with a start time, you'll jump the media controller to that time if it's not already past it. (So if there are several, you'll jump the media controller to the furthest one in the timeline.) --> </ol><p>Once the <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute reaches <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code>, <a href=#fire-loadeddata>after the <code title=event-media-loadeddata>loadeddata</code> event has been fired</a>, set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">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>media resource</a> would also stop buffering at this point, following <a href=#resourceSuspend>the rules described previously</a>, which involve the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute switching to the <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> value and a <code title=event-suspend>suspend</code> event firing.</p> <p class=note>The user agent is <em>required</em> to determine the duration of the <a href=#media-resource>media resource</a> and go through this step before playing.</p> <!-- actually defined in the 'duration' section --> </dd> <dt>Once the entire <a href=#media-resource>media resource</a> has been <a href=#fetch title=fetch>fetched</a> (but potentially before any of it has been decoded)</dt> <dd> <p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-media-progress><a href=#event-media-progress>progress</a></code> at the <a href=#media-element>media element</a>.</p> <p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-suspend><a href=#event-media-suspend>suspend</a></code> at the <a href=#media-element>media element</a>.</p> <p>If the user agent ever discards any <a href=#media-data>media data</a> and then needs to resume the network activity to obtain it again, then it must <a href=#queue-a-task>queue a task</a> to set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><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>media resource</a> loaded, then the algorithm will continue to its final step below, which aborts the algorithm.</p><!-- see FINAL STEP below --> </dd> <dt>If the connection is interrupted after some <a href=#media-data>media data</a> has been received, causing the user agent to give up trying to fetch the resource</dt> <dd> <p>Fatal network errors that occur after the user agent has established whether the <var title="">current media resource</var> is usable (i.e. once the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is no longer <code title=dom-media-HAVE_NOTHING><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> <li><p>Set the <code title=dom-media-error><a href=#dom-media-error>error</a></code> attribute to a new <code><a href=#mediaerror>MediaError</a></code> object whose <code title=dom-MediaError-code><a href=#dom-mediaerror-code>code</a></code> attribute is set to <code title=dom-MediaError-MEDIA_ERR_NETWORK><a href=#dom-mediaerror-media_err_network>MEDIA_ERR_NETWORK</a></code>.</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-media-error><a href=#event-media-error>error</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>Set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> value.</li> <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">delaying the load event</a>.</li> <li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> </ol></dd> <dt id=fatal-decode-error>If the <a href=#media-data>media data</a> is corrupted</dt> <dd> <p>Fatal errors in decoding the <a href=#media-data>media data</a> that occur after the user agent has established whether the <var title="">current media resource</var> is usable must cause the user agent to execute the following steps:</p> <ol><li><p>The user agent should cancel the fetching process.</li> <li><p>Set the <code title=dom-media-error><a href=#dom-media-error>error</a></code> attribute to a new <code><a href=#mediaerror>MediaError</a></code> object whose <code title=dom-MediaError-code><a href=#dom-mediaerror-code>code</a></code> attribute is set to <code title=dom-MediaError-MEDIA_ERR_DECODE><a href=#dom-mediaerror-media_err_decode>MEDIA_ERR_DECODE</a></code>.</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-media-error><a href=#event-media-error>error</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute has a value equal to <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> value and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-emptied><a href=#event-media-emptied>emptied</a></code> at the element. Otherwise, set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> value.</li> <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">delaying the load event</a>.</li> <li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> </ol></dd> <dt>If the <a href=#media-data>media data</a> fetching process is aborted by the user</dt> <dd> <p>The fetching process is aborted by the user, e.g. because the user navigated the browsing context to another page, the user agent must execute the following steps. These steps are not followed if the <code title=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> <li><p>Set the <code title=dom-media-error><a href=#dom-media-error>error</a></code> attribute to a new <code><a href=#mediaerror>MediaError</a></code> object whose <code title=dom-MediaError-code><a href=#dom-mediaerror-code>code</a></code> attribute is set to <code title=dom-MediaError-MEDIA_ERR_ABORTED><a href=#dom-mediaerror-media_err_aborted>MEDIA_ERR_ABORTED</a></code>.</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-media-abort><a href=#event-media-abort>abort</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute has a value equal to <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> value and <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-emptied><a href=#event-media-emptied>emptied</a></code> at the element. Otherwise, set the element's <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute to the <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> value.</li> <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load event">delaying the load event</a>.</li> <li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> </ol></dd> <dt id=non-fatal-media-error>If the <a href=#media-data>media data</a> can be fetched but has non-fatal errors or uses, in part, codecs that are unsupported, preventing the user agent from rendering the content completely correctly but not preventing playback altogether</dt> <dd> <p>The server returning data that is partially usable but cannot be optimally rendered must cause the user agent to render just the bits it can handle, and ignore the rest.</p> <!-- v2: fire a 'warning' event and set the 'error' flag to 'MEDIA_ERR_SUBOPTIMAL' or something --> </dd> <dt id=found-a-media-resource-specific-timed-track>If the <a href=#media-resource>media resource</a> is found to declare a <a href=#media-resource-specific-text-track>media-resource-specific text track</a> that the user agent supports</dt> <dd> <p>If the <a href=#media-data>media data</a> is <a href=#cors-same-origin>CORS-same-origin</a>, run the <a href=#steps-to-expose-a-media-resource-specific-text-track>steps to expose a media-resource-specific text track</a> with the relevant data.</p> <p class=note>Cross-origin videos do not expose their subtitles, since that would allow attacks such as hostile sites reading subtitles from confidential videos on a user's intranet.</p> </dd> </dl><p>When the <a href=#networking-task-source>networking task source</a> has <a href=#queue-a-task title="queue a task">queued</a> the last <a href=#concept-task title=concept-task>task</a> as part of <a href=#fetch title=fetch>fetching</a> the <a href=#media-resource>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 next step. 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>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 title="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 title="ended playback">playback has ended</a>, the user agent will end up firing a <code title=event-media-suspend><a href=#event-media-suspend>suspend</a></code> event, as described earlier.</p> </li> <!-- this step is mentioned above, search for "FINAL STEP" --> <li><p>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 title=concept-media-load-algorithm>resource selection algorithm</a>.</li> </ol></div> <hr><p>The <dfn id=attr-media-preload title=attr-media-preload><code>preload</code></dfn> attribute is an <a href=#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-media-preload-none title=attr-media-preload-none><code>none</code></dfn> <td><dfn id=attr-media-preload-none-state title=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 minimise unnecessary traffic. <tr><td><dfn id=attr-media-preload-metadata title=attr-media-preload-metadata><code>metadata</code></dfn> <td><dfn id=attr-media-preload-metadata-state title=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, first frame, track list, duration, etc) is reasonable. If the user agent precisely fetches no more than the metadata, then the <a href=#media-element>media element</a> will end up with its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute set to <code title=dom-media-HAVE_METADATA><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 title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>. <tr><td><dfn id=attr-media-preload-auto title=attr-media-preload-auto><code>auto</code></dfn> <td><dfn id=attr-media-preload-auto-state title=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 title=attr-media-preload-auto-state>Automatic</a> state. The attribute's <i>missing value default</i> is user-agent defined, though the <a href=#attr-media-preload-metadata-state title=attr-media-preload-metadata-state>Metadata</a> state is suggested as a compromise between reducing server load and providing an optimal user experience.</p> <div class=impl> <p>The <code title=attr-media-preload><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 title=dom-media-preload><code>preload</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> </div> <p class=note>The <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code> attribute can override the <code title=attr-media-preload><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 title=attr-media-preload><a href=#attr-media-preload>preload</a></code> attribute). Including both is not an error, however.</p> <hr><!--v3BUF (when readding this, also add a domintro block) <p>The <dfn title="dom-media-bufferingRate"><code>bufferingRate</code></dfn> attribute must return the average number of bits received per second for the current download over the past few seconds. If there is no download in progress, the attribute must return 0.</p> <p>The <dfn title="dom-media-bufferingThrottled"><code>bufferingThrottled</code></dfn> attribute must return true if the user agent is intentionally throttling the bandwidth used by the download (including when throttling to zero to pause the download altogether), and false otherwise.</p> <hr> --><dl class=domintro><dt><var title="">media</var> . <code title=dom-media-buffered><a href=#dom-media-buffered>buffered</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the ranges of the <a href=#media-resource>media resource</a> that the user agent has buffered.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-buffered title=dom-media-buffered><code>buffered</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the ranges of the <a href=#media-resource>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 title=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> </div> <h5 id=offsets-into-the-media-resource><span class=secno>4.8.10.6 </span>Offsets into the media resource</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-duration><a href=#dom-media-duration>duration</a></code></dt> <dd> <p>Returns the length of the <a href=#media-resource>media resource</a>, in seconds, assuming that the start of the <a href=#media-resource>media resource</a> is at time zero.</p> <p>Returns NaN if the duration isn't available.<p> <p>Returns Infinity for unbounded streams.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#official-playback-position>official playback position</a>, in seconds.</p> <p>Can be set, to seek to the given time.<p> <p>Will throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if there is no selected <a href=#media-resource>media resource</a> or if there is a <a href=#current-media-controller>current media controller</a>.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-initialTime><a href=#dom-media-initialtime>initialTime</a></code></dt> <dd> <p>Returns the <a href=#initial-playback-position>initial playback position</a>, that is, time to which the <a href=#media-resource>media resource</a> was automatically seeked when it was loaded. Returns zero if the <a href=#initial-playback-position>initial playback position</a> is still unknown.</p> </dd> </dl><div class=impl> <p>A <a href=#media-resource>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>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 title="establish the media timeline">Establishing the media timeline</dfn>: If the <a href=#media-resource>media resource</a> somehow specifies an explicit timeline whose origin is not negative, then the <a href=#media-timeline>media timeline</a> should be that timeline. (Whether the <a href=#media-resource>media resource</a> can specify a timeline or not depends on the <a href=#media-resource title="media resource">media resource's</a> format.) If the <a href=#media-resource>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>media timeline</a>; the <a href=#timeline-offset>timeline offset</a> will be the time and date, exposed using the <code title=dom-media-startOffsetTime><a href=#dom-media-startoffsettime>startOffsetTime</a></code> attribute.</p> <p>If the <a href=#media-resource>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>media timeline</a> of the <a href=#media-resource>media resource</a> increases linearly starting from the <a href=#earliest-possible-position>earliest possible position</a> (as defined below), even if the underlying <a href=#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 absence of an explicit timeline, the zero time on the <a href=#media-timeline>media timeline</a> should correspond to the first frame of the <a href=#media-resource>media resource</a>. For static audio and video files this is generally trivial. For streaming resources, if the user agent will 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>media resource</a>; otherwise, it should correspond to the first frame received from the server (the point in the <a href=#media-resource>media resource</a> at which the user agent began receiving the stream).</p> <p class=example>Another example would be 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. 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>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 title=dom-media-duration><a href=#dom-media-duration>duration</a></code> attribute would then return 3,600. The <code title=dom-media-startOffsetTime><a href=#dom-media-startoffsettime>startOffsetTime</a></code> attribute would return a <code>Date</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>media timeline</a> starting at 0s and extending to 3,300s (fifty five minutes). In this case, the <code title=dom-media-startOffsetTime><a href=#dom-media-startoffsettime>startOffsetTime</a></code> attribute would return a <code>Date</code> object with a time corresponding to 2010-03-20 23:20:00 UTC.</p> <p>In any case, the user agent must ensure that the <a href=#earliest-possible-position>earliest possible position</a> (as defined below) using the established <a href=#media-timeline>media timeline</a>, is greater than or equal to zero.</p> <p>The <a href=#media-timeline>media timeline</a> also has an associated clock. Which clock is used is user-agent defined, and may be <a href=#media-resource>media resource</a>-dependent, but it should approximate the user's wall clock.</p> <p class=note>All the <a href=#media-element title="media element">media elements</a> that share <a href=#current-media-controller>current media controller</a> use the same clock for their <a href=#media-timeline>media timeline</a>.</p> <p><a href=#media-element title="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>media data</a>) be zero seconds. The <a href=#current-playback-position>current playback position</a> is a time on the <a href=#media-timeline>media timeline</a>.</p> <p><a href=#media-element title="media element">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>official playback position</a> is an approximation of the <a href=#current-playback-position>current playback position</a> that is kept stable while scripts are running.</p> <p><a href=#media-element title="media element">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>The <dfn id=dom-media-currenttime title=dom-media-currentTime><code>currentTime</code></dfn> attribute must, on getting, return the <a href=#media-element>media element</a>'s <a href=#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>official playback position</a>. The returned value must be expressed in seconds. On setting, if the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then the user agent must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception; otherwise, if the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then it must set the <a href=#media-element>media element</a>'s <a href=#default-playback-start-position>default playback start position</a> to the new value; otherwise, it must set the <a href=#official-playback-position>official playback position</a> to the new value and then <a href=#dom-media-seek title=dom-media-seek>seek</a> to the new value. The new value must be interpreted as being in seconds.</p> <p><a href=#media-element title="media element">Media elements</a> have an <dfn id=initial-playback-position>initial playback position</dfn>, which must initially (i.e. in the absence of <a href=#media-data>media data</a>) be zero seconds. The <a href=#initial-playback-position>initial playback position</a> is updated when a <a href=#media-resource>media resource</a> is loaded. The <a href=#initial-playback-position>initial playback position</a> is a time on the <a href=#media-timeline>media timeline</a>.</p> <p>The <dfn id=dom-media-initialtime title=dom-media-initialTime><code>initialTime</code></dfn> attribute must, on getting, return the <a href=#initial-playback-position>initial playback position</a>, expressed in seconds.</p> <p>If the <a href=#media-resource>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 title="media resource">media resources</a> might have a <a href=#media-timeline>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>media timeline</a>.</p> <p class=note>The <a href=#earliest-possible-position>earliest possible position</a> is not explicitly exposed in the API; it corresponds to the start time of the first range in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute's <code><a href=#timeranges>TimeRanges</a></code> object, if any, or the <a href=#current-playback-position>current playback position</a> otherwise.</p> <p>When the <a href=#earliest-possible-position>earliest possible position</a> changes, then: if the <a href=#current-playback-position>current playback position</a> is before the <a href=#earliest-possible-position>earliest possible position</a>, the user agent must <a href=#dom-media-seek title=dom-media-seek>seek</a> to the <a href=#earliest-possible-position>earliest possible position</a>; otherwise, if the user agent has not fired a <code title=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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><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 title=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>current playback position</a> can never be less than the <a href=#earliest-possible-position>earliest possible position</a>.</p> <p>The <dfn id=dom-media-duration title=dom-media-duration><code>duration</code></dfn> attribute must return the time of the end of the <a href=#media-resource>media resource</a>, in seconds, on the <a href=#media-timeline>media timeline</a>. If no <a href=#media-data>media data</a> is available, then the attributes must return the Not-a-Number (NaN) value. If the <a href=#media-resource>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>media resource</a> before playing any part of the <a href=#media-data>media data</a> and before setting <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> to a value equal to or greater than <code title=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>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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> at the <a href=#media-element>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>current playback position</a> ends up being greater than the time of the end of the <a href=#media-resource>media resource</a>, then the user agent must also <a href=#dom-media-seek title=dom-media-seek>seek</a> the to the time of the end of the <a href=#media-resource>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 title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> event would be fired. Similarly, if the user agent initially estimated the <a href=#media-resource>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 title=event-media-durationchange><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>media timeline</a>, known as the <dfn id=timeline-offset>timeline offset</dfn>. Initially, the <a href=#timeline-offset>timeline offset</a> must be set to Not-a-Number (NaN).</p> <p>The <dfn id=dom-media-startoffsettime title=dom-media-startOffsetTime><code>startOffsetTime</code></dfn> attribute must return a new <code>Date</code> object representing the current <a href=#timeline-offset>timeline offset</a>.</p> </div> <hr><p>The <dfn id=attr-media-loop title=attr-media-loop><code>loop</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> that, if specified, indicates that the <a href=#media-element>media element</a> is to seek back to the start of the <a href=#media-resource>media resource</a> upon reaching the end.</p> <p>The <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code> attribute has no effect while the element has a <a href=#current-media-controller>current media controller</a>.</p> <div class=impl> <p>The <dfn id=dom-media-loop title=dom-media-loop><code>loop</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <h5 id=ready-states><span class=secno>4.8.10.7 </span>Ready states</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code></dt> <dd> <p>Returns a value that expresses the current state of the element with respect to rendering the <a href=#current-playback-position>current playback position</a>, from the codes in the list below.</p> </dd> </dl><div class=impl> <p><a href=#media-element title="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>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> </div> <dl><dt><dfn id=dom-media-have_nothing title=dom-media-HAVE_NOTHING><code>HAVE_NOTHING</code></dfn> (numeric value 0)</dt> <dd>No information regarding the <a href=#media-resource>media resource</a> is available. No data for the <a href=#current-playback-position>current playback position</a> is available. <a href=#media-element title="media element">Media elements</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute are set to <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> are always in the <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code> state.</dd> <dt><dfn id=dom-media-have_metadata title=dom-media-HAVE_METADATA><code>HAVE_METADATA</code></dfn> (numeric value 1)</dt> <dd>Enough of the resource has been obtained that the duration of the resource is available. In the case of a <code><a href=#the-video-element>video</a></code> element, the dimensions of the video are also available. The API will no longer throw an exception when seeking. No <a href=#media-data>media data</a> is available for the immediate <a href=#current-playback-position>current playback position</a>.</dd> <dt><dfn id=dom-media-have_current_data title=dom-media-HAVE_CURRENT_DATA><code>HAVE_CURRENT_DATA</code></dfn> (numeric value 2)</dt> <dd>Data for the immediate <a href=#current-playback-position>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>current playback position</a> in the <a href=#direction-of-playback>direction of playback</a> at all without immediately reverting to the <code title=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>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>current playback position</a> is at the end of the current frame; and to when <a href=#ended-playback title="ended playback">playback has ended</a>.</dd> <dt><dfn id=dom-media-have_future_data title=dom-media-HAVE_FUTURE_DATA><code>HAVE_FUTURE_DATA</code></dfn> (numeric value 3)</dt> <dd>Data for the immediate <a href=#current-playback-position>current playback position</a> is available, as well as enough data for the user agent to advance the <a href=#current-playback-position>current playback position</a> in the <a href=#direction-of-playback>direction of playback</a> at least a little without immediately reverting to the <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> state, and <a href=#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>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>current playback position</a> is in the middle of a frame. The user agent cannot be in this state if <a href=#ended-playback title="ended playback">playback has ended</a>, as the <a href=#current-playback-position>current playback position</a> can never advance in this case.</dd> <dt><dfn id=dom-media-have_enough_data title=dom-media-HAVE_ENOUGH_DATA><code>HAVE_ENOUGH_DATA</code></dfn> (numeric value 4)</dt> <dd>All the conditions described for the <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> state are met, and, in addition, the user agent estimates that data is being fetched at a rate where the <a href=#current-playback-position>current playback position</a>, if it were to advance at the <a href=#effective-playback-rate>effective playback rate</a>, would not overtake the available data before playback reaches the end of the <a href=#media-resource>media resource</a>.</dd> </dl><p class=note>In practice, the difference between <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> and <code title=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><a href=#the-video-element>video</a></code> element onto a <code><a href=#the-canvas-element>canvas</a></code>, where it distinguishes the case where something will be drawn (<code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or greater) from the case where nothing is drawn (<code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> or less). Similarly, the difference between <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> (only the current frame) and <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> (at least this frame and the next) can be negligible (in the extreme, only one frame). The only time that distinction really matters is when a page provides an interface for "frame-by-frame" navigation.</p> <div class=impl> <p>When the ready state of a <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is not <code title=dom-media-NETWORK_EMPTY><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><!-- going up to metadata --><dt>If the previous ready state was <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, and the new ready state is <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code></dt> <dd id=fire-loadedmetadata> <p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=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 event loop mechanism, the rendering will have been updated to resize the <code><a href=#the-video-element>video</a></code> element if appropriate.</p> </dd> <!-- going up to current for the first time --> <dt id=handling-first-frame-available>If the previous ready state was <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> and the new ready state is <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or greater</dt> <dd> <p id=fire-loadeddata>If this is the first time this occurs for this <a href=#media-element>media element</a> since the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> algorithm was last invoked, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-loadeddata><a href=#event-media-loadeddata>loadeddata</a></code> at the element.</p> <p>If the new ready state is <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> or <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code>, then the relevant steps below must then be run also.</p> </dd> <!-- going down --> <dt>If the previous ready state was <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> or more, and the new ready state is <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or less</dt> <dd> <p id=fire-waiting-when-waiting>If the <a href=#media-element>media element</a> was <a href=#potentially-playing>potentially playing</a> before its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute changed to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, and the element has not <a href=#ended-playback>ended playback</a>, and playback has not <a href=#stopped-due-to-errors>stopped due to errors</a>, and playback has not <a href=#paused-for-user-interaction>paused for user interaction</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element, and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at the element.</p> </dd> <!-- going up to future --> <dt>If the previous ready state was <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or less, and the new ready state is <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code></dt> <dd> <p>The user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-canplay><a href=#event-media-canplay>canplay</a></code>.</p> <p>If the element's <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-playing><a href=#event-media-playing>playing</a></code>.</p> </dd> <!-- going up to enough --> <dt>If the new ready state is <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code></dt> <dd> <p>If the previous ready state was <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or less, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-canplay><a href=#event-media-canplay>canplay</a></code>, and, if the element's <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-playing><a href=#event-media-playing>playing</a></code>.</p> <p>If the <a href=#autoplaying-flag>autoplaying flag</a> is true, and the <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is true, and the <a href=#media-element>media element</a> has an <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code> attribute specified, and the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-automatic-features-browsing-context-flag>sandboxed automatic features browsing context flag</a> set when the <code><a href=#document>Document</a></code> was created, then the user agent may also set the <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute to false, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-play><a href=#event-media-play>play</a></code>, and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-playing><a href=#event-media-playing>playing</a></code>.</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 title=attr-media-autoplay><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> <p>In any case, the user agent must finally <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-canplaythrough><a href=#event-media-canplaythrough>canplaythrough</a></code>.</p> </dd> </dl></li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>.</li> </ol></div> <p class=note>It is possible for the ready state of a media element to jump between these states discontinuously. For example, the state of a media element can jump straight from <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> to <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code> without passing through the <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> and <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> states.</p> <div class=impl> <p>The <dfn id=dom-media-readystate title=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>media element</a>.</p> </div> <p>The <dfn id=attr-media-autoplay title=attr-media-autoplay><code>autoplay</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When present, the user agent <span class=impl>(as described in the algorithm described herein)</span> will automatically begin playback of the <a href=#media-resource>media resource</a> as soon as it can do so without stopping.</p> <p class=note>Authors are urged to use the <code title=attr-media-autoplay><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> <div class=impl> <p>The <dfn id=dom-media-autoplay title=dom-media-autoplay><code>autoplay</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <h5 id=playing-the-media-resource><span class=secno>4.8.10.8 </span>Playing the media resource</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code></dt> <dd> <p>Returns true if playback is paused; false otherwise.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-ended><a href=#dom-media-ended>ended</a></code></dt> <dd> <p>Returns true if playback has reached the end of the <a href=#media-resource>media resource</a>.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the default rate of playback, for when the user is not fast-forwarding or reversing through the <a href=#media-resource>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> <p>When the element has a <a href=#current-media-controller>current media controller</a>, the <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> attribute is ignored and the <a href=#current-media-controller>current media controller</a>'s <code title=dom-MediaController-defaultPlaybackRate><a href=#dom-mediacontroller-defaultplaybackrate>defaultPlaybackRate</a></code> is used instead.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current rate playback, where 1.0 is normal speed.</p> <p>Can be set, to change the rate of playback.</p> <p>When the element has a <a href=#current-media-controller>current media controller</a>, the <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code> attribute is ignored and the <a href=#current-media-controller>current media controller</a>'s <code title=dom-MediaController-playbackRate><a href=#dom-mediacontroller-playbackrate>playbackRate</a></code> is used instead.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-played><a href=#dom-media-played>played</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the ranges of the <a href=#media-resource>media resource</a> that the user agent has played.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-play><a href=#dom-media-play>play</a></code>()</dt> <dd> <p>Sets the <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute to false, loading the <a href=#media-resource>media resource</a> and beginning playback if necessary. If the playback had ended, will restart it from the start.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-pause><a href=#dom-media-pause>pause</a></code>()</dt> <dd> <p>Sets the <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute to true, loading the <a href=#media-resource>media resource</a> if necessary.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-paused title=dom-media-paused><code>paused</code></dfn> attribute represents whether the <a href=#media-element>media element</a> is paused or not. The attribute must initially be true.</p> <p>A <a href=#media-element>media element</a> is a <dfn id=blocked-media-element>blocked media element</dfn> if its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is in the <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code> state, the <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> state, or the <code title=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>paused for user interaction</a>.</p> <p>A <a href=#media-element>media element</a> is said to be <dfn id=potentially-playing>potentially playing</dfn> when its <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, the element has not <a href=#ended-playback>ended playback</a>, playback has not <a href=#stopped-due-to-errors>stopped due to errors</a>, the element either has no <a href=#current-media-controller>current media controller</a> or has a <a href=#current-media-controller>current media controller</a> but is not <a href=#blocked-on-its-media-controller>blocked on its media controller</a>, and the element is not a <a href=#blocked-media-element>blocked media element</a>.</p> <p>A <a href=#media-element>media element</a> is said to have <dfn id=ended-playback>ended playback</dfn> when:</p> <ul><li>The element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> or greater, and <li> <p>Either: <ul><li>The <a href=#current-playback-position>current playback position</a> is the end of the <a href=#media-resource>media resource</a>, and <li>The <a href=#direction-of-playback>direction of playback</a> is forwards, and <li> Either the <a href=#media-element>media element</a> does not have a <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code> attribute specified, or the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>. </ul><p>Or: <ul><li>The <a href=#current-playback-position>current playback position</a> is the <a href=#earliest-possible-position>earliest possible position</a>, and <li>The <a href=#direction-of-playback>direction of playback</a> is backwards. </ul></li> </ul><p>The <dfn id=dom-media-ended title=dom-media-ended><code>ended</code></dfn> attribute must return true if, the last time the <a href=#event-loop>event loop</a> reached step 1, the <a href=#media-element>media element</a> had <a href=#ended-playback>ended playback</a> and the <a href=#direction-of-playback>direction of playback</a> was forwards, and false otherwise.</p> <p>A <a href=#media-element>media element</a> is said to have <dfn id=stopped-due-to-errors>stopped due to errors</dfn> when the element's <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is <code title=dom-media-HAVE_METADATA><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>media data</a>, and due to that error, is not able to play the content at the <a href=#current-playback-position>current playback position</a>.</p> <p>A <a href=#media-element>media element</a> is said to have <dfn id=paused-for-user-interaction>paused for user interaction</dfn> when its <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, the <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is either <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> or <code title=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>media resource</a> where the user has to make a selection for the resource to continue. If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a> when this happens, then the user agent must <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>. If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a> when the user makes a selection, allowing playback to resume, the user agent must similarly <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>. </p> <p>It is possible for a <a href=#media-element>media element</a> to have both <a href=#ended-playback>ended playback</a> and <a href=#paused-for-user-interaction>paused for user interaction</a> at the same time.</p> <p>When a <a href=#media-element>media element</a> that is <a href=#potentially-playing>potentially playing</a> stops playing because it has <a href=#paused-for-user-interaction>paused for user interaction</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</p> <p class=note>A <code title=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>potentially playing</a> stopping playback due to its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute changing to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>.</p> <p>When the <a href=#current-playback-position>current playback position</a> reaches the end of the <a href=#media-resource>media resource</a> when the <a href=#direction-of-playback>direction of playback</a> is forwards, then the user agent must follow these steps:</p> <ol><li><p>If the <a href=#media-element>media element</a> has a <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code> attribute specified and does not have a <a href=#current-media-controller>current media controller</a>, then <a href=#dom-media-seek title=dom-media-seek>seek</a> to the <a href=#earliest-possible-position>earliest possible position</a> of the <a href=#media-resource>media resource</a> and abort these steps.</li> <!-- v2/v3: We should fire a 'looping' event here to explain why this immediately fires a 'playing' event, otherwise the 'playing' event that fires from the readyState going from HAVE_CURRENT_DATA back to HAVE_FUTURE_DATA will seem inexplicable (since the normally matching 'ended' given below event doesn't fire in the loop case). --> <li><p>As defined above, the <code title=dom-media-ended><a href=#dom-media-ended>ended</a></code> IDL attribute starts returning true once the <a href=#event-loop>event loop</a>'s current <a href=#concept-task title=concept-task>task</a> ends.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the <a href=#media-element>media element</a>.</li> <li><p><a href=#queue-a-task>Queue a task</a> that, if the <a href=#media-element>media element</a> does not have a <a href=#current-media-controller>current media controller</a>, and the <a href=#media-element>media element</a> has still <a href=#ended-playback>ended playback</a>, and the <a href=#direction-of-playback>direction of playback</a> is still forwards, and <a href=#dom-media-paused title=dom-media-paused>paused</a> is false, changes <a href=#dom-media-paused title=dom-media-paused>paused</a> to true and <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-media-pause><a href=#event-media-pause>pause</a></code> at the <a href=#media-element>media element</a>.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-ended><a href=#event-media-ended>ended</a></code> at the <a href=#media-element>media element</a>.</li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>.</li> </ol><p>When the <a href=#current-playback-position>current playback position</a> reaches the <a href=#earliest-possible-position>earliest possible position</a> of the <a href=#media-resource>media resource</a> when the <a href=#direction-of-playback>direction of playback</a> is backwards, then the user agent must only <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</p> <hr><p>The <dfn id=dom-media-defaultplaybackrate title=dom-media-defaultPlaybackRate><code>defaultPlaybackRate</code></dfn> attribute gives the desired speed at which the <a href=#media-resource>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 title=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 title="expose a user interface to the user">exposes a user interface to the user</a>.</p> <p>The <dfn id=dom-media-playbackrate title=dom-media-playbackRate><code>playbackRate</code></dfn> attribute gives the <a href=#effective-playback-rate>effective playback rate</a> (assuming there is no <a href=#current-media-controller>current media controller</a> overriding it), which is the speed at which the <a href=#media-resource>media resource</a> plays, as a multiple of its intrinsic speed. If it is not equal to the <code title=dom-media-defaultPlaybackRate><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 attribute must be set to the new value, and the playback will change speed (if the element is <a href=#potentially-playing>potentially playing</a> and there is no <a href=#current-media-controller>current media controller</a>).</p> <p id=rateUpdate>When the <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> or <code title=dom-media-playbackRate><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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-ratechange><a href=#event-media-ratechange>ratechange</a></code> at the <a href=#media-element>media element</a>.</p> <p class=note>The <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> and <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code> attributes have no effect when the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>; the namesake attributes on the <code><a href=#mediacontroller>MediaController</a></code> object are used instead in that situation.</p> <hr><p>The <dfn id=dom-media-played title=dom-media-played><code>played</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the ranges of the <a href=#media-resource>media resource</a>, if any, that the user agent has so far rendered, at the time the attribute is evaluated.</p> <hr><p>When the <dfn id=dom-media-play title=dom-media-play><code>play()</code></dfn> method on a <a href=#media-element>media element</a> is invoked, the user agent must run the following steps.</p> <ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> <li> <p>If the <a href=#ended-playback title="ended playback">playback has ended</a> and the <a href=#direction-of-playback>direction of playback</a> is forwards, and the <a href=#media-element>media element</a> does not have a <a href=#current-media-controller>current media controller</a>, <a href=#dom-media-seek title=dom-media-seek>seek</a> to the <a href=#earliest-possible-position>earliest possible position</a> of the <a href=#media-resource>media resource</a>.</p> <p class=note>This <a href=#seekUpdate>will cause</a> the user agent to <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the <a href=#media-element>media element</a>.</p> <!-- if we're already playing at this point, it might also fire 'waiting' --> </li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then <a href=#bring-the-media-element-up-to-speed-with-its-new-media-controller>bring the media element up to speed with its new media controller</a>.</p> <li> <p>If the <a href=#media-element>media element</a>'s <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is true, run the following substeps:</p> <ol><li><p>Change the value of <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> to false.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-play><a href=#event-media-play>play</a></code> at the element.</li> <li> <p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute has the value <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code>, or <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at the element.</p> <p>Otherwise, the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute has the value <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> or <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code>: <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-playing><a href=#event-media-playing>playing</a></code> at the element.</p> </li> </ol></li> <li><p>Set the <a href=#media-element>media element</a>'s <a href=#autoplaying-flag>autoplaying flag</a> to false.</li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>.</li> </ol><hr><p>When the <dfn id=dom-media-pause title=dom-media-pause><code>pause()</code></dfn> method is invoked, and when the user agent is required to pause the <a href=#media-element>media element</a>, the user agent must run the following steps:</p> <ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.</li> <li><p>Set the <a href=#media-element>media element</a>'s <a href=#autoplaying-flag>autoplaying flag</a> to false.</li> <li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, run the following steps:</p> <ol><li><p>Change the value of <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> to true.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-pause><a href=#event-media-pause>pause</a></code> at the element.</li> <li><p>Set the <a href=#official-playback-position>official playback position</a> to the <a href=#current-playback-position>current playback position</a>.</li> </ol></li> <li><p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then <a href=#report-the-controller-state>report the controller state</a> for the <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>.</li> </ol><hr><p>The <dfn id=effective-playback-rate>effective playback rate</dfn> is not necessarily the element's <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code>. When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, its <a href=#effective-playback-rate>effective playback rate</a> is the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-playback-rate>media controller playback rate</a>. Otherwise, the <a href=#effective-playback-rate>effective playback rate</a> is just the element's <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code>. Thus, the <a href=#current-media-controller>current media controller</a> overrides the <a href=#media-element>media element</a>. </p> <p>If the <a href=#effective-playback-rate>effective playback rate</a> 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>media element</a> is <a href=#potentially-playing>potentially playing</a> and its <code><a href=#document>Document</a></code> is a <a href=#fully-active>fully active</a> <code><a href=#document>Document</a></code>, its <a href=#current-playback-position>current playback position</a> must increase monotonically at <a href=#effective-playback-rate>effective playback rate</a> units of media time per unit time of the <a href=#media-timeline>media timeline</a>'s clock.</p> <p class=note>The <a href=#effective-playback-rate>effective playback rate</a> can be 0.0, in which case the <a href=#current-playback-position>current playback position</a> doesn't move, despite playback not being paused (<code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> doesn't become true, and the <code title=event-media-pause><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=#provide-a-stable-state title="provide a stable state">provides a stable state</a>, the <a href=#official-playback-position>official playback position</a> must be set to the <a href=#current-playback-position>current playback position</a>.</p> <p>When the <a href=#direction-of-playback>direction of playback</a> is backwards, any corresponding audio must be muted. When the <a href=#effective-playback-rate>effective playback rate</a> is so low or so high that the user agent cannot play audio usefully, the corresponding audio must also be muted. If the <a href=#effective-playback-rate>effective playback rate</a> is not 1.0, the user agent may apply pitch adjustments to the audio as necessary to render it faithfully.</p> <p><a href=#media-element title="media element">Media elements</a> that are <a href=#potentially-playing>potentially playing</a> while not <a href=#in-a-document>in a <code>Document</code></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 have a <a href=#current-media-controller>current media controller</a> that still has references and can still be unpaused, or it could be unpaused but stalled waiting for content to buffer.</p> <hr><p>When the <a href=#current-playback-position>current playback position</a> of a <a href=#media-element>media element</a> changes (e.g. due to playback or seeking), the user agent must run the following steps. If the <a href=#current-playback-position>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 title="text track cue">cues</a> to be skipped over as the user agent rushes ahead to "catch up".) </p> <ol><li><p>Let <var title="">current cues</var> be a list of <a href=#text-track-cue title="text track cue">cues</a>, initialized to contain all the <a href=#text-track-cue title="text track cue">cues</a> of all the <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> <a href=#text-track title="text track">text tracks</a> of the <a href=#media-element>media element</a> (not the <a href=#text-track-disabled title="text track disabled">disabled</a> ones) whose <a href=#text-track-cue-start-time title="text track cue start time">start times</a> are less than or equal to the <a href=#current-playback-position>current playback position</a> and whose <a href=#text-track-cue-end-time title="text track cue end time">end times</a> are greater than the <a href=#current-playback-position>current playback position</a>.</li> <li><p>Let <var title="">other cues</var> be a list of <a href=#text-track-cue title="text track cue">cues</a>, initialized to contain all the <a href=#text-track-cue title="text track cue">cues</a> of <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, and <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> <a href=#text-track title="text track">text tracks</a> of the <a href=#media-element>media element</a> that are not present in <var title="">current cues</var>.</li> <li><p>Let <var title="">last time</var> be the <a href=#current-playback-position>current playback position</a> at the time this algorithm was last run for this <a href=#media-element>media element</a>, if this is not the first time it has run.</li> <li><p>If the <a href=#current-playback-position>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 title="">missed cues</var> be the list of <a href=#text-track-cue title="text track cue">cues</a> in <var title="">other cues</var> whose <a href=#text-track-cue-start-time title="text track cue start time">start times</a> are greater than or equal to <var title="">last time</var> and whose <a href=#text-track-cue-end-time title="text track cue end time">end times</a> are less than or equal to the <a href=#current-playback-position>current playback position</a>. Otherwise, let <var title="">missed cues</var> be an empty list.</li> <li><p>If the time was reached through the usual monotonic increase of the <a href=#current-playback-position>current playback position</a> during normal playback, and if the user agent has not fired a <code title=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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><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>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> <li><p>If all of the <a href=#text-track-cue title="text track cue">cues</a> in <var title="">current cues</var> have their <a href=#text-track-cue-active-flag>text track cue active flag</a> set, none of the <a href=#text-track-cue title="text track cue">cues</a> in <var title="">other cues</var> have their <a href=#text-track-cue-active-flag>text track cue active flag</a> set, and <var title="">missed cues</var> is empty, then abort these steps.</li> <li> <p>If the time was reached through the usual monotonic increase of the <a href=#current-playback-position>current playback position</a> during normal playback, and there are <a href=#text-track-cue title="text track cue">cues</a> in <var title="">other cues</var> that have their <a href=#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>text track cue active flag</a> set or are also in <var title="">missed cues</var>, then immediately <a href=#dom-media-pause title=dom-media-pause>pause</a> the <a href=#media-element>media element</a>. <!-- "pause" can in theory call load(), but never can it do so as part of this invokation, since we wouldn't be in this algorithm if the media element was empty. So, no need to couch all this in a task. --></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 title="text track cue">cue</a>, even if that <a href=#text-track-cue title="text track cue">cue</a> has its <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> set.</p> </li> <li> <p>Let <var title="">events</var> be a list of <a href=#concept-task title=concept-task>tasks</a>, initially empty. Each <a href=#concept-task title=concept-task>task</a> in this list will be associated with a <a href=#text-track>text track</a>, a <a href=#text-track-cue>text track cue</a>, and a time, which are used to sort the list before the <a href=#concept-task title=concept-task>tasks</a> are queued.</p> <p>Let <var title="">affected tracks</var> be a list of <a href=#text-track title="text track">text tracks</a>, initially empty.</p> <p>When the steps below say to <dfn id=prepare-an-event>prepare an event</dfn> named <var title="">event</var> for a <a href=#text-track-cue>text track cue</a> <var title="">target</var> with a time <var title="">time</var>, the user agent must run these substeps:</p> <ol><li><p>Let <var title="">track</var> be the <a href=#text-track>text track</a> with which the <a href=#text-track-cue>text track cue</a> <var title="">target</var> is associated.</li> <li><p>Create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <var title="">event</var> at <var title="">target</var>.</li> <li><p>Add to the newly create <a href=#concept-task title=concept-task>task</a> to <var title="">events</var>, associated with the time <var title="">time</var>, the <a href=#text-track>text track</a> <var title="">track</var>, and the <a href=#text-track-cue>text track cue</a> <var title="">target</var>.</li> <li><p>Add <var title="">track</var> to <var title="">affected tracks</var>.</li> </ol></li> <li><p>For each <a href=#text-track-cue title="text track cue">text track cue</a> in <var title="">missed cues</var>, <a href=#prepare-an-event>prepare an event</a> named <code title=event-enter>enter</code> for the <code><a href=#texttrackcue>TextTrackCue</a></code> object with the <a href=#text-track-cue-start-time>text track cue start time</a>.</li> <li><p>For each <a href=#text-track-cue title="text track cue">text track cue</a> in <var title="">other cues</var> that either has its <a href=#text-track-cue-active-flag>text track cue active flag</a> set or is in <var title="">missed cues</var>, <a href=#prepare-an-event>prepare an event</a> named <code title=event-exit>exit</code> for the <code><a href=#texttrackcue>TextTrackCue</a></code> object with the <a href=#text-track-cue-end-time>text track cue end time</a>.</li> <li><p>For each <a href=#text-track-cue title="text track cue">text track cue</a> in <var title="">current cues</var> that does not have its <a href=#text-track-cue-active-flag>text track cue active flag</a> set, <a href=#prepare-an-event>prepare an event</a> named <code title=event-enter>enter</code> for the <code><a href=#texttrackcue>TextTrackCue</a></code> object with the <a href=#text-track-cue-start-time>text track cue start time</a>.</li> <li> <p>Sort the <a href=#concept-task title=concept-task>tasks</a> in <var title="">events</var> in ascending time order (<a href=#concept-task title=concept-task>tasks</a> with earlier times first).</p> <p>Further sort <a href=#concept-task title=concept-task>tasks</a> in <var title="">events</var> that have the same time by the relative <a href=#text-track-cue-order>text track cue order</a> of the <a href=#text-track-cue title="text track cue">text track cues</a> associated with these <a href=#concept-task title=concept-task>tasks</a>.</p> </li> <li><p><a href=#queue-a-task title="queue a task">Queue</a> each <a href=#concept-task title=concept-task>task</a> in <var title="">events</var>, in list order.</li> <li><p>Sort <var title="">affected tracks</var> in the same order as the <a href=#text-track title="text track">text tracks</a> appear in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>, and remove duplicates.</p> <li><p>For each <a href=#text-track>text track</a> in <var title="">affected tracks</var>, in the list order, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-cuechange>cuechange</code> at the <code><a href=#texttrack>TextTrack</a></code> object, and, if the <a href=#text-track>text track</a> has a corresponding <code><a href=#the-track-element>track</a></code> element, to then <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-cuechange>cuechange</code> at the <code><a href=#the-track-element>track</a></code> element as well.</li> <li><p>Set the <a href=#text-track-cue-active-flag>text track cue active flag</a> of all the <a href=#text-track-cue title="text track cue">cues</a> in the <var title="">current cues</var>, and unset the <a href=#text-track-cue-active-flag>text track cue active flag</a> of all the <a href=#text-track-cue title="text track cue">cues</a> in the <var title="">other cues</var>.</li> <li><p>Run the <a href=#rules-for-updating-the-text-track-rendering>rules for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in <var title="">affected tracks</var> that are <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>. <!--TTVTT--> For example, for <a href=#text-track title="text track">text tracks</a> based on <a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>. <!--TTVTT--> </li> </ol><p>For the purposes of the algorithm above, a <a href=#text-track-cue>text track cue</a> is considered to be part of a <a href=#text-track>text track</a> only if it is listed in the <a href=#text-track-list-of-cues>text track list of cues</a>, not merely if it is associated with the <a href=#text-track>text track</a>.</p> <p class=note>If the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code> stops being a <a href=#fully-active>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>media element</a> is <a href=#remove-an-element-from-a-document title="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>Asynchronously <a href=#await-a-stable-state>await a stable state</a>, allowing the <a href=#concept-task title=concept-task>task</a> that removed the <a href=#media-element>media element</a> from the <code><a href=#document>Document</a></code> to continue. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are marked with ⌛.)</li> <li><p>⌛ If the <a href=#media-element>media element</a> is <a href=#in-a-document>in a <code>Document</code></a>, abort these steps.</li> <li><p>⌛ If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, abort these steps.</li> <li><p>⌛ <a href=#dom-media-pause title=dom-media-pause>Pause</a> the <a href=#media-element>media element</a>.</p> </ol></div> <h5 id=seeking><span class=secno>4.8.10.9 </span>Seeking</h5> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code></dt> <dd> <p>Returns true if the user agent is currently seeking.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the ranges of the <a href=#media-resource>media resource</a> to which it is possible for the user agent to seek.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-seeking title=dom-media-seeking><code>seeking</code></dfn> attribute must initially have the value false.</p> <p>When the user agent is required to <dfn id=dom-media-seek title=dom-media-seek>seek</dfn> to a particular <var title="">new playback position</var> in the <a href=#media-resource>media resource</a>, it means that the user agent must run the following steps. This algorithm interacts closely with the <a href=#event-loop>event loop</a> mechanism; in particular, it has a <a href=#synchronous-section>synchronous section</a> (which is triggered as part of the <a href=#event-loop>event loop</a> algorithm). Steps in that section are marked with ⌛.</p> <ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, abort these steps.</li> <li><p>If the element's <code title=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> <li><p>Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to true.</li> <li><p>If the seek was in response to a DOM method call or setting of an IDL attribute, then continue the script. The remainder of these steps must be run asynchronously. With the exception of the steps marked with ⌛, they could be aborted at any time by another instance of this algorithm being invoked.</li> <li><p>If the <var title="">new playback position</var> is later than the end of the <a href=#media-resource>media resource</a>, then let it be the end of the <a href=#media-resource>media resource</a> instead.</li> <li><p>If the <var title="">new playback position</var> is less than the <a href=#earliest-possible-position>earliest possible position</a>, let it be that position instead.</li> <li><p>If the (possibly now changed) <var title="">new playback position</var> is not in one of the ranges given in the <code title=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 title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute that is the nearest to the <var title="">new playback position</var>. If two positions both satisfy that constraint (i.e. the <var title="">new playback position</var> is exactly in the middle between two ranges in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute) then use the position that is closest to the <a href=#current-playback-position>current playback position</a>. If there are no ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute then set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to false and abort these steps.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the element.</li> <li> <p>Set the <a href=#current-playback-position>current playback position</a> to the given <var title="">new playback position</var>.</p> <p class=note>If the <a href=#media-element>media element</a> was <a href=#potentially-playing>potentially playing</a> immediately before it started seeking, but seeking caused its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, then a <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> <a href=#fire-waiting-when-waiting>will be fired</a> at the element.</p> <!-- also, timeupdate --> <!-- also, it will do the "report the controller state" thing --> <p class=note>The <code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> attribute does not get updated asynchronously, as it returns the <a href=#official-playback-position>official playback position</a>, not the <a href=#current-playback-position>current playback position</a>.</p> </li> <li><p>Wait until the user agent has established whether or not the <a href=#media-data>media data</a> for the <var title="">new playback position</var> is available, and, if it is, until it has decoded enough data to play back that position.</p> <!-- at which point, it will do the "port the controller state" thing again --> </li> <li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of all the remaining steps of this algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are marked with ⌛.)</li> <li><p>⌛ Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to false.</li> <li id=seekUpdate><p>⌛ <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</li> <li><p>⌛ <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> at the element.</li> </ol><p>The <dfn id=dom-media-seekable title=dom-media-seekable><code>seekable</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the ranges of the <a href=#media-resource>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>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>earliest possible position</a>, typically zero), and whose end is the same as the time of the first frame plus the <code title=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><a href=#media-resource title="media resource">Media resources</a> might be internally scripted or interactive. Thus, a <a href=#media-element>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 title=dom-media-seek>seeking</a> was used whenever the <a href=#current-playback-position>current playback position</a> changes in a discontinuous fashion (so that the relevant events fire). If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then the user agent must <a href=#seek-the-media-controller>seek the media controller</a> appropriately instead. </p> </div> <h5 id=media-resources-with-multiple-media-tracks><span class=secno>4.8.10.10 </span>Media resources with multiple media tracks</h5> <p>A <a href=#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>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 title="">media</var> . <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code></dt> <dd> <p>Returns an <code><a href=#audiotracklist>AudioTrackList</a></code> object representing the audio tracks available in the <a href=#media-resource>media resource</a>.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code></dt> <dd> <p>Returns a <code><a href=#videotracklist>VideoTrackList</a></code> object representing the video tracks available in the <a href=#media-resource>media resource</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-audiotracks title=dom-media-audioTracks><code>audioTracks</code></dfn> attribute of a <a href=#media-element>media element</a> must return a <a href=#live>live</a> <code><a href=#audiotracklist>AudioTrackList</a></code> object representing the audio tracks available in the <a href=#media-element>media element</a>'s <a href=#media-resource>media resource</a>. The same object must be returned each time.</p> <p>The <dfn id=dom-media-videotracks title=dom-media-videoTracks><code>videoTracks</code></dfn> attribute of a <a href=#media-element>media element</a> must return a <a href=#live>live</a> <code><a href=#videotracklist>VideoTrackList</a></code> object representing the video tracks available in the <a href=#media-element>media element</a>'s <a href=#media-resource>media resource</a>. The same object must be returned each time.</p> <p class=note>There are only ever one <code><a href=#audiotracklist>AudioTrackList</a></code> object and one <code><a href=#videotracklist>VideoTrackList</a></code> object per <a href=#media-element>media element</a>, even if another <a href=#media-resource>media resource</a> is loaded into the element: the objects are reused. (The <code><a href=#audiotrack>AudioTrack</a></code> and <code><a href=#videotrack>VideoTrack</a></code> objects are not, though.)</p> </div> <div class=example> <p>In this example, a script defines a function that takes a URL to a video and a reference to an element where the video is to be placed. That function then tries to load the video, and, once it is loaded, checks to see if there is a sign-language track available. If there is, it also displays that track. Both tracks are just placed in the given container; it's assumed that styles have been applied to make this work in a pretty way!</p> <pre><script> function loadVideo(url, container) { var controller = new MediaController(); var video = document.createElement('video'); video.src = url; video.autoplay = true; video.controls = true; video.controller = controller; container.appendChild(video); video.onloadedmetadata = function (event) { for (var i = 0; i < video.videoTracks.length; i += 1) { if (video.videoTracks[i].kind == 'sign') { var sign = document.createElement('video'); sign.src = url + '#track=' + video.videoTracks[i].id; <!-- should escape this probably --> sign.autoplay = true; sign.controller = controller; container.appendChild(sign); return; } } }; } </script></pre> </div> <h6 id=audiotracklist-and-videotracklist-objects><span class=secno>4.8.10.10.1 </span><code><a href=#audiotracklist>AudioTrackList</a></code> and <code><a href=#videotracklist>VideoTrackList</a></code> objects</h6> <p>The <code><a href=#audiotracklist>AudioTrackList</a></code> and <code><a href=#videotracklist>VideoTrackList</a></code> interfaces are used by attributes defined in the previous section.</p> <pre class=idl>interface <dfn id=audiotracklist>AudioTrackList</dfn> { readonly attribute unsigned long <a href=#dom-audiotracklist-length title=dom-AudioTrackList-length>length</a>; getter <a href=#audiotrack>AudioTrack</a> (unsigned long index); <a href=#audiotrack>AudioTrack</a>? <a href=#dom-audiotracklist-gettrackbyid title=dom-AudioTrackList-getTrackById>getTrackById</a>(DOMString id); [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-tracklist-onchange title=handler-TrackList-onchange>onchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-tracklist-onaddtrack title=handler-TrackList-onaddtrack>onaddtrack</a>; }; interface <dfn id=audiotrack>AudioTrack</dfn> { readonly attribute DOMString <a href=#dom-audiotrack-id title=dom-AudioTrack-id>id</a>; readonly attribute DOMString <a href=#dom-audiotrack-kind title=dom-AudioTrack-kind>kind</a>; readonly attribute DOMString <a href=#dom-audiotrack-label title=dom-AudioTrack-label>label</a>; readonly attribute DOMString <a href=#dom-audiotrack-language title=dom-AudioTrack-language>language</a>; attribute boolean <a href=#dom-audiotrack-enabled title=dom-AudioTrack-enabled>enabled</a>; }; interface <dfn id=videotracklist>VideoTrackList</dfn> { readonly attribute unsigned long <a href=#dom-videotracklist-length title=dom-VideoTrackList-length>length</a>; getter <a href=#videotrack>VideoTrack</a> (unsigned long index); <a href=#videotrack>VideoTrack</a>? <a href=#dom-videotracklist-gettrackbyid title=dom-VideoTrackList-getTrackById>getTrackById</a>(DOMString id); readonly attribute long <a href=#dom-videotracklist-selectedindex title=dom-VideoTrackList-selectedIndex>selectedIndex</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-tracklist-onchange title=handler-TrackList-onchange>onchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-tracklist-onaddtrack title=handler-TrackList-onaddtrack>onaddtrack</a>; }; interface <dfn id=videotrack>VideoTrack</dfn> { readonly attribute DOMString <a href=#dom-videotrack-id title=dom-VideoTrack-id>id</a>; readonly attribute DOMString <a href=#dom-videotrack-kind title=dom-VideoTrack-kind>kind</a>; readonly attribute DOMString <a href=#dom-videotrack-label title=dom-VideoTrack-label>label</a>; readonly attribute DOMString <a href=#dom-videotrack-language title=dom-VideoTrack-language>language</a>; attribute boolean <a href=#dom-videotrack-selected title=dom-VideoTrack-selected>selected</a>; };</pre> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> . <code title=dom-AudioTrackList-length><a href=#dom-audiotracklist-length>length</a></code></dt> <dt><var title="">media</var> . <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> . <code title=dom-VideoTrackList-length><a href=#dom-videotracklist-length>length</a></code></dt> <dd> <p>Returns the number of tracks in the list.</p> </dd> <dt><var title="">audioTrack</var> = <var title="">media</var> . <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code>[<var title="">index</var>]</dt> <dt><var title="">videoTrack</var> = <var title="">media</var> . <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code>[<var title="">index</var>]</dt> <dd> <p>Returns the specified <code><a href=#audiotrack>AudioTrack</a></code> or <code><a href=#videotrack>VideoTrack</a></code> object.</p> </dd> <dt><var title="">audioTrack</var> = <var title="">media</var> . <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> . <code title=dom-AudioTrackList-getTrackById><a href=#dom-audiotracklist-gettrackbyid>getTrackById</a></code>( <var title="">id</var> )</dt> <dt><var title="">videoTrack</var> = <var title="">media</var> . <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> . <code title=dom-VideoTrackList-getTrackById><a href=#dom-videotracklist-gettrackbyid>getTrackById</a></code>( <var title="">id</var> )</dt> <dd> <p>Returns the <code><a href=#audiotrack>AudioTrack</a></code> or <code><a href=#videotrack>VideoTrack</a></code> object with the given identifier, or null if no track has that identifier.</p> </dd> <dt><var title="">audioTrack</var> . <code title=dom-AudioTrack-id><a href=#dom-audiotrack-id>id</a></code></dt> <dt><var title="">videoTrack</var> . <code title=dom-VideoTrack-id><a href=#dom-videotrack-id>id</a></code></dt> <dd> <p>Returns the ID of the given track. This is the ID that can be used with a fragment identifier if the format supports the <cite>Media Fragments URI</cite> syntax, and that can be used with the <code title="">getTrackById()</code> method. <a href=#refsMEDIAFRAG>[MEDIAFRAG]</a></p> </dd> <dt><var title="">audioTrack</var> . <code title=dom-AudioTrack-kind><a href=#dom-audiotrack-kind>kind</a></code></dt> <dt><var title="">videoTrack</var> . <code title=dom-VideoTrack-kind><a href=#dom-videotrack-kind>kind</a></code></dt> <dd> <p>Returns the category the given track falls into. The <a href=#dom-TrackList-getKind-categories>possible track categories</a> are given below.</p> </dd> <dt><var title="">audioTrack</var> . <code title=dom-AudioTrack-label><a href=#dom-audiotrack-label>label</a></code></dt> <dt><var title="">videoTrack</var> . <code title=dom-VideoTrack-label><a href=#dom-videotrack-label>label</a></code></dt> <dd> <p>Returns the label of the given track, if known, or the empty string otherwise.</p> </dd> <dt><var title="">audioTrack</var> . <code title=dom-AudioTrack-language><a href=#dom-audiotrack-language>language</a></code></dt> <dt><var title="">videoTrack</var> . <code title=dom-VideoTrack-language><a href=#dom-videotrack-language>language</a></code></dt> <dd> <p>Returns the language of the given track, if known, or the empty string otherwise.</p> </dd> <dt><var title="">audioTrack</var> . <code title=dom-AudioTrack-enabled><a href=#dom-audiotrack-enabled>enabled</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the given track is active, and false otherwise.</p> <p>Can be set, to change whether the track is enabled or not. If multiple audio tracks are enabled simultaneously, they are mixed.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-videoTracks><a href=#dom-media-videotracks>videoTracks</a></code> . <code title=dom-VideoTrackList-selectedIndex><a href=#dom-videotracklist-selectedindex>selectedIndex</a></code></dt> <dd> <p>Returns the index of the currently selected track, if any, or −1 otherwise.</p> </dd> <dt><var title="">videoTrack</var> . <code title=dom-VideoTrack-selected><a href=#dom-videotrack-selected>selected</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the given track is active, and false otherwise.</p> <p>Can be set, to change whether the track is selected or not. Either zero or one video track is selected; selecting a new track while a previous one is selected will unselect the previous one.</p> </dd> </dl><div class=impl> <p>An <code><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><a href=#audiotrack>AudioTrack</a></code> object.</p> <p>A <code><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><a href=#videotrack>VideoTrack</a></code> object.</p> <p>Tracks in <code><a href=#audiotracklist>AudioTrackList</a></code> and <code><a href=#videotracklist>VideoTrackList</a></code> objects must be consistently ordered. If the <a href=#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>media resource</a>. The order used is called the <i>natural order</i> of the list.</p> <p class=note>Each track in a <code>TrackList</code> 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>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>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 title=dom-AudioTrackList-length><code>AudioTrackList.length</code></dfn> and <dfn id=dom-videotracklist-length title=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 href=#supported-property-indices>supported property indices</a> of <code><a href=#audiotracklist>AudioTrackList</a></code> and <code><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><a href=#audiotracklist>AudioTrackList</a></code> or <code><a href=#videotracklist>VideoTrackList</a></code> object represents no tracks, it has no <a href=#supported-property-indices>supported property indices</a>.</p> <p>To <a href=#determine-the-value-of-an-indexed-property>determine the value of an indexed property</a> for a given index <var title="">index</var> in an <code><a href=#audiotracklist>AudioTrackList</a></code> or <code><a href=#videotracklist>VideoTrackList</a></code> object <var title="">list</var>, the user agent must return the <code><a href=#audiotrack>AudioTrack</a></code> or <code><a href=#videotrack>VideoTrack</a></code> object that represents the <var title="">index</var>th track in <var title="">list</var>.</p> <p>The <dfn id=dom-audiotracklist-gettrackbyid title=dom-AudioTrackList-getTrackById><code>AudioTrackList.getTrackById(<var title="">id</var>)</code></dfn> and <dfn id=dom-videotracklist-gettrackbyid title=dom-VideoTrackList-getTrackById><code>VideoTrackList.getTrackById(<var title="">id</var>)</code></dfn> methods must return the first <code><a href=#audiotrack>AudioTrack</a></code> or <code><a href=#videotrack>VideoTrack</a></code> object (respectively) in the <code><a href=#audiotrack>AudioTrack</a></code> or <code><a href=#videotrack>VideoTrack</a></code> object (respectively) whose identifier is equal to the value of the <var title="">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><a href=#audiotrack>AudioTrack</a></code> and <code><a href=#videotrack>VideoTrack</a></code> objects represent specific tracks of a <a href=#media-resource>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>media resource</a>'s <code><a href=#audiotracklist>AudioTrackList</a></code> or <code><a href=#videotracklist>VideoTrackList</a></code> objects, those aspects do not change.</p> <p>In addition, <code><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><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 title=concept-media-load-resource>resource fetch algorithm</a> can override this.</p> <p>Similarly, a single <code><a href=#videotrack>VideoTrack</a></code> object per <code><a href=#videotracklist>VideoTrackList</a></code> object can be selected, this is the video track's <i>selection state</i>. When a <code><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 title=concept-media-load-resource>resource fetch algorithm</a> can override this.</p> <p>The <dfn id=dom-audiotrack-id title=dom-AudioTrack-id><code>AudioTrack.id</code></dfn> and <dfn id=dom-videotrack-id title=dom-VideoTrack-id><code>VideTrack.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>media resource</a> is in a format that supports the <cite>Media Fragments URI</cite> fragment identifier syntax, 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 fragment identifier. <a href=#refsMEDIAFRAG>[MEDIAFRAG]</a></p> <p>The <dfn id=dom-audiotrack-kind title=dom-AudioTrack-kind><code>AudioTrack.kind</code></dfn> and <dfn id=dom-videotrack-kind title=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>media resource</a>. For Ogg files, the Role header of the track gives the relevant metadata. 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><a href=#audiotrack>AudioTrack</a></code> objects if they are appropriate for audio, and must only be returned for <code><a href=#videotrack>VideoTrack</a></code> objects if they are appropriate for video.</p> </div> <table id=dom-TrackList-getKind-categories><caption>Return values for <code title=dom-AudioTrack-kind><a href=#dom-audiotrack-kind>AudioTrack.kind()</a></code> and <code title=dom-VideoTrack-kind><a href=#dom-videotrack-kind>VideoTrack.kind()</a></code></caption> <thead><tr><th>Category <th>Definition <th>Applies to...</th> <th>Examples <tbody><tr><td>"<dfn id=value-track-kind-alternate title=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". <tr><td>"<dfn id=value-track-kind-description title=value-track-kind-description><code>description</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 title=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. <tr><td>"<dfn id=value-track-kind-sign title=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-translation title=value-track-kind-translation><code>translation</code></dfn>" <td>A translated version of the main track. <td>Audio only. <td>Ogg: "audio/dub". <tr><!-- added because of the volume of use cases, but we should remove it if none of the formats start supporting it --><td>"<dfn id=value-track-kind-commentary title=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>No known formats expose this category at this time. <tr><td>"<dfn id=value-track-kind-none title=value-track-kind-none><code></code></dfn>" (empty string) <td>No explicit kind, or the kind given by the track's metadata is not recognised by the user agent. <td>Audio and video. <td>Any other track type or track role. </table><div class=impl> <p>The <dfn id=dom-audiotrack-label title=dom-AudioTrack-label><code>AudioTrack.label</code></dfn> and <dfn id=dom-videotrack-label title=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.</p> <p>The <dfn id=dom-audiotrack-language title=dom-AudioTrack-language><code>AudioTrack.language</code></dfn> and <dfn id=dom-videotrack-language title=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>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.</p> <p>The <dfn id=dom-audiotrack-enabled title=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><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><a href=#audiotrack>AudioTrack</a></code> object.)</p> <p>Whenever an audio track in an <code><a href=#audiotracklist>AudioTrackList</a></code> is enabled or disabled, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-change>change</code> at the <code><a href=#audiotracklist>AudioTrackList</a></code> object.</p> <p>The <dfn id=dom-videotracklist-selectedindex title=dom-VideoTrackList-selectedIndex><code>VideoTrackList.selectedIndex</code></dfn> attribute must return the index of the currently selected track, if any. If the <code><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 title=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><a href=#videotracklist>VideoTrackList</a></code>, then all the other <code><a href=#videotrack>VideoTrack</a></code> objects in that list must be unselected. (If the track is no longer in a <code><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><a href=#videotrack>VideoTrack</a></code> object.)</p> <p>Whenever a track in a <code><a href=#videotracklist>VideoTrackList</a></code> that was previously not selected is selected, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-change>change</code> at the <code><a href=#videotracklist>VideoTrackList</a></code> object.</p> <hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#audiotracklist>AudioTrackList</a></code> and <code><a href=#videotracklist>VideoTrackList</a></code> interfaces:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-tracklist-onchange title=handler-TrackList-onchange><code>onchange</code></dfn> <td> <code title=event-change>change</code> <tr><td><dfn id=handler-tracklist-onaddtrack title=handler-TrackList-onaddtrack><code>onaddtrack</code></dfn> <td> <code title=event-addtrack>addtrack</code> </table><hr><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> listed in this section is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <!-- v2 should also fire an event when the list changes --> </div> <h6 id=selecting-specific-audio-and-video-tracks-declaratively><span class=secno>4.8.10.10.2 </span>Selecting specific audio and video tracks declaratively</h6> <p>The <code title=dom-media-audioTracks><a href=#dom-media-audiotracks>audioTracks</a></code> and <code title=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 fragment identifier of the <a href=#url>URL</a> of the <a href=#media-resource>media resource</a>. The format of the fragment identifier depends on the <a href=#mime-type>MIME type</a> of the <a href=#media-resource>media resource</a>. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC3986>[RFC3986]</a></p> <div class=example> <p>In this example, a video that uses a format that supports the <cite>Media Fragments URI</cite> fragment identifier syntax is embedded in such a way that the alternative angles labeled "Alternative" are enabled instead of the default video track. <a href=#refsMEDIAFRAG>[MEDIAFRAG]</a></p> <pre><video src="myvideo#track=Alternative"></video></pre> <!-- XXX need to check with the mediafrag people about whether there's a way to select a specific audio or video track without affecting the default track selection of the other axis, e.g. setting the video track without changing the default audio track selection --> </div> <h5 id=synchronising-multiple-media-elements><span class=secno>4.8.10.11 </span>Synchronising multiple media elements</h5> <h6 id=introduction-0><span class=secno>4.8.10.11.1 </span>Introduction</h6> <p>Each <a href=#media-element>media element</a> can have a <code><a href=#mediacontroller>MediaController</a></code>. A <code><a href=#mediacontroller>MediaController</a></code> is an object that coordinates the playback of multiple <a href=#media-element title="media element">media elements</a>, for instance so that a sign-language interpreter track can be overlaid on a video track, with the two being kept in sync.</p> <p>By default, a <a href=#media-element>media element</a> has no <code><a href=#mediacontroller>MediaController</a></code>. An implicit <code><a href=#mediacontroller>MediaController</a></code> can be assigned using the <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> content attribute. An explicit <code><a href=#mediacontroller>MediaController</a></code> can be assigned directly using the <code title=dom-media-controller><a href=#dom-media-controller>controller</a></code> IDL attribute.</p> <p><a href=#media-element title="media element">Media elements</a> with a <code><a href=#mediacontroller>MediaController</a></code> are said to be <i>slaved</i> to their controller. The <code><a href=#mediacontroller>MediaController</a></code> modifies the playback rate and the playback volume of each of the <a href=#media-element title="media element">media elements</a> slaved to it, and ensures that when any of its slaved <a href=#media-element title="media element">media elements</a> unexpectedly stall, the others are stopped at the same time.</p> <p>When a <a href=#media-element>media element</a> is slaved to a <code><a href=#mediacontroller>MediaController</a></code>, its playback rate is fixed to that of the other tracks in the same <code><a href=#mediacontroller>MediaController</a></code>, and any looping is disabled.</p> <!-- v2: add control to loop, add control to playback rate <div class="example"> <p>In this example, two audio elements are slaved to the same (implicit) controller so that a waltz played by one audio element is kept exactly synchronised to the "tick tock tock" sound of the metronome played by the second element:</p> <pre><audio src="The%20Amelia%20Earhart%20Waltz.wav" controls autoplay mediagroup="song"></audio> <audio src="metronomes/3-4.wav" autoplay loop mediagroup="song"></audio></pre> <p>Assuming the song keeps a regular tempo throughout and assuming the metronome has the same tempo, this works even though if the metronome file only has one measure's worth of "tick tock tock", because the controller (implied by the <code title="attr-media-mediagroup">mediagroup</code> attribute) guarantees that the two elements will be kept synchronised, even if the user rewinds, jumps to a different part of the song, etc (the user agent controls made available by the <code title="attr-media-controls">controls</code> attribute on the song's <code>audio</code> element affect the <code>MediaController</code>'s state).</p> <p>If the metronome has the wrong rate, its rate can be adjusted by script separately from the song's (using the <code title="dom-media-playbackRate">audio.playbackRate</code> IDL attribute). The two elements will play back their <span>media data</span> at different rates, but the ratio will again be controlled by the <code>MediaController</code>.</p> </div> --> <h6 id=media-controllers><span class=secno>4.8.10.11.2 </span>Media controllers</h6> <pre class=idl>[<a href=#dom-mediacontroller title=dom-MediaController>Constructor</a>] interface <dfn id=mediacontroller>MediaController</dfn> { readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-mediacontroller-buffered title=dom-MediaController-buffered>buffered</a>; readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-mediacontroller-seekable title=dom-MediaController-seekable>seekable</a>; readonly attribute double <a href=#dom-mediacontroller-duration title=dom-MediaController-duration>duration</a>; attribute double <a href=#dom-mediacontroller-currenttime title=dom-MediaController-currentTime>currentTime</a>; readonly attribute boolean <a href=#dom-mediacontroller-paused title=dom-MediaController-paused>paused</a>; readonly attribute <a href=#timeranges>TimeRanges</a> <a href=#dom-mediacontroller-played title=dom-MediaController-played>played</a>; void <a href=#dom-mediacontroller-play title=dom-MediaController-play>play</a>(); void <a href=#dom-mediacontroller-pause title=dom-MediaController-pause>pause</a>(); attribute double <a href=#dom-mediacontroller-defaultplaybackrate title=dom-MediaController-defaultPlaybackRate>defaultPlaybackRate</a>; attribute double <a href=#dom-mediacontroller-playbackrate title=dom-MediaController-playbackRate>playbackRate</a>; attribute double <a href=#dom-mediacontroller-volume title=dom-MediaController-volume>volume</a>; attribute boolean <a href=#dom-mediacontroller-muted title=dom-MediaController-muted>muted</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onemptied title=handler-MediaController-onemptied>onemptied</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onloadedmetadata title=handler-MediaController-onloadedmetadata>onloadedmetadata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onloadeddata title=handler-MediaController-onloadeddata>onloadeddata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-oncanplay title=handler-MediaController-oncanplay>oncanplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-oncanplaythrough title=handler-MediaController-oncanplaythrough>oncanplaythrough</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onplaying title=handler-MediaController-onplaying>onplaying</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onended title=handler-MediaController-onended>onended</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onwaiting title=handler-MediaController-onwaiting>onwaiting</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-ondurationchange title=handler-MediaController-ondurationchange>ondurationchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-ontimeupdate title=handler-MediaController-ontimeupdate>ontimeupdate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onplay title=handler-MediaController-onplay>onplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onpause title=handler-MediaController-onpause>onpause</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onratechange title=handler-MediaController-onratechange>onratechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediacontroller-onvolumechange title=handler-MediaController-onvolumechange>onvolumechange</a>; };</pre> <dl class=domintro><dt><var title="">controller</var> = new <code title=dom-MediaController><a href=#dom-mediacontroller>MediaController</a></code>()</dt> <dd> <p>Returns a new <code><a href=#mediacontroller>MediaController</a></code> object.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-controller><a href=#dom-media-controller>controller</a></code> [ = <var title="">controller</var> ]</dt> <dd> <p>Returns the current <code><a href=#mediacontroller>MediaController</a></code> for the <a href=#media-element>media element</a>, if any; returns null otherwise.</p> <p>Can be set, to set an explicit <code><a href=#mediacontroller>MediaController</a></code>. Doing so removes the <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, if any.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-buffered><a href=#dom-mediacontroller-buffered>buffered</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the intersection of the time ranges for which the user agent has all relevant media data for all the slaved <a href=#media-element title="media element">media elements</a>.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-seekable><a href=#dom-mediacontroller-seekable>seekable</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the intersection of the time ranges into which the user agent can seek for all the slaved <a href=#media-element title="media element">media elements</a>.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-duration><a href=#dom-mediacontroller-duration>duration</a></code></dt> <dd> <p>Returns the difference between the earliest playable moment and the latest playable moment (not considering whether the data in question is actually buffered or directly seekable, but not including time in the future for infinite streams). Will return zero if there is no media.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-currentTime><a href=#dom-mediacontroller-currenttime>currentTime</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#current-playback-position>current playback position</a>, in seconds, as a position between zero time and the current <code title=dom-MediaController-duration><a href=#dom-mediacontroller-duration>duration</a></code>.</p> <p>Can be set, to seek to the given time.<p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-paused><a href=#dom-mediacontroller-paused>paused</a></code></dt> <dd> <p>Returns true if playback is paused; false otherwise. When this attribute is true, any <a href=#media-element>media element</a> slaved to this controller will be stopped.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-play><a href=#dom-mediacontroller-play>play</a></code>()</dt> <dd> <p>Sets the <code title=dom-MediaController-paused><a href=#dom-mediacontroller-paused>paused</a></code> attribute to false.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-pause><a href=#dom-mediacontroller-pause>pause</a></code>()</dt> <dd> <p>Sets the <code title=dom-MediaController-paused><a href=#dom-mediacontroller-paused>paused</a></code> attribute to true.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-played><a href=#dom-mediacontroller-played>played</a></code></dt> <dd> <p>Returns a <code><a href=#timeranges>TimeRanges</a></code> object that represents the union of the time ranges in all the slaved <a href=#media-element title="media element">media elements</a> that have been played.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-defaultPlaybackRate><a href=#dom-mediacontroller-defaultplaybackrate>defaultPlaybackRate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the default rate of playback.</p> <p>Can be set, to change the default rate of playback.</p> <p>This 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 rate of playback (<code title=dom-MediaController-playbackRate><a href=#dom-mediacontroller-playbackrate>playbackRate</a></code>) will be returned to this default rate.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-playbackRate><a href=#dom-mediacontroller-playbackrate>playbackRate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current rate of playback.</p> <p>Can be set, to change the rate of playback.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-volume><a href=#dom-mediacontroller-volume>volume</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current playback volume multiplier, 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 multiplier.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> if the new value is not in the range 0.0 .. 1.0.</p> </dd> <dt><var title="">controller</var> . <code title=dom-MediaController-muted><a href=#dom-mediacontroller-muted>muted</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if all audio is muted (regardless of other attributes either on the controller or on any <a href=#media-element title="media element">media elements</a> slaved to this controller), and false otherwise.</p> <p>Can be set, to change whether the audio is muted or not.</p> </dd> </dl><div class=impl> <p>A <a href=#media-element>media element</a> can have a <dfn id=current-media-controller>current media controller</dfn>, which is a <code><a href=#mediacontroller>MediaController</a></code> object. When a <a href=#media-element>media element</a> is created without a <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, it does not have a <a href=#current-media-controller>current media controller</a>. (If it is created <em>with</em> such an attribute, then that attribute initializes the <a href=#current-media-controller>current media controller</a>, as defined below.)</p> <p>The <dfn id=slaved-media-elements>slaved media elements</dfn> of a <code><a href=#mediacontroller>MediaController</a></code> are the <a href=#media-element title="media element">media elements</a> whose <a href=#current-media-controller>current media controller</a> is that <code><a href=#mediacontroller>MediaController</a></code>. All the <a href=#slaved-media-elements>slaved media elements</a> of a <code><a href=#mediacontroller>MediaController</a></code> must use the same clock for their definition of their <a href=#media-timeline>media timeline</a>'s unit time.</p> <hr><p>The <dfn id=dom-media-controller title=dom-media-controller><code>controller</code></dfn> attribute on a <a href=#media-element>media element</a>, on getting, must return the element's <a href=#current-media-controller>current media controller</a>, if any, or null otherwise. On setting, it must first remove the element's <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, if any, and then set the <a href=#current-media-controller>current media controller</a> to the given value. If the given value is null, the element no longer has a <a href=#current-media-controller>current media controller</a>; if it is not null, then the user agent must <a href=#bring-the-media-element-up-to-speed-with-its-new-media-controller>bring the media element up to speed with its new media controller</a>.</p> <hr><p>The <dfn id=dom-mediacontroller title=dom-MediaController><code>MediaController()</code></dfn> constructor, when invoked, must return a newly created <code><a href=#mediacontroller>MediaController</a></code> object.</p> <hr><p>The <dfn id=dom-mediacontroller-seekable title=dom-MediaController-seekable><code>seekable</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the intersection of the ranges of the <a href=#media-resource title="media resource">media resources</a> of the <a href=#slaved-media-elements>slaved media elements</a> that the user agent is able to seek to, at the time the attribute is evaluated.</p> <p>The <dfn id=dom-mediacontroller-buffered title=dom-MediaController-buffered><code>buffered</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the intersection of the ranges of the <a href=#media-resource title="media resource">media resources</a> of the <a href=#slaved-media-elements>slaved media elements</a> 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>The <dfn id=dom-mediacontroller-duration title=dom-MediaController-duration><code>duration</code></dfn> attribute must return the <a href=#media-controller-duration>media controller duration</a>.</p> <p>Every 15 to 250ms, or whenever the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-duration>media controller duration</a> changes, whichever happens least often, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-durationchange><a href=#event-mediacontroller-durationchange>durationchange</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>. If the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-duration>media controller duration</a> decreases such that the <a href=#media-controller-position>media controller position</a> is greater than the <a href=#media-controller-duration>media controller duration</a>, the user agent must immediately <a href=#seek-the-media-controller>seek the media controller</a> to <a href=#media-controller-duration>media controller duration</a>.</p> <p>The <dfn id=dom-mediacontroller-currenttime title=dom-MediaController-currentTime><code>currentTime</code></dfn> attribute must return the <a href=#media-controller-position>media controller position</a> on getting, and on setting must <a href=#seek-the-media-controller>seek the media controller</a> to the new value.</p> <p>Every 15 to 250ms, or whenever the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-position>media controller position</a> changes, whichever happens least often, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-timeupdate><a href=#event-mediacontroller-timeupdate>timeupdate</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>.</p> <hr><p>When a <code><a href=#mediacontroller>MediaController</a></code> is created it is a <dfn id=playing-media-controller>playing media controller</dfn>. It can be changed into a <dfn id=paused-media-controller>paused media controller</dfn> and back either via the user agent's user interface (when the element is <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface to the user</a>) or by script using the APIs defined in this section (see below).</p> <p>The <dfn id=dom-mediacontroller-paused title=dom-MediaController-paused><code>paused</code></dfn> attribute must return true if the <code><a href=#mediacontroller>MediaController</a></code> object is a <a href=#paused-media-controller>paused media controller</a>, and false otherwise.</p> <p>When the <dfn id=dom-mediacontroller-pause title=dom-MediaController-pause><code>pause()</code></dfn> method is invoked, if the <code><a href=#mediacontroller>MediaController</a></code> is a <a href=#playing-media-controller>playing media controller</a> then the user agent must change the <code><a href=#mediacontroller>MediaController</a></code> into a <a href=#paused-media-controller>paused media controller</a>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-pause><a href=#event-mediacontroller-pause>pause</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>, and then <a href=#report-the-controller-state>report the controller state</a> of the <code><a href=#mediacontroller>MediaController</a></code>.</p> <p>When the <dfn id=dom-mediacontroller-play title=dom-MediaController-play><code>play()</code></dfn> method is invoked, if the <code><a href=#mediacontroller>MediaController</a></code> is a <a href=#paused-media-controller>paused media controller</a>, the user agent must change the <code><a href=#mediacontroller>MediaController</a></code> into a <a href=#playing-media-controller>playing media controller</a>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-play><a href=#event-mediacontroller-play>play</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>, and then <a href=#report-the-controller-state>report the controller state</a> of the <code><a href=#mediacontroller>MediaController</a></code>.</p> <p>The <dfn id=dom-mediacontroller-played title=dom-MediaController-played><code>played</code></dfn> attribute must return a new static <a href=#normalized-timeranges-object>normalized <code>TimeRanges</code> object</a> that represents the union of the ranges of the <a href=#media-resource title="media resource">media resources</a> of the <a href=#slaved-media-elements>slaved media elements</a> that the user agent has so far rendered, at the time the attribute is evaluated.</p> <hr><p>A <code><a href=#mediacontroller>MediaController</a></code> has a <dfn id=media-controller-default-playback-rate>media controller default playback rate</dfn> and a <dfn id=media-controller-playback-rate>media controller playback rate</dfn>, which must both be set to 1.0 when the <code><a href=#mediacontroller>MediaController</a></code> object is created.</p> <p>The <dfn id=dom-mediacontroller-defaultplaybackrate title=dom-MediaController-defaultPlaybackRate><code>defaultPlaybackRate</code></dfn> attribute, on getting, must return the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-default-playback-rate>media controller default playback rate</a>, and on setting, must set the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-default-playback-rate>media controller default playback rate</a> to the new value, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-ratechange><a href=#event-mediacontroller-ratechange>ratechange</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>.</p> <p>The <dfn id=dom-mediacontroller-playbackrate title=dom-MediaController-playbackRate><code>playbackRate</code></dfn> attribute, on getting, must return the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-playback-rate>media controller playback rate</a>, and on setting, must set the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-playback-rate>media controller playback rate</a> to the new value, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-ratechange><a href=#event-mediacontroller-ratechange>ratechange</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>.</p> <hr><p>A <code><a href=#mediacontroller>MediaController</a></code> has a <dfn id=media-controller-volume-multiplier>media controller volume multiplier</dfn>, which must be set to 1.0 when the <code><a href=#mediacontroller>MediaController</a></code> object is created, and a <dfn id=media-controller-mute-override>media controller mute override</dfn>, much must initially be false.</p> <p>The <dfn id=dom-mediacontroller-volume title=dom-MediaController-volume><code>volume</code></dfn> attribute, on getting, must return the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-volume-multiplier>media controller volume multiplier</a>, and on setting, if the new value is in the range 0.0 to 1.0 inclusive, must set the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-volume-multiplier>media controller volume multiplier</a> to the new value and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-volumechange><a href=#event-mediacontroller-volumechange>volumechange</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception must be raised instead.</p> <p>The <dfn id=dom-mediacontroller-muted title=dom-MediaController-muted><code>muted</code></dfn> attribute, on getting, must return the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-mute-override>media controller mute override</a>, and on setting, must set the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-mute-override>media controller mute override</a> to the new value and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-MediaController-volumechange><a href=#event-mediacontroller-volumechange>volumechange</a></code> at the <code><a href=#mediacontroller>MediaController</a></code>.</p> <hr><p>The <a href=#media-resource title="media resource">media resources</a> of all the <a href=#slaved-media-elements>slaved media elements</a> of a <code><a href=#mediacontroller>MediaController</a></code> have a defined temporal relationship which provides relative offsets between the zero time of each such <a href=#media-resource>media resource</a>: for <a href=#media-resource title="media resource">media resources</a> with a <a href=#timeline-offset>timeline offset</a>, their relative offsets are the difference between their <a href=#timeline-offset>timeline offset</a>; the zero times of all the <a href=#media-resource title="media resource">media resources</a> without a <a href=#timeline-offset>timeline offset</a> are not offset from each other (i.e. the origins of their timelines are cotemporal); and finally, the zero time of the <a href=#media-resource>media resource</a> with the earliest <a href=#timeline-offset>timeline offset</a> (if any) is not offset from the zero times of the <a href=#media-resource title="media resource">media resources</a> without a <a href=#timeline-offset>timeline offset</a> (i.e. the origins of <a href=#media-resource title="media resource">media resources</a> without a <a href=#timeline-offset>timeline offset</a> are further cotemporal with the earliest defined point on the timeline of the <a href=#media-resource>media resource</a> with the earliest <a href=#timeline-offset>timeline offset</a>).</p> <p>The <dfn id=media-resource-end-position>media resource end position</dfn> of a <a href=#media-resource>media resource</a> in a <a href=#media-element>media element</a> is defined as follows: if the <a href=#media-resource>media resource</a> has a finite and known duration, the <a href=#media-resource-end-position>media resource end position</a> is the duration of the <a href=#media-resource>media resource</a>'s timeline (the last defined position on that timeline); otherwise, the <a href=#media-resource>media resource</a>'s duration is infinite or unknown, and the <a href=#media-resource-end-position>media resource end position</a> is the time of the last frame of <a href=#media-data>media data</a> currently available for that <a href=#media-resource>media resource</a>.</p> <p>Each <code><a href=#mediacontroller>MediaController</a></code> also has its own defined timeline. On this timeline, all the <a href=#media-resource title="media resource">media resources</a> of all the <a href=#slaved-media-elements>slaved media elements</a> of the <code><a href=#mediacontroller>MediaController</a></code> are temporally aligned according to their defined offsets. The <dfn id=media-controller-duration>media controller duration</dfn> of that <code><a href=#mediacontroller>MediaController</a></code> is the time from the earliest <a href=#earliest-possible-position>earliest possible position</a>, relative to this <code><a href=#mediacontroller>MediaController</a></code> timeline, of any of the <a href=#media-resource title="media resource">media resources</a> of the <a href=#slaved-media-elements>slaved media elements</a> of the <code><a href=#mediacontroller>MediaController</a></code>, to the time of the latest <a href=#media-resource-end-position>media resource end position</a> of the <a href=#media-resource title="media resource">media resources</a> of the <a href=#slaved-media-elements>slaved media elements</a> of the <code><a href=#mediacontroller>MediaController</a></code>, again relative to this <code><a href=#mediacontroller>MediaController</a></code> timeline.</p> <p>Each <code><a href=#mediacontroller>MediaController</a></code> has a <dfn id=media-controller-position>media controller position</dfn>. This is the time on the <code><a href=#mediacontroller>MediaController</a></code>'s timeline at which the user agent is trying to play the <a href=#slaved-media-elements>slaved media elements</a>. When a <code><a href=#mediacontroller>MediaController</a></code> is created, its <a href=#media-controller-position>media controller position</a> is initially zero.</p> <p>When the user agent is to <dfn id=bring-the-media-element-up-to-speed-with-its-new-media-controller title="bring the media element up to speed with its new media controller">bring a media element up to speed with its new media controller</dfn>, it must <a href=#dom-media-seek title=dom-media-seek>seek</a> that <a href=#media-element>media element</a> to the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-position>media controller position</a> relative to the <a href=#media-element>media element</a>'s timeline.</p> <p>When the user agent is to <dfn id=seek-the-media-controller>seek the media controller</dfn> to a particular <var title="">new playback position</var>, it must follow these steps:</p> <ol><li><p>If the <var title="">new playback position</var> is less than zero, then set it to zero.</li> <li><p>If the <var title="">new playback position</var> is greater than the <a href=#media-controller-duration>media controller duration</a>, then set it to the <a href=#media-controller-duration>media controller duration</a>.</li> <li><p>Set the <a href=#media-controller-position>media controller position</a> to the <var title="">new playback position</var>.</li> <li><p><a href=#dom-media-seek title=dom-media-seek>Seek</a> each <a href=#slaved-media-elements title="slaved media elements">slaved media element</a> to the <var title="">new playback position</var> relative to the <a href=#media-element>media element</a> timeline.</li> <!-- i.e. "bring the media element up to speed with its new media controller" --> </ol><p>A <code><a href=#mediacontroller>MediaController</a></code> is a <dfn id=blocked-media-controller>blocked media controller</dfn> if the <code><a href=#mediacontroller>MediaController</a></code> is a <a href=#paused-media-controller>paused media controller</a>, or if any of its <a href=#slaved-media-elements>slaved media elements</a> are <a href=#blocked-media-element title="blocked media element">blocked media elements</a>, or if any of its <a href=#slaved-media-elements>slaved media elements</a> whose <a href=#autoplaying-flag>autoplaying flag</a> is true still have their <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute set to true, or if all of its <a href=#slaved-media-elements>slaved media elements</a> have their <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute set to true.</p> <p>A <a href=#media-element>media element</a> is <dfn id=blocked-on-its-media-controller>blocked on its media controller</dfn> if the <code><a href=#mediacontroller>MediaController</a></code> is a <a href=#blocked-media-controller>blocked media controller</a>, or if its <a href=#media-controller-position>media controller position</a> is either before the <a href=#media-resource>media resource</a>'s <a href=#earliest-possible-position>earliest possible position</a> relative to the <code><a href=#mediacontroller>MediaController</a></code>'s timeline or after the end of the <a href=#media-resource>media resource</a> relative to the <code><a href=#mediacontroller>MediaController</a></code>'s timeline.</p> <p id=controller-playback>When a <code><a href=#mediacontroller>MediaController</a></code> is not a <a href=#blocked-media-controller>blocked media controller</a> and it has at least one <a href=#slaved-media-elements title="slaved media elements">slaved media element</a> whose <code><a href=#document>Document</a></code> is a <a href=#fully-active>fully active</a> <code><a href=#document>Document</a></code>, the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-position>media controller position</a> must increase monotonically at <a href=#media-controller-playback-rate>media controller playback rate</a> units of time on the <code><a href=#mediacontroller>MediaController</a></code>'s timeline per unit time of the clock used by its <a href=#slaved-media-elements>slaved media elements</a>.</p> <p>When the zero point on the timeline of a <code><a href=#mediacontroller>MediaController</a></code> moves relative to the timelines of the <a href=#slaved-media-elements>slaved media elements</a> by a time difference <var title="">ΔT</var>, the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#media-controller-position>media controller position</a> must be decremented by <var title="">ΔT</var>.</p> <p class=note>In some situations, e.g. when playing back a live stream without buffering anything, the <a href=#media-controller-position>media controller position</a> would increase monotonically as described above at the same rate as the <var title="">ΔT</var> described in the previous paragraph decreases it, with the end result that for all intents and purposes, the <a href=#media-controller-position>media controller position</a> would appear to remain constant (probably with the value 0).</p> <hr><p>A <code><a href=#mediacontroller>MediaController</a></code> has a <dfn id=most-recently-reported-readiness-state>most recently reported readiness state</dfn>, which is a number from 0 to 4 derived from the numbers used for the <a href=#media-element>media element</a> <code title=attr-media-readyState>readyState</code> attribute, and a <dfn id=most-recently-reported-playback-state>most recently reported playback state</dfn>, which is either <i>playing</i>, <i>waiting</i>, or <i>ended</i>.</p> <p>When a <code><a href=#mediacontroller>MediaController</a></code> is created, its <a href=#most-recently-reported-readiness-state>most recently reported readiness state</a> must be set to 0, and its <a href=#most-recently-reported-playback-state>most recently reported playback state</a> must be set to <i>waiting</i>.</p> <p>When a user agent is required to <dfn id=report-the-controller-state>report the controller state</dfn> for a <code><a href=#mediacontroller>MediaController</a></code>, the user agent must run the following steps:</p> <ol><li> <p>If the <code><a href=#mediacontroller>MediaController</a></code> has no <a href=#slaved-media-elements>slaved media elements</a>, let <var title="">new readiness state</var> be 0.</p> <p>Otherwise, let it have the lowest value of the <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> IDL attributes of all of its <a href=#slaved-media-elements>slaved media elements</a>.</p> </li> <li> <p>If the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#most-recently-reported-readiness-state>most recently reported readiness state</a> is not equal to <var title="">new readiness state</var> then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> at the <code><a href=#mediacontroller>MediaController</a></code> object, whose name is the event name corresponding to the value of <var title="">new readiness state</var> given in the table below:</p> <!-- hopefully everyone will understand what this means --> <table><thead><tr><th>Value of <var title="">new readiness state</var> <th>Event name <tbody><tr><td> 0 <td> <code title=event-MediaController-emptied><a href=#event-mediacontroller-emptied>emptied</a></code> <tr><td> 1 <td> <code title=event-MediaController-loadedmetadata><a href=#event-mediacontroller-loadedmetadata>loadedmetadata</a></code> <tr><td> 2 <td> <code title=event-MediaController-loadeddata><a href=#event-mediacontroller-loadeddata>loadeddata</a></code> <tr><td> 3 <td> <code title=event-MediaController-canplay><a href=#event-mediacontroller-canplay>canplay</a></code> <tr><td> 4 <td> <code title=event-MediaController-canplaythrough><a href=#event-mediacontroller-canplaythrough>canplaythrough</a></code> </table></li> <li><p>Let the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#most-recently-reported-readiness-state>most recently reported readiness state</a> be <var title="">new readiness state</var>.</li> <li> <p>Initialize <var title="">new playback state</var> by setting it to the state given for the first matching condition from the following list:</p> <dl class=switch><dt>If the <code><a href=#mediacontroller>MediaController</a></code> has no <a href=#slaved-media-elements>slaved media elements</a></dt> <dd>Let <var title="">new playback state</var> be <i>waiting</i>.</dd> <dt>If all of the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#slaved-media-elements>slaved media elements</a> have <a href=#ended-playback>ended playback</a> and the <a href=#media-controller-playback-rate>media controller playback rate</a> is positive or zero</dt> <dd>Let <var title="">new playback state</var> be <i>ended</i>.</dd> <dt>If the <code><a href=#mediacontroller>MediaController</a></code> is a <a href=#blocked-media-controller>blocked media controller</a></dt> <dd>Let <var title="">new playback state</var> be <i>waiting</i>.</dd> <dt>Otherwise</dt> <dd>Let <var title="">new playback state</var> be <i>playing</i>.</dd> </dl></li> <li><p>If the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#most-recently-reported-playback-state>most recently reported playback state</a> is not equal to <var title="">new playback state</var> and the <var title="">new playback state</var> is <i>ended</i>, then <a href=#queue-a-task>queue a task</a> that, if the <code><a href=#mediacontroller>MediaController</a></code> object is a <a href=#playing-media-controller>playing media controller</a>, and all of the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#slaved-media-elements>slaved media elements</a> have still <a href=#ended-playback>ended playback</a>, and the <a href=#media-controller-playback-rate>media controller playback rate</a> is still positive or zero, changes the <code><a href=#mediacontroller>MediaController</a></code> object to a <a href=#paused-media-controller>paused media controller</a> and then <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-MediaController-pause><a href=#event-mediacontroller-pause>pause</a></code> at the <code><a href=#mediacontroller>MediaController</a></code> object.</li> <li><p>If the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#most-recently-reported-playback-state>most recently reported playback state</a> is not equal to <var title="">new playback state</var> then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> at the <code><a href=#mediacontroller>MediaController</a></code> object, whose name is <code title=event-MediaController-playing><a href=#event-mediacontroller-playing>playing</a></code> if <var title="">new playback state</var> is <i>playing</i>, <code title=event-MediaController-ended><a href=#event-mediacontroller-ended>ended</a></code> if <var title="">new playback state</var> is <i>ended</i>, and <code title=event-MediaController-waiting><a href=#event-mediacontroller-waiting>waiting</a></code> otherwise.</li> <li><p>Let the <code><a href=#mediacontroller>MediaController</a></code>'s <a href=#most-recently-reported-playback-state>most recently reported playback state</a> be <var title="">new playback state</var>.</li> </ol><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#mediacontroller>MediaController</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-mediacontroller-onemptied title=handler-MediaController-onemptied><code>onemptied</code></dfn> <td> <code title=event-MediaController-emptied><a href=#event-mediacontroller-emptied>emptied</a></code> <tr><td><dfn id=handler-mediacontroller-onloadedmetadata title=handler-MediaController-onloadedmetadata><code>onloadedmetadata</code></dfn> <td> <code title=event-MediaController-loadedmetadata><a href=#event-mediacontroller-loadedmetadata>loadedmetadata</a></code> <tr><td><dfn id=handler-mediacontroller-onloadeddata title=handler-MediaController-onloadeddata><code>onloadeddata</code></dfn> <td> <code title=event-MediaController-loadeddata><a href=#event-mediacontroller-loadeddata>loadeddata</a></code> <tr><td><dfn id=handler-mediacontroller-oncanplay title=handler-MediaController-oncanplay><code>oncanplay</code></dfn> <td> <code title=event-MediaController-canplay><a href=#event-mediacontroller-canplay>canplay</a></code> <tr><td><dfn id=handler-mediacontroller-oncanplaythrough title=handler-MediaController-oncanplaythrough><code>oncanplaythrough</code></dfn> <td> <code title=event-MediaController-canplaythrough><a href=#event-mediacontroller-canplaythrough>canplaythrough</a></code> <tr><td><dfn id=handler-mediacontroller-onplaying title=handler-MediaController-onplaying><code>onplaying</code></dfn> <td> <code title=event-MediaController-playing><a href=#event-mediacontroller-playing>playing</a></code> <tr><td><dfn id=handler-mediacontroller-onended title=handler-MediaController-onended><code>onended</code></dfn> <td> <code title=event-MediaController-ended><a href=#event-mediacontroller-ended>ended</a></code> <tr><td><dfn id=handler-mediacontroller-onwaiting title=handler-MediaController-onwaiting><code>onwaiting</code></dfn> <td> <code title=event-MediaController-waiting><a href=#event-mediacontroller-waiting>waiting</a></code> <tbody><tr><td><dfn id=handler-mediacontroller-ondurationchange title=handler-MediaController-ondurationchange><code>ondurationchange</code></dfn> <td> <code title=event-MediaController-durationchange><a href=#event-mediacontroller-durationchange>durationchange</a></code> <tr><td><dfn id=handler-mediacontroller-ontimeupdate title=handler-MediaController-ontimeupdate><code>ontimeupdate</code></dfn> <td> <code title=event-MediaController-timeupdate><a href=#event-mediacontroller-timeupdate>timeupdate</a></code> <tr><td><dfn id=handler-mediacontroller-onplay title=handler-MediaController-onplay><code>onplay</code></dfn> <td> <code title=event-MediaController-play><a href=#event-mediacontroller-play>play</a></code> <tr><td><dfn id=handler-mediacontroller-onpause title=handler-MediaController-onpause><code>onpause</code></dfn> <td> <code title=event-MediaController-pause><a href=#event-mediacontroller-pause>pause</a></code> <tr><td><dfn id=handler-mediacontroller-onratechange title=handler-MediaController-onratechange><code>onratechange</code></dfn> <td> <code title=event-MediaController-ratechange><a href=#event-mediacontroller-ratechange>ratechange</a></code> <tr><td><dfn id=handler-mediacontroller-onvolumechange title=handler-MediaController-onvolumechange><code>onvolumechange</code></dfn> <td> <code title=event-MediaController-volumechange><a href=#event-mediacontroller-volumechange>volumechange</a></code> </table><hr><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> listed in this section is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> </div> <h6 id=assigning-a-media-controller-declaratively><span class=secno>4.8.10.11.3 </span>Assigning a media controller declaratively</h6> <p>The <dfn id=attr-media-mediagroup title=attr-media-mediagroup><code>mediagroup</code></dfn> content attribute on <a href=#media-element title="media element">media elements</a> can be used to link multiple <a href=#media-element title="media element">media elements</a> together by implicitly creating a <code><a href=#mediacontroller>MediaController</a></code>. The value is text; <a href=#media-element title="media element">media elements</a> with the same value are automatically linked by the user agent.</p> <div class=impl> <p>When a <a href=#media-element>media element</a> is created with a <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, and when a <a href=#media-element>media element</a>'s <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute is set, changed, or removed, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">m</var> be the <a href=#media-element>media element</a> in question.</li> <li><p>Let <var title="">m</var> have no <a href=#current-media-controller>current media controller</a>, if it currently has one.</li> <li><p>If <var title="">m</var>'s <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute is being removed, then abort these steps.</li> <li> <p>If there is another <a href=#media-element>media element</a> whose <code><a href=#document>Document</a></code> is the same as <var title="">m</var>'s <code><a href=#document>Document</a></code> (even if one or both of these elements are not actually <a href=#in-a-document title="in a Document"><em>in</em> the <code>Document</code></a>), and which also has a <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, and whose <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute has the same value as the new value of <var title="">m</var>'s <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, then let <var title="">controller</var> be that <a href=#media-element>media element</a>'s <a href=#current-media-controller>current media controller</a>.</p> <p>Otherwise, let <var title="">controller</var> be a newly created <code><a href=#mediacontroller>MediaController</a></code>.</p> </li> <li><p>Let <var title="">m</var>'s <a href=#current-media-controller>current media controller</a> be <var title="">controller</var>.</li> <li><p><a href=#bring-the-media-element-up-to-speed-with-its-new-media-controller>Bring the media element up to speed with its new media controller</a>.</li> </ol><p>The <dfn id=dom-media-mediagroup title=dom-media-mediaGroup><code>mediaGroup</code></dfn> IDL attribute on <a href=#media-element title="media element">media elements</a> must <a href=#reflect>reflect</a> the <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> content attribute.</p> </div> <div class=example> <p>Multiple <a href=#media-element title="media element">media elements</a> referencing the same <a href=#media-resource>media resource</a> will share a single network request. This can be used to efficiently play two (video) tracks from the same <a href=#media-resource>media resource</a> in two different places on the screen. Used with the <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code> attribute, these elements can also be kept synchronised.</p> <p>In this example, a sign-languge interpreter track from a movie file is overlaid on the primary video track of that same video file using two <code><a href=#the-video-element>video</a></code> elements, some CSS, and an implicit <code><a href=#mediacontroller>MediaController</a></code>:</p> <pre><article> <style scoped> div { margin: 1em auto; position: relative; width: 400px; height: 300px; } video { position; absolute; bottom: 0; right: 0; } video:first-child { width: 100%; height: 100%; } video:last-child { width: 30%; } </style> <div> <video src="movie.vid#track=Video&amp;track=English" autoplay controls mediagroup=movie></video> <video src="movie.vid#track=sign" autoplay mediagroup=movie></video> </div> </article></pre> </div> <!--v2: <h6>Ducking</h6> <p><dfn>Ducking</dfn> is the process of reducing the volume of one audio track when another audio track is playing, for example occasionally reducing the volume of a the soundtrack to allow the viewer to hear an intermittent commentary track.</p> (add an "autoduck" attribute that reduces the volume of other media elements with the same <span>current media controller</span> whenever this media element is playing audio) <video src="movie.vid#track=Video&amp;track=English" autoplay controls mediagroup=main></video> <audio src="movie.vid#track=Descriptions" mediagroup=main autoduck></audio> --> <h5 id=timed-text-tracks><span class=secno>4.8.10.12 </span>Timed text tracks</h5> <h6 id=text-track-model><span class=secno>4.8.10.12.1 </span>Text track model</h6> <p>A <a href=#media-element>media element</a> can have a group of associated <dfn id=text-track title="text track">text tracks</dfn>, known as the <a href=#media-element>media element</a>'s <dfn id=list-of-text-tracks>list of text tracks</dfn>. The <a href=#text-track title="text track">text tracks</a> are sorted as follows:</p> <ol class=brief><li>The <a href=#text-track title="text track">text tracks</a> corresponding to <code><a href=#the-track-element>track</a></code> element children of the <a href=#media-element>media element</a>, in <a href=#tree-order>tree order</a>.</li> <li>Any <a href=#text-track title="text track">text tracks</a> added using the <code title=dom-media-addTextTrack><a href=#dom-media-addtexttrack>addTextTrack()</a></code> method, in the order they were added, oldest first.</li> <li>Any <a href=#media-resource-specific-text-track title="media-resource-specific text track">media-resource-specific text tracks</a> (<a href=#text-track title="text track">text tracks</a> corresponding to data in the <a href=#media-resource>media resource</a>), in the order defined by the <a href=#media-resource>media resource</a>'s format specification.</li> </ol><p>A <a href=#text-track>text track</a> consists of:</p> <dl><dt><dfn id=text-track-kind title="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 title=dom-TextTrack-kind-subtitles><code>subtitles</code></dfn> <li><dfn id=dom-texttrack-kind-captions title=dom-TextTrack-kind-captions><code>captions</code></dfn> <li><dfn id=dom-texttrack-kind-descriptions title=dom-TextTrack-kind-descriptions><code>descriptions</code></dfn> <li><dfn id=dom-texttrack-kind-chapters title=dom-TextTrack-kind-chapters><code>chapters</code></dfn> <li><dfn id=dom-texttrack-kind-metadata title=dom-TextTrack-kind-metadata><code>metadata</code></dfn> </ul><p>The <a href=#text-track-kind title="text track kind">kind of track</a> can change dynamically, in the case of a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element.</p> </dd> <dt><dfn id=text-track-label title="text track label">A label</dfn> <dd> <p>This is a human-readable string intended to identify the track for the user. In certain cases, the label might be generated automatically.</p> <p>The <a href=#text-track-label title="text track label">label of a track</a> can change dynamically, in the case of a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element or in the case of an automatically-generated label whose value depends on variable factors such as the user's preferred user interface language.</p> </dd> <dt><dfn id=text-track-language title="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 title="text track language">language of a text track</a> can change dynamically, in the case of a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element.</p> </dd> <dt><dfn id=text-track-readiness-state title="text track readiness state">A readiness state</dfn> <dd> <p>One of the following:</p> <dl><dt><dfn id=text-track-not-loaded title="text track not loaded">Not loaded</dfn> <dd> <p>Indicates that the text track's cues have not been obtained.</p> </dd> <dt><dfn id=text-track-loading title="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> </dd> <dt><dfn id=text-track-loaded title="text track loaded">Loaded</dfn> <dd> <p>Indicates that the text track has been loaded with no fatal errors.</p> </dd> <dt><dfn id=text-track-failed-to-load title="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 href=#url>URL</a> could not be <a href=#resolve-a-url title="resolve a url">resolved</a>, network error, unknown text track format). Some or all of the cues are likely missing and will not be obtained.</p> </dd> </dl><p>The <a href=#text-track-readiness-state title="text track readiness state">readiness state</a> of a <a href=#text-track>text track</a> changes dynamically as the track is obtained.</p> </dd> <dt><dfn id=text-track-mode title="text track mode">A mode</dfn> <dd> <p>One of the following:</p> <dl><dt><dfn id=text-track-disabled title="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> </dd> <dt><dfn id=text-track-hidden title="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> </dd> <dt><dfn id=text-track-showing title="text track showing">Showing</dfn> <dt><dfn id=text-track-showing-by-default title="text track showing by default">Showing by default</dfn> </dt><dd> <p>Indicates that the text track is active. If no attempt has yet been made to obtain the track's cues, the user agent will perform such an attempt momentarily. The user agent is maintaining a list of which cues are active, and events are being fired accordingly. In addition, for text tracks whose <a href=#text-track-kind title="text track kind">kind</a> is <code title=dom-mediatrack-kind-subtitles>subtitles</code> or <code title=dom-mediatrack-kind-captions>captions</code>, the cues are being overlaid on the video as appropriate; for text tracks whose <a href=#text-track-kind title="text track kind">kind</a> is <code title=dom-mediatrack-kind-descriptions>descriptions</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 title="text track kind">kind</a> is <code title=dom-mediatrack-kind-chapters>chapters</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>media resource</a> by selecting a cue.</p> <p>The <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> state is used in conjunction with the <code title=attr-track-default><a href=#attr-track-default>default</a></code> attribute on <code><a href=#the-track-element>track</a></code> elements to indicate that the text track was enabled due to that attribute. This allows the user agent to override the state if a later track is discovered that is more appropriate per the user's preferences.</p> </dd> </dl></dd> <dt><dfn id=text-track-list-of-cues title="text track list of cues">A list of zero or more cues</dfn> <dd> <p>A list of <a href=#text-track-cue title="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>. <!--TTVTT--> For example, for <a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>. <!--TTVTT--> </p> <p>The <a href=#text-track-list-of-cues title="text track list of cues">list of cues of a text track</a> can change dynamically, either because the <a href=#text-track>text track</a> has <a href=#text-track-not-loaded title="text track not loaded">not yet been loaded</a> or is still <a href=#text-track-loading title="text track loading">loading</a>, or due to DOM manipulation.</p> </dd> </dl><p>Each <a href=#text-track>text track</a> has a corresponding <code><a href=#texttrack>TextTrack</a></code> object.</p> <p>The <a href=#text-track title="text track">text tracks</a> of a <a href=#media-element>media element</a> are <dfn id=the-text-tracks-are-ready title="the text tracks are ready">ready</dfn> if all the <a href=#text-track title="text track">text tracks</a> whose <a href=#text-track-mode title="text track mode">mode</a> was not in the <a href=#text-track-disabled title="text track disabled">disabled</a> state when the element's <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> last started now have a <a href=#text-track-readiness-state>text track readiness state</a> of <a href=#text-track-loaded title="text track loaded">loaded</a> or <a href=#text-track-failed-to-load title="text track failed to load">failed to load</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>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>text track cue</a> consists of:</p> <dl><dt><dfn id=text-track-cue-identifier title="text track cue identifier">An identifier</dfn> <dd> <p>An arbitrary string.</p> </dd> <dt><dfn id=text-track-cue-start-time title="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>media data</a> to which the cue applies.</p> </dd> <dt><dfn id=text-track-cue-end-time title="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>media data</a> to which the cue applies.</p> </dd> <dt><dfn id=text-track-cue-pause-on-exit-flag title="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>media resource</a> is to pause when the end of the range to which the cue applies is reached.</p> </dd> <dt><dfn id=text-track-cue-writing-direction title="text track cue writing direction">A writing direction</dfn> <dd> <p>A writing direction, either <dfn id=text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</dfn> (a line extends horizontally and is positioned vertically, with consecutive lines displayed below each other), <dfn id=text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</dfn> (a line extends vertically and is positioned horizontally, with consecutive lines displayed to the left of each other<!-- used for east asian-->), or <dfn id=text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</dfn> (a line extends vertically and is positioned horizontally, with consecutive lines displayed to the right of each other<!-- used for mongolian -->).</p> <!--TTVTT--> <p>If the <a href=#text-track-cue-writing-direction title="text track cue writing direction">writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, then <a href=#text-track-cue-line-position title="text track cue line position">line position</a> percentages are relative to the height of the video, and <a href=#text-track-cue-text-position title="text track cue text position">text position</a> and <a href=#text-track-cue-size title="text track cue size">size</a> percentages are relative to the width of the video.</p> <p>Otherwise, <a href=#text-track-cue-line-position title="text track cue line position">line position</a> percentages are relative to the width of the video, and <a href=#text-track-cue-text-position title="text track cue text position">text position</a> and <a href=#text-track-cue-size title="text track cue size">size</a> percentages are relative to the height of the video.</p> <!--TTVTT--> </dd> <!--TTVTT--> <dt><dfn id=text-track-cue-snap-to-lines-flag title="text track cue snap-to-lines flag">A snap-to-lines flag</dfn> <dd> <p>A boolean indicating whether the <a href=#text-track-cue-line-position title="text track cue line position">line's position</a> is a line position (positioned to a multiple of the line dimensions of the first line of the cue), or whether it is a percentage of the dimension of the video.</p> </dd> <dt><dfn id=text-track-cue-line-position title="text track cue line position">A line position</dfn> <dd> <p>Either a number giving the position of the lines of the cue, to be interpreted as defined by the <a href=#text-track-cue-writing-direction title="text track cue writing direction">writing direction</a> and <a href=#text-track-cue-snap-to-lines-flag title="text track cue snap-to-lines flag">snap-to-lines flag</a> of the cue, or the special value <dfn id=text-track-cue-automatic-line-position title="text track cue automatic line position">auto</dfn>, which means the position is to depend on the other active tracks.</p> <p>A <a href=#text-track-cue>text track cue</a> has a <dfn id=text-track-cue-computed-line-position>text track cue computed line position</dfn> whose value is defined in terms of the other aspects of the cue. If the <a href=#text-track-cue-line-position>text track cue line position</a> is numeric, then that is the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>. Otherwise, the <a href=#text-track-cue-line-position>text track cue line position</a> is the special value <a href=#text-track-cue-automatic-line-position title="text track cue automatic line position">auto</a>; if the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> of the <a href=#text-track-cue>text track cue</a> is not set, the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a> is the value 100; otherwise, it is the value returned by the following algorithm:</p> <ol><li><p>Let <var title="">cue</var> be the <a href=#text-track-cue>text track cue</a>.</li> <li><p>If <var title="">cue</var> is not associated with a <a href=#text-track>text track</a>, return −1 and abort these steps.</li> <li><p>Let <var title="">track</var> be the <a href=#text-track>text track</a> that the <var title="">cue</var> is associated with.</li> <li><p>Let <var title="">n</var> be the number of <a href=#text-track title="text track">text tracks</a> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> and that are in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> before <var title="">track</var>.</li> <li><p>Increment <var title="">n</var> by one.</li> <li><p>Negate <var title="">n</var>.</li> <li><p>Return <var title="">n</var>.</li> </ol></dd> <dt><dfn id=text-track-cue-text-position title="text track cue text position">A text position</dfn> <dd> <p>A number giving the position of the text of the cue within each line, to be interpreted as a percentage of the video, as defined by the <a href=#text-track-cue-writing-direction title="text track cue writing direction">writing direction</a>.</p> </dd> <!--TTVTT--> <dt><dfn id=text-track-cue-size title="text track cue size">A size</dfn> <dd> <p>A number giving the size of the box within which the text of each line of the cue is to be aligned, to be interpreted as a percentage of the video, as defined by the <a href=#text-track-cue-writing-direction title="text track cue writing direction">writing direction</a>.</p> </dd> <!--TTVTT--> <dt><dfn id=text-track-cue-alignment title="text track cue alignment">An alignment</dfn> <dd> <p>An alignment for the text of each line of the cue, either <dfn id=text-track-cue-start-alignment title="text track cue start alignment">start alignment</dfn> (the text is aligned towards its start side), <dfn id=text-track-cue-middle-alignment title="text track cue middle alignment">middle alignment</dfn> (the text is aligned centered between its start and end sides), <dfn id=text-track-cue-end-alignment title="text track cue end alignment">end alignment</dfn> (the text is aligned towards its end side). Which sides are the start and end sides depends on the Unicode bidirectional algorithm and the <a href=#text-track-cue-writing-direction title="text track cue writing direction">writing direction</a>. <a href=#refsBIDI>[BIDI]</a></p> </dd> <!--TTVTT--> <dt><dfn id=text-track-cue-text title="text track cue text">The text of the cue</dfn> <dd> <p>The raw text of the cue, and rules for its interpretation, allowing the text to be rendered and converted to a DOM fragment.</p> </dd> </dl><p>A <a href=#text-track-cue>text track cue</a> is immutable.</p> <p>Each <a href=#text-track-cue>text track cue</a> has a corresponding <code><a href=#texttrackcue>TextTrackCue</a></code> object, and can be associated with a particular <a href=#text-track>text track</a>. Once a <a href=#text-track-cue>text track cue</a> is associated with a particular <a href=#text-track>text track</a>, the association is permanent.</p> <p>In addition, each <a href=#text-track-cue>text track cue</a> has two pieces of dynamic information:</p> <dl><dt>The <dfn id=text-track-cue-active-flag title="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>text track cue</a> is removed from its <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues>text track list of cues</a>; whenever the <a href=#text-track>text track</a> itself is removed from its <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> or has its <a href=#text-track-mode>text track mode</a> changed to <a href=#text-track-disabled title="text track disabled">disabled</a>; and whenever the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is changed back to <code title=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 title="text track">text tracks</a> that were <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</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>rules for updating the text track rendering</a> of those <a href=#text-track title="text track">text tracks</a>. <!--TTVTT--> For example, for <a href=#text-track title="text track">text tracks</a> based on <a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>.</p> <!--TTVTT--> </dd> <dt>The <dfn id=text-track-cue-display-state title="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>text track cue active flag</a> is unset, the user agent must empty the <a href=#text-track-cue-display-state>text track cue display state</a>.</p> </dd> </dl><p>The <a href=#text-track-cue title="text track cue">text track cues</a> of a <a href=#media-element>media element</a>'s <a href=#text-track title="text track">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 title="text track cue">cues</a> by their <a href=#text-track>text track</a>, with the groups being sorted in the same order as their <a href=#text-track title="text track">text tracks</a> appear in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>; then, within each group, <a href=#text-track-cue title="text track cue">cues</a> must be sorted by their <a href=#text-track-cue-start-time title="text track cue start time">start time</a>, earliest first; then, any <a href=#text-track-cue title="text track cue">cues</a> with the same <a href=#text-track-cue-start-time title="text track cue start time">start time</a> must be sorted by their <a href=#text-track-cue-end-time title="text track cue end time">end time</a>, latest first; and finally, any <a href=#text-track-cue title="text track cue">cues</a> with identical <a href=#text-track-cue-end-time title="text track cue end time">end times</a> must be sorted in the order they were created (so e.g. for cues from a <a href=#webvtt>WebVTT</a> file, that would be the order in which the cues were listed in the file).</p> <h6 id=sourcing-in-band-text-tracks><span class=secno>4.8.10.12.2 </span>Sourcing in-band text tracks</h6> <p>A <dfn id=media-resource-specific-text-track>media-resource-specific text track</dfn> is a <a href=#text-track>text track</a> that corresponds to data found in the <a href=#media-resource>media resource</a>.</p> <div class=impl> <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>media resource</a> is a video.</p> <p>When a <a href=#media-resource>media resource</a> contains data that the user agent recognises and supports as being equivalent to a <a href=#text-track>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> <!-- this runs synchronously from a fetch task --> <ol><li><p>Associate the relevant data with a new <a href=#text-track>text track</a> and its corresponding new <code><a href=#texttrack>TextTrack</a></code> object. The <a href=#text-track>text track</a> is a <a href=#media-resource-specific-text-track>media-resource-specific text track</a>.</li> <li><p>Set the new <a href=#text-track>text track</a>'s <a href=#text-track-kind title="text track kind">kind</a>, <a href=#text-track-label title="text track label">label</a>, and <a href=#text-track-language title="text track language">language</a> based on the semantics of the relevant data, as defined by the relevant specification.</li> <li><p>Populate the new <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues title="text track list of cues">list of cues</a> with the cues parsed so far, folllowing the <a href=#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues>guidelines for exposing cues</a>, and begin updating it dynamically as necessary.</li> <li><p>Set the new <a href=#text-track>text track</a>'s <a href=#text-track-readiness-state title="text track readiness state">readiness state</a> to <a href=#text-track-loaded title="text track loaded">loaded</a>.</li> <!-- otherwise, you'll have to load the whole media file just to start playing the first frame... --> <li><p>Set the new <a href=#text-track>text track</a>'s <a href=#text-track-mode title="text track mode">mode</a> to the mode consistent with the user's preferences and the requirements of the relevant specification for the data.</li> <li><p>Leave the <a href=#text-track-list-of-cues>text track list of cues</a> empty, and associate with it the <a href=#rules-for-updating-the-text-track-rendering>rules for updating the text track rendering</a> appropriate for the format in question.</p> <li><p>Add the new <a href=#text-track>text track</a> to the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</li> <li><p>Fire an event with the name <code title=event-addtrack>addtrack</code>, that does not bubble and is not cancelable, and that uses the <code><a href=#trackevent>TrackEvent</a></code> interface, with the <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code> attribute initialized to the <a href=#text-track>text track</a>'s <code><a href=#texttrack>TextTrack</a></code> object, at the <a href=#media-element>media element</a>'s <code title=dom-media-textTracks><a href=#dom-media-texttracks>textTracks</a></code> attribute's <code><a href=#texttracklist>TextTrackList</a></code> object.</li> </ol><p>When a <a href=#media-element>media element</a> is to <dfn id="forget-the-media-element's-media-resource-specific-text-tracks">forget the media element's media-resource-specific text tracks</dfn>, the user agent must remove from the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> all the <a href=#media-resource-specific-text-track title="media-resource-specific text track">media-resource-specific text tracks</a>.</p> </div> <div class=impl> <h6 id=sourcing-out-of-band-text-tracks><span class=secno>4.8.10.12.3 </span>Sourcing out-of-band text tracks</h6> <p>When a <code><a href=#the-track-element>track</a></code> element is created, it must be associated with a new <a href=#text-track>text track</a> (with its value set as defined below) and its corresponding new <code><a href=#texttrack>TextTrack</a></code> object.</p> <p>The <a href=#text-track-kind>text track kind</a> is determined from the state of the element's <code title=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 title="text track kind">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 title=attr-track-kind-subtitles>Subtitles</a> <td><code title=dom-timedtrack-kind-subtitles>subtitles</code> <tr><td><a href=#attr-track-kind-captions title=attr-track-kind-captions>Captions</a> <td><code title=dom-timedtrack-kind-captions>captions</code> <tr><td><a href=#attr-track-kind-descriptions title=attr-track-kind-descriptions>Descriptions</a> <td><code title=dom-timedtrack-kind-descriptions>descriptions</code> <tr><td><a href=#attr-track-kind-chapters title=attr-track-kind-chapters>Chapters</a> <td><code title=dom-timedtrack-kind-chapters>chapters</code> <tr><td><a href=#attr-track-kind-metadata title=attr-track-kind-metadata>Metadata</a> <td><code title=dom-timedtrack-kind-metadata>metadata</code> </table><p>The <a href=#text-track-label>text track label</a> is the element's <a href=#track-label>track label</a>.</p> <p>The <a href=#text-track-language>text track language</a> is the element's <a href=#track-language>track language</a>, if any, or the empty string otherwise.</p> <p>As the <code title=attr-track-kind><a href=#attr-track-kind>kind</a></code>, <code title=attr-track-label><a href=#attr-track-label>label</a></code>, and <code title=attr-track-srclang><a href=#attr-track-srclang>srclang</a></code> attributes are set, changed, or removed, the <a href=#text-track>text track</a> must update accordingly, as per the definitions above.</p> <p class=note>Changes to the <a href=#track-url>track URL</a> are handled in the algorithm below.</p> <p>The <a href=#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>rules for updating the text track rendering</a> appropriate for the format in question; for <a href=#webvtt>WebVTT</a>, this is the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>.</p> <p>When a <code><a href=#the-track-element>track</a></code> element's parent element changes and the new parent is a <a href=#media-element>media element</a>, then the user agent must add the <code><a href=#the-track-element>track</a></code> element's corresponding <a href=#text-track>text track</a> to the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>, and then <a href=#queue-a-task>queue a task</a> to fire an event with the name <code title=event-addtrack>addtrack</code>, that does not bubble and is not cancelable, and that uses the <code><a href=#trackevent>TrackEvent</a></code> interface, with the <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code> attribute initialized to the <a href=#text-track>text track</a>'s <code><a href=#texttrack>TextTrack</a></code> object, at the <a href=#media-element>media element</a>'s <code title=dom-media-textTracks><a href=#dom-media-texttracks>textTracks</a></code> attribute's <code><a href=#texttracklist>TextTrackList</a></code> object.</p> <p>When a <code><a href=#the-track-element>track</a></code> element's parent element changes and the old parent was a <a href=#media-element>media element</a>, then the user agent must remove the <code><a href=#the-track-element>track</a></code> element's corresponding <a href=#text-track>text track</a> from the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</p> <!-- removetrack --> <p>When a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element is added to a <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>, the user agent must set the <a href=#text-track-mode>text track mode</a> appropriately, as determined by the following conditions:</p> <dl class=switch><dt>If the <a href=#text-track-kind>text track kind</a> is <code title=dom-TextTrack-kind-subtitles><a href=#dom-texttrack-kind-subtitles>subtitles</a></code> or <code title=dom-TextTrack-kind-captions><a href=#dom-texttrack-kind-captions>captions</a></code> and the user has indicated an interest in having a track with this <a href=#text-track-kind>text track kind</a>, <a href=#text-track-language>text track language</a>, and <a href=#text-track-label>text track label</a> enabled, and there is no other <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> with a <a href=#text-track-kind>text track kind</a> of either <code title=dom-TextTrack-kind-subtitles><a href=#dom-texttrack-kind-subtitles>subtitles</a></code> or <code title=dom-TextTrack-kind-captions><a href=#dom-texttrack-kind-captions>captions</a></code> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a></dt> <dt>If the <a href=#text-track-kind>text track kind</a> is <code title=dom-TextTrack-kind-descriptions><a href=#dom-texttrack-kind-descriptions>descriptions</a></code> and the user has indicated an interest in having text descriptions with this <a href=#text-track-language>text track language</a> and <a href=#text-track-label>text track label</a> enabled, and there is no other <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> with a <a href=#text-track-kind>text track kind</a> of <code title=dom-TextTrack-kind-descriptions><a href=#dom-texttrack-kind-descriptions>descriptions</a></code> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a></dt> <dd> <p>Let the <a href=#text-track-mode>text track mode</a> be <a href=#text-track-showing title="text track showing">showing</a>.</p> <p>If there is a <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>, the user agent must furthermore change <em>that</em> <a href=#text-track>text track</a>'s <a href=#text-track-mode>text track mode</a> to <a href=#text-track-hidden title="text track hidden">hidden</a>.</p> <!-- so that we still get events and stuff: we can expect authors to forget that default doesn't mean that it'll always be turned on, and that they'll still rely on events firing even if it doesn't show --> </dd> <dt>If the <a href=#text-track-kind>text track kind</a> is <code title=dom-TextTrack-kind-chapters><a href=#dom-texttrack-kind-chapters>chapters</a></code> and the <a href=#text-track-language>text track language</a> is one that the user agent has reason to believe is appropriate for the user, and there is no other <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> with a <a href=#text-track-kind>text track kind</a> of <code title=dom-TextTrack-kind-chapters><a href=#dom-texttrack-kind-chapters>chapters</a></code> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a></dt> <dd> <p>Let the <a href=#text-track-mode>text track mode</a> be <a href=#text-track-showing title="text track showing">showing</a>.</p> </dd> <dt>If the <code><a href=#the-track-element>track</a></code> element has a <code title=attr-track-default><a href=#attr-track-default>default</a></code> attribute specified, and there is no other <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a></dt> <dd> <p>Let the <a href=#text-track-mode>text track mode</a> be <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>.</p> </dd> <dt>Otherwise</dt> <dd> <p>Let the <a href=#text-track-mode>text track mode</a> be <a href=#text-track-disabled title="text track disabled">disabled</a>.</p> </dd> </dl><p>When a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element is created with <a href=#text-track-mode>text track mode</a> set to <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>, and when a <a href=#text-track>text track</a> corresponding to a <code><a href=#the-track-element>track</a></code> element is created with <a href=#text-track-mode>text track mode</a> set to <a href=#text-track-disabled title="text track disabled">disabled</a> and subsequently changes its <a href=#text-track-mode>text track mode</a> to <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> for the first time, the user agent must immediately and synchronously run the following algorithm. This algorithm interacts closely with the <a href=#event-loop>event loop</a> mechanism; in particular, it has a <a href=#synchronous-section>synchronous section</a> (which is triggered as part of the <a href=#event-loop>event loop</a> algorithm). The step in that section is marked with ⌛.</p> <ol><li><p>Set the <a href=#text-track-readiness-state>text track readiness state</a> to <a href=#text-track-loading title="text track loading">loading</a>.</li> <li><p>Let <var title="">URL</var> be the <a href=#track-url>track URL</a> of the <code><a href=#the-track-element>track</a></code> element.</li> <li><p>Asynchronously run the remaining steps, while continuing with whatever task was responsible for creating the <a href=#text-track>text track</a> or changing the <a href=#text-track-mode>text track mode</a>.</li> <li> <p><i>Download</i>: At this point, the text track is downloaded.</p> <p>If <var title="">URL</var> is not the empty string, perform a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of <var title="">URL</var>, with the <i>mode</i> being the state of the <a href=#media-element>media element</a>'s <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> content attribute, the <i title="">origin</i> being the <a href=#origin>origin</a> of the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code>, and the <i>default origin behaviour</i> set to <i>fail</i>.</p> <p>The resource obtained in this fashion, if any, contains the text track data. If any data is obtained, it is by definition <a href=#cors-same-origin>CORS-same-origin</a> (cross-origin resources that are not suitably CORS-enabled do not get this far).</p> <p>The <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#fetch title=fetch>fetching algorithm</a> on the <a href=#networking-task-source>networking task source</a> to process the data as it is being fetched must <a href=#content-type-sniffing-0 title="Content-Type sniffing">determine the sniffed type of a the resource</a>. If the sniffed 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 <!--TTVTT--> (e.g. the <a href=#webvtt-parser>WebVTT parser</a> if the file starts with the "<code title="">WEBVTT</code>" signature) <!--TTVTT--> as it is received, with the <a href=#text-track-list-of-cues>text track list of cues</a> being used for that parser's output.</p> <p>If the <a href=#fetch title=fetch>fetching algorithm</a> fails for any reason (network error, the server returns an error code, a cross-origin check fails, etc), if <var title="">URL</var> is the empty string, or if the sniffed type of the resource is not a supported text track format, then <a href=#queue-a-task>queue a task</a> to first change the <a href=#text-track-readiness-state>text track readiness state</a> to <a href=#text-track-failed-to-load title="text track failed to load">failed to load</a> and then <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-track-element>track</a></code> element; and then, once that <a href=#concept-task title=concept-task>task</a> is <a href=#queue-a-task title="queue a task">queued</a>, move on to the step below labeled <i>monitoring</i>.</p> <p>If the <a href=#fetch title=fetch>fetching algorithm</a> does not fail, then the final <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> must run the following steps:</p> <ol><li><p>Change the <a href=#text-track-readiness-state>text track readiness state</a> to <a href=#text-track-loaded title="text track loaded">loaded</a>.</li> <li> <p>If the file was successfully processed, <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-track-element>track</a></code> element.</p> <p>If 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 <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-track-element>track</a></code> element.</p> </li> <li><p>Jump to the step below labeled <i>monitoring</i>.</li> </ol><p>If, while the <a href=#fetch title=fetch>fetching algorithm</a> is active, either:</p> <ul><li>the <a href=#track-url>track URL</a> changes so that it is no longer equal to <var title="">URL</var>, while the <a href=#text-track-mode>text track mode</a> is set to <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>; or</li> <li>the <a href=#text-track-mode>text track mode</a> changes to <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>, while the <a href=#track-url>track URL</a> is not equal to <var title="">URL</var></li> </ul><p>...then the user agent must run the following steps:</p> <ol><li><p>Abort the <a href=#fetch title=fetch>fetching algorithm</a>, discarding any pending <a href=#concept-task title=concept-task>tasks</a> generated by that algorithm.</li> <li><p>Let <var title="">URL</var> be the new <a href=#track-url>track URL</a>.</li> <li><p>Jump back to the top of the step labeled <i>download</i>.</li> </ol><p>Until one of the above circumstances occurs, the user agent must remain on this step.</p> </li> <li><p><i>Monitoring</i>: Wait until the <a href=#track-url>track URL</a> is no longer equal to <var title="">URL</var>, at the same time as the <a href=#text-track-mode>text track mode</a> is set to <a href=#text-track-hidden title="text track hidden">hidden</a>, <a href=#text-track-showing title="text track showing">showing</a>, or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>.</li> <li><p>Wait until the <a href=#text-track-readiness-state>text track readiness state</a> is no longer set to <a href=#text-track-loading title="text track loading">loading</a>.</li> <li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of the following step. (The step in the <a href=#synchronous-section>synchronous section</a> is marked with ⌛.)</li> <li><p>⌛ Set the <a href=#text-track-readiness-state>text track readiness state</a> to <a href=#text-track-loading title="text track loading">loading</a>.</li> <!-- if you add more, change the grammar of the sentences above to be plural with respect to the number of synchronous steps (both in the step above and in the intro to the whole algorithm) --> <li><p>End the <a href=#synchronous-section>synchronous section</a>, continuing the remaining steps asynchronously.</li> <li><p>Jump to the step labeled <i>download</i>.</li> </ol></div> <!--TTVTT--> <div data-component="other Hixie drafts (editor: Ian Hickson)"> <div class=impl> <h6 id=guidelines-for-exposing-cues-in-various-formats-as-text-track-cues><span class=secno>4.8.10.12.4 </span><dfn>Guidelines for exposing cues</dfn> in various formats as <a href=#text-track-cue title="text track cue">text track cues</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>text track</a> model of HTML, each unit of timed data is converted to a <a href=#text-track-cue>text track cue</a>. Where the mapping of the format's features to the aspects of a <a href=#text-track-cue>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>text track cue</a> as defined above, as well as with the following constraints:</p> <dl><dt>The <a href=#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> </dd> <dt>The <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> <dd> <p>Should be set to false.</p> </dd> <dt>The <a href=#text-track-cue-writing-direction>text track cue writing direction</a> <dd> <p>Should be set to <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a> if the concept of writing direction doesn't really apply (e.g. the cue consists of a bitmap image).</p> </dd> <dt>The <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> <dd> <p>Should be set to false unless the format uses a rendering and positioning model for cues that is largely consistent with the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a>.</p> </dd> <dt>The <a href=#text-track-cue-line-position>text track cue line position</a> <dt>The <a href=#text-track-cue-text-position>text track cue text position</a> <dt>The <a href=#text-track-cue-size>text track cue size</a> <dt>The <a href=#text-track-cue-alignment>text track cue alignment</a> </dt></dt></dt><dd> <p>If the format uses a rendering and positioning model for cues that can be largely simulated using the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a>, then these should be set to the values that would give the same effect for <a href=#webvtt>WebVTT</a> cues. Otherwise, they should be set to zero.</p> </dd> </dl></div> </div> <!--TTVTT--> <h6 id=text-track-api><span class=secno>4.8.10.12.5 </span>Text track API</h6> <pre class=idl>interface <dfn id=texttracklist>TextTrackList</dfn> { readonly attribute unsigned long <a href=#dom-texttracklist-length title=dom-TextTrackList-length>length</a>; getter <a href=#texttrack>TextTrack</a> (unsigned long index); [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-texttracklist-onaddtrack title=handler-TextTrackList-onaddtrack>onaddtrack</a>; };</pre> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-textTracks><a href=#dom-media-texttracks>textTracks</a></code> . <code title="">length</code></dt> <dd> <p>Returns the number of <a href=#text-track title="text track">text tracks</a> associated with the <a href=#media-element>media element</a> (e.g. from <code><a href=#the-track-element>track</a></code> elements). This is the number of <a href=#text-track title="text track">text tracks</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-textTracks><a href=#dom-media-texttracks>textTracks[</a></code> <var title="">n</var> <code title="">]</code></dt> <dd> <p>Returns the <code><a href=#texttrack>TextTrack</a></code> object representing the <var title="">n</var>th <a href=#text-track>text track</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</p> </dd> <dt><var title="">track</var> . <code title=dom-track-track><a href=#dom-track-track>track</a></code></dt> <dd> <p>Returns the <code><a href=#texttrack>TextTrack</a></code> object representing the <code><a href=#the-track-element>track</a></code> element's <a href=#text-track>text track</a>.</p> </dd> </dl><div class=impl> <p>A <code><a href=#texttracklist>TextTrackList</a></code> object represents a dynamically updating list of <a href=#text-track title="text track">text tracks</a> in a given order.</p> <p>The <dfn id=dom-media-texttracks title=dom-media-textTracks><code>textTracks</code></dfn> attribute of <a href=#media-element title="media element">media elements</a> must return a <code><a href=#texttracklist>TextTrackList</a></code> object representing the <code><a href=#texttrack>TextTrack</a></code> objects of the <a href=#text-track title="text track">text tracks</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>, in the same order as in the <a href=#list-of-text-tracks>list of text tracks</a>. The same object must be returned each time the attribute is accessed. <a href=#refsWEBIDL>[WEBIDL]</a></p> <p>The <dfn id=dom-texttracklist-length title=dom-TextTrackList-length><code>length</code></dfn> attribute of a <code><a href=#texttracklist>TextTrackList</a></code> object must return the number of <a href=#text-track title="text track">text tracks</a> in the list represented by the <code><a href=#texttracklist>TextTrackList</a></code> object.</p> <p>The <a href=#supported-property-indices>supported property indices</a> of a <code><a href=#texttracklist>TextTrackList</a></code> object at any instant are the numbers from zero to the number of <a href=#text-track title="text track">text tracks</a> in the list represented by the <code><a href=#texttracklist>TextTrackList</a></code> object minus one, if any. If there are no <a href=#text-track title="text track">text tracks</a> in the list, there are no <a href=#supported-property-indices>supported property indices</a>.</p> <p>To <a href=#determine-the-value-of-an-indexed-property>determine the value of an indexed property</a> of a <code><a href=#texttracklist>TextTrackList</a></code> object for a given index <var title="">index</var>, the user agent must return the <var title="">index</var>th <a href=#text-track>text track</a> in the list represented by the <code><a href=#texttracklist>TextTrackList</a></code> object.</p> </div> <hr><pre class=idl>interface <dfn id=texttrack>TextTrack</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute DOMString <a href=#dom-texttrack-kind title=dom-TextTrack-kind>kind</a>; readonly attribute DOMString <a href=#dom-texttrack-label title=dom-TextTrack-label>label</a>; readonly attribute DOMString <a href=#dom-texttrack-language title=dom-TextTrack-language>language</a>; const unsigned short <a href=#dom-texttrack-disabled title=dom-TextTrack-DISABLED>DISABLED</a> = 0; const unsigned short <a href=#dom-texttrack-hidden title=dom-TextTrack-HIDDEN>HIDDEN</a> = 1; const unsigned short <a href=#dom-texttrack-showing title=dom-TextTrack-SHOWING>SHOWING</a> = 2; attribute unsigned short <a href=#dom-texttrack-mode title=dom-TextTrack-mode>mode</a>; readonly attribute <a href=#texttrackcuelist>TextTrackCueList</a>? <a href=#dom-texttrack-cues title=dom-TextTrack-cues>cues</a>; readonly attribute <a href=#texttrackcuelist>TextTrackCueList</a>? <a href=#dom-texttrack-activecues title=dom-TextTrack-activeCues>activeCues</a>; void <a href=#dom-texttrack-addcue title=dom-TextTrack-addCue>addCue</a>(<a href=#texttrackcue>TextTrackCue</a> cue); void <a href=#dom-texttrack-removecue title=dom-TextTrack-removeCue>removeCue</a>(<a href=#texttrackcue>TextTrackCue</a> cue); [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-texttrack-oncuechange title=handler-TextTrack-oncuechange>oncuechange</a>; };</pre> <dl class=domintro><dt><var title="">textTrack</var> . <code title=dom-TextTrack-kind><a href=#dom-texttrack-kind>kind</a></code></dt> <dd> <p>Returns the <a href=#text-track-kind>text track kind</a> string.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-label><a href=#dom-texttrack-label>label</a></code></dt> <dd> <p>Returns the <a href=#text-track-label>text track label</a>.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-language><a href=#dom-texttrack-language>language</a></code></dt> <dd> <p>Returns the <a href=#text-track-language>text track language</a> string.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-mode><a href=#dom-texttrack-mode>mode</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-mode>text track mode</a>, represented by a number from the following list:</p> <dl><dt><code><a href=#texttrack>TextTrack</a></code> . <code title=dom-TextTrack-DISABLED><a href=#dom-texttrack-disabled>DISABLED</a></code> (0)</dt> <dd> <p>The <a href=#text-track-disabled>text track disabled</a> mode.</p> </dd> <dt><code><a href=#texttrack>TextTrack</a></code> . <code title=dom-TextTrack-HIDDEN><a href=#dom-texttrack-hidden>HIDDEN</a></code> (1)</dt> <dd> <p>The <a href=#text-track-hidden>text track hidden</a> mode.</p> </dd> <dt><code><a href=#texttrack>TextTrack</a></code> . <code title=dom-TextTrack-SHOWING><a href=#dom-texttrack-showing>SHOWING</a></code> (2)</dt> <dd> <p>The <a href=#text-track-showing>text track showing</a> and <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> modes.</p> </dd> </dl><p>Can be set, to change the mode.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-cues><a href=#dom-texttrack-cues>cues</a></code></dt> <dd> <p>Returns the <a href=#text-track-list-of-cues>text track list of cues</a>, as a <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-activeCues><a href=#dom-texttrack-activecues>activeCues</a></code></dt> <dd> <p>Returns the <a href=#text-track-cue title="text track cue">text track cues</a> from the <a href=#text-track-list-of-cues>text track list of cues</a> that are currently active (i.e. that start before the <a href=#current-playback-position>current playback position</a> and end after it), as a <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-addCue><a href=#dom-texttrack-addcue>addCue</a></code>( <var title="">cue</var> )</dt> <dd> <p>Adds the given cue to <var title="">textTrack</var>'s <a href=#text-track-list-of-cues>text track list of cues</a>.</p> <p>Throws an exception if the argument is associated with another <a href=#text-track>text track</a> or already in the list of cues.</p> </dd> <dt><var title="">textTrack</var> . <code title=dom-TextTrack-removeCue><a href=#dom-texttrack-removecue>removeCue</a></code>( <var title="">cue</var> )</dt> <dd> <p>Removes the given cue from <var title="">textTrack</var>'s <a href=#text-track-list-of-cues>text track list of cues</a>.</p> <p>Throws an exception if the argument is associated with another <a href=#text-track>text track</a> or not in the list of cues.</p> </dd> <dt><var title="">textTrack</var> = <var title="">media</var> . <code title=dom-media-addTextTrack><a href=#dom-media-addtexttrack>addTextTrack</a></code>( <var title="">kind</var> [, <var title="">label</var> [, <var title="">language</var> ] ] )</dt> <dd> <p>Creates and returns a new <code><a href=#texttrack>TextTrack</a></code> object, which is also added to the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-texttrack-kind title=dom-TextTrack-kind><code>kind</code></dfn> attribute must return the <a href=#text-track-kind>text track kind</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents.</p> <p>The <dfn id=dom-texttrack-label title=dom-TextTrack-label><code>label</code></dfn> attribute must return the <a href=#text-track-label>text track label</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents.</p> <p>The <dfn id=dom-texttrack-language title=dom-TextTrack-language><code>language</code></dfn> attribute must return the <a href=#text-track-language>text track language</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents.</p> <p>The <dfn id=dom-texttrack-mode title=dom-TextTrack-mode><code>mode</code></dfn> attribute, on getting, must return the numeric value corresponding to the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents, as defined by the following list:</p> <dl><dt><dfn id=dom-texttrack-disabled title=dom-TextTrack-DISABLED><code>DISABLED</code></dfn> (numeric value 0)</dt> <dd>The <a href=#text-track-disabled>text track disabled</a> mode.</dd> <dt><dfn id=dom-texttrack-hidden title=dom-TextTrack-HIDDEN><code>HIDDEN</code></dfn> (numeric value 1)</dt> <dd>The <a href=#text-track-hidden>text track hidden</a> mode.</dd> <dt><dfn id=dom-texttrack-showing title=dom-TextTrack-SHOWING><code>SHOWING</code></dfn> (numeric value 2)</dt> <dd>The <a href=#text-track-showing>text track showing</a> and <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> modes.</dd> </dl><p>On setting, if the new value is not either 0, 1, or 2, the user agent must throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception. Otherwise, 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 0</dt> <dd> <p>Set the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents to the <a href=#text-track-disabled>text track disabled</a> mode.</p> </dd> <dt>If the new value is 1</dt> <dd> <p>Set the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents to the <a href=#text-track-hidden>text track hidden</a> mode.</p> </dd> <dt>If the new value is 2</dt> <dd> <p>Set the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents to the <a href=#text-track-showing>text track showing</a> mode.</p> <p class=note>If the mode had been <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>, this will change it to <a href=#text-track-showing title="text track showing">showing</a>, even though the value of <code title=dom-TextTrack-mode><a href=#dom-texttrack-mode>mode</a></code> would appear not to change.</p> </dd> </dl><p>If the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents is not the <a href=#text-track-disabled>text track disabled</a> mode, then the <dfn id=dom-texttrack-cues title=dom-TextTrack-cues><code>cues</code></dfn> attribute must return a <a href=#live>live</a> <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object that represents the subset of the <a href=#text-track-list-of-cues>text track list of cues</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents whose <a href=#text-track-cue-start-time title="text track cue start time">start times</a> occur at or after the <a href=#earliest-possible-position-when-the-script-started>earliest possible position when the script started</a>, in <a href=#text-track-cue-order>text track cue order</a>. Otherwise, it must return null. When an object is returned, the same 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>earliest possible position</a> was the last time the <a href=#event-loop>event loop</a> reached step 1.</p> <p>If the <a href=#text-track-mode>text track mode</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents is not the <a href=#text-track-disabled>text track disabled</a> mode, then the <dfn id=dom-texttrack-activecues title=dom-TextTrack-activeCues><code>activeCues</code></dfn> attribute must return a <a href=#live>live</a> <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object that represents the subset of the <a href=#text-track-list-of-cues>text track list of cues</a> of the <a href=#text-track>text track</a> that the <code><a href=#texttrack>TextTrack</a></code> object represents whose <a href=#active-flag-was-set-when-the-script-started>active flag was set when the script started</a>, in <a href=#text-track-cue-order>text track cue order</a>. Otherwise, it must return null. When an object is returned, the same object must be returned each time.</p> <p>A <a href=#text-track-cue>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>text track cue active flag</a> was set the last time the <a href=#event-loop>event loop</a> reached step 1.</p> <hr><p>The <dfn id=dom-texttrack-addcue title=dom-TextTrack-addCue><code>addCue(<var title="">cue</var>)</code></dfn> method of <code><a href=#texttrack>TextTrack</a></code> objects, when invoked, must run the following steps:</p> <ol><li><p>If the given <var title="">cue</var> is already associated with a <a href=#text-track>text track</a> other than the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>Associate <var title="">cue</var> with the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>, if it is not currently associated with a <a href=#text-track>text track</a>.</li> <li><p>If the given <var title="">cue</var> is already listed in the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues>text track list of cues</a>, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>Add <var title="">cue</var> to the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues>text track list of cues</a>.</li> </ol><p>The <dfn id=dom-texttrack-removecue title=dom-TextTrack-removeCue><code>removeCue(<var title="">cue</var>)</code></dfn> method of <code><a href=#texttrack>TextTrack</a></code> objects, when invoked, must run the following steps:</p> <ol><li><p>If the given <var title="">cue</var> is not associated with the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>If the given <var title="">cue</var> is not currently listed in the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues>text track list of cues</a>, then throw a <code><a href=#notfounderror>NotFoundError</a></code> exception.</li> <li><p>Remove <var title="">cue</var> from the method's <code><a href=#texttrack>TextTrack</a></code> object's <a href=#text-track>text track</a>'s <a href=#text-track-list-of-cues>text track list of cues</a>.</li> </ol><hr><p>The <dfn id=dom-media-addtexttrack title=dom-media-addTextTrack><code>addTextTrack(<var title="">kind</var>, <var title="">label</var>, <var title="">language</var>)</code></dfn> method of <a href=#media-element title="media element">media elements</a>, when invoked, must run the following steps:</p> <ol><li> <p>If <var title="">kind</var> is not one of the following strings, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps:</p> <ul class=brief><li><code title=dom-TextTrack-kind-subtitles><a href=#dom-texttrack-kind-subtitles>subtitles</a></code> <li><code title=dom-TextTrack-kind-captions><a href=#dom-texttrack-kind-captions>captions</a></code> <li><code title=dom-TextTrack-kind-descriptions><a href=#dom-texttrack-kind-descriptions>descriptions</a></code> <li><code title=dom-TextTrack-kind-chapters><a href=#dom-texttrack-kind-chapters>chapters</a></code> <li><code title=dom-TextTrack-kind-metadata><a href=#dom-texttrack-kind-metadata>metadata</a></code> </ul></li> <li> <p>If the <var title="">label</var> argument was omitted, let <var title="">label</var> be the empty string.</p> </li> <li> <p>If the <var title="">language</var> argument was omitted, let <var title="">language</var> be the empty string.</p> </li> <li> <p>Create a new <code><a href=#texttrack>TextTrack</a></code> object.</p> </li> <li> <p>Create a new <a href=#text-track>text track</a> corresponding to the new object, and set its <a href=#text-track-kind>text track kind</a> to <var title="">kind</var>, its <a href=#text-track-label>text track label</a> to <var title="">label</var>, its <a href=#text-track-language>text track language</a> to <var title="">language</var>, its <a href=#text-track-readiness-state>text track readiness state</a> to the <a href=#text-track-loaded>text track loaded</a> state, its <a href=#text-track-mode>text track mode</a> to the <a href=#text-track-hidden>text track hidden</a> mode, and its <a href=#text-track-list-of-cues>text track list of cues</a> to an empty list. <!--TTVTT--> Associate the <a href=#text-track-list-of-cues>text track list of cues</a> with the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a> as its <a href=#rules-for-updating-the-text-track-rendering>rules for updating the text track rendering</a>. <!--TTVTT--> </p> </li> <li> <p>Add the new <a href=#text-track>text track</a> to the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a>.</p> </li> <li> <p><a href=#queue-a-task>Queue a task</a> to fire an event with the name <code title=event-addtrack>addtrack</code>, that does not bubble and is not cancelable, and that uses the <code><a href=#trackevent>TrackEvent</a></code> interface, with the <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code> attribute initialized to the new <a href=#text-track>text track</a>'s <code><a href=#texttrack>TextTrack</a></code> object, at the <a href=#media-element>media element</a>'s <code title=dom-media-textTracks><a href=#dom-media-texttracks>textTracks</a></code> attribute's <code><a href=#texttracklist>TextTrackList</a></code> object.</p> </li> <li> <p>Return the new <code><a href=#texttrack>TextTrack</a></code> object.</p> </li> </ol></div> <div class=example> <p>In this example, an <code><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>var sfx = new Audio('sfx.wav'); var sounds = a.addTextTrack('metadata'); // add sounds we care about sounds.addCue(new TextTrackCue('dog bark', 12.783, 13.612, '', '', '', true)); sounds.addCue(new TextTrackCue('kitten mew', 13.612, 15.091, '', '', '', true)); function playSound(id) { sfx.currentTime = sounds.getCueById(id).startTime; sfx.play(); } sfx.oncanplaythrough = function () { playSound('dog bark'); } window.onbeforeunload = function () { playSound('kitten mew'); return 'Are you sure you want to leave this awesome page?'; }</pre> </div> <hr><pre class=idl>interface <dfn id=texttrackcuelist>TextTrackCueList</dfn> { readonly attribute unsigned long <a href=#dom-texttrackcuelist-length title=dom-TextTrackCueList-length>length</a>; getter <a href=#texttrackcue>TextTrackCue</a> (unsigned long index); <a href=#texttrackcue>TextTrackCue</a>? <a href=#dom-texttrackcuelist-getcuebyid title=dom-TextTrackCueList-getCueById>getCueById</a>(DOMString id); };</pre> <dl class=domintro><dt><var title="">cuelist</var> . <code title=dom-TextTrackCueList-length><a href=#dom-texttrackcuelist-length>length</a></code></dt> <dd> <p>Returns the number of <a href=#text-track-cue title="text track cue">cues</a> in the list.</p> </dd> <dt><var title="">cuelist</var>[<var title="">index</var>]</dt> <dd> <p>Returns the <a href=#text-track-cue>text track cue</a> with index <var title="">index</var> in the list. The cues are sorted in <a href=#text-track-cue-order>text track cue order</a>.</p> </dd> <dt><var title="">cuelist</var> . <code title=dom-TextTrackCueList-getCueById><a href=#dom-texttrackcuelist-getcuebyid>getCueById</a></code>( <var title="">id</var> )</dt> <dd> <p>Returns the first <a href=#text-track-cue>text track cue</a> (in <a href=#text-track-cue-order>text track cue order</a>) with <a href=#text-track-cue-identifier>text track cue identifier</a> <var title="">id</var>.</p> <p>Returns null if none of the cues have the given identifier or if the argument is the empty string.</p> </dd> </dl><div class=impl> <p>A <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object represents a dynamically updating list of <a href=#text-track-cue title="text track cue">text track cues</a> in a given order.</p> <p>The <dfn id=dom-texttrackcuelist-length title=dom-TextTrackCueList-length><code>length</code></dfn> attribute must return the number of <a href=#text-track-cue title="text track cue">cues</a> in the list represented by the <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object.</p> <p>The <a href=#supported-property-indices>supported property indices</a> of a <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object at any instant are the numbers from zero to the number of <a href=#text-track-cue title="text track cue">cues</a> in the list represented by the <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object minus one, if any. If there are no <a href=#text-track-cue title="text track cue">cues</a> in the list, there are no <a href=#supported-property-indices>supported property indices</a>.</p> <p>To <a href=#determine-the-value-of-an-indexed-property>determine the value of an indexed property</a> for a given index <var title="">index</var>, the user agent must return the <var title="">index</var>th <a href=#text-track-cue>text track cue</a> in the list represented by the <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object.</p> <p>The <dfn id=dom-texttrackcuelist-getcuebyid title=dom-TextTrackCueList-getCueById><code>getCueById(<var title="">id</var>)</code></dfn> method, when called with an argument other than the empty string, must return the first <a href=#text-track-cue>text track cue</a> in the list represented by the <code><a href=#texttrackcuelist>TextTrackCueList</a></code> object whose <a href=#text-track-cue-identifier>text track cue identifier</a> is <var title="">id</var>, if any, or null otherwise. If the argument is the empty string, then the method must return null.</p> </div> <hr><pre class=idl> [<a href=#dom-texttrackcue title=dom-TextTrackCue>Constructor</a>(DOMString id, double startTime, double endTime, DOMString text, optional DOMString settings, optional boolean pauseOnExit)] interface <dfn id=texttrackcue>TextTrackCue</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute <a href=#texttrack>TextTrack</a>? <a href=#dom-texttrackcue-track title=dom-TextTrackCue-track>track</a>; attribute DOMString <a href=#dom-texttrackcue-id title=dom-TextTrackCue-id>id</a>; attribute double <a href=#dom-texttrackcue-starttime title=dom-TextTrackCue-startTime>startTime</a>; attribute double <a href=#dom-texttrackcue-endtime title=dom-TextTrackCue-endTime>endTime</a>; attribute boolean <a href=#dom-texttrackcue-pauseonexit title=dom-TextTrackCue-pauseOnExit>pauseOnExit</a>; attribute DOMString <a href=#dom-texttrackcue-direction title=dom-TextTrackCue-direction>direction</a>; attribute boolean <a href=#dom-texttrackcue-snaptolines title=dom-TextTrackCue-snapToLines>snapToLines</a>; attribute long <a href=#dom-texttrackcue-lineposition title=dom-TextTrackCue-linePosition>linePosition</a>; attribute long <a href=#dom-texttrackcue-textposition title=dom-TextTrackCue-textPosition>textPosition</a>; attribute long <a href=#dom-texttrackcue-size title=dom-TextTrackCue-size>size</a>; attribute DOMString <a href=#dom-texttrackcue-alignment title=dom-TextTrackCue-alignment>alignment</a>; attribute DOMString <a href=#dom-texttrackcue-cueassource title=dom-TextTrackCue-cueAsSource>cueAsSource</a>; <a href=#documentfragment>DocumentFragment</a> <a href=#dom-texttrackcue-getcueashtml title=dom-TextTrackCue-getCueAsHTML>getCueAsHTML</a>(); [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-texttrackcue-onenter title=handler-TextTrackCue-onenter>onenter</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-texttrackcue-onexit title=handler-TextTrackCue-onexit>onexit</a>; };</pre> <dl class=domintro><dt><var title="">cue</var> = new <code title=dom-TextTrackCue><a href=#dom-texttrackcue>TextTrackCue</a></code>( <var title="">id</var>, <var title="">startTime</var>, <var title="">endTime</var>, <var title="">text</var> [, <var title="">settings</var> [, <var title="">pauseOnExit</var> ] ] )</dt> <dd> <p>Returns a new <code><a href=#texttrackcue>TextTrackCue</a></code> object, for use with the <code title=dom-TextTrack-addCue><a href=#dom-texttrack-addcue>addCue()</a></code> method.</p> <p>The <var title="">id</var> argument sets the <a href=#text-track-cue-identifier>text track cue identifier</a>.</p> <p>The <var title="">startTime</var> argument sets the <a href=#text-track-cue-start-time>text track cue start time</a>.</p> <p>The <var title="">endTime</var> argument sets the <a href=#text-track-cue-end-time>text track cue end time</a>.</p> <p>The <var title="">text</var> argument sets the <a href=#text-track-cue-text>text track cue text</a>.</p> <p>The <var title="">settings</var> argument is a string in the format of <a href=#webvtt-cue-settings>WebVTT cue settings</a>. If omitted, the empty string is assumed.</p> <p>The <var title="">pauseOnExit</var> argument sets the <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a>. If omitted, false is assumed.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-track title=dom-TextTrackCue-track>track</a></dt> <dd> <p>Returns the <code><a href=#texttrack>TextTrack</a></code> object to which this <a href=#text-track-cue>text track cue</a> belongs, if any, or null otherwise.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-id title=dom-TextTrackCue-id>id</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-identifier>text track cue identifier</a>.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-starttime title=dom-TextTrackCue-startTime>startTime</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-start-time>text track cue start time</a>, in seconds.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-endtime title=dom-TextTrackCue-endTime>endTime</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-end-time>text track cue end time</a>, in seconds.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-pauseonexit title=dom-TextTrackCue-pauseOnExit>pauseOnExit</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> is set, false otherwise.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-direction title=dom-TextTrackCue-direction>direction</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns a string representing the <a href=#text-track-cue-writing-direction>text track cue writing direction</a>, as follows:</p> <dl class=switch><dt>If it is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a></dt> <dd><p>The string "<code title="">horizontal</code>".</dd> <dt>If it is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a></dt> <dd><p>The string "<code title="">vertical</code>".</dd> <dt>If it is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a></dt> <dd><p>The string "<code title="">vertical-lr</code>".</dd> </dl><p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-snaptolines title=dom-TextTrackCue-snapToLines>snapToLines</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is set, false otherwise.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-lineposition title=dom-TextTrackCue-linePosition>linePosition</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-line-position>text track cue line position</a>. In the case of the value being <a href=#text-track-cue-automatic-line-position title="text track cue automatic line position">auto</a>, the appropriate default is returned.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-textposition title=dom-TextTrackCue-textPosition>textPosition</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-size title=dom-TextTrackCue-size>size</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-size>text track cue size</a>.</p> <p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-alignment title=dom-TextTrackCue-alignment>alignment</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns a string representing the <a href=#text-track-cue-alignment>text track cue alignment</a>, as follows:</p> <dl class=switch><dt>If it is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start alignment</a></dt> <dd><p>The string "<code title="">start</code>".</dd> <dt>If it is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle alignment</a></dt> <dd><p>The string "<code title="">middle</code>".</dd> <dt>If it is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end alignment</a></dt> <dd><p>The string "<code title="">end</code>".</dd> </dl><p>Can be set.</p> </dd> <dt><var title="">cue</var> . <a href=#dom-texttrackcue-cueassource title=dom-TextTrackCue-cueAsSource>cueAsSource</a> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#text-track-cue-text>text track cue text</a> in raw unparsed form.</p> <p>Can be set.</p> </dd> <dt><var title="">fragment</var> = <var title="">cue</var> . <a href=#dom-texttrackcue-getcueashtml title=dom-TextTrackCue-getCueAsHTML>getCueAsHTML</a>()</dt> <dd> <p>Returns the <a href=#text-track-cue-text>text track cue text</a> as a <code><a href=#documentfragment>DocumentFragment</a></code> of <a href=#html-elements>HTML elements</a> and other DOM nodes.</p> <p>Can be set.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-texttrackcue title=dom-TextTrackCue><code>TextTrackCue(<var title="">id</var>, <var title="">startTime</var>, <var title="">endTime</var>, <var title="">text</var>, <var title="">settings</var>, <var title="">pauseOnExit</var>)</code></dfn> constructor, when invoked, must run the following steps:</p> <ol><li><p>Create a new <a href=#text-track-cue>text track cue</a> that is not associated with any <a href=#text-track>text track</a>. Let <var title="">cue</var> be that <a href=#text-track-cue>text track cue</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-identifier>text track cue identifier</a> be the value of the <var title="">id</var> argument.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-start-time>text track cue start time</a> be the value of the <var title="">startTime</var> argument, interpreted as a time in seconds.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-end-time>text track cue end time</a> be the value of the <var title="">endTime</var> argument, interpreted as a time in seconds.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> be true if the <var title="">pauseOnExit</var> is present and true. Otherwise, let it be false.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-text>text track cue text</a> be the value of the <var title="">text</var> argument, and let the rules for its interpretation be the <a href=#webvtt-cue-text-parsing-rules>WebVTT cue text parsing rules</a>, the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a>, and the <a href=#webvtt-cue-text-dom-construction-rules>WebVTT cue text DOM construction rules</a>.</li> <!-- default settings --> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-writing-direction>text track cue writing direction</a> be <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> be true.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-line-position>text track cue line position</a> be <a href=#text-track-cue-automatic-line-position title="text track cue automatic line position">auto</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-text-position>text track cue text position</a> be 50.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-size>text track cue size</a> be 100.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-alignment>text track cue alignment</a> be <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle alignment</a>.</li> <li><p>Let <var title="">input</var> be the string given by the <var title="">settings</var> argument.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#parse-the-webvtt-settings>Parse the WebVTT settings</a> for <var title="">cue</var>.</li> <li><p>Return the <code><a href=#texttrackcue>TextTrackCue</a></code> object representing <var title="">cue</var>.</li> </ol><p>The <dfn id=dom-texttrackcue-track title=dom-TextTrackCue-track><code>track</code></dfn> attribute, on getting, must return the <code><a href=#texttrack>TextTrack</a></code> object of the <a href=#text-track>text track</a> with which the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents is associated, if any; or null otherwise.</p> <p>The <dfn id=dom-texttrackcue-id title=dom-TextTrackCue-id><code>id</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-identifier>text track cue identifier</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents. On setting, the <a href=#text-track-cue-identifier>text track cue identifier</a> must be set to the new value.</p> <p>The <dfn id=dom-texttrackcue-starttime title=dom-TextTrackCue-startTime><code>startTime</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-start-time>text track cue start time</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents, in seconds. On setting, the <a href=#text-track-cue-start-time>text track cue start time</a> must be set to the new value, interpreted in seconds.</p> <p>The <dfn id=dom-texttrackcue-endtime title=dom-TextTrackCue-endTime><code>endTime</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-end-time>text track cue end time</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents, in seconds. On setting, the <a href=#text-track-cue-end-time>text track cue end time</a> must be set to the new value, interpreted in seconds.</p> <p>The <dfn id=dom-texttrackcue-pauseonexit title=dom-TextTrackCue-pauseOnExit><code>pauseOnExit</code></dfn> attribute, on getting, must return true if the <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> of the <a href=#text-track-cue>text track cue</a> that the <code><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>text track cue pause-on-exit flag</a> must be set if the new value is true, and must be unset otherwise.</p> <p>The <dfn id=dom-texttrackcue-direction title=dom-TextTrackCue-direction><code>direction</code></dfn> attribute, on getting, must return the string from the second cell of the row in the table below whose first cell is the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents:</p> <table><thead><tr><th> <a href=#text-track-cue-writing-direction>Text track cue writing direction</a> <th> <code title=dom-TextTrackCue-direction><a href=#dom-texttrackcue-direction>direction</a></code> value <tbody><tr><td> <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">Horizontal</a> <td> "<code title="">horizontal</code>" <tr><td> <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">Vertical growing left</a> <td> "<code title="">vertical</code>" <tr><td> <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">Vertical growing right</a> <td> "<code title="">vertical-lr</code>" </table><p>On setting, the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> must be set to the value given in the first cell of the row in the table above whose second cell is a <a href=#case-sensitive>case-sensitive</a> match for the new value, if any. If none of the values match, then the user agent must instead throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p> <p>The <dfn id=dom-texttrackcue-snaptolines title=dom-TextTrackCue-snapToLines><code>snapToLines</code></dfn> attribute, on getting, must return true if the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents is set; or false otherwise. On setting, the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> must be set if the new value is true, and must be unset otherwise.</p> <p>The <dfn id=dom-texttrackcue-lineposition title=dom-TextTrackCue-linePosition><code>linePosition</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents. On setting, if the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is not set, and the new value is negative or greater than 100, then throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. Otherwise, set the <a href=#text-track-cue-line-position>text track cue line position</a> to the new value.</p> <p class=note>There is no way to explicitly set the <a href=#text-track-cue-line-position>text track cue line position</a> to the special default <a href=#text-track-cue-automatic-line-position title="text track cue automatic line position">auto</a> value.</p> <p>The <dfn id=dom-texttrackcue-textposition title=dom-TextTrackCue-textPosition><code>textPosition</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-text-position>text track cue text position</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents. On setting, if the new value is negative or greater than 100, then throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. Otherwise, set the <a href=#text-track-cue-text-position>text track cue text position</a> to the new value.</p> <p>The <dfn id=dom-texttrackcue-size title=dom-TextTrackCue-size><code>size</code></dfn> attribute, on getting, must return the <a href=#text-track-cue-size>text track cue size</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents. On setting, if the new value is negative or greater than 100, then throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. Otherwise, set the <a href=#text-track-cue-size>text track cue size</a> to the new value.</p> <p>The <dfn id=dom-texttrackcue-alignment title=dom-TextTrackCue-alignment><code>alignment</code></dfn> attribute, on getting, must return the string from the second cell of the row in the table below whose first cell is the <a href=#text-track-cue-alignment>text track cue alignment</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents:</p> <table><thead><tr><th><a href=#text-track-cue-alignment>Text track cue alignment</a> <th> <code title=dom-TextTrackCue-alignment><a href=#dom-texttrackcue-alignment>alignment</a></code> value <tbody><tr><td><a href=#text-track-cue-start-alignment title="text track cue start alignment">Start alignment</a> <td> "<code title="">start</code>" <tr><td><a href=#text-track-cue-middle-alignment title="text track cue middle alignment">Middle alignment</a> <td> "<code title="">middle</code>" <tr><td><a href=#text-track-cue-end-alignment title="text track cue end alignment">End alignment</a> <td> "<code title="">end</code>" </table><p>On setting, the <a href=#text-track-cue-alignment>text track cue alignment</a> must be set to the value given in the first cell of the row in the table above whose second cell is a <a href=#case-sensitive>case-sensitive</a> match for the new value, if any. If none of the values match, then the user agent must instead throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p> <p>The <dfn id=dom-texttrackcue-cueassource title=dom-TextTrackCue-cueAsSource><code>cueAsSource</code></dfn> attribute, on getting, must return the raw <a href=#text-track-cue-text>text track cue text</a> of the <a href=#text-track-cue>text track cue</a> that the <code><a href=#texttrackcue>TextTrackCue</a></code> object represents. On setting, the <a href=#text-track-cue-text>text track cue text</a> must be set to the new value.</p> <p>The <dfn id=dom-texttrackcue-getcueashtml title=dom-TextTrackCue-getCueAsHTML><code>getCueAsHTML()</code></dfn> method must convert the <a href=#text-track-cue-text>text track cue text</a> to a <code><a href=#documentfragment>DocumentFragment</a></code> for the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code>, using the appropriate rules for doing so. <!--TTVTT--> For example, for <a href=#webvtt>WebVTT</a>, those rules are the <a href=#webvtt-cue-text-parsing-rules>WebVTT cue text parsing rules</a> and the <a href=#webvtt-cue-text-dom-construction-rules>WebVTT cue text DOM construction rules</a>. <!--TTVTT--> </p> </div> <h6 id=text-tracks-describing-chapters><span class=secno>4.8.10.12.6 </span>Text tracks describing chapters</h6> <p>Chapters are segments of a <a href=#media-resource>media resource</a> with a given title. Chapters can be nested, in the same way that sections in a document outline can have subsections.</p> <p>Each <a href=#text-track-cue>text track cue</a> in a <a href=#text-track>text track</a> being used for describing chapters has three key features: the <a href=#text-track-cue-start-time>text track cue start time</a>, giving the start time of the chapter, the <a href=#text-track-cue-end-time>text track cue end time</a>, giving the end time of the chapter, and the <a href=#text-track-cue-text>text track cue text</a> giving the chapter title.</p> <div class=impl> <p>The <dfn id=rules-for-constructing-the-chapter-tree-from-a-text-track>rules for constructing the chapter tree from a text track</dfn> are as follows. They produce a potentially nested list of chapters, each of which have a start time, end time, title, and a list of nested chapters. This algorithm discards cues that do not correctly nest within each other, or that are out of order.</p> <ol><li><p>Let <var title="">list</var> be a copy of the <a href=#text-track-list-of-cues title="text track list of cues">list of cues</a> of the <a href=#text-track>text track</a> being processed.</li> <li><p>Let <var title="">output</var> be an empty list of chapters, where a chapter is a record consisting of a start time, an end time, a title, and a (potentially empty) list of nested chapters. For the purpose of this algorithm, each chapter also has a parent chapter.</li> <li><p>Let <var title="">current chapter</var> be a stand-in chapter whose start time is negative infinity, whose end time is positive infinity, and whose list of nested chapters is <var title="">output</var>. (This is just used to make the algorithm easier to describe.)</li> <!-- while not empty... --> <li><p><i>Loop</i>: If <var title="">list</var> is empty, jump to the step labeled <i>end</i>.</li> <!-- do... --> <li><p>Let <var title="">current cue</var> be the first cue in <var title="">list</var>, and then remove it from <var title="">list</var>.</li> <li><p>If <var title="">current cue</var>'s <a href=#text-track-cue-start-time>text track cue start time</a> is less than the start time of <var title="">current chapter</var>, then return to the step labeled <i>loop</i>.</p> <!-- out of order chapter --> <li><p>While <var title="">current cue</var>'s <a href=#text-track-cue-start-time>text track cue start time</a> is greater than or equal to <var title="">current chapter</var>'s end time, let <var title="">current chapter</var> be <var title="">current chapter</var>'s parent chapter.</li> <li><p>If <var title="">current cue</var>'s <a href=#text-track-cue-end-time>text track cue end time</a> is greater than the end time of <var title="">current chapter</var>, then return to the step labeled <i>loop</i>.</p> <!-- misnested chapter --> <li><p>Create a new chapter <var title="">new chapter</var>, whose start time is <var title="">current cue</var>'s <a href=#text-track-cue-start-time>text track cue start time</a>, whose end time is <var title="">current cue</var>'s <a href=#text-track-cue-end-time>text track cue end time</a>, whose title is <var title="">current cue</var>'s <a href=#text-track-cue-text>text track cue text</a> interpreted according to its rules for interpretation, and whose list of nested chapters is empty.</li> <li><p>Append <var title="">new chapter</var> to <var title="">current chapter</var>'s list of nested chapters, and let <var title="">current chapter</var> be <var title="">new chapter</var>'s parent.</li> <li><p>Let <var title="">current chapter</var> be <var title="">new chapter</var>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> <!-- ...end while --> <li><p><i>End</i>: Return <var title="">output</var>.</li> </ol></div> <!--TTVTT--> <div class=example> <p>The following snippet of a <a href=#webvtt-file>WebVTT file</a> shows how nested chapters can be marked up. The file describes three 50-minute chapters, "Astrophysics", "Computational Physics", and "General Relativity". The first has three subchapters, the second has four, and the third has two.</p> <pre>WEBVTT 00:00:00.000 --> 00:50:00.000 Astrophysics 00:00:00.000 --> 00:10:00.000 Introduction to Astrophysics 00:10:00.000 --> 00:45:00.000 The Solar System 00:00:00.000 --> 00:10:00.000 Coursework Description 00:50:00.000 --> 01:40:00.000 Computational Physics 00:50:00.000 --> 00:55:00.000 Introduction to Programming 00:55:00.000 --> 01:30:00.000 Data Structures 01:30:00.000 --> 01:35:00.000 Answers to Last Exam 01:35:00.000 --> 01:40:00.000 Coursework Description 01:40:00.000 --> 02:30:00.000 General Relativity 01:40:00.000 --> 02:00:00.000 Tensor Algebra 02:00:00.000 --> 02:30:00.000 The General Relativistic Field Equations</pre> </div> <!--TTVTT--> <div class=impl> <h6 id=cue-events><span class=secno>4.8.10.12.7 </span>Event definitions</h6> <p>The following are the <a href=#event-handlers>event handlers</a> that (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) must be supported, as IDL attributes, by all objects implementing the <code><a href=#texttracklist>TextTrackList</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-texttracklist-onaddtrack title=handler-TextTrackList-onaddtrack><code>onaddtrack</code></dfn> <td> <code title=event-addtrack>addtrack</code> </table><p>The following are the <a href=#event-handlers>event handlers</a> that (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) must be supported, as IDL attributes, by all objects implementing the <code><a href=#texttrack>TextTrack</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-texttrack-oncuechange title=handler-TextTrack-oncuechange><code>oncuechange</code></dfn> <td> <code title=event-cuechange>cuechange</code> </table><p>The following are the <a href=#event-handlers>event handlers</a> that (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) must be supported, as IDL attributes, by all objects implementing the <code><a href=#texttrackcue>TextTrackCue</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-texttrackcue-onenter title=handler-TextTrackCue-onenter><code>onenter</code></dfn> <td> <code title=event-enter>enter</code> <tr><td><dfn id=handler-texttrackcue-onexit title=handler-TextTrackCue-onexit><code>onexit</code></dfn> <td> <code title=event-exit>exit</code> </table></div> <!--TTVTT--> <div data-component="other Hixie drafts (editor: Ian Hickson)"> <h5 id=webvtt-0><span class=secno>4.8.10.13 </span>WebVTT</h5> <p>The <dfn id=webvtt>WebVTT</dfn> format (Web Video Text Tracks) is a format intended for marking up external text track resources.</p> <!-- v2 feature requests: Explicitly allow random comments on the line after the signature line, for metadata, copyrights, etc. A comment block, e.g. COMMENT - - > this is a comment, bla bla Inline CSS, maybe as: STYLE - - > ::cue(.narration) { color: blue; } Default settings: DEFAULTS - - > L:-1 A:middle S:50% Except in all these cases, - - > is really: --> <h6 id=introduction-1><span class=secno>4.8.10.13.1 </span>Introduction</h6> <p>The main use for WebVTT files is captioning video content. Here is a sample file that captions an interview:</p> <pre>WEBVTT 00:11.000 --> 00:13.000 <v Roger Bingham>We are in New York City 00:13.000 --> 00:16.000 <v Roger Bingham>We're actually at the Lucern Hotel, just down the street 00:16.000 --> 00:18.000 <v Roger Bingham>from the American Museum of Natural History 00:18.000 --> 00:20.000 <v Roger Bingham>And with me is Neil deGrasse Tyson 00:20.000 --> 00:22.000 <v Roger Bingham>Astrophysicist, Director of the Hayden Planetarium 00:22.000 --> 00:24.000 <v Roger Bingham>at the AMNH. 00:24.000 --> 00:26.000 <v Roger Bingham>Thank you for walking down here. 00:27.000 --> 00:30.000 <v Roger Bingham>And I want to do a follow-up on the last conversation we did. 00:30.000 --> 00:31.500 A:end S:50% <v Roger Bingham>When we e-mailed— 00:30.500 --> 00:32.500 A:start S:50% <v Neil deGrasse Tyson>Didn't we talk about enough in that conversation? 00:32.000 --> 00:35.500 A:end S:50% <v Roger Bingham>No! No no no no; 'cos 'cos obviously 'cos 00:32.500 --> 00:33.500 A:start S:50% <v Neil deGrasse Tyson><i>Laughs</i> 00:35.500 --> 00:38.000 <v Roger Bingham>You know I'm so excited my glasses are falling off here.</pre> <h6 id=syntax-0><span class=secno>4.8.10.13.2 </span>Syntax</h6> <p>A <dfn id=webvtt-file>WebVTT file</dfn> must consist of a <a href=#webvtt-file-body>WebVTT file body</a> encoded as UTF-8 and labeled with the <a href=#mime-type>MIME type</a> <code><a href=#text/vtt>text/vtt</a></code>. <a href=#refsRFC3629>[RFC3629]</a></p> <p>A <dfn id=webvtt-file-body>WebVTT file body</dfn> consists of the following components, in the following order:</p> <ol><li>An optional U+FEFF BYTE ORDER MARK (BOM) character.</li> <li>The string "<code title="">WEBVTT</code>".</li> <li>Optionally, either a U+0020 SPACE character or a U+0009 CHARACTER TABULATION (tab) character followed by any number of characters that are not U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</li> <!-- allows for Emacs line --> <li>Two or more <a href=#webvtt-line-terminator title="WebVTT line terminator">WebVTT line terminators</a>.</li> <!-- the first one to terminate the magic line, the second one to terminate the header block: in the future, we can add a metadata block before the first blank line --> <li>Zero or more <a href=#webvtt-cue title="WebVTT cue">WebVTT cues</a> separated from each other by two or more <a href=#webvtt-line-terminator title="WebVTT line terminator">WebVTT line terminators</a>.</li> <li>Zero or more <a href=#webvtt-line-terminator title="WebVTT line terminator">WebVTT line terminators</a>.</li> </ol><p>A <dfn id=webvtt-cue>WebVTT cue</dfn> consists of the following components, in the given order:</p> <ol><li>Optionally, a <a href=#webvtt-cue-identifier>WebVTT cue identifier</a> followed by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</li> <li><a href=#webvtt-cue-timings>WebVTT cue timings</a>.</li> <li>Optionally, one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters followed by <a href=#webvtt-cue-settings>WebVTT cue settings</a>.</li> <li>A <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</li> <li>The <dfn id=cue-payload>cue payload</dfn>: either <a href=#webvtt-cue-text>WebVTT cue text</a>, <a href=#webvtt-chapter-title-text>WebVTT chapter title text</a>, or <a href=#webvtt-metadata-text>WebVTT metadata text</a>.</li> </ol><p class=note>A <a href=#webvtt-cue>WebVTT cue</a> corresponds to one piece of time-aligned text or data in the <a href=#webvtt-file>WebVTT file</a>, for example one subtitle. The <a href=#cue-payload>cue payload</a> is the text or data associated with the cue.</p> <p><a href=#webvtt-chapter-title-text>WebVTT chapter title text</a> is syntactically a subset of <a href=#webvtt-cue-text>WebVTT cue text</a>, and <a href=#webvtt-cue-text>WebVTT cue text</a> is syntactically a subset of <a href=#webvtt-metadata-text>WebVTT metadata text</a>. Conformance checkers, when validating <a href=#webvtt>WebVTT</a> files, may offer to restrict all cues to only having <a href=#webvtt-chapter-title-text>WebVTT chapter title text</a> or <a href=#webvtt-cue-text>WebVTT cue text</a> as their <a href=#cue-payload>cue payload</a>; <a href=#webvtt-metadata-text>WebVTT metadata text</a> cues are only useful for scripted applications (using the <code title=dom-timedtrack-kind-metadata>metadata</code> <a href=#text-track-kind>text track kind</a>).</p> <p>A <a href=#webvtt-file>WebVTT file</a> whose cues all have a <a href=#cue-payload>cue payload</a> that is <a href=#webvtt-chapter-title-text>WebVTT chapter title text</a> is said to be a <dfn id=webvtt-file-using-chapter-title-text>WebVTT file using chapter title text</dfn>.</p> <p>A <a href=#webvtt-file>WebVTT file</a> whose cues all have a <a href=#cue-payload>cue payload</a> that is <a href=#webvtt-cue-text>WebVTT cue text</a> is said to be a <dfn id=webvtt-file-using-cue-text>WebVTT file using cue text</dfn>. By definition, any file that is a <a href=#webvtt-file-using-chapter-title-text>WebVTT file using chapter title text</a> is also a <a href=#webvtt-file-using-cue-text>WebVTT file using cue text</a>.</p> <p>A <dfn id=webvtt-line-terminator>WebVTT line terminator</dfn> consists of one of the following:</p> <ul class=brief><li>A U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair.</li> <li>A single U+000A LINE FEED (LF) character.</li> <li>A single U+000D CARRIAGE RETURN (CR) character.</li> </ul><p>A <dfn id=webvtt-cue-identifier>WebVTT cue identifier</dfn> is any sequence of one or more characters not containing the substring "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN), nor containing any U+000A LINE FEED (LF) characters or U+000D CARRIAGE RETURN (CR) characters.</p> <p class=note>A <a href=#webvtt-cue-identifier>WebVTT cue identifier</a> can be used to reference a specific cue, for example from script or CSS.</p> <p>The <dfn id=webvtt-cue-timings>WebVTT cue timings</dfn> part of a <a href=#webvtt-cue>WebVTT cue</a> consists of the following components, in the given order:</p> <ol><!-- we could allow leading and trailing spaces and tabs, and make the space between the arrow either optional or allow multiple spaces or tabs --><li>A <a href=#webvtt-timestamp>WebVTT timestamp</a> representing the start time offset of the cue. The time represented by this <a href=#webvtt-timestamp>WebVTT timestamp</a> must be greater than or equal to the start time offsets of all previous cues in the file.</li> <li>One or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.</li> <li>The string "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).</li> <li>One or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.</li> <li>A <a href=#webvtt-timestamp>WebVTT timestamp</a> representing the end time offset of the cue. The time represented by this <a href=#webvtt-timestamp>WebVTT timestamp</a> must be greater than the start time offset of the cue.</li> </ol><p class=note>The <a href=#webvtt-cue-timings>WebVTT cue timings</a> give the start and end offsets of the <a href=#webvtt-cue>WebVTT cue</a>. Different cues can overlap. Cues are always listed ordered by their start time.</p> <p>A <a href=#webvtt-file>WebVTT file</a> whose cues all have an end time offset <var title="">x</var> greater than or equal to the end time offsets of all the cues whose start time offsets are less than <var title="">x</var> is said to be a <dfn id=webvtt-file-using-only-nested-cues>WebVTT file using only nested cues</dfn>.</p> <p>A <dfn id=webvtt-timestamp>WebVTT timestamp</dfn> representing a time in seconds and fractions of a second is a <a href=#webvtt-timestamp>WebVTT timestamp</a> representing hours <var title="">hours</var>, minutes <var title="">minutes</var>, seconds <var title="">seconds</var>, and thousandths of a second <var title="">seconds-frac</var>, calculated as follows:</p> <ol><li><p>Let <var title="">seconds</var> be the integer part of the time.</li> <li><p>Let <var title="">seconds-frac</var> be the fractional component of the time, expressed as the digits of the decimal fraction given to three decimal digits.</li> <li><p>If <var title="">seconds</var> is greater than 59, then let <var title="">minutes</var> be the integer component of <var title="">seconds</var> divided by sixty, and then let <var title="">seconds</var> be the remainder of dividing <var title="">seconds</var> divided by sixty. Otherwise, let <var title="">minutes</var> be zero.</li> <li><p>If <var title="">minutes</var> is greater than 59, then let <var title="">hours</var> be the integer component of <var title="">minutes</var> divided by sixty, and then let <var title="">minutes</var> be the remainder of dividing <var title="">minutes</var> divided by sixty. Otherwise, let <var title="">hours</var> be zero.</li> </ol><p>A <a href=#webvtt-timestamp>WebVTT timestamp</a> representing hours <var title="">hours</var>, minutes <var title="">minutes</var>, seconds <var title="">seconds</var>, and thousandths of a second <var title="">seconds-frac</var>, consists of the following components, in the given order:</p> <ol><li>Optionally (required if <var title="">hour</var> is non-zero): <ol><li>Two or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing the <var title="">hours</var> as a base ten integer.</li> <li>A U+003A COLON character (:)</li> </ol></li> <li>Two characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing the <var title="">minutes</var> as a base ten integer in the range 0 ≤ <var title="">minutes</var> ≤ 59.</li> <li>A U+003A COLON character (:)</li> <li>Two characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing the <var title="">seconds</var> as a base ten integer in the range 0 ≤ <var title="">seconds</var> ≤ 59.</li> <li>A U+002E FULL STOP character (.).</li> <li>Three characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing the thousandths of a second <var title="">seconds-frac</var> as a base ten integer.</li> </ol><p>The <dfn id=webvtt-cue-settings>WebVTT cue settings</dfn> part of a <a href=#webvtt-cue>WebVTT cue</a> consists of zero or more of the following components, in any order, separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters. Each component must not be included more than once per <a href=#webvtt-cue-settings>WebVTT cue settings</a> string.</p> <ul class=brief><li>A <a href=#webvtt-vertical-text-cue-setting>WebVTT vertical text cue setting</a>.</li> <!-- D:vertical/vertical-lr --> <li>A <a href=#webvtt-line-position-cue-setting>WebVTT line position cue setting</a>.</li> <!-- L:100% L:1 L:-1 --> <li>A <a href=#webvtt-text-position-cue-setting>WebVTT text position cue setting</a>.</li> <!-- T:100% --> <li>A <a href=#webvtt-size-cue-setting>WebVTT size cue setting</a>.</li> <!-- S:100% --> <li>A <a href=#webvtt-alignment-cue-setting>WebVTT alignment cue setting</a>.</li> <!-- A:start/middle/end --> </ul><p class=note><a href=#webvtt-cue-settings>WebVTT cue settings</a> give configuration options regarding the position and alignment of the cue. For example, it allows a cue to be aligned to the left or positioned at the top right.</p> <p>A <dfn id=webvtt-vertical-text-cue-setting>WebVTT vertical text cue setting</dfn> consists of the following components, in the order given:</p> <ol><li>A U+0044 LATIN CAPITAL LETTER D character.</li> <li>A U+003A COLON character (:).</li> <li>One of the following strings: "<code title="">vertical</code>", "<code title="">vertical-lr</code>".</li> </ol><p class=note>A <a href=#webvtt-vertical-text-cue-setting>WebVTT vertical text cue setting</a> configures the cue to use vertical text layout rather than horizontal text layout. Vertical text layout is sometimes used in Japanese, for example. The default is horiontal layout.</p> <p>A <dfn id=webvtt-line-position-cue-setting>WebVTT line position cue setting</dfn> consists of the following components, in the order given:</p> <ol><li><p>A U+004C LATIN CAPITAL LETTER L character.</li> <li><p>A U+003A COLON character (:).</li> <li>Either: <dl><dt>To represent a specific position relative to the video frame</dt> <dd> <ol><li>One or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>A U+0025 PERCENT SIGN character (%).</li> </ol></dd> <dt>To represent a line number</dt> <dd> <ol><li>Optionally a U+002D HYPHEN-MINUS character (-).</li> <li>One or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol></dd> </dl></li> </ol><p class=note>A <a href=#webvtt-line-position-cue-setting>WebVTT line position cue setting</a> configures the position of the cue. For horizontal cues, this is the vertical position. The position can be given either as a percentage, which gives the distance from the top of the frame, or as a line number. Line numbers are based on the size of the first line of the cue. Positive line numbers count from the top of the frame (the top line is numbered 0), negative line numbers from the bottom of the frame (the bottom line is numbered −1).</p> <p>A <dfn id=webvtt-text-position-cue-setting>WebVTT text position cue setting</dfn> consists of the following components, in the order given:</p> <ol><li>A U+0054 LATIN CAPITAL LETTER T character.</li> <li>A U+003A COLON character (:).</li> <li>One or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>A U+0025 PERCENT SIGN character (%).</li> </ol><p class=note>A <a href=#webvtt-text-position-cue-setting>WebVTT text position cue setting</a> configures the position of the text in the direction orthogonal to the <a href=#webvtt-line-position-cue-setting>WebVTT line position cue setting</a>. For horizontal cues, this is the horizontal position. The <a href=#webvtt-text-position-cue-setting>WebVTT text position cue setting</a> is given as a percentage, calculated from the edge of the frame that the text begins (so for left-to-right English text, the left edge).</p> <p>A <dfn id=webvtt-size-cue-setting>WebVTT size cue setting</dfn> consists of the following components, in the order given:</p> <ol><li>A U+0053 LATIN CAPITAL LETTER S character.</li> <li>A U+003A COLON character (:).</li> <li>One or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>A U+0025 PERCENT SIGN character (%).</li> </ol><p class=note>A <a href=#webvtt-size-cue-setting>WebVTT size cue setting</a> configures the size of the cue in the same direction as the <a href=#webvtt-text-position-cue-setting>WebVTT text position cue setting</a>. For horizontal cues, this is the width of the cue. It is given as a percentage of the width of the frame.</p> <p>A <dfn id=webvtt-alignment-cue-setting>WebVTT alignment cue setting</dfn> consists of the following components, in the order given:</p> <ol><li>A U+0041 LATIN CAPITAL LETTER A character.</li> <li>A U+003A COLON character (:).</li> <li>One of the following strings: "<code title="">start</code>", "<code title="">middle</code>", "<code title="">end</code>"</li> </ol><p class=note>A <a href=#webvtt-alignment-cue-setting>WebVTT alignment cue setting</a> configures the alignment of the text within the cue. The keywords are relative to the text direction; for left-to-right English text, "<code title="">start</code>" means left-aligned.</p> <p><dfn id=webvtt-metadata-text>WebVTT metadata text</dfn> consists of any sequence of zero or more characters other than U+000A LINE FEED (LF) characters and U+000D CARRIAGE RETURN (CR) characters, each optionally separated from the next by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>. (In other words, any text that does not have two consecutive <a href=#webvtt-line-terminator title="WebVTT line terminator">WebVTT line terminators</a> and does not start or end with a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.)</p> <p><dfn id=webvtt-chapter-title-text>WebVTT chapter title text</dfn> consists of zero or more of the following, each optionally separated from the next by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>:</p> <ul><li>A <a href=#webvtt-cue-text-span>WebVTT cue text span</a>, representing the text of the cue.</li> <li>A <a href=#webvtt-cue-amp-escape>WebVTT cue amp escape</a>, representing a "&" character in the text of the cue.</li> <li>A <a href=#webvtt-cue-lt-escape>WebVTT cue lt escape</a>, representing a "<" character in the text of the cue.</li> <li>A <a href=#webvtt-cue-gt-escape>WebVTT cue gt escape</a>, representing a ">" character in the text of the cue.</li> </ul><p><dfn id=webvtt-cue-text>WebVTT cue text</dfn> consists of zero or more <a href=#webvtt-cue-components>WebVTT cue components</a>, in any order, each optionally separated from the next by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</p> <p>The <dfn id=webvtt-cue-components>WebVTT cue components</dfn> are:</p> <ul><li>A <a href=#webvtt-cue-class-span>WebVTT cue class span</a>.</li> <li>A <a href=#webvtt-cue-italics-span>WebVTT cue italics span</a>.</li> <li>A <a href=#webvtt-cue-bold-span>WebVTT cue bold span</a>.</li> <li>A <a href=#webvtt-cue-underline-span>WebVTT cue underline span</a>.</li> <li>A <a href=#webvtt-cue-ruby-span>WebVTT cue ruby span</a>.</li> <li>A <a href=#webvtt-cue-voice-span>WebVTT cue voice span</a>.</li> <li>A <a href=#webvtt-cue-timestamp>WebVTT cue timestamp</a>.</li> <li>A <a href=#webvtt-cue-text-span>WebVTT cue text span</a>, representing the text of the cue.</li> <li>A <a href=#webvtt-cue-amp-escape>WebVTT cue amp escape</a>, representing a "&" character in the text of the cue.</li> <li>A <a href=#webvtt-cue-lt-escape>WebVTT cue lt escape</a>, representing a "<" character in the text of the cue.</li> <li>A <a href=#webvtt-cue-gt-escape>WebVTT cue gt escape</a>, representing a ">" character in the text of the cue.</li> </ul><p><dfn id=webvtt-cue-internal-text>WebVTT cue internal text</dfn> consists of an optional <a href=#webvtt-line-terminator>WebVTT line terminator</a>, followed by zero or more <a href=#webvtt-cue-components>WebVTT cue components</a>, in any order, each optionally followed by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</p> <p>A <dfn id=webvtt-cue-class-span>WebVTT cue class span</dfn> consists of a <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">c</code>" that disallows an annotation, <a href=#webvtt-cue-internal-text>WebVTT cue internal text</a> representing cue text, and a <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">c</code>".</p> <p>A <dfn id=webvtt-cue-italics-span>WebVTT cue italics span</dfn> consists of a <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">i</code>" that disallows an annotation, <a href=#webvtt-cue-internal-text>WebVTT cue internal text</a> representing the italicized text, and a <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">i</code>".</p> <p>A <dfn id=webvtt-cue-bold-span>WebVTT cue bold span</dfn> consists of a <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">b</code>" that disallows an annotation, <a href=#webvtt-cue-internal-text>WebVTT cue internal text</a> representing the boldened text, and a <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">b</code>".</p> <p>A <dfn id=webvtt-cue-underline-span>WebVTT cue underline span</dfn> consists of a <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">u</code>" that disallows an annotation, <a href=#webvtt-cue-internal-text>WebVTT cue internal text</a> representing the underlined text, and a <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">u</code>".</p> <p>A <dfn id=webvtt-cue-ruby-span>WebVTT cue ruby span</dfn> consists of the following components, in the order given:</p> <ol><li>A <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">ruby</code>" that disallows an annotation.</li> <li>One or more occurrences of the following group of components, in the order given: <ol><li><a href=#webvtt-cue-internal-text>WebVTT cue internal text</a>, representing the ruby base.</li> <li>A <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">rt</code>" that disallows an annotation.</li> <li>A <dfn id=webvtt-cue-ruby-text-span>WebVTT cue ruby text span</dfn>: <a href=#webvtt-cue-internal-text>WebVTT cue internal text</a>, representing the ruby text component of the ruby annotation.</li> <li>A <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">rt</code>". If this is the last occurance of this group of components in the <a href=#webvtt-cue-ruby-span>WebVTT cue ruby span</a>, then this last end tag string may be omitted.</li> </ol></li> <li>If the last end tag string was not omitted: Optionally, a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</li> <li>If the last end tag string was not omitted: Zero or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters, each optionally followed by a <a href=#webvtt-line-terminator>WebVTT line terminator</a>.</li> <li>A <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">ruby</code>".</li> </ol><p>A <dfn id=webvtt-cue-voice-span>WebVTT cue voice span</dfn> consists of the following components, in the order given:</p> <ol><li>A <a href=#webvtt-cue-span-start-tag>WebVTT cue span start tag</a> "<code title="">v</code>" that requires an annotation; the annotation represents the name of the voice.</li> <li><a href=#webvtt-cue-internal-text>WebVTT cue internal text</a>.</li> <li>A <a href=#webvtt-cue-span-end-tag>WebVTT cue span end tag</a> "<code title="">v</code>". If this <a href=#webvtt-cue-voice-span>WebVTT cue voice span</a> is the only <a href=#webvtt-cue-components title="WebVTT cue components">component</a> of its <a href=#webvtt-cue-text>WebVTT cue text</a> sequence, then the end tag may be omitted for brevity.</li> </ol><p>A <dfn id=webvtt-cue-span-start-tag>WebVTT cue span start tag</dfn> has a <var title="">tag name</var> and either <!--allows,--> requires<!--,--> or disallows an annotation, and consists of the following components, in the order given:</p> <ol><li>A U+003C LESS-THAN SIGN character (<).</li> <li>The <var title="">tag name</var>.</li> <li>Zero or more occurrences of the following sequence: <ol><li>U+002E FULL STOP character (.)</li> <li>One or more characters other than U+0009 CHARACTER TABULATION (tab) characters, U+000A LINE FEED (LF) characters, U+000D CARRIAGE RETURN (CR) characters, U+0020 SPACE characters, U+0026 AMPERSAND characters (&), U+003C LESS-THAN SIGN characters (<), U+003E GREATER-THAN SIGN characters (>), and U+002E FULL STOP characters (.), representing a class that describes the cue span's significance.</li> </ol></li> <li> <!-- <dl class="switch"> <dt>If the start tag allows an annotation:</dt> <dd>Optionally, a <span>WebVTT cue span start tag annotation</span>.</dd> <dt>-->If the start tag requires an annotation:<!--</dt> <dd>A <span>WebVTT cue span start tag annotation</span>.</dd> </dl> <p>A <dfn>WebVTT cue span start tag annotation</dfn> consists of--> a U+0020 SPACE character or a U+0009 CHARACTER TABULATION (tab) character, followed by one or more of the following components, the concatenation of their representations having a value that contains at least one character other than U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters:<!--</p>--> <ul><li><a href=#webvtt-cue-span-start-tag-annotation-text>WebVTT cue span start tag annotation text</a>, representing the text of the annotation.</li> <li>A <a href=#webvtt-cue-amp-escape>WebVTT cue amp escape</a>, representing a "&" character in the text of the annotation.</li> <li>A <a href=#webvtt-cue-lt-escape>WebVTT cue lt escape</a>, representing a "<" character in the text of the annotation.</li> <li>A <a href=#webvtt-cue-gt-escape>WebVTT cue gt escape</a>, representing a ">" character in the text of the annotation.</li> </ul></li> <li>A U+003E GREATER-THAN SIGN character (>).</li> </ol><p>A <dfn id=webvtt-cue-span-end-tag>WebVTT cue span end tag</dfn> has a <var title="">tag name</var> and consists of the following components, in the order given:</p> <ol><li>A U+003C LESS-THAN SIGN character (<).</li> <li>U+002F SOLIDUS character (/).</li> <li>The <var title="">tag name</var>.</li> <li>A U+003E GREATER-THAN SIGN character (>).</li> </ol><p>A <dfn id=webvtt-cue-timestamp>WebVTT cue timestamp</dfn> consists of a U+003C LESS-THAN SIGN character (<), followed by a <a href=#webvtt-timestamp>WebVTT timestamp</a> representing the time that the given point in the cue becomes active, followed by a U+003E GREATER-THAN SIGN character (>). The time represented by the <a href=#webvtt-timestamp>WebVTT timestamp</a> must be greater than the times represented by any previous <a href=#webvtt-cue-timestamp title="WebVTT cue timestamp">WebVTT cue timestamps</a> in the cue, as well as greater than the cue's start time offset, and less than the cue's end time offset.</p> <p>A <dfn id=webvtt-cue-text-span>WebVTT cue text span</dfn> consists of one or more characters other than U+000A LINE FEED (LF) characters, U+000D CARRIAGE RETURN (CR) characters, U+0026 AMPERSAND characters (&), and U+003C LESS-THAN SIGN characters (<).</p> <p><dfn id=webvtt-cue-span-start-tag-annotation-text>WebVTT cue span start tag annotation text</dfn> consists of one or more characters other than U+000A LINE FEED (LF) characters, U+000D CARRIAGE RETURN (CR) characters, U+0026 AMPERSAND characters (&), and U+003E GREATER-THAN SIGN characters (>).</p> <p>A <dfn id=webvtt-cue-amp-escape>WebVTT cue amp escape</dfn> is the five character string "<code title="">&amp;</code>".</p> <p>A <dfn id=webvtt-cue-lt-escape>WebVTT cue lt escape</dfn> is the four character string "<code title="">&lt;</code>".</p> <p>A <dfn id=webvtt-cue-gt-escape>WebVTT cue gt escape</dfn> is the four character string "<code title="">&gt;</code>".</p> <div class=impl> <h6 id=parsing-0><span class=secno>4.8.10.13.3 </span>Parsing</h6> <p>A <dfn id=webvtt-parser>WebVTT parser</dfn>, given an input byte stream and a <a href=#text-track-list-of-cues>text track list of cues</a> <var title="">output</var>, must <a href=#decoded-as-utf-8,-with-error-handling title="decoded as UTF-8, with error handling">decode the byte stream as UTF-8, with error handling</a>, and then must parse the resulting string according to the <a href=#webvtt-parser-algorithm>WebVTT parser algorithm</a> below. This results in <a href=#text-track-cue title="text track cue">text track cues</a> being added to <var title="">output</var>. <a href=#refsRFC3629>[RFC3629]</a></p> <p>A <a href=#webvtt-parser>WebVTT parser</a>, specifically its conversion and parsing steps, is typically run asynchronously, with the input byte stream being updated incrementally as the resource is downloaded; this is called an <dfn id=incremental-webvtt-parser>incremental WebVTT parser</dfn>.</p> <p>A <a href=#webvtt-parser>WebVTT parser</a> verifies a file signature before parsing the provided byte stream. If the stream lacks this WebVTT file signature, then the parser aborts.</p> <p>The <dfn id=webvtt-parser-algorithm>WebVTT parser algorithm</dfn> is as follows:</p> <ol><li> <p>Let <var title="">input</var> be the string being parsed, after conversion to Unicode, and with the following transformations applied:</p> <ul><li><p>Replace all U+0000 NULL characters by U+FFFD REPLACEMENT CHARACTERs.</li> <li><p>Replace each U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair by a single U+000A LINE FEED (LF) character.</li> <li><p>Replace all remaining U+000D CARRIAGE RETURN characters by U+000A LINE FEED (LF) characters.</li> </ul></li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string. In an <a href=#incremental-webvtt-parser>incremental WebVTT parser</a>, when this algorithm (or further algorithms that it uses) moves the <var title="">position</var> pointer, the user agent must wait until appropriate further characters from the byte stream have been added to <var title="">input</var> before moving the pointer, so that the algorithm never reads past the end of the <var title="">input</var> string. Once the byte stream has ended, and all characters have been added to <var title="">input</var>, then the <var title="">position</var> pointer may, when so instructed by the algorithms, be moved past the end of <var title="">input</var>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+FEFF BYTE ORDER MARK (BOM) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li>Let <var title="">line</var> be a string variable. Unset the <var title="">already collected line</var> flag.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">line</var> is less than six characters long, then abort these steps. The file is not a <a href=#webvtt-file>WebVTT file</a>.</li> <li><p>If <var title="">line</var> is exactly six characters long but does not exactly equal "<code title="">WEBVTT</code>", then abort these steps. The file does not start with the correct <a href=#webvtt-file>WebVTT file</a> signature and was therefore not successfully processed.</li> <li><p>If <var title="">line</var> is more than six characters long but the first six characters do not exactly equal "<code title="">WEBVTT</code>", or the seventh character is neither a U+0020 SPACE character nor a U+0009 CHARACTER TABULATION (tab) character, then abort these steps. The file is not a <a href=#webvtt-file>WebVTT file</a>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>end</i>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+000A LINE FEED (LF) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p><i title="">Header</i>: <a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>end</i>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+000A LINE FEED (LF) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>If <var title="">line</var> contains the three-character substring "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN), then set the <var title="">already collected line</var> flag and jump to the step labeled <i>cue loop</i>.</li> <!-- In v2, this is where we can put header metadata processing --> <li><p>If <var title="">line</var> is not the empty string, then jump back to the step labeled <i title="">header</i>.</li> <li><p><i>Cue loop</i>: If the <var title="">already collected line</var> flag is set, then jump to the step labeled <var title="">cue creation</var>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are U+000A LINE FEED (LF) characters.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">line</var> is the empty string, then jump to the step labeled <i>end</i>. (In such a case, <var title="">position</var> is also forcibly past the end of <var title="">input</var><!-- since we've just collected newlines, so we have none of those, and we've failed to collect anything that's not a newline, so we have none of that either, meaning we have nothing. -->.)</li> <li><p><i>Cue creation</i>: Let <var title="">cue</var> be a new <a href=#text-track-cue>text track cue</a> associated with <var title="">output</var>'s <a href=#text-track>text track</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-identifier>text track cue identifier</a> be the empty string.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-pause-on-exit-flag>text track cue pause-on-exit flag</a> be false.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-writing-direction>text track cue writing direction</a> be <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> be true.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-line-position>text track cue line position</a> be <a href=#text-track-cue-automatic-line-position title="text track cue automatic line position">auto</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-text-position>text track cue text position</a> be 50.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-size>text track cue size</a> be 100.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-alignment>text track cue alignment</a> be <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle alignment</a>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-text>text track cue text</a> be the empty string.</li> <li><p>If <var title="">line</var> contains the three-character substring "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN), then jump to the step labeled <i>timings</i> below.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-identifier>text track cue identifier</a> be <var title="">line</var>.<p></li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then discard <var title="">cue</var> and jump to the step labeled <i>end</i>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+000A LINE FEED (LF) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">line</var> is the empty string, then discard <var title="">cue</var> and jump to the step labeled <i>cue loop</i>.</li> <li><p><i>Timings</i>: Unset the <var title="">already collected line</var> flag.</li> <li><p><a href=#collect-webvtt-cue-timings-and-settings>Collect WebVTT cue timings and settings</a> from <var title="">line</var>, using <var title="">cue</var> for the results. If that fails, jump to the step labeled <i>bad cue</i>.</li> <li><p>Let <var title="">cue text</var> be the empty string.</li> <li><p><i>Cue text loop</i>: If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>cue text processing</i>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+000A LINE FEED (LF) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">line</var> is the empty string, then jump to the step labeled <i>cue text processing</i>.</li> <li><p>If <var title="">line</var> contains the three-character substring "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN), then set the <var title="">already collected line</var> flag and jump to the step labeled <i>cue text processing</i>.</li> <li><p>If <var title="">cue text</var> is not empty, append a U+000A LINE FEED (LF) character to <var title="">cue text</var>.</li> <li><p>Let <var title="">cue text</var> be the concatenation of <var title="">cue text</var> and <var title="">line</var>.</li> <li><p>Return to the step labeled <i>cue text loop</i>.</li> <li><p><i>Cue text processing</i>: Let the <a href=#text-track-cue-text>text track cue text</a> of <var title="">cue</var> be <var title="">cue text</var>, and let the rules for its interpretation be the <a href=#webvtt-cue-text-parsing-rules>WebVTT cue text parsing rules</a>, the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a>, and the <a href=#webvtt-cue-text-dom-construction-rules>WebVTT cue text DOM construction rules</a>.</li> <li><p>Add <var title="">cue</var> to the <a href=#text-track-list-of-cues>text track list of cues</a> <var title="">output</var>.</li> <li><p>Jump to the step labeled <i>cue loop</i>.</li> <li><p><i>Bad cue</i>: Discard <var title="">cue</var>.</li> <li><p><i>Bad cue loop</i>: If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled <i>end</i>.</li> <li><p>If the character indicated by <var title="">position</var> is a U+000A LINE FEED (LF) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) characters. Let <var title="">line</var> be those characters, if any.</li> <li><p>If <var title="">line</var> contains the three-character substring "<code title="">--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN), then set the <var title="">already collected line</var> flag and jump to the step labeled <i>cue loop</i>.</li> <li><p>If <var title="">line</var> is the empty string, then jump to the step labeled <i>cue loop</i>.</li> <li><p>Otherwise, jump to the step labeled <i>bad cue loop</i>.</li> <li><p><i>End</i>: The file has ended. Abort these steps. The <a href=#webvtt-parser>WebVTT parser</a> has finished.</li> </ol><p>When the algorithm above requires that the user agent <dfn id=collect-webvtt-cue-timings-and-settings>collect WebVTT cue timings and settings</dfn> from a string <var title="">input</var> for a <a href=#text-track-cue>text track cue</a> <var title="">cue</var>, the user agent must run the following algorithm.</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p><a href=#collect-a-webvtt-timestamp>Collect a WebVTT timestamp</a>. If that algorithm fails, then abort these steps and return failure. Otherwise, let <var title="">cue</var>'s <a href=#text-track-cue-start-time>text track cue start time</a> be the collected time.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <!-- we can't be beyond the end of the string until we've seen the arrow, since we know the arrow is in the string and nothing we've done so far would move us past the first "-". --> <li><p>If <!--<var title="">position</var> is beyond the end of <var title="">input</var> or if--> the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character (-) then abort these steps and return failure. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p>If <!--<var title="">position</var> is beyond the end of <var title="">input</var> or if--> the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character (-) then abort these steps and return failure. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p>If <!--<var title="">position</var> is beyond the end of <var title="">input</var> or if--> the character at <var title="">position</var> is not a U+003E GREATER-THAN SIGN character (>) then abort these steps and return failure. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p><a href=#collect-a-webvtt-timestamp>Collect a WebVTT timestamp</a>. If that algorithm fails, then abort these steps and return failure. Otherwise, let <var title="">cue</var>'s <a href=#text-track-cue-end-time>text track cue end time</a> be the collected time.</li> <li><p><a href=#parse-the-webvtt-settings>Parse the WebVTT settings</a> for <var title="">cue</var>.</li> </ol><p>When the user agent is to <dfn id=parse-the-webvtt-settings>parse the WebVTT settings</dfn> for a <a href=#text-track-cue>text track cue</a> <var title="">cue</var>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same name in the algorithm that invoked these steps.</li> <li><p><i>Settings</i>: <a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> then abort these steps.</li> <li><p>Let <var title="">setting</var> be the character at <var title="">position</var>, and move <var title="">position</var> forwards one character.</p> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> then abort these steps.</li> <li><p>If the character at <var title="">position</var> is a <a href=#space-character>space character</a>, then jump back to the step labeled <i>settings</i>.</li> <li><p>If the character at <var title="">position</var> is not a U+003A COLON character (:), then set <var title="">setting</var> to the empty string.</li> <li><p>Move <var title="">position</var> forwards one character.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> then abort these steps.</li> <li> <p>Run the appropriate substeps that apply for the value of <var title="">setting</var>, as follows:</p> <dl><dt>If <var title="">setting</var> is a U+0044 LATIN CAPITAL LETTER D character</dt> <dd> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not <a href=#space-character title="space character">space characters</a>. Let <var title="">value</var> be those characters, if any.</li> <li><p>If <var title="">value</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">vertical</code>", then let <var title="">cue</var>'s <a href=#text-track-cue-writing-direction>text track cue writing direction</a> be <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>.</li> <li><p>Otherwise, if <var title="">value</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">vertical-lr</code>", then let <var title="">cue</var>'s <a href=#text-track-cue-writing-direction>text track cue writing direction</a> be <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>.</li> </ol></dd> <dt>If <var title="">setting</var> is a U+004C LATIN CAPITAL LETTER L character</dt> <dd> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are either U+002D HYPHEN-MINUS characters (-), U+0025 PERCENT SIGN characters (%), or characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). Let <var title="">value</var> be those characters, if any.</li> <li><p>If <var title="">position</var> is not beyond the end of <var title="">input</var> but the character at <var title="">position</var> is not a <a href=#space-character>space character</a>, then jump to the "otherwise" case below.</li> <li><p>If <var title="">value</var> does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump back to the step labeled <i>settings</i>.</li> <li><p>If any character in <var title="">value</var> other than the first character is a U+002D HYPHEN-MINUS character (-), then jump back to the step labeled <i>settings</i>.</li> <li><p>If any character in <var title="">value</var> other than the last character is a U+0025 PERCENT SIGN character (%), then jump back to the step labeled <i>settings</i>.</li> <li><p>If the first character in <var title="">value</var> is a U+002D HYPHEN-MINUS character (-) <em>and</em> the last character in <var title="">value</var> is a U+0025 PERCENT SIGN character (%), then jump back to the step labeled <i>settings</i>.</li> <li><p>Ignoring the trailing percent sign, if any, interpret <var title="">value</var> as a (potentially signed) integer, and let <var title="">number</var> be that number.</li> <li><p>If the last character in <var title="">value</var> is a U+0025 PERCENT SIGN character (%), but <var title="">number</var> is not in the range 0 ≤ <var title="">number</var> ≤ 100, then jump back to the step labeled <i>settings</i>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-line-position>text track cue line position</a> be <var title="">number</var>.</li> <li><p>If the last character in <var title="">value</var> is a U+0025 PERCENT SIGN character (%), then let <var title="">cue</var>'s <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> be false.</li> </ol></dd> <dt>If <var title="">setting</var> is a U+0054 LATIN CAPITAL LETTER T character</dt> <dd> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). Let <var title="">value</var> be those characters, if any.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> then jump back to the step labeled <i>settings</i>.</li> <li><p>If the character at <var title="">position</var> is not a U+0025 PERCENT SIGN character (%), then then jump to the "otherwise" case below.</li> <li><p>Move <var title="">position</var> forwards one character.</li> <li><p>If <var title="">position</var> is not beyond the end of <var title="">input</var> but the character at <var title="">position</var> is not a <a href=#space-character>space character</a>, then jump to the "otherwise" case below.</li> <li><p>If <var title="">value</var> is the empty string, then jump back to the step labeled <i>settings</i>.</li> <li><p>Interpret <var title="">value</var> as an integer, and let <var title="">number</var> be that number.</li> <li><p>If <var title="">number</var> is not in the range 0 ≤ <var title="">number</var> ≤ 100, then jump back to the step labeled <i>settings</i>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-text-position>text track cue text position</a> be <var title="">number</var>.</li> </ol></dd> <dt>If <var title="">setting</var> is a U+0053 LATIN CAPITAL LETTER S character</dt> <dd> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). Let <var title="">value</var> be those characters, if any.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> then jump back to the step labeled <i>settings</i>.</li> <li><p>If the character at <var title="">position</var> is not a U+0025 PERCENT SIGN character (%), then then jump to the "otherwise" case below.</li> <li><p>Move <var title="">position</var> forwards one character.</li> <li><p>If <var title="">position</var> is not beyond the end of <var title="">input</var> but the character at <var title="">position</var> is not a <a href=#space-character>space character</a>, then jump to the "otherwise" case below.</li> <li><p>If <var title="">value</var> is the empty string, then jump back to the step labeled <i>settings</i>.</li> <li><p>Interpret <var title="">value</var> as an integer, and let <var title="">number</var> be that number.</li> <li><p>If <var title="">number</var> is not in the range 0 ≤ <var title="">number</var> ≤ 100, then jump back to the step labeled <i>settings</i>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-size>text track cue size</a> be <var title="">number</var>.</li> </ol></dd> <dt>If <var title="">setting</var> is a U+0041 LATIN CAPITAL LETTER A character</dt> <dd> <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not <a href=#space-character title="space character">space characters</a>. Let <var title="">value</var> be those characters, if any.</li> <li><p>If <var title="">value</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">start</code>", then let <var title="">cue</var>'s <a href=#text-track-cue-alignment>text track cue alignment</a> be <a href=#text-track-cue-start-alignment title="text track cue start alignment">start alignment</a>.</li> <li><p>If <var title="">value</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">middle</code>", then let <var title="">cue</var>'s <a href=#text-track-cue-alignment>text track cue alignment</a> be <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle alignment</a>.</li> <li><p>If <var title="">value</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">end</code>", then let <var title="">cue</var>'s <a href=#text-track-cue-alignment>text track cue alignment</a> be <a href=#text-track-cue-end-alignment title="text track cue end alignment">end alignment</a>.</li> </ol></dd> <dt>Otherwise</dt> <dd> <p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not <a href=#space-character title="space character">space characters</a> and discard them.</p> </dd> </dl></li> <li><p>Jump back to the step labeled <i>settings</i>.</li> </ol><p>When this specification says that a user agent is to <dfn id=collect-a-webvtt-timestamp>collect a WebVTT timestamp</dfn>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same name in the algorithm that invoked these steps.</li> <li><p>Let <var title="">most significant units</var> be <i title="">minutes</i>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error and abort these steps.</li> <li><p>If the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then return an error and abort these steps.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let <var title="">string</var> be the collected substring.</li> <li><p>Interpret <var title="">string</var> as a base-ten integer. Let <var title="">value<sub>1</sub></var> be that integer.</li> <li><p>If <var title="">string</var> is not exactly two characters in length, or if <var title="">value<sub>1</sub></var> is greater than 59, let <var title="">most significant units</var> be <i title="">hours</i>.</li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character (:), then return an error and abort these steps. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let <var title="">string</var> be the collected substring.</li> <li><p>If <var title="">string</var> is not exactly two characters in length, return an error and abort these steps.</li> <li><p>Interpret <var title="">string</var> as a base-ten integer. Let <var title="">value<sub>2</sub></var> be that integer.</li> <li> <p>If <var title="">most significant units</var> is <i title="">hours</i>, or if <var title="">position</var> is not beyond the end of <var title="">input</var> and the character at <var title="">position</var> is a U+003A COLON character (:), run these substeps:</p> <ol><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character (:), then return an error and abort these steps. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let <var title="">string</var> be the collected substring.</li> <li><p>If <var title="">string</var> is not exactly two characters in length, return an error and abort these steps.</li> <li><p>Interpret <var title="">string</var> as a base-ten integer. Let <var title="">value<sub>3</sub></var> be that integer.</li> </ol><p>Otherwise (if <var title="">most significant units</var> is not <i title="">hours</i>, and either <var title="">position</var> is beyond the end of <var title="">input</var>, or the character at <var title="">position</var> is not a U+003A COLON character (:)), let <var title="">value<sub>3</sub></var> have the value of <var title="">value<sub>2</sub></var>, then <var title="">value<sub>2</sub></var> have the value of <var title="">value<sub>1</sub></var>, then let <var title="">value<sub>1</sub></var> equal zero.</p> </li> <li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002E FULL STOP character (.), then return an error and abort these steps. Otherwise, move <var title="">position</var> forwards one character.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let <var title="">string</var> be the collected substring.</li> <li><p>If <var title="">string</var> is not exactly three characters in length, return an error and abort these steps.</li> <li><p>Interpret <var title="">string</var> as a base-ten integer. Let <var title="">value<sub>4</sub></var> be that integer.</li> <li><p>If <var title="">value<sub>2</sub></var> is greater than 59 or if <var title="">value<sub>3</sub></var> is greater than 59, return an error and abort these steps.</li> <!-- no need to check if <var title="">value<sub>4</sub></var> is greater than 999, since we know it had exactly three characters in the range 0-9, so we know it's a number in the range 0-999 --> <li><p>Let <var title="">result</var> be <span title=""><var title="">value<sub>1</sub></var>×60×60 + <var title="">value<sub>2</sub></var>×60 + <var title="">value<sub>3</sub></var> + <var title="">value<sub>4</sub></var>∕1000</span>. <!-- ÷ is the division sign if people prefer that to the slash --></li> <li><p>Return <var title="">result</var>.</li> </ol><h6 id=webvtt-cue-text-parsing-rules><span class=secno>4.8.10.13.4 </span><dfn>WebVTT cue text parsing rules</dfn></h6> <p>A <dfn id=webvtt-node-object>WebVTT Node Object</dfn> is a conceptual construct used to represent components of <a href=#webvtt-cue-text>WebVTT cue text</a> so that its processing can be described without reference to the underlying syntax.</p> <p>There are two broad classes of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>: <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> and <a href=#webvtt-leaf-node-object title="WebVTT Leaf Node Object">WebVTT Leaf Node Objects</a>.</p> <p><dfn id=webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</dfn> are those that can contain further <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>. They are conceptually similar to elements in HTML or the DOM. <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> have an ordered list of child <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>. The <a href=#webvtt-internal-node-object>WebVTT Internal Node Object</a> is said to be the <i>parent</i> of the children. Cycles do not occur; the parent-child relationships so constructed form a tree structure. <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> also have an ordered list of class names, know as their <dfn id="webvtt-node-object's-applicable-classes" title="WebVTT Node Object's applicable classes">applicable classes</dfn>.</p> <p>There are several concrete classes of <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a>:</p> <dl><dt><dfn id=list-of-webvtt-node-objects title="List of WebVTT Node Objects">Lists of WebVTT Node Objects</dfn></dt> <dd> <p>These are used as root nodes for trees of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>.</p> </dd> <dt><dfn id=webvtt-class-object title="WebVTT Class Object">WebVTT Class Objects</dfn></dt> <dd> <p>These represent spans of text (a <a href=#webvtt-cue-class-span>WebVTT cue class span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>, and are used to annotate parts of the cue with <a href="#webvtt-node-object's-applicable-classes" title="WebVTT Node Object's applicable classes">applicable classes</a> without implying further meaning (such as italics or bold).</p> </dd> <dt><dfn id=webvtt-italic-object title="WebVTT Italic Object">WebVTT Italic Objects</dfn></dt> <dd> <p>These represent spans of italic text (a <a href=#webvtt-cue-italics-span>WebVTT cue italics span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>.</p> </dd> <dt><dfn id=webvtt-bold-object title="WebVTT Bold Object">WebVTT Bold Objects</dfn></dt> <dd> <p>These represent spans of bold text (a <a href=#webvtt-cue-bold-span>WebVTT cue bold span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>.</p> </dd> <dt><dfn id=webvtt-underline-object title="WebVTT Underline Object">WebVTT Underline Objects</dfn></dt> <dd> <p>These represent spans of underline text (a <a href=#webvtt-cue-underline-span>WebVTT cue underline span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>.</p> </dd> <dt><dfn id=webvtt-ruby-object title="WebVTT Ruby Object">WebVTT Ruby Objects</dfn></dt> <dd> <p>These represent spans of ruby (a <a href=#webvtt-cue-ruby-span>WebVTT cue ruby span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>.</p> </dd> <dt><dfn id=webvtt-ruby-text-object title="WebVTT Ruby Text Object">WebVTT Ruby Text Objects</dfn></dt> <dd> <p>These represent spans of ruby text (a <a href=#webvtt-cue-ruby-text-span>WebVTT cue ruby text span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>.</p> </dd> <dt><dfn id=webvtt-voice-object title="WebVTT Voice Object">WebVTT Voice Objects</dfn></dt> <dd> <p>These represent spans of text associated with a specific voice (a <a href=#webvtt-cue-voice-span>WebVTT cue voice span</a>) in <a href=#webvtt-cue-text>WebVTT cue text</a>. A <a href=#webvtt-voice-object>WebVTT Voice Object</a> has a value, which is the name of the voice.</p> </dd> </dl><p><dfn id=webvtt-leaf-node-object title="WebVTT Leaf Node Object">WebVTT Leaf Node Objects</dfn> are those that contain data, such as text, and cannot contain child <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>.</p> <p>There are two concrete classes of <a href=#webvtt-leaf-node-object title="WebVTT Leaf Node Object">WebVTT Leaf Node Objects</a>:</p> <dl><dt><dfn id=webvtt-text-object title="WebVTT Text Object">WebVTT Text Objects</dfn></dt> <dd> <p>A fragment of text. A <a href=#webvtt-text-object>WebVTT Text Object</a> has a value, which is the text it represents.</p> </dd> <dt><dfn id=webvtt-timestamp-object title="WebVTT Timestamp Object">WebVTT Timestamp Objects</dfn></dt> <dd> <p>A timestamp. A <a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a> has a value, in seconds and fractions of a second, which is the time represented by the timestamp.</p> </dd> </dl><p>To parse a string <var title="">input</var> supposedly containing <a href=#webvtt-cue-text>WebVTT cue text</a>, user agents must use the following algorithm. This algorithm returns a <a href=#list-of-webvtt-node-objects>list of WebVTT Node Objects</a>.</p> <ol><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">result</var> be a <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, initially empty.</li> <li><p>Let <var title="">current</var> be the <a href=#webvtt-internal-node-object>WebVTT Internal Node Object</a> <var title="">result</var>.</li> <li><p><i>Loop</i>: If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">result</var> and abort these steps.</li> <li><p>Let <var title="">token</var> be the result of invoking the <a href=#webvtt-cue-text-tokenizer>WebVTT cue text tokenizer</a>.</li> <li> <p>Run the appropriate steps given the type of <var title="">token</var>:</p> <dl><dt>If <var title="">token</var> is a string</dt> <dd> <ol><li><p>Create a <a href=#webvtt-text-object>WebVTT Text Object</a> whose value is the value of the string token <var title="">token</var>.</li> <li><p>Append the newly created <a href=#webvtt-text-object>WebVTT Text Object</a> to <var title="">current</var>.</li> </ol></dd> <dt>If <var title="">token</var> is a start tag</dt> <dd> <p>How the start tag token <var title="">token</var> is processed depends on its tag name, as follows:</p> <dl><!-- <dt>If the tag name is the empty string</dt> <dd> <p>Ignore the token.</p> </dd> --><dt>If the tag name is "<code title="">c</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-class-object>WebVTT Class Object</a>.</p> </dd> <dt>If the tag name is "<code title="">i</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-italic-object>WebVTT Italic Object</a>.</p> </dd> <dt>If the tag name is "<code title="">b</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-bold-object>WebVTT Bold Object</a>.</p> </dd> <dt>If the tag name is "<code title="">u</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-underline-object>WebVTT Underline Object</a>.</p> </dd> <dt>If the tag name is "<code title="">ruby</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-ruby-object>WebVTT Ruby Object</a>.</p> </dd> <dt>If the tag name is "<code title="">rt</code>"</dt> <dd> <p>If <var title="">current</var> is a <a href=#webvtt-ruby-object>WebVTT Ruby Object</a>, then <a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">attach</a> a <a href=#webvtt-ruby-text-object>WebVTT Ruby Text Object</a>.</p> </dd> <dt>If the tag name is "<code title="">v</code>"</dt> <dd> <p><a href=#attach-a-webvtt-internal-node-object title="attach a WebVTT Internal Node Object">Attach</a> a <a href=#webvtt-voice-object>WebVTT Voice Object</a>, and set its value to the token's annotation string, or the empty string if there is no annotation string.</p> </dd> <dt>Otherwise</dt> <dd> <p>Ignore the token.</p> </dd> </dl><p>When the steps above say to <dfn id=attach-a-webvtt-internal-node-object>attach a WebVTT Internal Node Object</dfn> of a particular concrete class, the user agent must run the following steps:</p> <ol><li><p>Create a new <a href=#webvtt-internal-node-object>WebVTT Internal Node Object</a> of the specified concrete class.</li> <li><p>Set the new object's list of <a href="#webvtt-node-object's-applicable-classes" title="WebVTT Node Object's applicable classes">applicable classes</a> to the list of classes in the token, excluding any classes that are the empty string.</p> <li><p>Append the newly created node object to <var title="">current</var>.</li> <li><p>Let <var title="">current</var> be the newly created node object.</li> </ol></dd> <dt>If <var title="">token</var> is an end tag</dt> <dd> <p>If any of the following conditions is true, then let <var title="">current</var> be the parent node of <var title="">current</var>.</p> <ul class=brief><li>The tag name of the end tag token <var title="">token</var> is "<code title="">c</code>" and <var title="">current</var> is a <a href=#webvtt-class-object>WebVTT Class Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">i</code>" and <var title="">current</var> is a <a href=#webvtt-italic-object>WebVTT Italic Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">b</code>" and <var title="">current</var> is a <a href=#webvtt-bold-object>WebVTT Bold Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">u</code>" and <var title="">current</var> is a <a href=#webvtt-underline-object>WebVTT Underline Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">ruby</code>" and <var title="">current</var> is a <a href=#webvtt-ruby-object>WebVTT Ruby Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">rt</code>" and <var title="">current</var> is a <a href=#webvtt-ruby-text-object>WebVTT Ruby Text Object</a>.</li> <li>The tag name of the end tag token <var title="">token</var> is "<code title="">v</code>" and <var title="">current</var> is a <a href=#webvtt-voice-object>WebVTT Voice Object</a>.</li> </ul><p>Otherwise, if the tag name of the end tag token <var title="">token</var> is "<code title="">ruby</code>" and <var title="">current</var> is a <a href=#webvtt-ruby-text-object>WebVTT Ruby Text Object</a>, then let <var title="">current</var> be the parent node of the parent node of <var title="">current</var>.</p> <p>Otherwise, ignore the token.</p> </dd> <dt>If <var title="">token</var> is a timestamp tag</dt> <dd> <ol><li><p>Let <var title="">input</var> be the tag value.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#collect-a-webvtt-timestamp>Collect a WebVTT timestamp</a>.</li> <li> <p>If that algorithm does not fail, and if <var title="">position</var> now points at the end of <var title="">input</var> (i.e. there are no trailing characters after the timestamp), then create a <a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a> whose value is the collected time, then append it to <var title="">current</var>.</p> <p>Otherwise, ignore the token.</p> </li> </ol></dd> </dl></li> <li><p>Jump to the step labeled <i>loop</i>.</li> </ol><p>The <dfn id=webvtt-cue-text-tokenizer>WebVTT cue text tokenizer</dfn> is as follows. It emits a token, which is either a string (whose value is a sequence of characters), a start tag (with a tag name, a list of classes, and optionally an annotation), an end tag (with a tag name), or a timestamp tag (with a tag value).</p> <ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same name in the algorithm that invoked these steps.</li> <li><p>Let <var title="">tokenizer state</var> be <a href=#webvtt-data-state>WebVTT data state</a>.</li> <li><p>Let <var title="">result</var> be the empty string.</li> <li><p>Let <var title="">buffer</var> be the empty string.</li> <li><p>Let <var title="">classes</var> be an empty list.</li> <li> <p><i>Loop</i>: If <var title="">position</var> is past the end of <var title="">input</var>, let <var title="">c</var> be an end-of-file marker. Otherwise, let <var title="">c</var> be the character in <var title="">input</var> pointed to by <var title="">position</var>.</p> <p class=note>An end-of-file marker is not a Unicode character, it is used to end the tokenizer.</p> </li> <li> <p>Jump to the state given by <var title="">tokenizer state</var>:</p> <dl><dt><dfn id=webvtt-data-state>WebVTT data state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+0026 AMPERSAND (&)</dt> <dd> <p>Set <var title="">buffer</var> to <var title="">c</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-escape-state>WebVTT escape state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd> <p>If <var title="">result</var> is the empty string, then set <var title="">tokenizer state</var> to the <a href=#webvtt-tag-state>WebVTT tag state</a> and jump to the step labeled <i>next</i>.</p> <p>Otherwise, return a string token whose value is <var title="">result</var> and abort these steps.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Return a string token whose value is <var title="">result</var> and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">result</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-escape-state>WebVTT escape state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+0026 AMPERSAND (&)</dt> <dd> <p>Append <var title="">buffer</var> to <var title="">result</var>, set <var title="">buffer</var> to <var title="">c</var>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>Characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9)</dt> <dt>Characters in the range U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z</dt> <dt>Characters in the range U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z</dt> <dd> <p>Append <var title="">c</var> to <var title="">buffer</var> and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003B SEMICOLON character (;)</dt> <dd> <p>First, examine the value of <var title="">buffer</var>:</p> <p>If <var title="">buffer</var> is the string "<code title="">&amp</code>", then append a U+0026 AMPERSAND character (&) to <var title="">result</var>.</p> <p>If <var title="">buffer</var> is the string "<code title="">&lt</code>", then append a U+003C LESS-THAN SIGN character (<) to <var title="">result</var>.</p> <p>If <var title="">buffer</var> is the string "<code title="">&gt</code>", then append a U+003E GREATER-THAN SIGN character (>) to <var title="">result</var>.</p> <p>Otherwise, append <var title="">buffer</var> followed by a U+003B SEMICOLON character (;) to <var title="">result</var>.</p> <p>Then, in any case, set <var title="">tokenizer state</var> to the <a href=#webvtt-data-state>WebVTT data state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dt>End-of-file marker</dt> <dd> <p>Append <var title="">buffer</var> to <var title="">result</var>, return a string token whose value is <var title="">result</var>, and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">buffer</var> to <var title="">result</var>, append <var title="">c</var> to <var title="">result</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-data-state>WebVTT data state</a>, and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-tag-state>WebVTT tag state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+0009 CHARACTER TABULATION (tab) character</dt> <dt>U+000A LINE FEED (LF) character</dt> <dt>U+000C FORM FEED (FF) character</dt> <dt>U+0020 SPACE character</dt> <dd> <!-- assert: >result< is the empty string --> <p>Set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-annotation-state>WebVTT start tag annotation state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+002E FULL STOP character (.)</dt> <dd> <!-- assert: >result< is the empty string --> <p>Set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-class-state>WebVTT start tag class state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+002F SOLIDUS character (/)</dt> <dd> <p>Set <var title="">tokenizer state</var> to the <a href=#webvtt-end-tag-state>WebVTT end tag state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>Characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9)</dt> <dd> <p>Set <var title="">result</var> to <var title="">c</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-timestamp-tag-state>WebVTT timestamp tag state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Return a start tag whose tag name is the empty string, with no classes and no annotation, and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Set <var title="">result</var> to <var title="">c</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-state>WebVTT start tag state</a>, and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-start-tag-state>WebVTT start tag state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+0009 CHARACTER TABULATION (tab) character</dt> <dt>U+000C FORM FEED (FF) character</dt> <dt>U+0020 SPACE character</dt> <dd> <p>Set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-annotation-state>WebVTT start tag annotation state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+000A LINE FEED (LF) character</dt> <dd> <p>Set <var title="">buffer</var> to <var title="">c</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-annotation-state>WebVTT start tag annotation state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+002E FULL STOP character (.)</dt> <dd> <p>Set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-class-state>WebVTT start tag class state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Return a start tag whose tag name is <var title="">result</var>, with no classes and no annotation, and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">result</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-start-tag-class-state>WebVTT start tag class state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+0009 CHARACTER TABULATION (tab) character</dt> <dt>U+000C FORM FEED (FF) character</dt> <dt>U+0020 SPACE character</dt> <dd> <p>Append to <var title="">classes</var> an entry whose value is <var title="">buffer</var>, set <var title="">buffer</var> to the empty string, set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-annotation-state>WebVTT start tag annotation state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+000A LINE FEED (LF) character</dt> <dd> <p>Append to <var title="">classes</var> an entry whose value is <var title="">buffer</var>, set <var title="">buffer</var> to <var title="">c</var>, set <var title="">tokenizer state</var> to the <a href=#webvtt-start-tag-annotation-state>WebVTT start tag annotation state</a>, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+002E FULL STOP character (.)</dt> <dd> <p>Append to <var title="">classes</var> an entry whose value is <var title="">buffer</var>, set <var title="">buffer</var> to the empty string, and jump to the step labeled <i>next</i>.</p> </dd> <dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Append to <var title="">classes</var> an entry whose value is <var title="">buffer</var>, then return a start tag whose tag name is <var title="">result</var>, with the classes given in <var title="">classes</var> but no annotation, and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">buffer</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-start-tag-annotation-state>WebVTT start tag annotation state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Remove any leading or trailing <a href=#space-character title="space character">space characters</a> from <var title="">buffer</var>, and replace any sequence of one or more consecutive <a href=#space-character title="space character">space characters</a> in <var title="">buffer</var> with a single U+0020 SPACE character; then, return a start tag whose tag name is <var title="">result</var>, with the classes given in <var title="">classes</var>, and with <var title="">buffer</var> as the annotation, and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">buffer</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-end-tag-state>WebVTT end tag state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><!-- should we ignore anything after spaces, tabs, and line feeds? --><dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Return an end tag whose tag name is <var title="">result</var> and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">result</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> <dt><dfn id=webvtt-timestamp-tag-state>WebVTT timestamp tag state</dfn></dt> <dd> <p>Jump to the entry that matches the value of <var title="">c</var>:</p> <dl><dt>U+003E GREATER-THAN SIGN character (>)</dt> <dd> <p>Advance <var title="">position</var> to the next character in <var title="">input</var>, then jump to the next "end-of-file marker" entry below.</p> </dd> <dt>End-of-file marker</dt> <dd> <p>Return a timestamp tag whose tag name is <var title="">result</var> and abort these steps.</p> </dd> <dt>Anything else</dt> <dd> <p>Append <var title="">c</var> to <var title="">result</var> and jump to the step labeled <i>next</i>.</p> </dd> </dl></dd> </dl></li> <li><p><i>Next</i>: Advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>Jump to the step labeled <i>loop</i>.</li> </ol><h6 id=webvtt-cue-text-dom-construction-rules><span class=secno>4.8.10.13.5 </span><dfn>WebVTT cue text DOM construction rules</dfn></h6> <p>To convert a <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> to a DOM tree for <code><a href=#document>Document</a></code> <var title="">owner</var>, user agents must create a tree of DOM nodes that is isomorphous to the tree of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>, with the following mapping of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> to DOM nodes:</p> <table><thead><tr><th><a href=#webvtt-node-object>WebVTT Node Object</a> <th>DOM node <tbody><tr><td><a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> <td><code><a href=#documentfragment>DocumentFragment</a></code> node <tr><td><a href=#webvtt-class-object>WebVTT Class Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-span-element>span</a></code>". <tr><td><a href=#webvtt-italic-object>WebVTT Italic Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-i-element>i</a></code>". <tr><td><a href=#webvtt-bold-object>WebVTT Bold Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-b-element>b</a></code>". <tr><td><a href=#webvtt-underline-object>WebVTT Underline Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-u-element>u</a></code>". <tr><td><a href=#webvtt-ruby-object>WebVTT Ruby Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-ruby-element>ruby</a></code>". <tr><td><a href=#webvtt-ruby-text-object>WebVTT Ruby Text Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-rt-element>rt</a></code>". <tr><td><a href=#webvtt-voice-object>WebVTT Voice Object</a> <td><code><a href=#htmlelement>HTMLElement</a></code> element node with <code title=dom-Node-localName><a href=#dom-node-localname>localName</a></code> "<code><a href=#the-span-element>span</a></code>", a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute set to the <a href=#webvtt-voice-object>WebVTT Voice Object</a>'s value. <tr><td><a href=#webvtt-text-object>WebVTT Text Object</a> <td><code><a href=#text>Text</a></code> node whose character data is the value of the <a href=#webvtt-text-object>WebVTT Text Object</a>. <tr><td><a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a> <td><code><a href=#processinginstruction>ProcessingInstruction</a></code> node whose <code title=dom-ProcessingInstruction-target>target</code> is "<code title="">timestamp</code>" and whose <code title=dom-ProcessingInstruction-data>data</code> is a <a href=#webvtt-timestamp>WebVTT timestamp</a> representing the value of the <a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a>, with all optional components included. </table><p><code><a href=#htmlelement>HTMLElement</a></code> nodes created as part of the mapping described above must have their <code title=dom-Node-namespaceURI><a href=#dom-node-namespaceuri>namespaceURI</a></code> set to the <a href=#html-namespace-0>HTML namespace</a>, and must have a <code title=attr-class><a href=#classes>class</a></code> attribute set to the string obtained by concatenating all the classes that apply to the corresponding <a href=#webvtt-internal-node-object>WebVTT Internal Node Object</a>, each separated from the next by a single U+0020 SPACE character.</p> <p>The <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> attribute of all nodes in the DOM tree must be set to the given document <var title="">owner</var>.</p> <p>All characteristics of the DOM nodes that are not described above or dependent on characteristics defined above must be left at their initial values.</p> </div> </div> <!--TTVTT--> <h5 id=user-interface><span class=secno>4.8.10.14 </span>User interface</h5> <p>The <dfn id=attr-media-controls title=attr-media-controls><code>controls</code></dfn> attribute is a <a href=#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> <div class=impl> <p>If the attribute is present, or if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the <a href=#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. full-screen video or in an independent resizable window). Other controls may also be made available.</p> <p>If the <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, then the user agent should expose audio tracks from all the <a href=#slaved-media-elements>slaved media elements</a> (although avoiding duplicates if the same <a href=#media-resource>media resource</a> is being used several times). If a <a href=#media-resource>media resource</a>'s audio track exposed in this way has no known name, and it is the only audio track for a particular <a href=#media-element>media element</a>, the user agent should use the element's <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute, if any, as the name (or as part of the name) of that track.</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, 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>media element</a>'s context menu.</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>When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, the user agent's user interface for pausing and unpausing playback, for seeking, for changing the rate of playback, for fast-forwarding or rewinding, and for muting or changing the volume of audio of the entire group must be implemented in terms of the <code><a href=#mediacontroller>MediaController</a></code> API exposed on that <a href=#current-media-controller>current media controller</a>.</p> <p>The "play" function in the user agent's interface must set the <code title="">playbackRate</code> attribute to the value of the <code title="">defaultPlaybackRate</code> attribute before invoking the <code title="">play()</code> method. When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, the attributes and method with those names on that <code><a href=#mediacontroller>MediaController</a></code> object must be used. Otherwise, the attributes and method with those names on the <a href=#media-element>media element</a> itself must be used. </p> <p>Features such as fast-forward or rewind must be implemented by only changing the <code title="">playbackRate</code> attribute (and not the <code title="">defaultPlaybackRate</code> attribute). Again, when a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, the attributes with those names on that <code><a href=#mediacontroller>MediaController</a></code> object must be used; otherwise, the attributes with those names on the <a href=#media-element>media element</a> itself must be used. </p> <p>When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, and all the <a href=#slaved-media-elements>slaved media elements</a> of that <code><a href=#mediacontroller>MediaController</a></code> are paused, the user agent should unpause all the <a href=#slaved-media-elements>slaved media elements</a> when the user invokes a user agent interface control for beginning playback.</p> <p>When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, seeking must be implemented in terms of the <code title=dom-MediaController-currentTime><a href=#dom-mediacontroller-currenttime>currentTime</a></code> attribute on that <code><a href=#mediacontroller>MediaController</a></code> object. Otherwise, the user agent must directly <a href=#dom-media-seek title=dom-media-seek>seek</a> to the requested position in the <a href=#media-element>media element</a>'s <a href=#media-timeline>media timeline</a>.</p> <p>When a <a href=#media-element>media element</a> has a <a href=#current-media-controller>current media controller</a>, user agents may additionally provide the user with controls that directly manipulate an individual <a href=#media-element>media element</a> without affecting the <code><a href=#mediacontroller>MediaController</a></code>, but such features are considered relatively advanced and unlikely to be useful to most users. <p>For the purposes of listing chapters in the <a href=#media-resource>media resource</a>, only <a href=#text-track title="text track">text tracks</a> in the <a href=#media-element>media element</a>'s <a href=#list-of-text-tracks>list of text tracks</a> <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> and whose <a href=#text-track-kind>text track kind</a> is <code title=dom-timedtrack-kind-chapters>chapters</code> should be used. Such tracks must be interpreted according to the <a href=#rules-for-constructing-the-chapter-tree-from-a-text-track>rules for constructing the chapter tree from a text track</a>.</p> <p>The <dfn id=dom-media-controls title=dom-media-controls><code>controls</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr></div> <dl class=domintro><dt><var title="">media</var> . <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current playback volume, as a number in the range 0.0 to 1.0, where 0.0 is the quietest and 1.0 the loudest.</p> <p>Can be set, to change the volume.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> if the new value is not in the range 0.0 .. 1.0.</p> </dd> <dt><var title="">media</var> . <code title=dom-media-muted><a href=#dom-media-muted>muted</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if audio is muted, overriding the <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> attribute, and false if the <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> attribute is being honored.</p> <p>Can be set, to change whether the audio is muted or not.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-media-volume title=dom-media-volume><code>volume</code></dfn> attribute must return the playback volume of any audio portions of the <a href=#media-element>media element</a>, 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. On setting, if the new value is in the range 0.0 to 1.0 inclusive, the playback volume of any audio portions of the <a href=#media-element>media element</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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception must be raised instead.</p> <p>The <dfn id=dom-media-muted title=dom-media-muted><code>muted</code></dfn> attribute must return true if the audio output is muted and false otherwise. Initially, the audio output should not be muted (false), but user agents may remember the last set value across sessions, on a per-site basis or otherwise, so the muted state may start as muted (true). On setting, if the new value is true then the audio output should be muted and if the new value is false it should be unmuted.</p> <p>Whenever either of the values that would be returned by the <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> and <code title=dom-media-muted><a href=#dom-media-muted>muted</a></code> attributes change, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-volumechange><a href=#event-media-volumechange>volumechange</a></code> at the <a href=#media-element>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 the element's <a href=#effective-media-volume>effective media volume</a> is the volume desired by the user. Abort these steps.</li> <li><p>If the element's audio output is muted, the element's <a href=#effective-media-volume>effective media volume</a> is zero. Abort these steps.</li> <li><p>If the element has a <a href=#current-media-controller>current media controller</a> and that <code><a href=#mediacontroller>MediaController</a></code> object's <a href=#media-controller-mute-override>media controller mute override</a> is true, the element's <a href=#effective-media-volume>effective media volume</a> is zero. Abort these steps.</li> <li><p>Let <var title="">volume</var> be the playback volume of the audio portions of the <a href=#media-element>media element</a>, in range 0.0 (silent) to 1.0 (loudest).</li> <li><p>If the element has a <a href=#current-media-controller>current media controller</a>, multiply <var title="">volume</var> by that <code><a href=#mediacontroller>MediaController</a></code> object's <a href=#media-controller-volume-multiplier>media controller volume multiplier</a>.</li> <li><p>The element's <a href=#effective-media-volume>effective media volume</a> is <var title="">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.</li> </ol></div> <p>The <dfn id=attr-media-muted title=attr-media-muted><code>muted</code></dfn> attribute on <a href=#media-element title="media element">media elements</a> is a <a href=#boolean-attribute>boolean attribute</a> that controls the default state of the audio output of the <a href=#media-resource>media resource</a>, potentially overriding user preferences.</p> <div class=impl> <p>When a <a href=#media-element>media element</a> is created, if it has a <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code> attribute specified, the user agent must mute the <a href=#media-element>media element</a>'s audio output, overriding any user preference.</p> <p>The <dfn id=dom-media-defaultmuted title=dom-media-defaultMuted><code>defaultMuted</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code> content attribute.</p> </div> <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 advertisment) autoplays, but to avoid annoying users, it does so without sound, and allows the user to turn the sound on.</p> <pre><video src="adverts.cgi?kind=video" controls autoplay loop muted></video></pre> </div> <h5 id=time-ranges><span class=secno>4.8.10.15 </span>Time ranges</h5> <p>Objects implementing the <code><a href=#timeranges>TimeRanges</a></code> interface represent a list of ranges (periods) of time.</p> <pre class=idl>interface <dfn id=timeranges>TimeRanges</dfn> { readonly attribute unsigned long <a href=#dom-timeranges-length title=dom-TimeRanges-length>length</a>; double <a href=#dom-timeranges-start title=dom-TimeRanges-start>start</a>(unsigned long index); double <a href=#dom-timeranges-end title=dom-TimeRanges-end>end</a>(unsigned long index); };</pre> <dl class=domintro><dt><var title="">media</var> . <code title=dom-TimeRanges-length><a href=#dom-timeranges-length>length</a></code></dt> <dd> <p>Returns the number of ranges in the object.</p> </dd> <dt><var title="">time</var> = <var title="">media</var> . <code title=dom-TimeRanges-start><a href=#dom-timeranges-start>start</a></code>(<var title="">index</var>)</dt> <dd> <p>Returns the time for the start of the range with the given index.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> if the index is out of range.</p> </dd> <dt><var title="">time</var> = <var title="">media</var> . <code title=dom-TimeRanges-end><a href=#dom-timeranges-end>end</a></code>(<var title="">index</var>)</dt> <dd> <p>Returns the time for the end of the range with the given index.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> if the index is out of range.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-timeranges-length title=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 title=dom-TimeRanges-start><code>start(<var title="">index</var>)</code></dfn> method must return the position of the start of the <var title="">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 title=dom-TimeRanges-end><code>end(<var title="">index</var>)</code></dfn> method must return the position of the end of the <var title="">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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exceptions if called with an <var title="">index</var> argument greater than or equal to the number of ranges represented by the object.</p> <p>When a <code><a href=#timeranges>TimeRanges</a></code> object is said to be a <dfn id=normalized-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> <li>The start of a range must be less than the end of that same range.</li> </ul><p>In other words, the ranges in such an object are ordered, don't overlap, aren't empty, and don't touch (adjacent ranges are folded into one bigger range).</p> <p>Ranges in a <code><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 title=dom-media-buffered><a href=#dom-media-buffered>buffered</a></code>, <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> and <code title=dom-media-played><a href=#dom-media-played>played</a></code> IDL attributes of <a href=#media-element title="media element">media elements</a> must be that element's <a href=#media-timeline>media timeline</a>.</p> </div> <h5 id=event-definitions><span class=secno>4.8.10.16 </span>Event definitions</h5> <pre class=idl>[Constructor(DOMString type, optional <a href=#trackeventinit>TrackEventInit</a> eventInitDict)] interface <dfn id=trackevent>TrackEvent</dfn> : <a href=#event>Event</a> { readonly attribute object? <a href=#dom-trackevent-track title=dom-TrackEvent-track>track</a>; }; dictionary <dfn id=trackeventinit>TrackEventInit</dfn> : <a href=#eventinit>EventInit</a> { object? Track; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-TrackEvent-track><a href=#dom-trackevent-track>track</a></code></dt> <dd> <p>Returns the track object (<code><a href=#texttrack>TextTrack</a></code>, <code><a href=#audiotrack>AudioTrack</a></code>, or <code><a href=#videotrack>VideoTrack</a></code>) to which the event relates.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-trackevent-track title=dom-TrackEvent-track><code>track</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the context information for the event.</p> </div> <h5 id=mediaevents><span class=secno>4.8.10.17 </span>Event summary</h5> <p><i>This section is non-normative.</i></p> <p>The following events fire on <a href=#media-element title="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 title=event-media-loadstart><code>loadstart</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent begins looking for <a href=#media-data>media data</a>, as part of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>. <td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code> <tr><td><dfn id=event-media-progress title=event-media-progress><code>progress</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent is fetching <a href=#media-data>media data</a>. <td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code> <tr><td><dfn id=event-media-suspend title=event-media-suspend><code>suspend</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent is intentionally not currently fetching <a href=#media-data>media data</a>. <td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code> <tr><td><dfn id=event-media-abort title=event-media-abort><code>abort</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent stops fetching the <a href=#media-data>media data</a> before it is completely downloaded, but not due to an error. <td><code title=dom-media-error><a href=#dom-media-error>error</a></code> is an object with the code <code title=dom-MediaError-MEDIA_ERR_ABORTED><a href=#dom-mediaerror-media_err_aborted>MEDIA_ERR_ABORTED</a></code>. <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals either <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> or <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code>, depending on when the download was aborted. <tr><td><dfn id=event-media-error title=event-media-error><code>error</code></dfn> <td><code><a href=#event>Event</a></code> <td>An error occurs while fetching the <a href=#media-data>media data</a>. <td><code title=dom-media-error><a href=#dom-media-error>error</a></code> is an object with the code <code title=dom-MediaError-MEDIA_ERR_NETWORK><a href=#dom-mediaerror-media_err_network>MEDIA_ERR_NETWORK</a></code> or higher. <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals either <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> or <code title=dom-media-NETWORK_IDLE><a href=#dom-media-network_idle>NETWORK_IDLE</a></code>, depending on when the download was aborted. <tr><td><dfn id=event-media-emptied title=event-media-emptied><code>emptied</code></dfn> <td><code><a href=#event>Event</a></code> <td>A <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> was previously not in the <code title=dom-media-NETWORK_EMPTY><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 title=dom-media-load><a href=#dom-media-load>load()</a></code> method was invoked while the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> was already running). <td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is <code title=dom-media-NETWORK_EMPTY><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 title=event-media-stalled><code>stalled</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent is trying to fetch <a href=#media-data>media data</a>, but data is unexpectedly not forthcoming. <td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>. <tbody><tr><td><dfn id=event-media-loadedmetadata title=event-media-loadedmetadata><code>loadedmetadata</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent has just determined the duration and dimensions of the <a href=#media-resource>media resource</a> and <a href=#the-text-tracks-are-ready>the text tracks are ready</a>. <td><code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is newly equal to <code title=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 title=event-media-loadeddata><code>loadeddata</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent can render the <a href=#media-data>media data</a> at the <a href=#current-playback-position>current playback position</a> for the first time. <td><code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> newly increased to <code title=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 title=event-media-canplay><code>canplay</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent can resume playback of the <a href=#media-data>media data</a>, but estimates that if playback were to be started now, the <a href=#media-resource>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 title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> newly increased to <code title=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 title=event-media-canplaythrough><code>canplaythrough</code></dfn> <td><code><a href=#event>Event</a></code> <td>The user agent estimates that if playback were to be started now, the <a href=#media-resource>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 title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is newly equal to <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code>. <tr><td><dfn id=event-media-playing title=event-media-playing><code>playing</code></dfn> <td><code><a href=#event>Event</a></code> <td>Playback is ready to start after having been paused or delayed due to lack of <a href=#media-data>media data</a>. <td><code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is newly equal to or greater than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> and <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> is false, or <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> is newly false and <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is equal to or greater than <code title=dom-media-HAVE_FUTURE_DATA><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>potentially playing</a>, e.g. if the element is <a href=#blocked-on-its-media-controller>blocked on its media controller</a> (e.g. because the <a href=#current-media-controller>current media controller</a> is paused, or another <a href=#slaved-media-elements title="slaved media elements">slaved media element</a> is stalled somehow, or because the <a href=#media-resource>media resource</a> has no data corresponding to the <a href=#media-controller-position>media controller position</a>), or the element is <a href=#paused-for-user-interaction>paused for user interaction</a>. <tr><td><dfn id=event-media-waiting title=event-media-waiting><code>waiting</code></dfn> <td><code><a href=#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 title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is equal to or less than <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code>, and <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> is false. Either <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> is true, or the <a href=#current-playback-position>current playback position</a> is not contained in any of the ranges in <code title=dom-media-buffered><a href=#dom-media-buffered>buffered</a></code>. It is possible for playback to stop for other reasons without <code title=dom-media-paused><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 title=event-media-playing><a href=#event-media-playing>playing</a></code> event is not fired either): e.g. the element is newly <a href=#blocked-on-its-media-controller>blocked on its media controller</a>, or <a href=#ended-playback title="ended playback">playback ended</a>, or playback <a href=#stopped-due-to-errors>stopped due to errors</a>, or the element has <a href=#paused-for-user-interaction>paused for user interaction</a>. <tbody><tr><td><dfn id=event-media-seeking title=event-media-seeking><code>seeking</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute changed to true. <td> <tr><td><dfn id=event-media-seeked title=event-media-seeked><code>seeked</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute changed to false. <td> <tr><td><dfn id=event-media-ended title=event-media-ended><code>ended</code></dfn> <td><code><a href=#event>Event</a></code> <td>Playback has stopped because the end of the <a href=#media-resource>media resource</a> was reached. <td><code title=dom-media-currentTime><a href=#dom-media-currenttime>currentTime</a></code> equals the end of the <a href=#media-resource>media resource</a>; <code title=dom-media-ended><a href=#dom-media-ended>ended</a></code> is true. <tbody><tr><td><dfn id=event-media-durationchange title=event-media-durationchange><code>durationchange</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-media-duration><a href=#dom-media-duration>duration</a></code> attribute has just been updated. <td> <tr><td><dfn id=event-media-timeupdate title=event-media-timeupdate><code>timeupdate</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <a href=#current-playback-position>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 title=event-media-play><code>play</code></dfn> <td><code><a href=#event>Event</a></code> <td>The element is no longer paused. Fired after the <code title=dom-media-play><a href=#dom-media-play>play()</a></code> method has returned, or when the <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code> attribute has caused playback to begin. <td><code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> is newly false. <tr><td><dfn id=event-media-pause title=event-media-pause><code>pause</code></dfn> <td><code><a href=#event>Event</a></code> <td>The element has been paused. Fired after the <code title=dom-media-pause><a href=#dom-media-pause>pause()</a></code> method has returned. <td><code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> is newly true. <tr><td><dfn id=event-media-ratechange title=event-media-ratechange><code>ratechange</code></dfn> <td><code><a href=#event>Event</a></code> <td>Either the <code title=dom-media-defaultPlaybackRate><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> or the <code title=dom-media-playbackRate><a href=#dom-media-playbackrate>playbackRate</a></code> attribute has just been updated. <td> <tr><td><dfn id=event-media-volumechange title=event-media-volumechange><code>volumechange</code></dfn> <td><code><a href=#event>Event</a></code> <td>Either the <code title=dom-media-volume><a href=#dom-media-volume>volume</a></code> attribute or the <code title=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 events fire on <code><a href=#mediacontroller>MediaController</a></code> objects:</p> <table><thead><tr><th>Event name <th>Interface <th>Fired when... <tbody><tr><td><dfn id=event-mediacontroller-emptied title=event-MediaController-emptied><code>emptied</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> newly have <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> set to <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code> or greater, or there are no longer any <a href=#slaved-media-elements>slaved media elements</a>. <tr><td><dfn id=event-mediacontroller-loadedmetadata title=event-MediaController-loadedmetadata><code>loadedmetadata</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> newly have <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> set to <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code> or greater. <tr><td><dfn id=event-mediacontroller-loadeddata title=event-MediaController-loadeddata><code>loadeddata</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> newly have <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> set to <code title=dom-media-HAVE_CURRENT_DATA><a href=#dom-media-have_current_data>HAVE_CURRENT_DATA</a></code> or greater. <tr><td><dfn id=event-mediacontroller-canplay title=event-MediaController-canplay><code>canplay</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> newly have <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> set to <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code> or greater. <tr><td><dfn id=event-mediacontroller-canplaythrough title=event-MediaController-canplaythrough><code>canplaythrough</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> newly have <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> set to <code title=dom-media-HAVE_ENOUGH_DATA><a href=#dom-media-have_enough_data>HAVE_ENOUGH_DATA</a></code> or greater. <tr><td><dfn id=event-mediacontroller-playing title=event-MediaController-playing><code>playing</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code><a href=#mediacontroller>MediaController</a></code> is no longer a <a href=#blocked-media-controller>blocked media controller</a>. <tr><td><dfn id=event-mediacontroller-ended title=event-MediaController-ended><code>ended</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code><a href=#mediacontroller>MediaController</a></code> has reached the end of all the <a href=#slaved-media-elements>slaved media elements</a>. <tr><td><dfn id=event-mediacontroller-waiting title=event-MediaController-waiting><code>waiting</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code><a href=#mediacontroller>MediaController</a></code> is now a <a href=#blocked-media-controller>blocked media controller</a>. <tr><td><dfn id=event-mediacontcoller-ended title=event-MediaContcoller-ended><code>ended</code></dfn> <td><code><a href=#event>Event</a></code> <td>All the <a href=#slaved-media-elements>slaved media elements</a> have newly <a href=#ended-playback>ended playback</a>. <tbody><tr><td><dfn id=event-mediacontroller-durationchange title=event-MediaController-durationchange><code>durationchange</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-MediaController-duration><a href=#dom-mediacontroller-duration>duration</a></code> attribute has just been updated. <tr><td><dfn id=event-mediacontroller-timeupdate title=event-MediaController-timeupdate><code>timeupdate</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <a href=#media-controller-position>media controller position</a> changed. <tr><td><dfn id=event-mediacontroller-play title=event-MediaController-play><code>play</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-MediaController-paused><a href=#dom-mediacontroller-paused>paused</a></code> attribute is newly false. <tr><td><dfn id=event-mediacontroller-pause title=event-MediaController-pause><code>pause</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code title=dom-MediaController-paused><a href=#dom-mediacontroller-paused>paused</a></code> attribute is newly true. <tr><td><dfn id=event-mediacontroller-ratechange title=event-MediaController-ratechange><code>ratechange</code></dfn> <td><code><a href=#event>Event</a></code> <td>Either the <code title=dom-MediaController-defaultPlaybackRate><a href=#dom-mediacontroller-defaultplaybackrate>defaultPlaybackRate</a></code> attribute or the <code title=dom-MediaController-playbackRate><a href=#dom-mediacontroller-playbackrate>playbackRate</a></code> attribute has just been updated. <tr><td><dfn id=event-mediacontroller-volumechange title=event-MediaController-volumechange><code>volumechange</code></dfn> <td><code><a href=#event>Event</a></code> <td>Either the <code title=dom-MediaController-volume><a href=#dom-mediacontroller-volume>volume</a></code> attribute or the <code title=dom-MediaController-muted><a href=#dom-mediacontroller-muted>muted</a></code> attribute has just been updated. </table><div class=impl> <h5 id=security-and-privacy-considerations><span class=secno>4.8.10.18 </span>Security and privacy considerations</h5> <p>The main security and privacy implications of the <code><a href=#the-video-element>video</a></code> and <code><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><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>top-level browsing context</a>.</p> <p class=example>For instance, if an SVG animation was embedded in a <code><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><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 or chapter titles. Such information is therefore only exposed if the video resource passes a CORS <a href=#resource-sharing-check>resource sharing check</a>. The <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> attribute allows authors to control how this check is performed. <a href=#refsCORS>[CORS]</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> </div> <h5 id=best-practices-for-authors-using-media-elements><span class=secno>4.8.10.19 </span>Best practices for authors using media elements</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 title="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 title=attr-media-src><a href=#attr-media-src>src</a></code> attribute and any <code><a href=#the-source-element>source</a></code> element descendants, and invoking the element's <code title=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> <div class=impl> <h5 id=best-practices-for-implementors-of-media-elements><span class=secno>4.8.10.20 </span>Best practices for implementors of media elements</h5> <p><i>This section is non-normative.</i></p> <p>How accurately various aspects of the <a href=#media-element>media element</a> API are implemented is considered a quality-of-implementation issue.</p> <p>For example, when implementing the <code title=attr-media-buffered>buffered</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-bit-rate 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 bit rate 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> <p>When multiple tracks are synchronised with a <code><a href=#mediacontroller>MediaController</a></code>, it is possible for scripts to add and remove media elements from the <code><a href=#mediacontroller>MediaController</a></code>'s list of <a href=#slaved-media-elements>slaved media elements</a>, even while these tracks are playing. How smoothly the media plays back in such situations is another quality-of-implementation issue.</p> <hr><p>When a <a href=#media-element>media element</a> that is paused is <a href=#remove-an-element-from-a-document title="remove an element from a document">removed from a document</a> and not reinserted before the next time the <a href=#event-loop>event loop</a> spins, 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>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> </div> <h4 id=the-canvas-element><span class=secno>4.8.11 </span>The <dfn id=canvas><code>canvas</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#embedded-content>Embedded content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#embedded-content>embedded content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#transparent>Transparent</a>.</dd> <dd><a href=#transparent>Transparent</a><!-- --><!--FORK--><!-- -->, but with no <a href=#interactive-content>interactive content</a> descendants except for <code><a href=#the-a-element>a</a></code> elements, <code><a href=#the-button-element>button</a></code> elements, <code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute are in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> or <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> states, and <code><a href=#the-input-element>input</a></code> elements that are <a href=#concept-button title=concept-button>buttons</a><!-- --><!--FORK--><!-- -->.</dd> <!-- and maybe <select>, I guess? I've left it in for now, since I guess authors might make accessible selects if they're simple enough, and it's not obvious how to distinguish the simple ones from the complex ones... --> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-canvas-width><a href=#attr-canvas-width>width</a></code></dd> <dd><code title=attr-canvas-height><a href=#attr-canvas-height>height</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlcanvaselement>HTMLCanvasElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute unsigned long <a href=#dom-canvas-width title=dom-canvas-width>width</a>; attribute unsigned long <a href=#dom-canvas-height title=dom-canvas-height>height</a>; DOMString <a href=#dom-canvas-todataurl title=dom-canvas-toDataURL>toDataURL</a>(optional DOMString type, any... args); void <a href=#dom-canvas-toblob title=dom-canvas-toBlob>toBlob</a>(<span>FileCallback</span>? callback, optional DOMString type, any... args); object? <a href=#dom-canvas-getcontext title=dom-canvas-getContext>getContext</a>(DOMString contextId, any... args); };</pre> </dd> </dl><p>The <code><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, or other visual images on the fly.</p> <p>Authors should not use the <code><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><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><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>) and then styled using CSS and supporting technologies such as XBL.</p> <p>When authors use the <code><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 bitmap canvas. This content may be placed as content of the <code><a href=#the-canvas-element>canvas</a></code> element. The contents of the <code><a href=#the-canvas-element>canvas</a></code> element, if any, are the element's <a href=#fallback-content>fallback content</a>.</p> <p>In interactive visual media, if <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the <code><a href=#the-canvas-element>canvas</a></code> element, and if support for <code><a href=#the-canvas-element>canvas</a></code> elements has been enabled, the <code><a href=#the-canvas-element>canvas</a></code> element <a href=#represents>represents</a> <a href=#embedded-content>embedded content</a> consisting of a dynamically created image.</p> <p>In non-interactive, static, visual media, if the <code><a href=#the-canvas-element>canvas</a></code> element has been previously painted on (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><a href=#the-canvas-element>canvas</a></code> element <a href=#represents>represents</a> <a href=#embedded-content>embedded content</a> with the current image and size. Otherwise, the element represents its <a href=#fallback-content>fallback content</a> instead.</p> <p>In non-visual media, and in visual media if <a href=#concept-n-noscript title=concept-n-noscript>scripting is disabled</a> for the <code><a href=#the-canvas-element>canvas</a></code> element or if support for <code><a href=#the-canvas-element>canvas</a></code> elements has been disabled, the <code><a href=#the-canvas-element>canvas</a></code> element <a href=#represents>represents</a> its <a href=#fallback-content>fallback content</a> instead.</p> <!-- CANVAS-FOCUS-FALLBACK --> <p>When a <code><a href=#the-canvas-element>canvas</a></code> element <a href=#represents>represents</a> <a href=#embedded-content>embedded content</a>, the user can still focus descendants of the <code><a href=#the-canvas-element>canvas</a></code> element (in the <a href=#fallback-content>fallback content</a>). When an element is focused, 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 focusable elements in the <a href=#fallback-content>fallback content</a>. (Focus has no effect on mouse interaction events.) <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> <p>The <code><a href=#the-canvas-element>canvas</a></code> element has two attributes to control the size of the coordinate space: <dfn id=attr-canvas-width title=attr-canvas-width><code>width</code></dfn> and <dfn id=attr-canvas-height title=attr-canvas-height><code>height</code></dfn>. These attributes, when specified, must have values that are <a href=#valid-non-negative-integer title="valid non-negative integer">valid non-negative integers</a>. <span class=impl>The <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> must be used to obtain their numeric values. If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead.</span> The <code title=attr-canvas-width><a href=#attr-canvas-width>width</a></code> attribute defaults to 300, and the <code title=attr-canvas-height><a href=#attr-canvas-height>height</a></code> attribute defaults to 150.</p> <p>The intrinsic dimensions of the <code><a href=#the-canvas-element>canvas</a></code> element equal the size of the coordinate space, with the numbers interpreted in CSS pixels. However, the element can be sized arbitrarily by a style sheet. During rendering, the image is scaled to fit this layout size.</p> <div class=impl> <p>The size of the coordinate space does not necessarily represent the size of the actual bitmap that the user agent will use internally or during rendering. On high-definition displays, for instance, the user agent may internally use a bitmap with two device pixels per unit in the coordinate space, so that the rendering remains at high quality throughout.</p> <p>When the <code><a href=#the-canvas-element>canvas</a></code> element is created, and subsequently whenever the <code title=attr-canvas-width><a href=#attr-canvas-width>width</a></code> and <code title=attr-canvas-height><a href=#attr-canvas-height>height</a></code> attributes are set (whether to a new value or to the previous value), the bitmap and any associated contexts must be cleared back to their initial state and reinitialized with the newly specified coordinate space dimensions.</p> <p>When the canvas is initialized, its bitmap must be cleared to transparent black.</p> <p>When a <code><a href=#the-canvas-element>canvas</a></code> element does not represent its <a href=#fallback-content>fallback content</a>, it <a href=#provides-a-paint-source>provides a paint source</a> whose width is the element's intrinsic width, whose height is the element's intrinsic height, and whose appearance is the element's bitmap.</p> <p>The <dfn id=dom-canvas-width title=dom-canvas-width><code>width</code></dfn> and <dfn id=dom-canvas-height title=dom-canvas-height><code>height</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name, with the same defaults.</p> </div> <div class=example> <p>Only one square appears to be drawn in the following example:</p> <pre> // canvas is a reference to a <canvas> element var context = canvas.getContext('2d'); context.fillRect(0,0,50,50); canvas.setAttribute('width', '300'); // clears the canvas context.fillRect(0,100,50,50); canvas.width = canvas.width; // clears the canvas context.fillRect(100,0,50,50); // only this square remains</pre> </div> <hr><dl class=domintro><dt><var title="">context</var> = <var title="">canvas</var> . <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext</a></code>(<var title="">contextId</var> [, ... ])</dt> <dd> <p>Returns an object that exposes an API for drawing on the canvas. The first argument specifies the desired API. Subsequent arguments are handled by that API.</p> <!--2DCONTEXT--> <p>This specification defines the "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>" context below. There is also a specification that defines a "<code title=canvas-context-webgl>webgl</code>" context. <a href=#refsWEBGL>[WEBGL]</a></p> <!--2DCONTEXT--> <p>The list of defined contexts is given on the <a href=http://wiki.whatwg.org/wiki/CanvasContexts>WHATWG Wiki CanvasContexts page</a>. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a> <p>Returns null if the given context ID is not supported or if the canvas has already been initialized with some other (incompatible) context type (e.g. trying to get a "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>" context after getting a "<code title=canvas-context-webgl>webgl</code>" context).</p> </dd> </dl><div class=impl> <p>A <code><a href=#the-canvas-element>canvas</a></code> element can have a <dfn id=primary-context>primary context</dfn>, which is the first context to have been obtained for that element. When created, a <code><a href=#the-canvas-element>canvas</a></code> element must not have a <a href=#primary-context>primary context</a>.</p> <p>The <dfn id=dom-canvas-getcontext title=dom-canvas-getContext><code>getContext(<var title="">contextId</var>, <var title="">args...</var>)</code></dfn> method of the <code><a href=#the-canvas-element>canvas</a></code> element, when invoked, must run the following steps:</p> <ol><li><p>Let <var title="">contextId</var> be the first argument to the method.</li> <li> <p>If <var title="">contextId</var> is not the name of a context supported by the user agent, return null and abort these steps.</p> <p class=note>An example of this would be a user agent that theoretically supports the "<code title=canvas-context-webgl>webgl</code>" 3D context, in the case where the platform does not have hardware support for OpenGL and the user agent does not have a software OpenGL implementation. Despite the user agent recognising the "<code title=canvas-context-webgl>webgl</code>" name, it would return null at this step because that context is not, in practice, supported at the time of the call.</p> </li> <li><p>If the element has a <a href=#primary-context>primary context</a> and that context's entry in the <a href=http://wiki.whatwg.org/wiki/CanvasContexts>WHATWG Wiki CanvasContexts page</a> does not list <var title="">contextId</var> as a context with which it is compatible, return null and abort these steps. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a></li> <li><p>If the element does not have a <a href=#primary-context>primary context</a>, let the element's <a href=#primary-context>primary context</a> be <var title="">contextId</var>.</li> <li><p>If the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> method has already been invoked on this element for the same <var title="">contextId</var>, return the same object as was returned that time, and abort these steps. The additional arguments are ignored.</li> <li><p><dfn id=getcontext-return title=getContext-return>Return a new object for <var title="">contextId</var></dfn>, as defined by the specification given for <var title="">contextId</var>'s entry in the <a href=http://wiki.whatwg.org/wiki/CanvasContexts>WHATWG Wiki CanvasContexts page</a>. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a></li> </ol><p>New context types may be registered in the <a href=http://wiki.whatwg.org/wiki/CanvasContexts>WHATWG Wiki CanvasContexts page</a>. <a href=#refsWHATWGWIKI>[WHATWGWIKI]</a></p> <p>Anyone is free to edit the WHATWG Wiki CanvasContexts page at any time to add a new context type. These new context types must be specified with the following information:</p> <dl><dt>Keyword</dt> <dd><p>The value of <var title="">contextID</var> that will return the object for the new API.</dd> <dt>Specification</dt> <dd><p>A link to a formal specification of the context type's API. It could be another page on the Wiki, or a link to an external page. If the type does not have a formal specification, an informal description can be substituted until such time as a formal specification is available.</dd> <dt>Compatible with</dt> <dd><p>The list of context types that are compatible with this one (i.e. that operate on the same underlying bitmap). This list must be transitive and symmetric; if one context type is defined as compatible with another, then all types it is compatible with must be compatible with all types the other is compatible with.</dd> </dl><p>Vendors may also define experimental contexts using the syntax <code><var title="">vendorname</var>-<var title="">context</var></code>, for example, <code>moz-3d</code>. Such contexts should be registered in the WHATWG Wiki CanvasContexts page.</p> </div> <hr><dl class=domintro><dt><var title="">url</var> = <var title="">canvas</var> . <code title=dom-canvas-toDataURL><a href=#dom-canvas-todataurl>toDataURL</a></code>( [ <var title="">type</var>, ... ])</dt> <dd> <p>Returns a <a href=#data-protocol title="data protocol"><code title="">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 title="">image/png</code>; that type is also used if the given type isn't supported. The other arguments are specific to the type, and control the way that the image is generated, as given in the table below.</p> <p>When trying to use types other than "<code>image/png</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 title="">data:image/png,</code>" or "<code title="">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 title="">data:,</code>".)</p> </dd> <dt><var title="">canvas</var> . <code title=dom-canvas-toBlob><a href=#dom-canvas-toblob>toBlob</a></code>(<var title="">callback</var> [, <var title="">type</var>, ... ])</dt> <dd> <p>Creates a <code><a href=#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 title="">image/png</code>; that type is also used if the given type isn't supported. The other arguments are specific to the type, and control the way that the image is generated, as given in the table below.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-canvas-todataurl title=dom-canvas-toDataURL><code>toDataURL()</code></dfn> method must run the following steps:</p> <ol><li><p>If the canvas has no pixels (i.e. either its horizontal dimension or its vertical dimension is zero) then return the string "<code title="">data:,</code>" and abort these steps. (This is the shortest <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a>; it represents the empty string in a <code title="">text/plain</code> resource.)</li> <li><p>Let <var title="">file</var> be <a href=#a-serialization-of-the-image-as-a-file>a serialization of the image as a file</a>, using the method's arguments (if any) as the <var title="">arguments</var>.</li> <li><p>Return a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> representing <var title="">file</var>. <a href=#refsRFC2397>[RFC2397]</a></p> <!-- should we explicitly require the URL to be base64-encoded and not have any parameters, to ensure the same exact URL is generated in each browser? --> </ol><p>The <dfn id=dom-canvas-toblob title=dom-canvas-toBlob><code>toBlob()</code></dfn> method must run the following steps:</p> <ol><li><p>Let <var title="">callback</var> be the first argument.</li> <li><p>Let <var title="">arguments</var> be the second and subsequent arguments to the method, if any.</li> <li><p>Let <var title="">file</var> be <a href=#a-serialization-of-the-image-as-a-file>a serialization of the image as a file</a>, using <var title="">arguments</var>.</li> <li><p>Return, but continue running these steps asynchronously.</li> <li><p>If <var title="">callback</var> is null, abort these steps.</li> <li><p><a href=#queue-a-task>Queue a task</a> to invoke the <code>FileCallback</code> <var title="">callback</var> with a <code><a href=#blob>Blob</a></code> object representing <var title="">file</var> as its argument. The <a href=#task-source>task source</a> for this task is the <dfn id=canvas-blob-serialization-task-source>canvas blob serialization task source</dfn>. <a href=#refsFILESYSTEMAPI>[FILESYSTEMAPI]</a> <a href=#refsFILEAPI>[FILEAPI]</a> </li> </ol><p>When a user agent is to create <dfn id=a-serialization-of-the-image-as-a-file>a serialization of the image as a file</dfn>, optionally with some given <var title="">arguments</var>, it must create an image file in the format given by the first value of <var title="">arguments</var>, or, if there are no <var title="">arguments</var>, in the PNG format. <a href=#refsPNG>[PNG]</a></p> <p>If <var title="">arguments</var> is not empty, the first value must be interpreted as a <a href=#mime-type title="MIME type">MIME type</a> giving the format to use. If the type has any parameters, it must be treated as not supported.</p> <p class=example>For example, the value "<code>image/png</code>" would mean to generate a PNG image, the value "<code>image/jpeg</code>" would mean to generate a JPEG image, and the value "<code>image/svg+xml</code>" would mean to generate an SVG image (which would probably require that the implementation actually keep enough information to reliably render an SVG image from the canvas).</p> <p>User agents must support PNG ("<code>image/png</code>"). User agents may support other types. If the user agent does not support the requested type, it must create the file using the PNG format. <a href=#refsPNG>[PNG]</a></p> <p>User agents must <a href=#converted-to-ascii-lowercase title="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 canvas image composited onto a solid black background using the source-over operator.</p> <p>If the first argument in <var title="">arguments</var> gives a type corresponding to one of the types given in the first column of the following table, and the user agent supports that type, then the subsequent arguments, if any, must be treated as described in the second cell of that row.</p> </div> <table><thead><tr><th> Type <th> Other arguments <th> Reference <tbody><tr><td> <code>image/jpeg</code> <td> The second argument<span class=impl>, if it</span> is a number in the range 0.0 to 1.0 inclusive<span class=impl>, must be</span> treated as the desired quality level. <span class=impl>If it is not a number or is outside that range, the user agent must use its default value, as if the argument had been omitted.</span> <td> <a href=#refsJPEG>[JPEG]</a> </table><div class=impl> <p>For the purposes of these rules, an argument is considered to be a number if it is converted to an IDL double value by the rules for handling arguments of type <code title="">any</code> in the Web IDL specification. <a href=#refsWEBIDL>[WEBIDL]</a></p> <p>Other arguments must be ignored and must not cause the user agent to throw an exception. A future version of this specification will probably define other parameters to be passed to these methods to allow authors to more carefully control compression settings, image metadata, etc.</p> </div> <!--2DCONTEXT--> <div data-component="HTML Canvas 2D Context (editor: Ian Hickson)"> <h5 id=2dcontext><span class=secno>4.8.11.1 </span>The 2D context</h5> <!-- v2: we're on v4.1. suggestions for next version are marked v5, v6. --> <p>This specification defines the <dfn id=canvas-context-2d title=canvas-context-2d><code>2d</code></dfn> context type, whose API is implemented using the <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> interface.</p> <div class=impl> <p>When the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> method of a <code><a href=#the-canvas-element>canvas</a></code> element is to <a href=#getcontext-return title=getContext-return>return a new object for the <var title="">contextId</var></a> <code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>, the user agent must return a new <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object. Any additional arguments are ignored.</p> </div> <p>The 2D context represents a flat Cartesian surface whose origin (0,0) is at the top left corner, with the coordinate space having <var title="">x</var> values increasing when going right, and <var title="">y</var> values increasing when going down.</p> <pre class=idl>interface <dfn id=canvasrenderingcontext2d>CanvasRenderingContext2D</dfn> { // back-reference to the canvas readonly attribute <a href=#htmlcanvaselement>HTMLCanvasElement</a> <a href=#dom-context-2d-canvas title=dom-context-2d-canvas>canvas</a>; // state void <a href=#dom-context-2d-save title=dom-context-2d-save>save</a>(); // push state on state stack void <a href=#dom-context-2d-restore title=dom-context-2d-restore>restore</a>(); // pop state stack and restore state <!-- // v6 we've also received requests for: attribute boolean <span title="dom-context-2d-forceHighQuality">forceHighQuality</span> // (default false) // when enabled, it would prevent the UA from falling back on lower-quality but faster rendering routines // useful e.g. for when an image manipulation app uses <canvas> both for UI previews and the actual work --> // transformations (default transform is the identity matrix) void <a href=#dom-context-2d-scale title=dom-context-2d-scale>scale</a>(double x, double y); void <a href=#dom-context-2d-rotate title=dom-context-2d-rotate>rotate</a>(double angle); void <a href=#dom-context-2d-translate title=dom-context-2d-translate>translate</a>(double x, double y); void <a href=#dom-context-2d-transform title=dom-context-2d-transform>transform</a>(double a, double b, double c, double d, double e, double f); void <a href=#dom-context-2d-settransform title=dom-context-2d-setTransform>setTransform</a>(double a, double b, double c, double d, double e, double f); <!-- // v6 we've also received requests for: void skew(...); void reflect(...); // or mirror(...) --> // compositing attribute double <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>globalAlpha</a>; // (default 1.0) attribute DOMString <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>globalCompositeOperation</a>; // (default source-over) <!-- // v6 we've also received requests for: - turning off antialiasing to avoid seams when patterns are painted next to each other - might be better to overdraw? - might be better to just draw at a higher res then downsample, like for 3d? - nested layers - the ability to composite an entire set of drawing operations with one shadow all at once http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/015567.html --> // colors and styles attribute any <a href=#dom-context-2d-strokestyle title=dom-context-2d-strokeStyle>strokeStyle</a>; // (default black) attribute any <a href=#dom-context-2d-fillstyle title=dom-context-2d-fillStyle>fillStyle</a>; // (default black) <a href=#canvasgradient>CanvasGradient</a> <a href=#dom-context-2d-createlineargradient title=dom-context-2d-createLinearGradient>createLinearGradient</a>(double x0, double y0, double x1, double y1); <a href=#canvasgradient>CanvasGradient</a> <a href=#dom-context-2d-createradialgradient title=dom-context-2d-createRadialGradient>createRadialGradient</a>(double x0, double y0, double r0, double x1, double y1, double r1); <a href=#canvaspattern>CanvasPattern</a> <a href=#dom-context-2d-createpattern title=dom-context-2d-createPattern>createPattern</a>(<a href=#htmlimageelement>HTMLImageElement</a> image, DOMString repetition); <a href=#canvaspattern>CanvasPattern</a> <a href=#dom-context-2d-createpattern title=dom-context-2d-createPattern>createPattern</a>(<a href=#htmlcanvaselement>HTMLCanvasElement</a> image, DOMString repetition); <a href=#canvaspattern>CanvasPattern</a> <a href=#dom-context-2d-createpattern title=dom-context-2d-createPattern>createPattern</a>(<a href=#htmlvideoelement>HTMLVideoElement</a> image, DOMString repetition); // line caps/joins attribute double <a href=#dom-context-2d-linewidth title=dom-context-2d-lineWidth>lineWidth</a>; // (default 1) attribute DOMString <a href=#dom-context-2d-linecap title=dom-context-2d-lineCap>lineCap</a>; // "butt", "round", "square" (default "butt") attribute DOMString <a href=#dom-context-2d-linejoin title=dom-context-2d-lineJoin>lineJoin</a>; // "round", "bevel", "miter" (default "miter") attribute double <a href=#dom-context-2d-miterlimit title=dom-context-2d-miterLimit>miterLimit</a>; // (default 10) // shadows attribute double <a href=#dom-context-2d-shadowoffsetx title=dom-context-2d-shadowOffsetX>shadowOffsetX</a>; // (default 0) attribute double <a href=#dom-context-2d-shadowoffsety title=dom-context-2d-shadowOffsetY>shadowOffsetY</a>; // (default 0) attribute double <a href=#dom-context-2d-shadowblur title=dom-context-2d-shadowBlur>shadowBlur</a>; // (default 0) attribute DOMString <a href=#dom-context-2d-shadowcolor title=dom-context-2d-shadowColor>shadowColor</a>; // (default transparent black) // rects void <a href=#dom-context-2d-clearrect title=dom-context-2d-clearRect>clearRect</a>(double x, double y, double w, double h); void <a href=#dom-context-2d-fillrect title=dom-context-2d-fillRect>fillRect</a>(double x, double y, double w, double h); void <a href=#dom-context-2d-strokerect title=dom-context-2d-strokeRect>strokeRect</a>(double x, double y, double w, double h); // path API void <a href=#dom-context-2d-beginpath title=dom-context-2d-beginPath>beginPath</a>(); void <a href=#dom-context-2d-closepath title=dom-context-2d-closePath>closePath</a>(); void <a href=#dom-context-2d-moveto title=dom-context-2d-moveTo>moveTo</a>(double x, double y); void <a href=#dom-context-2d-lineto title=dom-context-2d-lineTo>lineTo</a>(double x, double y); void <a href=#dom-context-2d-quadraticcurveto title=dom-context-2d-quadraticCurveTo>quadraticCurveTo</a>(double cpx, double cpy, double x, double y); void <a href=#dom-context-2d-beziercurveto title=dom-context-2d-bezierCurveTo>bezierCurveTo</a>(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void <a href=#dom-context-2d-arcto title=dom-context-2d-arcTo>arcTo</a>(double x1, double y1, double x2, double y2, double radius); <!-- see ARC-ORDER note below --> void <a href=#dom-context-2d-rect title=dom-context-2d-rect>rect</a>(double x, double y, double w, double h); void <a href=#dom-context-2d-arc title=dom-context-2d-arc>arc</a>(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise); <!-- see ARC-ORDER note below --> void <a href=#dom-context-2d-fill title=dom-context-2d-fill>fill</a>(); void <a href=#dom-context-2d-stroke title=dom-context-2d-stroke>stroke</a>(); void <a href=#dom-context-2d-drawsystemfocusring title=dom-context-2d-drawSystemFocusRing>drawSystemFocusRing</a>(<a href=#element>Element</a> element); boolean <a href=#dom-context-2d-drawcustomfocusring title=dom-context-2d-drawCustomFocusRing>drawCustomFocusRing</a>(<a href=#element>Element</a> element); void <a href=#dom-context-2d-scrollpathintoview title=dom-context-2d-scrollPathIntoView>scrollPathIntoView</a>(); void <a href=#dom-context-2d-clip title=dom-context-2d-clip>clip</a>(); boolean <a href=#dom-context-2d-ispointinpath title=dom-context-2d-isPointInPath>isPointInPath</a>(double x, double y); // text attribute DOMString <a href=#dom-context-2d-font title=dom-context-2d-font>font</a>; // (default 10px sans-serif) attribute DOMString <a href=#dom-context-2d-textalign title=dom-context-2d-textAlign>textAlign</a>; // "start", "end", "left", "right", "center" (default: "start") attribute DOMString <a href=#dom-context-2d-textbaseline title=dom-context-2d-textBaseline>textBaseline</a>; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic") void <a href=#dom-context-2d-filltext title=dom-context-2d-fillText>fillText</a>(DOMString text, double x, double y, optional double maxWidth); void <a href=#dom-context-2d-stroketext title=dom-context-2d-strokeText>strokeText</a>(DOMString text, double x, double y, optional double maxWidth);<!-- v6DVT void <span title="dom-context-2d-fillVerticalText">fillVerticalText</span>(DOMString text, double x, double y, optional double maxHeight); void <span title="dom-context-2d-strokeVerticalText">strokeVerticalText</span>(DOMString text, double x, double y, optional double maxHeight); --> <a href=#textmetrics>TextMetrics</a> <a href=#dom-context-2d-measuretext title=dom-context-2d-measureText>measureText</a>(DOMString text); // drawing images void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlimageelement>HTMLImageElement</a> image, double dx, double dy); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlimageelement>HTMLImageElement</a> image, double dx, double dy, double dw, double dh); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlimageelement>HTMLImageElement</a> image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlcanvaselement>HTMLCanvasElement</a> image, double dx, double dy); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlcanvaselement>HTMLCanvasElement</a> image, double dx, double dy, double dw, double dh); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlcanvaselement>HTMLCanvasElement</a> image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlvideoelement>HTMLVideoElement</a> image, double dx, double dy); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlvideoelement>HTMLVideoElement</a> image, double dx, double dy, double dw, double dh); void <a href=#dom-context-2d-drawimage title=dom-context-2d-drawImage>drawImage</a>(<a href=#htmlvideoelement>HTMLVideoElement</a> image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh); // pixel manipulation <a href=#imagedata>ImageData</a> <a href=#dom-context-2d-createimagedata title=dom-context-2d-createImageData>createImageData</a>(double sw, double sh); <a href=#imagedata>ImageData</a> <a href=#dom-context-2d-createimagedata title=dom-context-2d-createImageData>createImageData</a>(<a href=#imagedata>ImageData</a> imagedata); <a href=#imagedata>ImageData</a> <a href=#dom-context-2d-getimagedata title=dom-context-2d-getImageData>getImageData</a>(double sx, double sy, double sw, double sh); void <a href=#dom-context-2d-putimagedata title=dom-context-2d-putImageData>putImageData</a>(<a href=#imagedata>ImageData</a> imagedata, double dx, double dy); void <a href=#dom-context-2d-putimagedata title=dom-context-2d-putImageData>putImageData</a>(<a href=#imagedata>ImageData</a> imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight); }; interface <dfn id=canvasgradient>CanvasGradient</dfn> { // opaque object void <a href=#dom-canvasgradient-addcolorstop title=dom-canvasgradient-addColorStop>addColorStop</a>(double offset, DOMString color); }; interface <dfn id=canvaspattern>CanvasPattern</dfn> { // opaque object }; interface <dfn id=textmetrics>TextMetrics</dfn> { readonly attribute double <a href=#dom-textmetrics-width title=dom-textmetrics-width>width</a>; }; interface <dfn id=imagedata>ImageData</dfn> { readonly attribute unsigned long <a href=#dom-imagedata-width title=dom-imagedata-width>width</a>; readonly attribute unsigned long <a href=#dom-imagedata-height title=dom-imagedata-height>height</a>; readonly attribute <a href=#uint8clampedarray>Uint8ClampedArray</a> <a href=#dom-imagedata-data title=dom-imagedata-data>data</a>; };</pre> <!-- ARC-ORDER note (see above): some demos rely on the precise order of the arc() and arcTo() methods, see https://bugzilla.mozilla.org/show_bug.cgi?id=623437 for an example, and its duplicates for more --> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-canvas><a href=#dom-context-2d-canvas>canvas</a></code></dt> <dd> <p>Returns the <code><a href=#the-canvas-element>canvas</a></code> element.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-canvas title=dom-context-2d-canvas><code>canvas</code></dfn> attribute must return the <code><a href=#the-canvas-element>canvas</a></code> element that the context paints on.</p> <p>Except where otherwise specified, for the 2D context interface, any method call with a numeric argument whose value is infinite or a NaN value must be ignored.</p> <!-- Philip Taylor wrote: > My experience with some 3d canvas code is that infinities come up in > naturally harmless places, e.g. having a function that scales by x then > translates by 1/x and wanting it to work when x=0 (which ought to draw > nothing, since anything it draws is zero pixels wide), and it's a bit > annoying to track down and fix those issues, so I'd probably like it if > they were harmless in canvas methods. Opera appears to silently not draw > anything if the transformation matrix is not finite, but Firefox throws > exceptions when passing in non-finite arguments. --> <p>Whenever the CSS value <code title="">currentColor</code> is used as a color in this API, the "computed value of the 'color' property" for the purposes of determining the computed value of the <code title="">currentColor</code> keyword is the computed value of the 'color' property on the element in question at the time that the color is specified (e.g. when the appropriate attribute is set, or when the method is called; not when the color is rendered or otherwise used). If the computed value of the 'color' property is undefined for a particular case (e.g. because the element is not <a href=#in-a-document>in a <code>Document</code></a>), then the "computed value of the 'color' property" for the purposes of determining the computed value of the <code title="">currentColor</code> keyword is fully opaque black. <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p> <p>In the case of <code title=dom-canvasgradient-addColorStop><a href=#dom-canvasgradient-addcolorstop>addColorStop()</a></code> on <code><a href=#canvasgradient>CanvasGradient</a></code>, the "computed value of the 'color' property" for the purposes of determining the computed value of the <code title="">currentColor</code> keyword is always fully opaque black (there is no associated element). <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p> <p class=note>This is because <code><a href=#canvasgradient>CanvasGradient</a></code> objects are <code><a href=#the-canvas-element>canvas</a></code>-neutral — a <code><a href=#canvasgradient>CanvasGradient</a></code> object created by one <code><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> </div> <h6 id=the-canvas-state><span class=secno>4.8.11.1.1 </span>The canvas state</h6> <p>Each context maintains a stack of drawing states. <dfn id=drawing-state title="drawing state">Drawing states</dfn> consist of:</p> <ul class=brief><li>The current <a href=#transformations title=dom-context-2d-transformation>transformation matrix</a>.</li> <li>The current <a href=#clipping-region>clipping region</a>.</li> <li>The current values of the following attributes: <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code>, <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>, <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>, <code title=dom-context-2d-lineWidth><a href=#dom-context-2d-linewidth>lineWidth</a></code>, <code title=dom-context-2d-lineCap><a href=#dom-context-2d-linecap>lineCap</a></code>, <code title=dom-context-2d-lineJoin><a href=#dom-context-2d-linejoin>lineJoin</a></code>, <code title=dom-context-2d-miterLimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code>, <code title=dom-context-2d-shadowOffsetX><a href=#dom-context-2d-shadowoffsetx>shadowOffsetX</a></code>, <code title=dom-context-2d-shadowOffsetY><a href=#dom-context-2d-shadowoffsety>shadowOffsetY</a></code>, <code title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code>, <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>, <code title=dom-context-2d-globalCompositeOperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code>, <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code>, <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code>, <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code>.</li> </ul><p class=note>The current path and the current bitmap are not part of the drawing state. The current path is persistent, and can only be reset using the <code title=dom-context-2d-beginPath><a href=#dom-context-2d-beginpath>beginPath()</a></code> method. The current bitmap is a property of the canvas, not the context.</p> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-save><a href=#dom-context-2d-save>save</a></code>()</dt> <dd> <p>Pushes the current state onto the stack.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-restore><a href=#dom-context-2d-restore>restore</a></code>()</dt> <dd> <p>Pops the top state on the stack, restoring the context to that state.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-save title=dom-context-2d-save><code>save()</code></dfn> method must push a copy of the current drawing state onto the drawing state stack.</p> <p>The <dfn id=dom-context-2d-restore title=dom-context-2d-restore><code>restore()</code></dfn> method must pop the top entry in the drawing state stack, and reset the drawing state it describes. If there is no saved state, the method must do nothing.</p> <!-- v6 idea from Mihai: > 5. Drawing states should be saveable with IDs, and for easier restoring. > > save(id) > restore(id) > > If id is not provided, then save() works as defined now. The same for > restore(). > > Currently, it's not trivial to save and restore a specific state. ...and from Philip: > I think a more convenient syntax would be: > var state = ctx.save(); > ctx.restore(state); > But how would it interact with normal calls to ctx.restore()? --> </div> <h6 id=transformations><span class=secno>4.8.11.1.2 </span><dfn title=dom-context-2d-transformation>Transformations</dfn></h6> <p>The transformation matrix is applied to coordinates when creating shapes and paths.</p> <!-- conformance criteria for actual drawing are described in the various sections below --> <div class=impl> <p>When the context is created, the transformation matrix must initially be the identity transform. It may then be adjusted using the transformation methods.</p> <p>The transformations must be performed in reverse order. For instance, if a scale transformation that doubles the width is applied, 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> </div> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-scale><a href=#dom-context-2d-scale>scale</a></code>(<var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Changes the transformation matrix to apply a scaling transformation with the given characteristics.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-rotate><a href=#dom-context-2d-rotate>rotate</a></code>(<var title="">angle</var>)</dt> <dd> <p>Changes the transformation matrix to apply a rotation transformation with the given characteristics. The angle is in radians.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-translate><a href=#dom-context-2d-translate>translate</a></code>(<var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Changes the transformation matrix to apply a translation transformation with the given characteristics.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-transform><a href=#dom-context-2d-transform>transform</a></code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt> <dd> <p>Changes the transformation matrix to apply the matrix given by the arguments as described below.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-setTransform><a href=#dom-context-2d-settransform>setTransform</a></code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt> <dd> <p>Changes the transformation matrix <em>to</em> the matrix given by the arguments as described below.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-scale title=dom-context-2d-scale><code>scale(<var title="">x</var>, <var title="">y</var>)</code></dfn> method must add the scaling transformation described by the arguments to the transformation matrix. The <var title="">x</var> argument represents the scale factor in the horizontal direction and the <var title="">y</var> argument represents the scale factor in the vertical direction. The factors are multiples.</p> <p>The <dfn id=dom-context-2d-rotate title=dom-context-2d-rotate><code>rotate(<var title="">angle</var>)</code></dfn> method must add the rotation transformation described by the argument to the transformation matrix. The <var title="">angle</var> argument represents a clockwise rotation angle expressed in radians.</p> <p>The <dfn id=dom-context-2d-translate title=dom-context-2d-translate><code>translate(<var title="">x</var>, <var title="">y</var>)</code></dfn> method must add the translation transformation described by the arguments to the transformation matrix. The <var title="">x</var> argument represents the translation distance in the horizontal direction and the <var title="">y</var> argument represents the translation distance in the vertical direction. The arguments are in coordinate space units.</p> <p>The <dfn id=dom-context-2d-transform title=dom-context-2d-transform><code>transform(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</code></dfn> method must replace the current transformation matrix with the result of multiplying the current transformation matrix with the matrix described by:</p> </div> <table class=matrix><tr><td><var title="">a</var></td> <td><var title="">c</var></td> <td><var title="">e</var></td> <tr><td><var title="">b</var></td> <td><var title="">d</var></td> <td><var title="">f</var></td> <tr><td>0</td> <td>0</td> <td>1</td> </table><p class=note>The arguments <var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, and <var title="">f</var> are sometimes called <var title="">m11</var>, <var title="">m12</var>, <var title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>, and <var title="">dy</var> or <var title="">m11</var>, <var title="">m21</var>, <var title="">m12</var>, <var title="">m22</var>, <var title="">dx</var>, and <var title="">dy</var>. Care should be taken in particular with the order of the second and third arguments (<var title="">b</var> and <var title="">c</var>) as their order varies from API to API and APIs sometimes use the notation <var title="">m12</var>/<var title="">m21</var> and sometimes <var title="">m21</var>/<var title="">m12</var> for those positions.</p> <div class=impl> <p>The <dfn id=dom-context-2d-settransform title=dom-context-2d-setTransform><code>setTransform(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</code></dfn> method must reset the current transform to the identity matrix, and then invoke the <code><a href=#dom-context-2d-transform title=dom-context-2d-transform>transform</a>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</code> method with the same arguments.</p> </div> <h6 id=compositing><span class=secno>4.8.11.1.3 </span>Compositing</h6> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> [ = <var title="">value</var> ]</dt> <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> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-globalCompositeOperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current composition operation, from the list below.</p> <p>Can be set, to change the composition operation. Unknown values are ignored.</p> </dd> </dl><div class=impl> <p>All drawing operations are affected by the global compositing attributes, <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> and <code title=dom-context-2d-globalCompositeOperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code>.</p> <!-- conformance criteria for painting are described in the "drawing model" section below --> <p>The <dfn id=dom-context-2d-globalalpha title=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 canvas. 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, the attribute must retain its previous value. When the context is created, the <code title=dom-context-2d-globalAlpha><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 title=dom-context-2d-globalCompositeOperation><code>globalCompositeOperation</code></dfn> attribute sets how shapes and images are drawn onto the existing bitmap, once they have had <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> and the current transformation matrix applied. It must be set to a value from the following list. In the descriptions below, the source image, <var title="">A</var>, is the shape or image being rendered, and the destination image, <var title="">B</var>, is the current state of the bitmap.</p> </div> <dl><dt><dfn id=gcop-source-atop title=gcop-source-atop><code>source-atop</code></dfn></dt> <dd><var title="">A</var> atop <var title="">B</var>. <span class=note>Display the source image wherever both images are opaque. Display the destination image wherever the destination image is opaque but the source image is transparent. Display transparency elsewhere.</span></dd> <dt><dfn id=gcop-source-in title=gcop-source-in><code>source-in</code></dfn></dt> <dd><var title="">A</var> in <var title="">B</var>. <span class=note>Display the source image wherever both the source image and destination image are opaque. Display transparency elsewhere.</span></dd> <dt><dfn id=gcop-source-out title=gcop-source-out><code>source-out</code></dfn></dt> <dd><var title="">A</var> out <var title="">B</var>. <span class=note>Display the source image wherever the source image is opaque and the destination image is transparent. Display transparency elsewhere.</span></dd> <dt><dfn id=gcop-source-over title=gcop-source-over><code>source-over</code></dfn> (default)</dt> <dd><var title="">A</var> over <var title="">B</var>. <span class=note>Display the source image wherever the source image is opaque. Display the destination image elsewhere.</span></dd> <dt><dfn id=gcop-destination-atop title=gcop-destination-atop><code>destination-atop</code></dfn></dt> <dd><var title="">B</var> atop <var title="">A</var>. <span class=note>Same as <code title=gcop-source-atop><a href=#gcop-source-atop>source-atop</a></code> but using the destination image instead of the source image and vice versa.</span></dd> <dt><dfn id=gcop-destination-in title=gcop-destination-in><code>destination-in</code></dfn></dt> <dd><var title="">B</var> in <var title="">A</var>. <span class=note>Same as <code title=gcop-source-in><a href=#gcop-source-in>source-in</a></code> but using the destination image instead of the source image and vice versa.</span></dd> <dt><dfn id=gcop-destination-out title=gcop-destination-out><code>destination-out</code></dfn></dt> <dd><var title="">B</var> out <var title="">A</var>. <span class=note>Same as <code title=gcop-source-out><a href=#gcop-source-out>source-out</a></code> but using the destination image instead of the source image and vice versa.</span></dd> <dt><dfn id=gcop-destination-over title=gcop-destination-over><code>destination-over</code></dfn></dt> <dd><var title="">B</var> over <var title="">A</var>. <span class=note>Same as <code title=gcop-source-over><a href=#gcop-source-over>source-over</a></code> but using the destination image instead of the source image and vice versa.</span></dd> <!-- no clear definition of this operator (doesn't correspond to a PorterDuff operator) <dt><dfn title="gcop-darker"><code>darker</code></dfn></dt> <dd><span class="note">Display the sum of the source image and destination image, with color values approaching 0 as a limit.</span></dd> --> <dt><dfn id=gcop-lighter title=gcop-lighter><code>lighter</code></dfn></dt> <dd><var title="">A</var> plus <var title="">B</var>. <span class=note>Display the sum of the source image and destination image, with color values approaching 255 (100%) as a limit.</span></dd> <dt><dfn id=gcop-copy title=gcop-copy><code>copy</code></dfn></dt> <dd><var title="">A</var> (<var title="">B</var> is ignored). <span class=note>Display the source image instead of the destination image.</span></dd> <dt><dfn id=gcop-xor title=gcop-xor><code>xor</code></dfn></dt> <dd><var title="">A</var> xor <var title="">B</var>. <span class=note>Exclusive OR of the source image and destination image.</span></dd> <dt class=impl><code><var title="">vendorName</var>-<var title="">operationName</var></code></dt> <dd class=impl>Vendor-specific extensions to the list of composition operators should use this syntax.</dd> </dl><div class=impl> <p>The operators in the above list must be treated as described by the Porter-Duff operator given at the start of their description (e.g. <var title="">A</var> over <var title="">B</var>). They are to be applied as part of the <a href=#drawing-model>drawing model</a>, at which point the <a href=#clipping-region>clipping region</a> is also applied. (Without a clipping region, these operators act on the whole bitmap with every operation.) <a href=#refsPORTERDUFF>[PORTERDUFF]</a></p> <p>These values are all case-sensitive — they must be used exactly as shown. User agents must not recognize values that are not a <a href=#case-sensitive>case-sensitive</a> match for one of the values given above.</p> <p>On setting, if the user agent does not recognize the specified value, it must be ignored, leaving the value of <code title=dom-context-2d-globalCompositeOperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> unaffected.</p> <p>When the context is created, the <code title=dom-context-2d-globalCompositeOperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> attribute must initially have the value <code>source-over</code>.</p> </div> <h6 id=colors-and-styles><span class=secno>4.8.11.1.4 </span>Colors and styles</h6> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> [ = <var title="">value</var> ]</dt> <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><a href=#canvasgradient>CanvasGradient</a></code> or <code><a href=#canvaspattern>CanvasPattern</a></code> object. Invalid values are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> [ = <var title="">value</var> ]</dt> <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><a href=#canvasgradient>CanvasGradient</a></code> or <code><a href=#canvaspattern>CanvasPattern</a></code> object. Invalid values are ignored.</p> </dd> </dl><div class=impl> <!-- v6 feature requests: * Getting and setting colours by component to bypass the CSS value parsing. Either: context.fillStyle.red += 1; Or: var array = context.fillStyle; array[1] += 1; context.fillStyle = array; * A more performant way of setting colours in general, e.g.: context.setFillColor(r,g,b,a) // already supported by webkit Or: context.fillStyle = 0xRRGGBBAA; // set a 32bit int directly * fill rule for deciding between winding and even-odd algorithms. SVG has fill-rule: nonzero | evenodd http://www.w3.org/TR/SVG/painting.html#FillProperties --> <p>The <dfn id=dom-context-2d-strokestyle title=dom-context-2d-strokeStyle><code>strokeStyle</code></dfn> attribute represents the color or style to use for the lines around shapes, and the <dfn id=dom-context-2d-fillstyle title=dom-context-2d-fillStyle><code>fillStyle</code></dfn> attribute represents the color or style to use inside the shapes.</p> <p>Both attributes can be either strings, <code><a href=#canvasgradient>CanvasGradient</a></code>s, or <code><a href=#canvaspattern>CanvasPattern</a></code>s. On setting, strings must be <a href=#parsed-as-a-css-color-value title="parsed as a CSS <color> value">parsed as CSS <color> values</a> and the color assigned, and <code><a href=#canvasgradient>CanvasGradient</a></code> and <code><a href=#canvaspattern>CanvasPattern</a></code> objects must be assigned themselves. <a href=#refsCSSCOLOR>[CSSCOLOR]</a> If the value is a string but cannot be <a href=#parsed-as-a-css-color-value>parsed as a CSS <color> value</a>, or is neither a string, a <code><a href=#canvasgradient>CanvasGradient</a></code>, nor a <code><a href=#canvaspattern>CanvasPattern</a></code>, then it must be ignored, and the attribute must retain its previous value.</p> <p>When set to a <code><a href=#canvaspattern>CanvasPattern</a></code> or <code><a href=#canvasgradient>CanvasGradient</a></code> object, the assignment is <a href=#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=#serialization-of-a-color title="serialization of a color">serialization of the color</a> must be returned. Otherwise, if it is not a color but a <code><a href=#canvasgradient>CanvasGradient</a></code> or <code><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=serialization-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 in the range 0-9 a-f (U+0030 to U+0039 and U+0061 to U+0066). Otherwise, the color value has alpha less than 1.0, and the string is the color value in the CSS <code title="">rgba()</code> functional-notation format: the literal string <code title="">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 digits 0-9, U+0030 to U+0039, 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 digits in the range 0-9 (U+0030 to U+0039) representing the fractional part of the alpha<!-- value with no trailing zeros (implied by next sentence)-->, 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> <!-- if people complain this is unreadable, expand it into a <dl> with two nested <ol>s --> <p>When the context is created, the <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> and <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> attributes must initially have the string value <code title="">#000000</code>.</p> <p>When the value is a color, it must not be affected by the transformation matrix when used to draw on the canvas.</p> <!-- so singular matrices don't affect solid color fillStyles --> </div> <hr><p>There are two types of gradients, linear gradients and radial gradients, both represented by objects implementing the opaque <code><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. <span class=impl>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 transparent black.</span></p> <dl class=domintro><dt><var title="">gradient</var> . <code title=dom-canvasgradient-addColorStop><a href=#dom-canvasgradient-addcolorstop>addColorStop</a></code>(<var title="">offset</var>, <var title="">color</var>)</dt> <dd> <p>Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception if the offset is out of range. Throws a <code><a href=#syntaxerror>SyntaxError</a></code> exception if the color cannot be parsed.</p> </dd> <dt><var title="">gradient</var> = <var title="">context</var> . <code title=dom-context-2d-createLinearGradient><a href=#dom-context-2d-createlineargradient>createLinearGradient</a></code>(<var title="">x0</var>, <var title="">y0</var>, <var title="">x1</var>, <var title="">y1</var>)</dt> <dd> <p>Returns a <code><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> <p>If any of the arguments are not finite numbers, throws a <code><a href=#notsupportederror>NotSupportedError</a></code> exception.</p> </dd> <dt><var title="">gradient</var> = <var title="">context</var> . <code title=dom-context-2d-createRadialGradient><a href=#dom-context-2d-createradialgradient>createRadialGradient</a></code>(<var title="">x0</var>, <var title="">y0</var>, <var title="">r0</var>, <var title="">x1</var>, <var title="">y1</var>, <var title="">r1</var>)</dt> <dd> <p>Returns a <code><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 any of the arguments are not finite numbers, throws a <code><a href=#notsupportederror>NotSupportedError</a></code> exception. If either of the radii are negative, throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-canvasgradient-addcolorstop title=dom-canvasgradient-addColorStop><code>addColorStop(<var title="">offset</var>, <var title="">color</var>)</code></dfn> method on the <code><a href=#canvasgradient>CanvasGradient</a></code> interface adds a new stop to a gradient. If the <var title="">offset</var> is less than 0, greater than 1, infinite, or NaN, then an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception must be raised. If the <var title="">color</var> cannot be <a href=#parsed-as-a-css-color-value>parsed as a CSS <color> value</a>, then a <code><a href=#syntaxerror>SyntaxError</a></code> exception must be raised. Otherwise, the gradient must have a new stop placed, at offset <var title="">offset</var> relative to the whole gradient, and with the color obtained by parsing <var title="">color</var> as a CSS <color> value. If multiple stops are added at the same offset on a gradient, 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> <p>The <dfn id=dom-context-2d-createlineargradient title=dom-context-2d-createLinearGradient><code>createLinearGradient(<var title="">x0</var>, <var title="">y0</var>, <var title="">x1</var>, <var title="">y1</var>)</code></dfn> method takes four arguments that represent the start point (<var title="">x0</var>, <var title="">y0</var>) and end point (<var title="">x1</var>, <var title="">y1</var>) of the gradient. If any of the arguments to <code title=dom-context-2d-createLinearGradient><a href=#dom-context-2d-createlineargradient>createLinearGradient()</a></code> are infinite or NaN, the method must throw a <code><a href=#notsupportederror>NotSupportedError</a></code> exception. Otherwise, the method must return a linear <code><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 title=dom-context-2d-transformation>current transformation matrix</a> when rendering.</p> <p>If <span title=""><var title="">x0</var> = <var title="">x1</var></span> and <span title=""><var title="">y0</var> = <var title="">y1</var></span>, then the linear gradient must paint nothing.</p> <p>The <dfn id=dom-context-2d-createradialgradient title=dom-context-2d-createRadialGradient><code>createRadialGradient(<var title="">x0</var>, <var title="">y0</var>, <var title="">r0</var>, <var title="">x1</var>, <var title="">y1</var>, <var title="">r1</var>)</code></dfn> method takes six arguments, the first three representing the start circle with origin (<var title="">x0</var>, <var title="">y0</var>) and radius <var title="">r0</var>, and the last three representing the end circle with origin (<var title="">x1</var>, <var title="">y1</var>) and radius <var title="">r1</var>. The values are in coordinate space units. If any of the arguments are infinite or NaN, a <code><a href=#notsupportederror>NotSupportedError</a></code> exception must be raised. If either of <var title="">r0</var> or <var title="">r1</var> are negative, an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception must be raised. Otherwise, the method must return a radial <code><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 <span title=""><var title="">x<sub>0</sub></var> = <var title="">x<sub>1</sub></var></span> and <span title=""><var title="">y<sub>0</sub></var> = <var title="">y<sub>1</sub></var></span> and <span title=""><var title="">r<sub>0</sub></var> = <var title="">r<sub>1</sub></var></span>, then the radial gradient must paint nothing. Abort these steps.</li> <li> <p>Let <span title="">x(<var title="">ω</var>) = (<var title="">x<sub>1</sub></var>-<var title="">x<sub>0</sub></var>)<var title="">ω</var> + <var title="">x<sub>0</sub></var></span></p> <p>Let <span title="">y(<var title="">ω</var>) = (<var title="">y<sub>1</sub></var>-<var title="">y<sub>0</sub></var>)<var title="">ω</var> + <var title="">y<sub>0</sub></var></span></p> <p>Let <span title="">r(<var title="">ω</var>) = (<var title="">r<sub>1</sub></var>-<var title="">r<sub>0</sub></var>)<var title="">ω</var> + <var title="">r<sub>0</sub></var></span></p> <p>Let the color at <var title="">ω</var> be the color at that position on the gradient (with the colors coming from the <a href=#interpolation>interpolation and extrapolation</a> described above).</p> </li> <li><p>For all values of <var title="">ω</var> where <span title="">r(<var title="">ω</var>) > 0</span>, starting with the value of <var title="">ω</var> nearest to positive infinity and ending with the value of <var title="">ω</var> nearest to negative infinity, draw the circumference of the circle with radius <span title="">r(<var title="">ω</var>)</span> at position (<span title="">x(<var title="">ω</var>)</span>, <span title="">y(<var title="">ω</var>)</span>), with the color at <var title="">ω</var>, but only painting on the parts of the canvas that have not yet been painted on by earlier circles in this step for this rendering of the gradient.</li> </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 (transparent black).</p> <p>The resulting radial gradient must then be transformed as described by the <a href=#transformations title=dom-context-2d-transformation>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> </div> <hr><p>Patterns are represented by objects implementing the opaque <code><a href=#canvaspattern>CanvasPattern</a></code> interface.</p> <dl class=domintro><dt><var title="">pattern</var> = <var title="">context</var> . <code title=dom-context-2d-createPattern><a href=#dom-context-2d-createpattern>createPattern</a></code>(<var title="">image</var>, <var title="">repetition</var>)</dt> <dd> <p>Returns a <code><a href=#canvaspattern>CanvasPattern</a></code> object that uses the given image and repeats in the direction(s) given by the <var title="">repetition</var> argument.</p> <p>The allowed values for <var title="">repetition</var> are <code title="">repeat</code> (both directions), <code title="">repeat-x</code> (horizontal only), <code title="">repeat-y</code> (vertical only), and <code title="">no-repeat</code> (neither). If the <var title="">repetition</var> argument is empty, the value <code title="">repeat</code> is used.</p> <p>If the image has no image data, throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. If the second argument isn't one of the allowed values, throws a <code><a href=#syntaxerror>SyntaxError</a></code> exception. If the image isn't yet fully decoded, then the method returns null.</p> </dd> </dl><div class=impl> <p>To create objects of this type, the <dfn id=dom-context-2d-createpattern title=dom-context-2d-createPattern><code>createPattern(<var title="">image</var>, <var title="">repetition</var>)</code></dfn> method is used. The first argument gives the image to use as the pattern (either an <code><a href=#htmlimageelement>HTMLImageElement</a></code>, <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code>, or <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> object). Modifying this image after calling the <code title=dom-context-2d-createPattern><a href=#dom-context-2d-createpattern>createPattern()</a></code> method must not affect the pattern. The second argument must be a string with one of the following values: <code title="">repeat</code>, <code title="">repeat-x</code>, <code title="">repeat-y</code>, <code title="">no-repeat</code>. If the empty string is specified, <code title="">repeat</code> must be assumed. If an unrecognized value is given, then the user agent must throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception. User agents must recognize the four values described above exactly (e.g. they must not do case folding). Except as specified below, the method must return a <code><a href=#canvaspattern>CanvasPattern</a></code> object suitably initialized.</p> <p>The <var title="">image</var> argument is an instance of either <code><a href=#htmlimageelement>HTMLImageElement</a></code>, <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code>, or <code><a href=#htmlvideoelement>HTMLVideoElement</a></code>.</p> <!-- drawImage() has an equivalent paragraph --> <p>If the <var title="">image</var> argument is an <code><a href=#htmlimageelement>HTMLImageElement</a></code> object that is not <a href=#img-good title=img-good>fully decodable</a>, or if the <var title="">image</var> argument is an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> object whose <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is either <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code> or <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code>, then the implementation must return null.</p> <!-- drawImage() has an equivalent paragraph --> <p>If the <var title="">image</var> argument is an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> object with either a horizontal dimension or a vertical dimension equal to zero, then the implementation must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</p> <!-- drawImage() has an equivalent paragraph --> <p>Patterns must be painted so that the top left of the first image is anchored at the origin of the coordinate space, and images are then repeated horizontally to the left and right, if the <code>repeat-x</code> string was specified, or vertically up and down, if the <code>repeat-y</code> string was specified, or in all four directions all over the canvas, if the <code>repeat</code> string was specified, to create the repeated pattern that is used for rendering. The images are not scaled by this process; one CSS pixel of the image must be painted on one coordinate space unit in generating the repeated pattern. When rendered, however, patterns must actually be painted only where the stroking or filling effect requires that they be drawn, and the repeated pattern must be affected by the current transformation matrix. Pixels not covered by the repeating pattern (if the <code>repeat</code> string was not specified) must be transparent black.</p> <p>If the original image data is a bitmap image, the value painted at a point in the area of the repetitions 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 wrapping the pixel's coordinates to the original image's dimensions. (That is, the filter uses 'repeat' behavior, regardless of the value of <var title="">repetition</var>.) <!-- drawImage() has a similar paragraph with different rules --> <p>When the <code title=dom-context-2d-createPattern><a href=#dom-context-2d-createpattern>createPattern()</a></code> method is passed an animated image as its <var title="">image</var> argument, the user agent must use the poster frame of the animation, or, if there is no poster frame, the first frame of the animation.</p> <!-- drawImage() has an equivalent paragraph --> <p>When the <var title="">image</var> argument is an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code>, then the frame at the <a href=#current-playback-position>current playback position</a> must be used as the source image, and the source image's dimensions must be the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</a> and <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</a> of the <a href=#media-resource>media resource</a> (i.e. after any aspect-ratio correction has been applied).</p> <!-- drawImage() has an equivalent paragraph --> <!-- Requests for v6 features: * apply transforms to patterns, so you don't have to create transformed patterns manually by rendering them to an off-screen canvas then using that canvas as the pattern. --> </div> <div class=impl> <hr><p>If a radial gradient or repeated pattern is used when the transformation matrix is singular, the resulting style must be transparent black (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 tranformation matrices.</p> </div> <h6 id=line-styles><span class=secno>4.8.11.1.5 </span>Line styles</h6> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-lineWidth><a href=#dom-context-2d-linewidth>lineWidth</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current line width.</p> <p>Can be set, to change the line width. Values that are not finite values greater than zero are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-lineCap><a href=#dom-context-2d-linecap>lineCap</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current line cap style.</p> <p>Can be set, to change the line cap style.</p> <p>The possible line cap styles are <code>butt</code>, <code>round</code>, and <code>square</code>. Other values are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-lineJoin><a href=#dom-context-2d-linejoin>lineJoin</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current line join style.</p> <p>Can be set, to change the line join style.</p> <p>The possible line join styles are <code>bevel</code>, <code>round</code>, and <code>miter</code>. Other values are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-miterLimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current miter limit ratio.</p> <p>Can be set, to change the miter limit ratio. Values that are not finite values greater than zero are ignored.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-linewidth title=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 context is created, the <code title=dom-context-2d-lineWidth><a href=#dom-context-2d-linewidth>lineWidth</a></code> attribute must initially have the value <code>1.0</code>.</p> <hr><p>The <dfn id=dom-context-2d-linecap title=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>. The <code>butt</code> value means that the end of each line has a flat edge perpendicular to the direction of the line (and that no additional line cap is added). The <code>round</code> value means that a semi-circle with the diameter equal to the width of the line must then be added on to the end of the line. The <code>square</code> value means that a rectangle with the length of the line width and the width of half the line width, placed flat against the edge perpendicular to the direction of the line, must be added at the end of each line.</p> <p>On getting, it must return the current value. On setting, if the new value is one of the literal strings <code>butt</code>, <code>round</code>, and <code>square</code>, then the current value must be changed to the new value; other values must ignored, leaving the value unchanged.</p> <p>When the context is created, the <code title=dom-context-2d-lineCap><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 title=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, if the new value is one of the literal strings <code>bevel</code>, <code>round</code>, and <code>miter</code>, then the current value must be changed to the new value; other values must be ignored, leaving the value unchanged.</p> <p>When the context is created, the <code title=dom-context-2d-lineJoin><a href=#dom-context-2d-linejoin>lineJoin</a></code> attribute must initially have the value <code>miter</code>.</p> <hr><p>A join exists at any point in a subpath shared by two consecutive lines. When a subpath is closed, then a join also exists at its first point (equivalent to its last point) connecting the first and last lines in the subpath.</p> <p>In addition to the point where the 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 filled triangle connecting these two opposite corners with a straight line, with the third point of the triangle being the join point, must be rendered at all joins. The <code title=dom-context-2d-lineJoin><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 a filled 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 rendered at joins.</p> <p>The <code>miter</code> value means that a second filled triangle must (if it can given the miter length) be rendered 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 to be exceeded, this second triangle must not be rendered.</p> <p>The miter limit ratio can be explicitly set using the <dfn id=dom-context-2d-miterlimit title=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 context is created, the <code title=dom-context-2d-miterLimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code> attribute must initially have the value <code>10.0</code>.</p> <!-- v6: dashed lines have been requested. Philip Taylor provides these notes on what would need to be defined for dashed lines: > I don't think it's entirely trivial to add, to the detail that's > necessary in a specification. The common graphics APIs (at least > Cairo, Quartz and java.awt.Graphics, and any SVG implementation) all > have dashes specified by passing an array of dash lengths (alternating > on/off), so that should be alright as long as you define what units > it's measured in and what happens when you specify an odd number of > values and how errors are handled and what happens if you update the > array later. But after that, what does it do when stroking multiple > subpaths, in terms of offsetting the dashes? When you use strokeRect, > where is offset 0? Does moveTo reset the offset? How does it interact > with lineCap/lineJoin? All the potential issues need test cases too, > and the implementations need to make sure they handle any edge cases > that the underlying graphics library does differently. (SVG Tiny 1.2 > appears to skip some of the problems by leaving things undefined and > allowing whatever behavior the graphics library has.) Another request has been for hairline width lines, that remain hairline width with transform. ack Shaun Morris. --> </div> <h6 id=shadows><span class=secno>4.8.11.1.6 </span><dfn>Shadows</dfn></h6> <p>All drawing operations are affected by the four global shadow attributes.</p> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current shadow color.</p> <p>Can be set, to change the shadow color. Values that cannot be parsed as CSS colors are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-shadowOffsetX><a href=#dom-context-2d-shadowoffsetx>shadowOffsetX</a></code> [ = <var title="">value</var> ]</dt> <dt><var title="">context</var> . <code title=dom-context-2d-shadowOffsetY><a href=#dom-context-2d-shadowoffsety>shadowOffsetY</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current shadow offset.</p> <p>Can be set, to change the shadow offset. Values that are not finite numbers are ignored.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current level of blur applied to shadows.</p> <p>Can be set, to change the blur level. Values that are not finite numbers greater than or equal to zero are ignored.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-shadowcolor title=dom-context-2d-shadowColor><code>shadowColor</code></dfn> attribute sets the color of the shadow.</p> <p>When the context is created, the <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code> attribute initially must be fully-transparent black.</p> <p>On getting, the <a href=#serialization-of-a-color title="serialization 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>parsed as a CSS <color> value</a> and the color assigned. If the value cannot be parsed as a CSS <color> value 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 title=dom-context-2d-shadowOffsetX><code>shadowOffsetX</code></dfn> and <dfn id=dom-context-2d-shadowoffsety title=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 <code>0</code>.</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 title=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 title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code> attribute must initially have the value <code>0</code>.</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 title="when shadows are drawn">Shadows are only drawn if</dfn> the opacity component of the alpha component of the color of <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code> is non-zero and either the <code title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code> is non-zero, or the <code title=dom-context-2d-shadowOffsetX><a href=#dom-context-2d-shadowoffsetx>shadowOffsetX</a></code> is non-zero, or the <code title=dom-context-2d-shadowOffsetY><a href=#dom-context-2d-shadowoffsety>shadowOffsetY</a></code> is non-zero.</p> <p class=critical>It is likely that this will change: browser vendors have indicated an interest in changing the processing model for shadows such that they only draw when the composition operator is "source-over" (the default). <a href=http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/thread.html#31457>Read more...</a></p> <p><a href=#when-shadows-are-drawn>When shadows are drawn</a>, they must be rendered as follows:</p> <ol><li> <p>Let <var title="">A</var> be an infinite transparent black bitmap on which the source image for which a shadow is being created has been rendered.</p> </li> <li> <p>Let <var title="">B</var> be an infinite transparent black bitmap, with a coordinate space and an origin identical to <var title="">A</var>.</p> </li> <li> <p>Copy the alpha channel of <var title="">A</var> to <var title="">B</var>, offset by <code title=dom-context-2d-shadowOffsetX><a href=#dom-context-2d-shadowoffsetx>shadowOffsetX</a></code> in the positive <var title="">x</var> direction, and <code title=dom-context-2d-shadowOffsetY><a href=#dom-context-2d-shadowoffsety>shadowOffsetY</a></code> in the positive <var title="">y</var> direction.</p> </li> <li> <p>If <code title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code> is greater than 0:</p> <ol><li> <p>Let <var title="">σ</var> be half the value of <code title=dom-context-2d-shadowBlur><a href=#dom-context-2d-shadowblur>shadowBlur</a></code>.</li> <li> <p>Perform a 2D Gaussian Blur on <var title="">B</var>, using <var title="">σ</var> as the standard deviation.</p> <!-- wish i could find a reference for this --> </li> </ol><p>User agents may limit values of <var title="">σ</var> to an implementation-specific maximum value to avoid exceeding hardware limitations during the Gaussian blur operation.</p> </li> <li> <p>Set the red, green, and blue components of every pixel in <var title="">B</var> to the red, green, and blue components (respectively) of the color of <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>.</p> </li> <li> <p>Multiply the alpha component of every pixel in <var title="">B</var> by the alpha component of the color of <code title=dom-context-2d-shadowColor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>.</p> </li> <li> <p>The shadow is in the bitmap <var title="">B</var>, and is rendered as part of the <a href=#drawing-model>drawing model</a> described below.</p> </li> </ol></div> <p>If the current composition operation is <code title=gcop-copy><a href=#gcop-copy>copy</a></code>, shadows effectively won't render (since the shape will overwrite the shadow).</p> <h6 id=simple-shapes-(rectangles)><span class=secno>4.8.11.1.7 </span>Simple shapes (rectangles)</h6> <p>There are three methods that immediately draw rectangles to the bitmap. They each take four arguments; the first two give the <var title="">x</var> and <var title="">y</var> coordinates of the top left of the rectangle, and the second two give the width <var title="">w</var> and height <var title="">h</var> of the rectangle, respectively.</p> <div class=impl> <p>The <a href=#transformations title=dom-context-2d-transformation>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 title="">(<var title="">x</var>, <var title="">y</var>)</span>, <span title="">(<span title=""><var title="">x</var>+<var title="">w</var></span>, <var title="">y</var>)</span>, <span title="">(<span title=""><var title="">x</var>+<var title="">w</var></span>, <span title=""><var title="">y</var>+<var title="">h</var></span>)</span>, <span title="">(<var title="">x</var>, <span title=""><var title="">y</var>+<var title="">h</var></span>)</span>.</p> <p>Shapes are painted without affecting the current path, and are subject to the <a href=#clipping-region title="clipping region">clipping region</a>, and, with the exception of <code title=dom-context-2d-clearRect><a href=#dom-context-2d-clearrect>clearRect()</a></code>, also <a href=#shadows title=shadows>shadow effects</a>, <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, and <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>.</p> </div> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-clearRect><a href=#dom-context-2d-clearrect>clearRect</a></code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt> <dd> <p>Clears all pixels on the canvas in the given rectangle to transparent black.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-fillRect><a href=#dom-context-2d-fillrect>fillRect</a></code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt> <dd> <p>Paints the given rectangle onto the canvas, using the current fill style.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-strokeRect><a href=#dom-context-2d-strokerect>strokeRect</a></code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt> <dd> <p>Paints the box that outlines the given rectangle onto the canvas, using the current stroke style.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-clearrect title=dom-context-2d-clearRect><code>clearRect(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</code></dfn> method must clear the pixels in the specified rectangle that also intersect the current clipping region to a fully transparent black, erasing any previous image. If either height or width are zero, this method has no effect.</p> <p>The <dfn id=dom-context-2d-fillrect title=dom-context-2d-fillRect><code>fillRect(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</code></dfn> method must paint the specified rectangular area using the <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>. If either height or width are zero, this method has no effect.</p> <p>The <dfn id=dom-context-2d-strokerect title=dom-context-2d-strokeRect><code>strokeRect(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</code></dfn> method must stroke the specified rectangle's path using the <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code>, <code title=dom-context-2d-lineWidth><a href=#dom-context-2d-linewidth>lineWidth</a></code>, <code title=dom-context-2d-lineJoin><a href=#dom-context-2d-linejoin>lineJoin</a></code>, and (if appropriate) <code title=dom-context-2d-miterLimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code> attributes. If both height and width are zero, this method has no effect, since there is no path to stroke (it's a point). If only one of the two is zero, then the method will draw a line instead (the path for the outline is just a straight line along the non-zero dimension).</p> </div> <h6 id=complex-shapes-(paths)><span class=secno>4.8.11.1.8 </span>Complex shapes (paths)</h6> <p>The context always has a current path. There is only one current path, it is not part of the <a href=#drawing-state>drawing state</a>.</p> <p>A <dfn id=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 lines, 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 fewer than two points are ignored when painting the path.</p> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-beginPath><a href=#dom-context-2d-beginpath>beginPath</a></code>()</dt> <dd> <p>Resets the current path.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-moveTo><a href=#dom-context-2d-moveto>moveTo</a></code>(<var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Creates a new subpath with the given point.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-closePath><a href=#dom-context-2d-closepath>closePath</a></code>()</dt> <dd> <p>Marks the current subpath as closed, and starts a new subpath with a point the same as the start and end of the newly closed subpath.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-lineTo><a href=#dom-context-2d-lineto>lineTo</a></code>(<var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Adds the given point to the current subpath, connected to the previous one by a straight line.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-quadraticCurveTo><a href=#dom-context-2d-quadraticcurveto>quadraticCurveTo</a></code>(<var title="">cpx</var>, <var title="">cpy</var>, <var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Adds the given point to the current subpath, connected to the previous one by a quadratic Bézier curve with the given control point.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-bezierCurveTo><a href=#dom-context-2d-beziercurveto>bezierCurveTo</a></code>(<var title="">cp1x</var>, <var title="">cp1y</var>, <var title="">cp2x</var>, <var title="">cp2y</var>, <var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Adds the given point to the current subpath, connected to the previous one by a cubic Bézier curve with the given control points.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-arcTo><a href=#dom-context-2d-arcto>arcTo</a></code>(<var title="">x1</var>, <var title="">y1</var>, <var title="">x2</var>, <var title="">y2</var>, <var title="">radius</var>)</dt> <dd> <p>Adds an arc with the given control points and radius to the current subpath, connected to the previous point by a straight line.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception if the given radius is negative.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-arc><a href=#dom-context-2d-arc>arc</a></code>(<var title="">x</var>, <var title="">y</var>, <var title="">radius</var>, <var title="">startAngle</var>, <var title="">endAngle</var> [, <var title="">anticlockwise</var> ] )</dt> <dd> <p>Adds points to the subpath such that the arc described by the circumference of the circle described by the arguments, starting at the given start angle and ending at the given end angle, going in the given direction (defaulting to clockwise), is added to the path, connected to the previous point by a straight line.</p> <p>Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception if the given radius is negative.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-rect><a href=#dom-context-2d-rect>rect</a></code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt> <dd> <p>Adds a new closed subpath to the path, representing the given rectangle.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-fill><a href=#dom-context-2d-fill>fill</a></code>()</dt> <dd> <p>Fills the subpaths with the current fill style.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-stroke><a href=#dom-context-2d-stroke>stroke</a></code>()</dt> <dd> <p>Strokes the subpaths with the current stroke style.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-drawSystemFocusRing><a href=#dom-context-2d-drawsystemfocusring>drawSystemFocusRing</a></code>(<var title="">element</var>)</dt> <dd> <p>If the given element is focused, draws a focus ring around the current path, following the platform conventions for focus rings.</p> </dd> <dt><var title="">shouldDraw</var> = <var title="">context</var> . <code title=dom-context-2d-drawCustomFocusRing><a href=#dom-context-2d-drawcustomfocusring>drawCustomFocusRing</a></code>(<var title="">element</var>)</dt> <dd> <p>If the given element is focused, and the user has configured his system to draw focus rings in a particular manner (for example, high contrast focus rings), draws a focus ring around the current path and returns false.</p> <p>Otherwise, returns true if the given element is focused, and false otherwise. This can thus be used to determine when to draw a focus ring (see <a href=#drawCustomFocusRingExample>the example</a> below).</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-scrollPathIntoView><a href=#dom-context-2d-scrollpathintoview>scrollPathIntoView</a></code>()</dt> <dd> <p>Scrolls the current path into view. This is especially useful on devices with small screens, where the whole canvas might not be visible at once.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-clip><a href=#dom-context-2d-clip>clip</a></code>()</dt> <dd> <p>Further constrains the clipping region to the given path.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-isPointInPath><a href=#dom-context-2d-ispointinpath>isPointInPath</a></code>(<var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Returns true if the given point is in the current path.</p> </dd> </dl><div class=impl> <p>Initially, the context's path must have zero subpaths.</p> <p>The points and lines added to the path by these methods must be transformed according to the <a href=#transformations title=dom-context-2d-transformation>current transformation matrix</a> as they are added.</p> <p>The <dfn id=dom-context-2d-beginpath title=dom-context-2d-beginPath><code>beginPath()</code></dfn> method must empty the list of subpaths so that the context once again has zero subpaths.</p> <p>The <dfn id=dom-context-2d-moveto title=dom-context-2d-moveTo><code>moveTo(<var title="">x</var>, <var title="">y</var>)</code></dfn> method must create a new subpath with the specified point as its first (and only) point.</p> <p>When the user agent is to <dfn id=ensure-there-is-a-subpath>ensure there is a subpath</dfn> for a coordinate (<var title="">x</var>, <var title="">y</var>), the user agent must check to see if the context has any subpaths, and if it does not, then the user agent must create a new subpath with the point (<var title="">x</var>, <var title="">y</var>) as its first (and only) point, as if the <code title=dom-context-2d-moveTo><a href=#dom-context-2d-moveto>moveTo()</a></code> method had been called.</p> <p>The <dfn id=dom-context-2d-closepath title=dom-context-2d-closePath><code>closePath()</code></dfn> method must do nothing if the context 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, thus "closing" the shape, and then repeating the last (possibly implied) <code title=dom-context-2d-moveTo><a href=#dom-context-2d-moveto>moveTo()</a></code> call.</p> <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 context's paths.</p> <p>The <dfn id=dom-context-2d-lineto title=dom-context-2d-lineTo><code>lineTo(<var title="">x</var>, <var title="">y</var>)</code></dfn> method must <a href=#ensure-there-is-a-subpath>ensure there is a subpath</a> for <span title="">(<var title="">x</var>, <var title="">y</var>)</span> if the context has no subpaths. Otherwise, it must connect the last point in the subpath to the given point (<var title="">x</var>, <var title="">y</var>) using a straight line, and must then add the given point (<var title="">x</var>, <var title="">y</var>) to the subpath.</p> <p>The <dfn id=dom-context-2d-quadraticcurveto title=dom-context-2d-quadraticCurveTo><code>quadraticCurveTo(<var title="">cpx</var>, <var title="">cpy</var>, <var title="">x</var>, <var title="">y</var>)</code></dfn> method must <a href=#ensure-there-is-a-subpath>ensure there is a subpath</a> for <span title="">(<var title="">cpx</var>, <var title="">cpy</var>)</span>, and then must connect the last point in the subpath to the given point (<var title="">x</var>, <var title="">y</var>) using a quadratic Bézier curve with control point (<var title="">cpx</var>, <var title="">cpy</var>), and must then add the given point (<var title="">x</var>, <var title="">y</var>) to the subpath. <a href=#refsBEZIER>[BEZIER]</a></p> <p>The <dfn id=dom-context-2d-beziercurveto title=dom-context-2d-bezierCurveTo><code>bezierCurveTo(<var title="">cp1x</var>, <var title="">cp1y</var>, <var title="">cp2x</var>, <var title="">cp2y</var>, <var title="">x</var>, <var title="">y</var>)</code></dfn> method must <a href=#ensure-there-is-a-subpath>ensure there is a subpath</a> for <span title="">(<var title="">cp1x</var>, <var title="">cp1y</var>)</span>, and then must connect the last point in the subpath to the given point (<var title="">x</var>, <var title="">y</var>) using a cubic Bézier curve with control points (<var title="">cp1x</var>, <var title="">cp1y</var>) and (<var title="">cp2x</var>, <var title="">cp2y</var>). Then, it must add the point (<var title="">x</var>, <var title="">y</var>) to the subpath. <a href=#refsBEZIER>[BEZIER]</a></p> <hr><p>The <dfn id=dom-context-2d-arcto title=dom-context-2d-arcTo><code>arcTo(<var title="">x1</var>, <var title="">y1</var>, <var title="">x2</var>, <var title="">y2</var>, <var title="">radius</var>)</code></dfn> method must first <a href=#ensure-there-is-a-subpath>ensure there is a subpath</a> for <span title="">(<var title="">x1</var>, <var title="">y1</var>)</span>. Then, the behavior depends on the arguments and the last point in the subpath, as described below.</p> <p>Negative values for <var title="">radius</var> must cause the implementation to throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <p>Let the point (<var title="">x0</var>, <var title="">y0</var>) be the last point in the subpath.</p> <p>If the point (<var title="">x0</var>, <var title="">y0</var>) is equal to the point (<var title="">x1</var>, <var title="">y1</var>), or if the point (<var title="">x1</var>, <var title="">y1</var>) is equal to the point (<var title="">x2</var>, <var title="">y2</var>), or if the radius <var title="">radius</var> is zero, then the method must add the point (<var title="">x1</var>, <var title="">y1</var>) to the subpath, and connect that point to the previous point (<var title="">x0</var>, <var title="">y0</var>) by a straight line.</p> <p>Otherwise, if the points (<var title="">x0</var>, <var title="">y0</var>), (<var title="">x1</var>, <var title="">y1</var>), and (<var title="">x2</var>, <var title="">y2</var>) all lie on a single straight line, then the method must add the point (<var title="">x1</var>, <var title="">y1</var>) to the subpath, and connect that point to the previous point (<var title="">x0</var>, <var title="">y0</var>) by a straight line.</p> <p>Otherwise, let <var title="">The Arc</var> be the shortest arc given by circumference of the circle that has radius <var title="">radius</var>, and that has one point tangent to the half-infinite line that crosses the point (<var title="">x0</var>, <var title="">y0</var>) and ends at the point (<var title="">x1</var>, <var title="">y1</var>), and that has a different point tangent to the half-infinite line that ends at the point (<var title="">x1</var>, <var title="">y1</var>) and crosses the point (<var title="">x2</var>, <var title="">y2</var>). The points at which this circle touches these two lines are called the start and end tangent points respectively. The method must connect the point (<var title="">x0</var>, <var title="">y0</var>) to the start tangent point by a straight line, adding the start tangent point to the subpath, and then must connect the start tangent point to the end tangent point by <var title="">The Arc</var>, adding the end tangent point to the subpath.</p> <hr><p>The <dfn id=dom-context-2d-arc title=dom-context-2d-arc><code>arc(<var title="">x</var>, <var title="">y</var>, <var title="">radius</var>, <var title="">startAngle</var>, <var title="">endAngle</var>, <var title="">anticlockwise</var>)</code></dfn> method draws an arc. If the context has any subpaths, then the method must add a straight line from the last point in the subpath to the start point of the arc. In any case, it must draw the arc between the start point of the arc and the end point of the arc, and add the start and end points of the arc to the subpath. The arc and its start and end points are defined as follows:</p> <p>Consider a circle that has its origin at (<var title="">x</var>, <var title="">y</var>) and that has radius <var title="">radius</var>. The points at <var title="">startAngle</var> and <var title="">endAngle</var> along this circle's circumference, measured in radians clockwise from the positive x-axis, are the start and end points respectively.</p> <p>If the <var title="">anticlockwise</var> argument is omitted or false and <span title=""><var title="">endAngle</var>-<var title="">startAngle</var></span> is equal to or greater than <span title="">2π</span>, or, if the <var title="">anticlockwise</var> argument is <em>true</em> and <span title=""><var title="">startAngle</var>-<var title="">endAngle</var></span> is equal to or greater than <span title="">2π</span>, then the arc is the whole circumference of this circle.</p> <p>Otherwise, the arc is the path along the circumference of this circle from the start point to the end point, going anti-clockwise if the <var title="">anticlockwise</var> argument is true, and clockwise otherwise. Since the points are on the circle, as opposed to being simply angles from zero, the arc can never cover an angle greater than <span title="">2π</span> radians. If the two points are the same, or if the radius is zero, then the arc is defined as being of zero length in both directions.</p> <p>Negative values for <var title="">radius</var> must cause the implementation to throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <hr><p>The <dfn id=dom-context-2d-rect title=dom-context-2d-rect><code>rect(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</code></dfn> method must create a new subpath containing just the four points (<var title="">x</var>, <var title="">y</var>), (<var title="">x</var>+<var title="">w</var>, <var title="">y</var>), (<var title="">x</var>+<var title="">w</var>, <var title="">y</var>+<var title="">h</var>), (<var title="">x</var>, <var title="">y</var>+<var title="">h</var>), with those four points connected by straight lines, and must then mark the subpath as closed. It must then create a new subpath with the point (<var title="">x</var>, <var title="">y</var>) as the only point in the subpath.</p> <!-- v6 feature request: * points as a primitive shape http://home.comcast.net/~urbanjost/canvas/vogle4.html --> <p>The <dfn id=dom-context-2d-fill title=dom-context-2d-fill><code>fill()</code></dfn> method must fill all the subpaths of the current path, using <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>, and using the non-zero winding number rule. Open subpaths must be implicitly closed when being filled (without affecting the actual subpaths).</p> <p class=note>Thus, if two overlapping but otherwise independent subpaths have opposite windings, they cancel out and result in no fill. If they have the same winding, that area just gets painted once.</p> <p>The <dfn id=dom-context-2d-stroke title=dom-context-2d-stroke><code>stroke()</code></dfn> method must calculate the strokes of all the subpaths of the current path, using the <code title=dom-context-2d-lineWidth><a href=#dom-context-2d-linewidth>lineWidth</a></code>, <code title=dom-context-2d-lineCap><a href=#dom-context-2d-linecap>lineCap</a></code>, <code title=dom-context-2d-lineJoin><a href=#dom-context-2d-linejoin>lineJoin</a></code>, and (if appropriate) <code title=dom-context-2d-miterLimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code> attributes, and then fill the combined stroke area using the <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> attribute.</p> <p class=note>Since the subpaths are all stroked as one, overlapping parts of the paths in one stroke operation are treated as if their union was what was painted.</p> <p>Paths, when filled or stroked, must be painted without affecting the current path, and must be subject to <a href=#shadows title=shadows>shadow effects</a>, <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, the <a href=#clipping-region title="clipping region">clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>. (Transformations affect the path when the path is created, not when it is painted, though the stroke <em>style</em> is still affected by the transformation during painting.)</p> <p>Zero-length line segments must be pruned before stroking a path. Empty subpaths must be ignored.</p> <hr><p id=dom-context-2d-drawosfocusring>The <dfn id=dom-context-2d-drawsystemfocusring title=dom-context-2d-drawSystemFocusRing><code>drawSystemFocusRing(<var title="">element</var>)</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>If <var title="">element</var> is not focused or is not a descendant of the element with whose context the method is associated, then abort these steps.</li> <li> <p>If the user has requested the use of particular focus rings (e.g. high-contrast focus rings), or if the <var title="">element</var> would have a focus ring drawn around it, then draw a focus ring of the appropriate style along the path, following platform conventions, and abort these steps.</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 title=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 title=shadows>shadow effects</a>, the <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, or the <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>, but <em>should</em> be subject to the <a href=#clipping-region title="clipping region">clipping region</a>.</p> </li> <li> <p>Optionally, <a href=#inform>inform the user</a> that the focus is at the location given by the path. User agents may wait until the next time the <a href=#event-loop>event loop</a> reaches its "update the rendering" step to optionally inform the user.</p> </li> </ol><p>The <dfn id=dom-context-2d-drawcustomfocusring title=dom-context-2d-drawCustomFocusRing><code>drawCustomFocusRing(<var title="">element</var>)</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>If <var title="">element</var> is not focused or is not a descendant of the element with whose context the method is associated, then return false and abort these steps.</li> <li> <p>If the user has requested the use of particular focus rings (e.g. high-contrast focus rings), then draw a focus ring of the appropriate style along the path, return false, and abort these steps.</p> <p>The focus ring should not be subject to the <a href=#shadows title=shadows>shadow effects</a>, the <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, or the <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>, but <em>should</em> be subject to the <a href=#clipping-region title="clipping region">clipping region</a>.</p> </li> <li> <p>Optionally, <a href=#inform>inform the user</a> that the focus is at the location given by the path. User agents may wait until the next time the <a href=#event-loop>event loop</a> reaches its "update the rendering" step to optionally inform the user.</p> </li> <li><p>Return true.</li> </ol><p>The <dfn id=dom-context-2d-scrollpathintoview title=dom-context-2d-scrollPathIntoView><code>scrollPathIntoView()</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>Let <var title="">notional child</var> be a hypothetical element that is a rendered child of the <code><a href=#the-canvas-element>canvas</a></code> element whose dimensions are exactly the rectangle of the bounding box of the current path.</li> <li><p><a href=#scroll-an-element-into-view title="scroll an element into view">Scroll <var title="">notional child</var> into view</a> with the <var title="">align to top flag</var> set.</p> <li><p>Optionally, <a href=#inform>inform the user</a> that the caret and/or selection cover <var title="">the specified rectangle</var> of the canvas. User agents may wait until the next time the <a href=#event-loop>event loop</a> reaches its "update the rendering" step to optionally inform the user.</li> </ol><p class=note id=inform>"Inform the user", as used in this section, could mean calling a system accessibility API, which would notify assistive technologies such as magnification tools. To properly drive magnification based on a focus change, a system accessibility API driving a screen magnifier needs the bounds for the newly focused object. The methods above are intended to enable this by allowing the user agent to report the bounding box of the path used to render the focus ring as the bounds of the <var title="">element</var> element passed as an argument, if that element is focused, and the bounding box of the area to which the user agent is scrolling as the bounding box of the current selection.</p> <hr><p>The <dfn id=dom-context-2d-clip title=dom-context-2d-clip><code>clip()</code></dfn> method 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 current path, using the non-zero winding number rule. 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 rectangle with the top left corner at (0,0) and the width and height of the coordinate space.</p> <!-- v6 Jordan OSETE suggests: * support ways of extending the clipping region (union instead of intersection) - also "add", "subtract", "replace", "intersect" and "xor" * support ways of resetting the clipping region without save/restore --> <hr><p>The <dfn id=dom-context-2d-ispointinpath title=dom-context-2d-isPointInPath><code>isPointInPath(<var title="">x</var>, <var title="">y</var>)</code></dfn> method must return true if the point given by the <var title="">x</var> and <var title="">y</var> coordinates passed to the method, when treated as coordinates in the canvas coordinate space unaffected by the current transformation, is inside the current path as determined by the non-zero winding number rule; and must return false otherwise. Points on the path itself are considered to be inside the path. If either of the arguments is infinite or NaN, then the method must return false.</p> </div> <div class=example id=drawCustomFocusRingExample> <p>This <code><a href=#the-canvas-element>canvas</a></code> element has a couple of checkboxes. The path-related commands are highlighted:</p> <pre><canvas height=400 width=750> <label><input type=checkbox id=showA> Show As</label> <label><input type=checkbox id=showB> Show Bs</label> <!-- ... --> </canvas> <script> function drawCheckbox(context, element, x, y, paint) { context.save(); context.font = '10px sans-serif'; context.textAlign = 'left'; context.textBaseline = 'middle'; var metrics = context.measureText(element.labels[0].textContent); if (paint) { <strong> context.beginPath(); context.strokeStyle = 'black'; context.rect(x-5, y-5, 10, 10); context.stroke(); </strong> if (element.checked) { <strong> context.fillStyle = 'black'; context.fill(); </strong> } context.fillText(element.labels[0].textContent, x+5, y); } <strong> context.beginPath(); context.rect(x-7, y-7, 12 + metrics.width+2, 14); if (paint && context.drawCustomFocusRing(element)) { context.strokeStyle = 'silver'; context.stroke(); } </strong> context.restore(); } function drawBase() { /* ... */ } function drawAs() { /* ... */ } function drawBs() { /* ... */ } function redraw() { var canvas = document.getElementsByTagName('canvas')[0]; var context = canvas.getContext('2d'); context.clearRect(0, 0, canvas.width, canvas.height); drawCheckbox(context, document.getElementById('showA'), 20, 40, true); drawCheckbox(context, document.getElementById('showB'), 20, 60, true); drawBase(); if (document.getElementById('showA').checked) drawAs(); if (document.getElementById('showB').checked) drawBs(); } function processClick(event) { var canvas = document.getElementsByTagName('canvas')[0]; var context = canvas.getContext('2d'); var x = event.clientX; var y = event.clientY; while (node) { x -= node.offsetLeft - node.scrollLeft; y -= node.offsetTop - node.scrollTop; node = node.offsetParent; } drawCheckbox(context, document.getElementById('showA'), 20, 40, false); if (<strong>context.isPointInPath(x, y)</strong>) document.getElementById('showA').checked = !(document.getElementById('showA').checked); drawCheckbox(context, document.getElementById('showB'), 20, 60, false); if (<strong>context.isPointInPath(x, y)</strong>) document.getElementById('showB').checked = !(document.getElementById('showB').checked); redraw(); } document.getElementsByTagName('canvas')[0].addEventListener('focus', redraw, true); document.getElementsByTagName('canvas')[0].addEventListener('blur', redraw, true); document.getElementsByTagName('canvas')[0].addEventListener('change', redraw, true); document.getElementsByTagName('canvas')[0].addEventListener('click', processClick, false); redraw(); </script></pre> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/340 --> </div> <h6 id=text-0><span class=secno>4.8.11.1.9 </span>Text</h6> <!-- a v3 feature --> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current font settings.</p> <p>Can be set, to change the font. The syntax is the same as for the CSS 'font' 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><a href=#the-canvas-element>canvas</a></code> element.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current text alignment settings.</p> <p>Can be set, to change the alignment. The possible values are <code title="">start</code>, <code title="">end</code>, <code title="">left</code>, <code title="">right</code>, and <code title="">center</code>. Other values are ignored. The default is <code title="">start</code>.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current baseline alignment settings.</p> <p>Can be set, to change the baseline alignment. The possible values and their meanings are given below. Other values are ignored. The default is <code title="">alphabetic</code>.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-fillText><a href=#dom-context-2d-filltext>fillText</a></code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt> <dt><var title="">context</var> . <code title=dom-context-2d-strokeText><a href=#dom-context-2d-stroketext>strokeText</a></code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt> <dd> <p>Fills or strokes (respectively) the given text at the given position. If a maximum width is provided, the text will be scaled to fit that width if necessary.</p> </dd> <dt><var title="">metrics</var> = <var title="">context</var> . <code title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText</a></code>(<var title="">text</var>)</dt> <dd> <p>Returns a <code><a href=#textmetrics>TextMetrics</a></code> object with the metrics of the given text in the current font.</p> </dd> <dt><var title="">metrics</var> . <code title=dom-textmetrics-width><a href=#dom-textmetrics-width>width</a></code></dt> <dd> <p>Returns the advance width of the text that was passed to the <code title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText()</a></code> method.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-font title=dom-context-2d-font><code>font</code></dfn> IDL attribute, on setting, must be parsed the same way as the 'font' property of CSS (but without supporting property-independent style sheet syntax like 'inherit'), and the resulting font must be assigned to the context, with the 'line-height' component forced to 'normal', with the 'font-size' component converted to CSS pixels, 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 names must be interpreted in the context of the <code><a href=#the-canvas-element>canvas</a></code> element's stylesheets; any fonts embedded using <code title="">@font-face</code> must therefore be available once they are loaded. (If a font is referenced before it is fully loaded, 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></p> <p>Only vector fonts should be used by the user agent; if a user agent were to use bitmap fonts then transformations would likely make the font look very ugly.</p> <p>On getting, the <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code> attribute must return the <a href=#serializing-a-css-value title="serializing a CSS value">serialized form</a> of the current font of the context (with no 'line-height' component). <a href=#refsCSSOM>[CSSOM]</a></p> <div class=example> <p>For example, after the following statement:</p> <pre>context.font = 'italic 400 12px/2 Unknown Font, sans-serif';</pre> <p>...the expression <code title="">context.font</code> would evaluate to the string "<code title="">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 context is created, the font of the context must be set to 10px sans-serif. When the 'font-size' component is set to lengths using percentages, 'em' or 'ex' units, or the 'larger' or 'smaller' keywords, these must be interpreted relative to the computed value of the 'font-size' property of the corresponding <code><a href=#the-canvas-element>canvas</a></code> element at the time that the attribute is set. When the 'font-weight' component is set to the relative values 'bolder' and 'lighter', these must be interpreted relative to the computed value of the 'font-weight' property of the corresponding <code><a href=#the-canvas-element>canvas</a></code> element at the time that the attribute is set. If the computed values are undefined for a particular case (e.g. because the <code><a href=#the-canvas-element>canvas</a></code> element is not <a href=#in-a-document>in a <code>Document</code></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 title=dom-context-2d-textAlign><code>textAlign</code></dfn> IDL attribute, on getting, must return the current value. On setting, if the value is one of <code title="">start</code>, <code title="">end</code>, <code title="">left</code>, <code title="">right</code>, or <code title="">center</code>, then the value must be changed to the new value. Otherwise, the new value must be ignored. When the context is created, the <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> attribute must initially have the value <code title="">start</code>.</p> <p>The <dfn id=dom-context-2d-textbaseline title=dom-context-2d-textBaseline><code>textBaseline</code></dfn> IDL attribute, on getting, must return the current value. On setting, if the value is one of <code title=dom-context-2d-textBaseline-top><a href=#dom-context-2d-textbaseline-top>top</a></code>, <code title=dom-context-2d-textBaseline-hanging><a href=#dom-context-2d-textbaseline-hanging>hanging</a></code>, <code title=dom-context-2d-textBaseline-middle><a href=#dom-context-2d-textbaseline-middle>middle</a></code>, <code title=dom-context-2d-textBaseline-alphabetic><a href=#dom-context-2d-textbaseline-alphabetic>alphabetic</a></code>, <code title=dom-context-2d-textBaseline-ideographic><a href=#dom-context-2d-textbaseline-ideographic>ideographic</a></code>, or <code title=dom-context-2d-textBaseline-bottom><a href=#dom-context-2d-textbaseline-bottom>bottom</a></code>, then the value must be changed to the new value. Otherwise, the new value must be ignored. When the context is created, the <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> attribute must initially have the value <code title="">alphabetic</code>.</p> </div> <p>The <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> attribute's allowed keywords correspond to alignment points in the font:</p> <!-- this is filler to make sure the TCP packet boundary doesn't fall in the middle of one of the NCRs below --> <!-- (because otherwise the parser in anolis screws it up) --> <p><img 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 src=http://images.whatwg.org/baselines.png width=738></p> <p>The keywords map to these alignment points as follows:</p> <dl><dt><dfn id=dom-context-2d-textbaseline-top title=dom-context-2d-textBaseline-top><code>top</code></dfn> <dd>The top of the em square</dd> <dt><dfn id=dom-context-2d-textbaseline-hanging title=dom-context-2d-textBaseline-hanging><code>hanging</code></dfn> <dd>The hanging baseline</dd> <dt><dfn id=dom-context-2d-textbaseline-middle title=dom-context-2d-textBaseline-middle><code>middle</code></dfn> <dd>The middle of the em square</dd> <dt><dfn id=dom-context-2d-textbaseline-alphabetic title=dom-context-2d-textBaseline-alphabetic><code>alphabetic</code></dfn> <dd>The alphabetic baseline</dd> <dt><dfn id=dom-context-2d-textbaseline-ideographic title=dom-context-2d-textBaseline-ideographic><code>ideographic</code></dfn> <dd>The ideographic baseline</dd> <dt><dfn id=dom-context-2d-textbaseline-bottom title=dom-context-2d-textBaseline-bottom><code>bottom</code></dfn> <dd>The bottom of the em square</dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-filltext title=dom-context-2d-fillText><code>fillText()</code></dfn> and <dfn id=dom-context-2d-stroketext title=dom-context-2d-strokeText><code>strokeText()</code></dfn> methods take three or four arguments, <var title="">text</var>, <var title="">x</var>, <var title="">y</var>, and optionally <var title="">maxWidth</var>, and render the given <var title="">text</var> at the given (<var title="">x</var>, <var title="">y</var>) coordinates ensuring that the text isn't wider than <var title="">maxWidth</var> if specified, using the current <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code>, <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code>, and <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> values. Specifically, when the methods are called, the user agent must run the following steps:</p> <ol><li><p>If <var title="">maxWidth</var> is present but less than or equal to zero, return without doing anything; abort these steps.</li> <li><p>Let <var title="">font</var> be the current font of the context, as given by the <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code> attribute.</li> <li><p>Replace all the <a href=#space-character title="space character">space characters</a> in <var title="">text</var> with U+0020 SPACE characters.</li> <li><p>Form a hypothetical infinitely wide CSS line box containing a single inline box containing the text <var title="">text</var>, with all the properties at their initial values except the 'font' property of the inline box set to <var title="">font</var>, the 'direction' property of the inline box set to <a href=#the-directionality>the directionality</a> of the <code><a href=#the-canvas-element>canvas</a></code> element, and the 'white-space' property set to 'pre'. <a href=#refsCSS>[CSS]</a></li> <!-- if you insert a step here, make sure to adjust the next step's final words --> <li><p>If the <var title="">maxWidth</var> argument was specified and the hypothetical width of the inline box in the hypothetical line box is greater than <var title="">maxWidth</var> CSS pixels, then change <var title="">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> <li> <p>Let the <var title="">anchor point</var> be a point on the inline box, determined by the <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> and <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> values, as follows:</p> <p>Horizontal position:</p> <dl><dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">left</code></dt> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">start</code> and <a href=#the-directionality>the directionality</a> of the <code><a href=#the-canvas-element>canvas</a></code> element is 'ltr'</dt> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">end</code> and <a href=#the-directionality>the directionality</a> of the <code><a href=#the-canvas-element>canvas</a></code> element is 'rtl'</dt> <dd>Let the <var title="">anchor point</var>'s horizontal position be the left edge of the inline box.</dd> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">right</code></dt> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">end</code> and <a href=#the-directionality>the directionality</a> of the <code><a href=#the-canvas-element>canvas</a></code> element is 'ltr'</dt> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">start</code> and <a href=#the-directionality>the directionality</a> of the <code><a href=#the-canvas-element>canvas</a></code> element is 'rtl'</dt> <dd>Let the <var title="">anchor point</var>'s horizontal position be the right edge of the inline box.</dd> <dt> If <code title=dom-context-2d-textAlign><a href=#dom-context-2d-textalign>textAlign</a></code> is <code title="">center</code></dt> <dd>Let the <var title="">anchor point</var>'s horizontal position be half way between the left and right edges of the inline box.</dd> </dl><p>Vertical position:</p> <dl><dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-top><a href=#dom-context-2d-textbaseline-top>top</a></code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the top of the em box of the first available font of the inline box.</dd> <dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-hanging><a href=#dom-context-2d-textbaseline-hanging>hanging</a></code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the hanging baseline of the first available font of the inline box.</dd> <dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-middle><a href=#dom-context-2d-textbaseline-middle>middle</a></code></dt> <dd>Let the <var title="">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 inline box.</dd> <dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-alphabetic><a href=#dom-context-2d-textbaseline-alphabetic>alphabetic</a></code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the alphabetic baseline of the first available font of the inline box.</dd> <dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-ideographic><a href=#dom-context-2d-textbaseline-ideographic>ideographic</a></code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the ideographic baseline of the first available font of the inline box.</dd> <dt> If <code title=dom-context-2d-textBaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> is <code title=dom-context-2d-textBaseline-bottom><a href=#dom-context-2d-textbaseline-bottom>bottom</a></code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the bottom of the em box of the first available font of the inline box.</dd> </dl></li> <li> <p>Paint the hypothetical inline box as the shape given by the text's glyphs, as transformed by the <a href=#transformations title=dom-context-2d-transformation>current transformation matrix</a>, and anchored and sized so that before applying the <a href=#transformations title=dom-context-2d-transformation>current transformation matrix</a>, the <var title="">anchor point</var> is at (<var title="">x</var>, <var title="">y</var>) and each CSS pixel is mapped to one coordinate space unit.</p> <p>For <code title=dom-context-2d-fillText><a href=#dom-context-2d-filltext>fillText()</a></code> <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> must be applied to the glyphs and <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> must be ignored. For <code title=dom-context-2d-strokeText><a href=#dom-context-2d-stroketext>strokeText()</a></code> the reverse holds and <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> must be applied to the glyph outlines and <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> must be ignored.</p> <p>Text is painted without affecting the current path, and is subject to <a href=#shadows title=shadows>shadow effects</a>, <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, the <a href=#clipping-region title="clipping region">clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>.</p> </li> </ol><!--v6DVT - this is commented out until CSS can get its act together enough to actual specify vertical text rendering (how long have we been waiting now?) WHEN EDITING THIS, FIX THE PARTS MARKED "XXX" BELOW <p>The <dfn title="dom-context-2d-fillVerticalText"><code>fillVerticalText()</code></dfn> and <dfn title="dom-context-2d-strokeVerticalText"><code>strokeVerticalText()</code></dfn> methods take three or four arguments, <var title="">text</var>, <var title="">x</var>, <var title="">y</var>, and optionally <var title="">maxHeight</var>, and render the given <var title="">text</var> as vertical text at the given (<var title="">x</var>, <var title="">y</var>) coordinates ensuring that the text isn't taller than <var title="">maxHeight</var> if specified, using the current <code title="dom-context-2d-font">font</code> and <code title="dom-context-2d-textAlign">textAlign</code> values. Specifically, when the methods are called, the user agent must run the following steps:</p> <ol> <li><p>If <var title="">maxHeight</var> is present but less than or equal to zero, return without doing anything; abort these steps.</p></li> <li><p>Let <var title="">font</var> be the current font of the context, as given by the <code title="dom-context-2d-font">font</code> attribute.</p></li> <li><p>Replace all the <span title="space character">space characters</span> in <var title="">text</var> with U+0020 SPACE characters.</p></li> <li><p>Form a <em class="XXX">whatever CSS ends up calling vertical line boxes and inline boxes</em> containing the text <var title="">text</var>, with all the properties at their initial values except the 'font' property of the inline box set to <var title="">font</var> and the 'direction' property of the inline box set to <span>the directionality</span> of the <code>canvas</code> element.</p></li> <!- - if you insert a step here, make sure to adjust the next step's final words - -> <li><p>If the <var title="">maxHeight</var> argument was specified and the hypothetical height of the <em class="XXX">box</em> in the hypothetical line box is greater than <var title="">maxHeight</var> CSS pixels, then change <var title="">font</var> to have a more condensed font (if one is available or if a reasonably readable one can be synthesized by applying an appropriate scale factor to the font) or a smaller font, and return to the previous step.</p></li> <li> <p>Let the <var title="">anchor point</var> be a point on the <em class="XXX">inline box</var>, determined by the <code title="dom-context-2d-textAlign">textAlign</code>, as follows:</p> <p>Vertical position:</p> <dl> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">start</code></dt> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">left</code> and <span>the directionality</span> of the <code>canvas</code> element is 'ltr'</dt> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">right</code> and <span>the directionality</span> of the <code>canvas</code> element is 'rtl'</dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the top edge of the <em class="XXX">inline box</em>.</dd> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">end</code></dt> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">right</code> and <span>the directionality</span> of the <code>canvas</code> element is 'ltr'</dt> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">left</code> and <span>the directionality</span> of the <code>canvas</code> element is 'rtl'</dt> <dd>Let the <var title="">anchor point</var>'s vertical position be the bottom edge of the <em class="XXX">inline box</em>.</dd> <dt> If <code title="dom-context-2d-textAlign">textAlign</code> is <code title="">center</code></dt> <dd>Let the <var title="">anchor point</var>'s vertical position be half way between the top and bottom edges of the <em class="XXX">inline box</em>.</dd> </dl> <p>Let the horizontal position be half way between the left and right edges of the em box of the first available font of the <em class="XXX">inline box</em>.</p> </li> <li> <p>Paint the hypothetical inline box as the shape given by the text's glyphs, as transformed by the <span title="dom-context-2d-transformation">current transformation matrix</span>, and anchored and sized so that before applying the <span title="dom-context-2d-transformation">current transformation matrix</span>, the <var title="">anchor point</var> is at (<var title="">x</var>, <var title="">y</var>) and each CSS pixel is mapped to one coordinate space unit.</p> <p>For <code title="dom-context-2d-fillVerticalText">fillVerticalText()</code> <code title="dom-context-2d-fillStyle">fillStyle</code> must be applied and <code title="dom-context-2d-strokeStyle">strokeStyle</code> must be ignored. For <code title="dom-context-2d-strokeVerticalText">strokeVerticalText()</code> the reverse holds and <code title="dom-context-2d-strokeStyle">strokeStyle</code> must be applied and <code title="dom-context-2d-fillStyle">fillStyle</code> must be ignored.</p> <p>Text is painted without affecting the current path, and is subject to <span title="shadows">shadow effects</span>, <span title="dom-context-2d-globalAlpha">global alpha</span>, the <span title="clipping region">clipping region</span>, and <span title="dom-context-2d-globalCompositeOperation">global composition operators</span>.</p> </li> </ol> v6DVT (also check for '- -' bits in the part above) --><p>The <dfn id=dom-context-2d-measuretext title=dom-context-2d-measureText><code>measureText()</code></dfn> method takes one argument, <var title="">text</var>. When the method is invoked, the user agent must replace all the <a href=#space-character title="space character">space characters</a> in <var title="">text</var> with U+0020 SPACE characters, and then must form a hypothetical infinitely wide CSS line box containing a single inline box containing the text <var title="">text</var>, with all the properties at their initial values except the 'white-space' property of the inline element set to 'pre' and the 'font' property of the inline element set to the current font of the context as given by the <code title=dom-context-2d-font><a href=#dom-context-2d-font>font</a></code> attribute, and must then return a new <code><a href=#textmetrics>TextMetrics</a></code> object with its <code title=dom-textmetrics-width><a href=#dom-textmetrics-width>width</a></code> attribute set to the width of that inline box, in CSS pixels. <a href=#refsCSS>[CSS]</a></p> <p>The <code><a href=#textmetrics>TextMetrics</a></code> interface is used for the objects returned from <code title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText()</a></code>. It has one attribute, <dfn id=dom-textmetrics-width title=dom-textmetrics-width><code>width</code></dfn>, which is set by the <code title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText()</a></code> method.</p> <p class=note>Glyphs rendered using <code title=dom-context-2d-fillText><a href=#dom-context-2d-filltext>fillText()</a></code> and <code title=dom-context-2d-strokeText><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 title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText()</a></code> (the text width). This version of the specification does not provide a way to obtain the bounding box dimensions of the text. If the text is to be rendered and removed, care needs to be taken to replace the entire area of the canvas that the clipping region covers, not just the box given by the em square height and measured text width.</p> <!-- v6: Drawing text along a given path --> <!-- v6: Adding text to a path --> <!-- see also: http://www.w3.org/TR/SVG11/text.html#TextpathLayoutRules --> <!-- see also: http://developer.mozilla.org/en/docs/Drawing_text_using_a_canvas --> </div> <p class=note>A future version of the 2D context API may 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=images><span class=secno>4.8.11.1.10 </span>Images</h6> <p>To draw images onto the canvas, the <dfn id=dom-context-2d-drawimage title=dom-context-2d-drawImage><code>drawImage</code></dfn> method can be used.</p> <p>This method can be invoked with three different sets of arguments:</p> <ul class=brief><li><code title="">drawImage(<var title="">image</var>, <var title="">dx</var>, <var title="">dy</var>)</code> <li><code title="">drawImage(<var title="">image</var>, <var title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var title="">dh</var>)</code> <li><code title="">drawImage(<var title="">image</var>, <var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>, <var title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var title="">dh</var>)</code> </ul><!-- v3: drawImage() of an ImageData object might make sense (when resizing as well as filtering) - ack Charles Pritchard --><p>Each of those three can take either an <code><a href=#htmlimageelement>HTMLImageElement</a></code>, an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code>, or an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> for the <var title="">image</var> argument.</p> <dl class=domintro><dt><var title="">context</var> . <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage</a></code>(<var title="">image</var>, <var title="">dx</var>, <var title="">dy</var>)</dt> <dt><var title="">context</var> . <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage</a></code>(<var title="">image</var>, <var title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var title="">dh</var>)</dt> <dt><var title="">context</var> . <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage</a></code>(<var title="">image</var>, <var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>, <var title="">dx</var>, <var title="">dy</var>, <var title="">dw</var>, <var title="">dh</var>)</dt> <dd> <p>Draws the given image onto the canvas. The arguments are interpreted as follows:</p> <p><img 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 src=http://images.whatwg.org/drawImage.png width=356></p> <p>If the first argument isn't an <code><a href=#the-img-element>img</a></code>, <code><a href=#the-canvas-element>canvas</a></code>, or <code><a href=#the-video-element>video</a></code> element, throws a <code><a href=#typemismatcherror>TypeMismatchError</a></code> exception. If the image has no image data, throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. If the one of the source rectangle dimensions is zero, throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception. If the image isn't yet fully decoded, then nothing is drawn.</p> </dd> </dl><div class=impl> <p>If not specified, the <var title="">dw</var> and <var title="">dh</var> arguments must default to the values of <var title="">sw</var> and <var title="">sh</var>, interpreted such that one CSS pixel in the image is treated as one unit in the canvas coordinate space. If the <var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, and <var title="">sh</var> arguments are omitted, they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively. If the image has no intrinsic dimensions, the <i>concrete object size</i> must be used instead, as determined using the CSS "<a href=http://dev.w3.org/csswg/css3-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 contraints, the object's intrinsic properties being those of the <var title="">image</var> argument, and the <i>default object size</i> being the size of the <code><a href=#the-canvas-element>canvas</a></code> element. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p> <p>The <var title="">image</var> argument is an instance of either <code><a href=#htmlimageelement>HTMLImageElement</a></code>, <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code>, or <code><a href=#htmlvideoelement>HTMLVideoElement</a></code>.</p> <!-- createPattern() has an equivalent paragraph --> <p>If the <var title="">image</var> argument is an <code><a href=#htmlimageelement>HTMLImageElement</a></code> object that is not <a href=#img-good title=img-good>fully decodable</a>, or if the <var title="">image</var> argument is an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> object whose <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> attribute is either <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code> or <code title=dom-media-HAVE_METADATA><a href=#dom-media-have_metadata>HAVE_METADATA</a></code>, then the implementation must return without drawing anything.</p> <!-- createPattern() has an equivalent paragraph --> <p>If the <var title="">image</var> argument is an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> object with either a horizontal dimension or a vertical dimension equal to zero, then the implementation must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</p> <!-- createPattern() has an equivalent paragraph --> <p>The source rectangle is the rectangle whose corners are the four points (<var title="">sx</var>, <var title="">sy</var>), (<span title=""><var title="">sx</var>+<var title="">sw</var></span>, <var title="">sy</var>), (<span title=""><var title="">sx</var>+<var title="">sw</var></span>, <span title=""><var title="">sy</var>+<var title="">sh</var></span>), (<var title="">sx</var>, <span title=""><var title="">sy</var>+<var title="">sh</var></span>).</p> <p>If one of the <var title="">sw</var> or <var title="">sh</var> arguments is zero, the implementation must throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <p>The destination rectangle is the rectangle whose corners are the four points (<var title="">dx</var>, <var title="">dy</var>), (<span title=""><var title="">dx</var>+<var title="">dw</var></span>, <var title="">dy</var>), (<span title=""><var title="">dx</var>+<var title="">dw</var></span>, <span title=""><var title="">dy</var>+<var title="">dh</var></span>), (<var title="">dx</var>, <span title=""><var title="">dy</var>+<var title="">dh</var></span>).</p> <p>When <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> is invoked, the region of the image specified by the source rectangle must be painted on the region of the canvas specified by the destination rectangle, after applying the <a href=#transformations title=dom-context-2d-transformation>current transformation matrix</a> to the points of the destination rectangle.</p> <p>The original image data of the source image must be used, not the image as it is rendered (e.g. <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes on the source element have no effect). The image data must be processed in the original direction, even if the dimensions given are negative. <!-- remove that last sentence if it causes confusion. Someone once suggested that 5,5,-2,-2 was different than 3,3,2,2; this is trying to clarify that this is no the case. --></p> <p class=note>This specification does not define the algorithm to use when scaling the image, if necessary.</p> <p class=note>When a canvas is drawn onto itself, the <a href=#drawing-model>drawing model</a> requires the source to be copied before the image is drawn back onto the canvas, so it is possible to copy parts of a canvas onto overlapping parts of itself.</p> <p>If the original image data is a bitmap image, 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.)</p> <!-- see CORE-32111 and: http://krijnhoetmer.nl/irc-logs/whatwg/20100818#l-737 http://www.w3.org/Bugs/Public/show_bug.cgi?id=10799#c11 --> <!-- createPattern() has a similar paragraph with different rules --> <p>When the <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method is passed an animated image as its <var title="">image</var> argument, the user agent must use the poster frame of the animation, or, if there is no poster frame, the first frame of the animation.</p> <!-- createPattern() has an equivalent paragraph --> <p>When the <var title="">image</var> argument is an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code>, then the frame at the <a href=#current-playback-position>current playback position</a> must be used as the source image, and the source image's dimensions must be the <a href=#concept-video-intrinsic-width title=concept-video-intrinsic-width>intrinsic width</a> and <a href=#concept-video-intrinsic-height title=concept-video-intrinsic-height>intrinsic height</a> of the <a href=#media-resource>media resource</a> (i.e. after any aspect-ratio correction has been applied).</p> <!-- createPattern() has an equivalent paragraph --> <p>Images are painted without affecting the current path, and are subject to <a href=#shadows title=shadows>shadow effects</a>, <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, the <a href=#clipping-region title="clipping region">clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operators</a>.</p> </div> <h6 id=pixel-manipulation><span class=secno>4.8.11.1.11 </span><dfn>Pixel manipulation</dfn></h6> <dl class=domintro><dt><var title="">imagedata</var> = <var title="">context</var> . <code title=dom-context-2d-createImageData><a href=#dom-context-2d-createimagedata>createImageData</a></code>(<var title="">sw</var>, <var title="">sh</var>)</dt> <dd> <p>Returns an <code><a href=#imagedata>ImageData</a></code> object with the given dimensions in CSS pixels (which might map to a different number of actual device pixels exposed by the object itself). All the pixels in the returned object are transparent black.</p> </dd> <dt><var title="">imagedata</var> = <var title="">context</var> . <code title=dom-context-2d-createImageData><a href=#dom-context-2d-createimagedata>createImageData</a></code>(<var title="">imagedata</var>)</dt> <dd> <p>Returns an <code><a href=#imagedata>ImageData</a></code> object with the same dimensions as the argument. All the pixels in the returned object are transparent black.</p> </dd> <dt><var title="">imagedata</var> = <var title="">context</var> . <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData</a></code>(<var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>)</dt> <dd> <p>Returns an <code><a href=#imagedata>ImageData</a></code> object containing the image data for the given rectangle of the canvas.</p> <p>Throws a <code><a href=#notsupportederror>NotSupportedError</a></code> exception if any of the arguments are not finite. Throws an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception if the either of the width or height arguments are zero.</p> </dd> <dt><var title="">imagedata</var> . <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code></dt> <dt><var title="">imagedata</var> . <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code></dt> <dd> <p>Returns the actual dimensions of the data in the <code><a href=#imagedata>ImageData</a></code> object, in device pixels.</p> </dd> <dt><var title="">imagedata</var> . <code title=dom-imagedata-data><a href=#dom-imagedata-data>data</a></code></dt> <dd> <p>Returns the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255.</p> </dd> <dt><var title="">context</var> . <code title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData</a></code>(<var title="">imagedata</var>, <var title="">dx</var>, <var title="">dy</var> [, <var title="">dirtyX</var>, <var title="">dirtyY</var>, <var title="">dirtyWidth</var>, <var title="">dirtyHeight</var> ])</dt> <dd> <p>Paints the data from the given <code><a href=#imagedata>ImageData</a></code> object onto the canvas. If a dirty rectangle is provided, only the pixels from that rectangle are painted.</p> <p>The <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> and <code title=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 a <code><a href=#notsupportederror>NotSupportedError</a></code> exception if any of the arguments are not finite.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-context-2d-createimagedata title=dom-context-2d-createImageData><code>createImageData()</code></dfn> method is used to instantiate new blank <code><a href=#imagedata>ImageData</a></code> objects. When the method is invoked with two arguments <var title="">sw</var> and <var title="">sh</var>, it must return an <code><a href=#imagedata>ImageData</a></code> object representing a rectangle with a width in CSS pixels equal to the absolute magnitude of <var title="">sw</var> and a height in CSS pixels equal to the absolute magnitude of <var title="">sh</var>. When invoked with a single <var title="">imagedata</var> argument, it must return an <code><a href=#imagedata>ImageData</a></code> object representing a rectangle with the same dimensions as the <code><a href=#imagedata>ImageData</a></code> object passed as the argument. The <code><a href=#imagedata>ImageData</a></code> object returned must be filled with transparent black.</p> <p>The <dfn id=dom-context-2d-getimagedata title=dom-context-2d-getImageData><code>getImageData(<var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>)</code></dfn> method must return an <code><a href=#imagedata>ImageData</a></code> object representing the underlying pixel data for the area of the canvas denoted by the rectangle whose corners are the four points (<var title="">sx</var>, <var title="">sy</var>), (<span title=""><var title="">sx</var>+<var title="">sw</var></span>, <var title="">sy</var>), (<span title=""><var title="">sx</var>+<var title="">sw</var></span>, <span title=""><var title="">sy</var>+<var title="">sh</var></span>), (<var title="">sx</var>, <span title=""><var title="">sy</var>+<var title="">sh</var></span>), in canvas coordinate space units. Pixels outside the canvas must be returned as transparent black. Pixels must be returned as non-premultiplied alpha values.</p> <p>If any of the arguments to <code title=dom-context-2d-createImageData><a href=#dom-context-2d-createimagedata>createImageData()</a></code> or <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> are infinite or NaN, the method must instead throw a <code><a href=#notsupportederror>NotSupportedError</a></code> exception. If either the <var title="">sw</var> or <var title="">sh</var> arguments are zero, the method must instead throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <p><code><a href=#imagedata>ImageData</a></code> objects must be initialized so that their <dfn id=dom-imagedata-width title=dom-imagedata-width><code>width</code></dfn> attribute is set to <var title="">w</var>, the number of physical device pixels per row in the image data, their <dfn id=dom-imagedata-height title=dom-imagedata-height><code>height</code></dfn> attribute is set to <var title="">h</var>, the number of rows in the image data, and their <dfn id=dom-imagedata-data title=dom-imagedata-data><code>data</code></dfn> attribute is initialized to a <code><a href=#uint8clampedarray>Uint8ClampedArray</a></code> object. The <code><a href=#uint8clampedarray>Uint8ClampedArray</a></code> object must use a <a href=#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>Canvas Pixel <code>ArrayBuffer</code></a> must contain the image data. At least one pixel's worth of image data must be returned. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p> <p>A <dfn id=canvas-pixel-arraybuffer>Canvas Pixel <code>ArrayBuffer</code></dfn> is an <code><a href=#arraybuffer>ArrayBuffer</a></code> that 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 device 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. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p> <p>The <dfn id=dom-context-2d-putimagedata title=dom-context-2d-putImageData><code>putImageData(<var title="">imagedata</var>, <var title="">dx</var>, <var title="">dy</var>, <var title="">dirtyX</var>, <var title="">dirtyY</var>, <var title="">dirtyWidth</var>, <var title="">dirtyHeight</var>)</code></dfn> method writes data from <code><a href=#imagedata>ImageData</a></code> structures back to the canvas.</p> <p>If any of the arguments to the method are infinite or NaN, the method must throw a <code><a href=#notsupportederror>NotSupportedError</a></code> exception.</p> <p>When the last four arguments are omitted, they must be assumed to have the values 0, 0, the <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> member of the <var title="">imagedata</var> structure, and the <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> member of the <var title="">imagedata</var> structure, respectively.</p> <p>When invoked with arguments that do not, per the last few paragraphs, cause an exception to be raised, the <code title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData()</a></code> method must act as follows:</p> <ol><li> <p>Let <var title="">dx<sub>device</sub></var> be the x-coordinate of the device pixel in the underlying pixel data of the canvas corresponding to the <var title="">dx</var> coordinate in the canvas coordinate space.</p> <p>Let <var title="">dy<sub>device</sub></var> be the y-coordinate of the device pixel in the underlying pixel data of the canvas corresponding to the <var title="">dy</var> coordinate in the canvas coordinate space.</p> </li> <li> <p>If <var title="">dirtyWidth</var> is negative, let <var title="">dirtyX</var> be <span title=""><var title="">dirtyX</var>+<var title="">dirtyWidth</var></span>, and let <var title="">dirtyWidth</var> be equal to the absolute magnitude of <var title="">dirtyWidth</var>.</p> <p>If <var title="">dirtyHeight</var> is negative, let <var title="">dirtyY</var> be <span title=""><var title="">dirtyY</var>+<var title="">dirtyHeight</var></span>, and let <var title="">dirtyHeight</var> be equal to the absolute magnitude of <var title="">dirtyHeight</var>.</p> </li> <li> <p>If <var title="">dirtyX</var> is negative, let <var title="">dirtyWidth</var> be <span title=""><var title="">dirtyWidth</var>+<var title="">dirtyX</var></span>, and let <var title="">dirtyX</var> be zero.</p> <p>If <var title="">dirtyY</var> is negative, let <var title="">dirtyHeight</var> be <span title=""><var title="">dirtyHeight</var>+<var title="">dirtyY</var></span>, and let <var title="">dirtyY</var> be zero.</p> </li> <li> <p>If <span title=""><var title="">dirtyX</var>+<var title="">dirtyWidth</var></span> is greater than the <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> attribute of the <var title="">imagedata</var> argument, let <var title="">dirtyWidth</var> be the value of that <code title=dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> attribute, minus the value of <var title="">dirtyX</var>.</p> <p>If <span title=""><var title="">dirtyY</var>+<var title="">dirtyHeight</var></span> is greater than the <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> attribute of the <var title="">imagedata</var> argument, let <var title="">dirtyHeight</var> be the value of that <code title=dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> attribute, minus the value of <var title="">dirtyY</var>.</p> </li> <li> <p>If, after those changes, either <var title="">dirtyWidth</var> or <var title="">dirtyHeight</var> is negative or zero, stop these steps without affecting the canvas.</p> </li> <li><p>Otherwise, for all integer values of <var title="">x</var> and <var title="">y</var> where <span title=""><var title="">dirtyX</var> ≤ <var title="">x</var> < <span title=""><var title="">dirtyX</var>+<var title="">dirtyWidth</var></span></span> and <span title=""><var title="">dirtyY</var> ≤ <var title="">y</var> < <span title=""><var title="">dirtyY</var>+<var title="">dirtyHeight</var></span></span>, copy the four channels of the pixel with coordinate (<var title="">x</var>, <var title="">y</var>) in the <var title="">imagedata</var> data structure to the pixel with coordinate (<span title=""><var title="">dx<sub>device</sub></var>+<var title="">x</var></span>, <span title=""><var title="">dy<sub>device</sub></var>+<var title="">y</var></span>) in the underlying pixel data of the canvas.</li> </ol><p>The handling of pixel rounding when the specified coordinates do not exactly map to the device coordinate space is not defined by this specification, except that the following must result in no visible changes to the rendering:</p> <pre>context.putImageData(context.getImageData(x, y, w, h), p, q);</pre> <p>...for any value of <var title="">x</var>, <var title="">y</var>, <var title="">w</var>, and <var title="">h</var> and where <var title="">p</var> is the smaller of <var title="">x</var> and the sum of <var title="">x</var> and <var title="">w</var>, and <var title="">q</var> is the smaller of <var title="">y</var> and the sum of <var title="">y</var> and <var title="">h</var>; and except that the following two calls:</p> <pre>context.createImageData(w, h); context.getImageData(0, 0, w, h);</pre> <p>...must return <code><a href=#imagedata>ImageData</a></code> objects with the same dimensions, for any value of <var title="">w</var> and <var title="">h</var>. In other words, while user agents may round the arguments of these methods so that they map to device pixel boundaries, any rounding performed must be performed consistently for all of the <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>createImageData()</a></code>, <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> and <code title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData()</a></code> operations.</p> <p class=note>This implies that the data returned by <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> is at the resolution of the canvas backing store. This is likely to not be one device pixel to each CSS pixel if the display used is a high resolution display.</p> <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 title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData()</a></code> might be returned to an equivalent <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> as different values.</p> <p>The current path, <a href=#transformations title=dom-context-2d-transformation>transformation matrix</a>, <a href=#shadows title=shadows>shadow attributes</a>, <a href=#dom-context-2d-globalalpha title=dom-context-2d-globalAlpha>global alpha</a>, the <a href=#clipping-region title="clipping region">clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation title=dom-context-2d-globalCompositeOperation>global composition operator</a> must not affect the <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> and <code title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData()</a></code> methods.</p> </div> <div class=example> <p>In the following example, the script generates an <code><a href=#imagedata>ImageData</a></code> object so that it can draw onto it.</p> <pre>// canvas is a reference to a <canvas> element var context = canvas.getContext('2d'); // create a blank slate var data = context.createImageData(canvas.width, canvas.height); // create some plasma FillPlasma(data, 'green'); // green plasma // add a cloud to the plasma AddCloud(data, data.width/2, data.height/2); // put a cloud in the middle // paint the plasma+cloud on the canvas context.putImageData(data, 0, 0); // support methods function FillPlasma(data, color) { ... } function AddCloud(data, x, y) { ... }</pre> </div> <div class=example> <p>Here is an example of using <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> and <code title=dom-context-2d-putImageData><a href=#dom-context-2d-putimagedata>putImageData()</a></code> to implement an edge detection filter.</p> <pre><!DOCTYPE HTML> <html> <head> <title>Edge detection demo</title> <script> var image = new Image(); function init() { image.onload = demo; image.src = "image.jpeg"; } function demo() { var canvas = document.getElementsByTagName('canvas')[0]; var context = canvas.getContext('2d'); // draw the image onto the canvas context.drawImage(image, 0, 0); // get the image data to manipulate var input = context.getImageData(0, 0, canvas.width, canvas.height); // get an empty slate to put the data into var output = context.createImageData(canvas.width, canvas.height); // alias some variables for convenience // notice that we are using input.width and input.height here // as they might not be the same as canvas.width and canvas.height // (in particular, they might be different on high-res displays) var w = input.width, h = input.height; var inputData = input.data; var outputData = output.data; // edge detection for (var y = 1; y < h-1; y += 1) { for (var x = 1; x < w-1; x += 1) { for (var c = 0; c < 3; c += 1) { var i = (y*w + x)*4 + c; outputData[i] = 127 + -inputData[i - w*4 - 4] - inputData[i - w*4] - inputData[i - w*4 + 4] + -inputData[i - 4] + 8*inputData[i] - inputData[i + 4] + -inputData[i + w*4 - 4] - inputData[i + w*4] - inputData[i + w*4 + 4]; } outputData[(y*w + x)*4 + 3] = 255; // alpha } } // put the image data back after manipulation context.putImageData(output, 0, 0); } </script> </head> <body onload="init()"> <canvas></canvas> </body> </html></pre> </div> <div class=impl> <h6 id=drawing-model><span class=secno>4.8.11.1.12 </span><dfn>Drawing model</dfn></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 transparent black bitmap, creating image <var title="">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> <li><p><a href=#when-shadows-are-drawn>When shadows are drawn</a>, render the shadow from image <var title="">A</var>, using the current shadow styles, creating image <var title="">B</var>.</li> <li><p><a href=#when-shadows-are-drawn>When shadows are drawn</a>, multiply the alpha component of every pixel in <var title="">B</var> by <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>.</li> <li><p><a href=#when-shadows-are-drawn>When shadows are drawn</a>, composite <var title="">B</var> within the <a href=#clipping-region>clipping region</a> over the current canvas bitmap using the current composition operator.</li> <li><p>Multiply the alpha component of every pixel in <var title="">A</var> by <code title=dom-context-2d-globalAlpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>.</li> <li><p>Composite <var title="">A</var> within the <a href=#clipping-region>clipping region</a> over the current canvas bitmap using the current composition operator.</li> </ol></div> <h6 id=best-practices><span class=secno>4.8.11.1.13 </span>Best practices</h6> <p><i>This section is non-normative.</i></p> <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>To indicate which focusable part of the canvas is currently focused, authors should use the <code title=dom-context-2d-drawSystemFocusRing><a href=#dom-context-2d-drawsystemfocusring>drawSystemFocusRing()</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 focused, so that it can simply be called whenever drawing the element, without checking whether the element is focused or not first.</p> <p>Authors should avoid implementing text editing controls using the <code><a href=#the-canvas-element>canvas</a></code> element. Doing so has a large number of disadvantages:</p> <ul><li>Mouse placement of the caret has to be reimplemented.</li> <li>Keyboard movement of the caret has to be reimplemented (possibly across lines, for multiline text input).</li> <li>Scrolling of the text field has to be implemented (horizontally for long lines, vertically for multiline input).</li> <li>Native features such as copy-and-paste have to be reimplemented.</li> <li>Native features such as spell-checking have to be reimplemented.</li> <li>Native features such as drag-and-drop have to be reimplemented.</li> <li>Native features such as page-wide text search have to be reimplemented.</li> <li>Native features specific to the user, for example custom text services, have to be reimplemented. This is close to impossible since each user might have different services installed, and there is an unbounded set of possible such services.</li> <li>Bidirectional text editing has to be reimplemented.</li> <li>For multiline text editing, line wrapping has to be implemented for all relevant languages.</li> <li>Text selection has to be reimplemented.</li> <li>Dragging of bidirectional text selections has to be reimplemented.</li> <li>Platform-native keyboard shortcuts have to be reimplemented.</li> <li>Platform-native input method editors (IMEs) have to be reimplemented.</li> <li>Undo and redo functionality has to be reimplemented.</li> <li>Accessibility features such as magnification following the caret or selection have to be reimplemented.</li> </ul><p>This is a huge amount of work, and authors are most strongly encouraged to avoid doing any of it by instead using the <code><a href=#the-input-element>input</a></code> element, the <code><a href=#the-textarea-element>textarea</a></code> element, or the <code title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code> attribute.</p> <h6 id=examples><span class=secno>4.8.11.1.14 </span>Examples</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><canvas width="800" height="450"></canvas> <script> var context = document.getElementsByTagName('canvas')[0].getContext('2d'); var lastX = context.canvas.width * Math.random(); var lastY = context.canvas.height * Math.random(); var hue = 0; function line() { context.save(); context.translate(context.canvas.width/2, context.canvas.height/2); context.scale(0.9, 0.9); context.translate(-context.canvas.width/2, -context.canvas.height/2); context.beginPath(); context.lineWidth = 5 + Math.random() * 10; context.moveTo(lastX, lastY); lastX = context.canvas.width * Math.random(); lastY = context.canvas.height * Math.random(); context.bezierCurveTo(context.canvas.width * Math.random(), context.canvas.height * Math.random(), context.canvas.width * Math.random(), context.canvas.height * Math.random(), lastX, lastY); hue = hue + 10 * Math.random(); context.strokeStyle = 'hsl(' + hue + ', 50%, 50%)'; context.shadowColor = 'white'; context.shadowBlur = 10; context.stroke(); context.restore(); } setInterval(line, 50); function blank() { context.fillStyle = 'rgba(0,0,0,0.1)'; context.fillRect(0, 0, context.canvas.width, context.canvas.height); } setInterval(blank, 40); </script></pre> </div> </div><!--data-component--> <!--2DCONTEXT--> <div class=impl> <h5 id=color-spaces-and-color-correction><span class=secno>4.8.11.2 </span>Color spaces and color correction</h5> <p>The <code><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 the canvas, to convert the image to the color space used by the canvas (e.g. using the 2D Context's <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method with an <code><a href=#htmlimageelement>HTMLImageElement</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 title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> method.</p> <p>The <code title=dom-canvas-toDataURL><a href=#dom-canvas-todataurl>toDataURL()</a></code> method must not include color space information in the resource returned. Where the output format allows it, the color of pixels in resources created by <code title=dom-canvas-toDataURL><a href=#dom-canvas-todataurl>toDataURL()</a></code> must match those returned by the <code title=dom-context-2d-getImageData><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><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><a href=#the-img-element>img</a></code> element would use the same colors as one painted on a <code><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 title=dom-canvas-toDataURL><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 title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method to render the output of the <code title=dom-canvas-toDataURL><a href=#dom-canvas-todataurl>toDataURL()</a></code> method to the canvas, given the appropriate dimensions, has no visible effect.</p> </div> <div class=impl> <h5 id=security-with-canvas-elements><span class=secno>4.8.11.3 </span>Security with <code><a href=#the-canvas-element>canvas</a></code> elements</h5> <p><strong>Information leakage</strong> can occur if scripts from one <a href=#origin>origin</a> can access information (e.g. read pixels) from images from another origin (one that isn't the <a href=#same-origin title="same origin">same</a>).</p> <p>To mitigate this, <code><a href=#the-canvas-element>canvas</a></code> elements are defined to have a flag indicating whether they are <i>origin-clean</i>. All <code><a href=#the-canvas-element>canvas</a></code> elements must start with their <i>origin-clean</i> set to true. The flag must be set to false if any of the following actions occur:</p> <ul><li><p>The element's 2D context's <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method is called with an <code><a href=#htmlimageelement>HTMLImageElement</a></code> or an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> whose <a href=#origin>origin</a> is not the <a href=#same-origin title="same origin">same</a> as that of the <code><a href=#document>Document</a></code> object that owns the <code><a href=#the-canvas-element>canvas</a></code> element.</li> <li><p>The element's 2D context's <code title=dom-context-2d-drawImage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method is called with an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> whose <i>origin-clean</i> flag is false.</li> <li><p>The element's 2D context's <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> attribute is set to a <code><a href=#canvaspattern>CanvasPattern</a></code> object that was created from an <code><a href=#htmlimageelement>HTMLImageElement</a></code> or an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> whose <a href=#origin>origin</a> was not the <a href=#same-origin title="same origin">same</a> as that of the <code><a href=#document>Document</a></code> object that owns the <code><a href=#the-canvas-element>canvas</a></code> element when the pattern was created.</li> <li><p>The element's 2D context's <code title=dom-context-2d-fillStyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> attribute is set to a <code><a href=#canvaspattern>CanvasPattern</a></code> object that was created from an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> whose <i>origin-clean</i> flag was false when the pattern was created.</li> <li><p>The element's 2D context's <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> attribute is set to a <code><a href=#canvaspattern>CanvasPattern</a></code> object that was created from an <code><a href=#htmlimageelement>HTMLImageElement</a></code> or an <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> whose <a href=#origin>origin</a> was not the <a href=#same-origin title="same origin">same</a> as that of the <code><a href=#document>Document</a></code> object that owns the <code><a href=#the-canvas-element>canvas</a></code> element when the pattern was created.</li> <li><p>The element's 2D context's <code title=dom-context-2d-strokeStyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> attribute is set to a <code><a href=#canvaspattern>CanvasPattern</a></code> object that was created from an <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> whose <i>origin-clean</i> flag was false when the pattern was created.</li> <li><p>The element's 2D context's <code title=dom-context-2d-fillText><a href=#dom-context-2d-filltext>fillText()</a></code> or <code title=dom-context-2d-fillText><a href=#dom-context-2d-filltext>strokeText()</a></code> methods are invoked and consider using a font that has an <a href=#origin>origin</a> that is not the <a href=#same-origin title="same origin">same</a> as that of the <code><a href=#document>Document</a></code> object that owns the <code><a href=#the-canvas-element>canvas</a></code> element. (The font doesn't even have to be used; all that matters is whether the font was considered for any of the glyphs drawn.)</li> <!-- because fonts could consider sensitive material, I guess; and because that sensitivity could extend to whether or not a particular glyph is in the font in the first place. --> </ul><p>Whenever the <code title=dom-canvas-toDataURL><a href=#dom-canvas-todataurl>toDataURL()</a></code> method of a <code><a href=#the-canvas-element>canvas</a></code> element whose <i>origin-clean</i> flag is set to false is called, the method must throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p>Whenever the <code title=dom-context-2d-getImageData><a href=#dom-context-2d-getimagedata>getImageData()</a></code> method of the 2D context of a <code><a href=#the-canvas-element>canvas</a></code> element whose <i>origin-clean</i> flag is set to false is called with otherwise correct arguments, the method must throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p>Whenever the <code title=dom-context-2d-measureText><a href=#dom-context-2d-measuretext>measureText()</a></code> method of the 2D context of a <code><a href=#the-canvas-element>canvas</a></code> element ends up using a font that has an <a href=#origin>origin</a> that is not the <a href=#same-origin title="same origin">same</a> as that of the <code><a href=#document>Document</a></code> object that owns the <code><a href=#the-canvas-element>canvas</a></code> element, the method must throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p class=note>Even resetting the canvas state by changing its <code title=attr-canvas-width><a href=#attr-canvas-width>width</a></code> or <code title=attr-canvas-height><a href=#attr-canvas-height>height</a></code> attributes doesn't reset the <i>origin-clean</i> flag.</p> </div> <h4 id=the-map-element><span class=secno>4.8.12 </span>The <dfn><code>map</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: <a href=#phrasing-content>phrasing content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>When the element only contains <a href=#phrasing-content>phrasing content</a>: where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dd>Otherwise: where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#transparent>Transparent</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-map-name><a href=#attr-map-name>name</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlmapelement>HTMLMapElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-map-name title=dom-map-name>name</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-map-areas title=dom-map-areas>areas</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-map-images title=dom-map-images>images</a>; };</pre> </dd> </dl><p>The <code><a href=#the-map-element>map</a></code> element, in conjunction with any <code><a href=#the-area-element>area</a></code> element descendants, defines an <a href=#image-map>image map</a>. The element <a href=#represents>represents</a> its children.</p> <p>The <dfn id=attr-map-name title=attr-map-name><code>name</code></dfn> attribute gives the map a name so that it can be referenced. The attribute must be present and must have a non-empty value with no <a href=#space-character title="space character">space characters</a>. The value of the <code title=attr-map-name><a href=#attr-map-name>name</a></code> attribute must not be a <a href=#compatibility-caseless title="compatibility caseless">compatibility-caseless</a> match for the value of the <code title=attr-map-name><a href=#attr-map-name>name</a></code> attribute of another <code><a href=#the-map-element>map</a></code> element in the same document. If the <code title=attr-id><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 title="">map</var> . <code title=dom-map-areas><a href=#dom-map-areas>areas</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-area-element>area</a></code> elements in the <code><a href=#the-map-element>map</a></code>.</p> </dd> <dt><var title="">map</var> . <code title=dom-map-images><a href=#dom-map-images>images</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-img-element>img</a></code> and <code><a href=#the-object-element>object</a></code> elements that use the <code><a href=#the-map-element>map</a></code>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-map-areas title=dom-map-areas><code>areas</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-map-element>map</a></code> element, whose filter matches only <code><a href=#the-area-element>area</a></code> elements.</p> <p>The <dfn id=dom-map-images title=dom-map-images><code>images</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-img-element>img</a></code> and <code><a href=#the-object-element>object</a></code> elements that are associated with this <code><a href=#the-map-element>map</a></code> element according to the <a href=#image-map>image map</a> processing model.</p> <p>The IDL attribute <dfn id=dom-map-name title=dom-map-name><code>name</code></dfn> must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <div class=example> <p>Image maps can be defined in conjunction with other content on the page, to ease maintenance. This example is of a page with an image map at the top of the page and a corresponding set of text links at the bottom.</p> <pre><!DOCTYPE HTML> <TITLE>Babies™: Toys</TITLE> <HEADER> <H1>Toys</H1> <IMG SRC="/images/menu.gif" ALT="Babies™ navigation menu. Select a department to go to its page." USEMAP="#NAV"> </HEADER> ... <FOOTER> <MAP NAME="NAV"> <P> <A HREF="/clothes/">Clothes</A> <AREA ALT="Clothes" COORDS="0,0,100,50" HREF="/clothes/"> | <A HREF="/toys/">Toys</A> <AREA ALT="Toys" COORDS="0,0,100,50" HREF="/toys/"> | <A HREF="/food/">Food</A> <AREA ALT="Food" COORDS="0,0,100,50" HREF="/food/"> | <A HREF="/books/">Books</A> <AREA ALT="Books" COORDS="0,0,100,50" HREF="/books/"> </MAP> </FOOTER></pre> </div> <h4 id=the-area-element><span class=secno>4.8.13 </span>The <dfn><code>area</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected, but only if there is a <code><a href=#the-map-element>map</a></code> element ancestor.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-area-alt><a href=#attr-area-alt>alt</a></code></dd> <dd><code title=attr-area-coords><a href=#attr-area-coords>coords</a></code></dd> <dd><code title=attr-area-shape><a href=#attr-area-shape>shape</a></code></dd> <dd><code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code></dd> <dd><code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code></dd> <!--DOWNLOAD--><!--PING--> <dd><code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code></dd> <dd><code title=attr-hyperlink-ping><a href=#ping>ping</a></code></dd> <!--DOWNLOAD--><!--PING--> <dd><code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code></dd> <dd><code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code></dd> <dd><code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code></dd> <dd><code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlareaelement>HTMLAreaElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-area-alt title=dom-area-alt>alt</a>; attribute DOMString <a href=#dom-area-coords title=dom-area-coords>coords</a>; attribute DOMString <a href=#dom-area-shape title=dom-area-shape>shape</a>; stringifier attribute DOMString <a href=#dom-area-href title=dom-area-href>href</a>; attribute DOMString <a href=#dom-area-target title=dom-area-target>target</a>; <!--DOWNLOAD--><!--PING--> attribute DOMString <a href=#dom-area-download title=dom-area-download>download</a>; attribute DOMString <a href=#dom-area-ping title=dom-area-ping>ping</a>; <!--DOWNLOAD--><!--PING--> attribute DOMString <a href=#dom-area-rel title=dom-area-rel>rel</a>; readonly attribute <a href=#domtokenlist>DOMTokenList</a> <a href=#dom-area-rellist title=dom-area-relList>relList</a>; attribute DOMString <a href=#dom-area-media title=dom-area-media>media</a>; attribute DOMString <a href=#dom-area-hreflang title=dom-area-hreflang>hreflang</a>; attribute DOMString <a href=#dom-area-type title=dom-area-type>type</a>; // <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> attribute DOMString <a href=#dom-area-protocol title=dom-area-protocol>protocol</a>; attribute DOMString <a href=#dom-area-host title=dom-area-host>host</a>; attribute DOMString <a href=#dom-area-hostname title=dom-area-hostname>hostname</a>; attribute DOMString <a href=#dom-area-port title=dom-area-port>port</a>; attribute DOMString <a href=#dom-area-pathname title=dom-area-pathname>pathname</a>; attribute DOMString <a href=#dom-area-search title=dom-area-search>search</a>; attribute DOMString <a href=#dom-area-hash title=dom-area-hash>hash</a>; };</pre> </dd> </dl><p>The <code><a href=#the-area-element>area</a></code> element <a href=#represents>represents</a> either a hyperlink with some text and a corresponding area on an <a href=#image-map>image map</a>, or a dead area on an image map.</p> <p>If the <code><a href=#the-area-element>area</a></code> element has an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then the <code><a href=#the-area-element>area</a></code> element represents a <a href=#hyperlink>hyperlink</a>. In this case, the <dfn id=attr-area-alt title=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>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 title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute may be left blank if there is another <code><a href=#the-area-element>area</a></code> element in the same <a href=#image-map>image map</a> that points to the same resource and has a non-blank <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute.</p> <p>If the <code><a href=#the-area-element>area</a></code> element has no <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then the area represented by the element cannot be selected, and the <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute must be omitted.</p> <p>In both cases, the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> and <code title=attr-area-coords><a href=#attr-area-coords>coords</a></code> attributes specify the area.</p> <p>The <dfn id=attr-area-shape title=attr-area-shape><code>shape</code></dfn> attribute is an <a href=#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. <span class=impl>Some of the keywords are non-conforming, as noted in the last column.</span></p> <table><thead><tr><th>State <th>Keywords <th class=impl>Notes <tbody><tr><td rowspan=2><a href=#attr-area-shape-circle title=attr-area-shape-circle>Circle state</a> <td><dfn id=attr-area-shape-keyword-circle title=attr-area-shape-keyword-circle><code>circle</code></dfn> <td class=impl> <tr><td class=impl><dfn id=attr-area-shape-keyword-circ title=attr-area-shape-keyword-circ><code>circ</code></dfn> <td class=impl>Non-conforming <tr><td><a href=#attr-area-shape-default title=attr-area-shape-default>Default state</a> <td><dfn id=attr-area-shape-keyword-default title=attr-area-shape-keyword-default><code>default</code></dfn> <td class=impl> <tr><td rowspan=2><a href=#attr-area-shape-poly title=attr-area-shape-poly>Polygon state</a> <td><dfn id=attr-area-shape-keyword-poly title=attr-area-shape-keyword-poly><code>poly</code></dfn> <td class=impl> <tr><td class=impl><dfn id=attr-area-shape-keyword-polygon title=attr-area-shape-keyword-polygon><code>polygon</code></dfn> <td class=impl>Non-conforming <tr><td rowspan=2><a href=#attr-area-shape-rect title=attr-area-shape-rect>Rectangle state</a> <td><dfn id=attr-area-shape-keyword-rect title=attr-area-shape-keyword-rect><code>rect</code></dfn> <td class=impl> <tr><td class=impl><dfn id=attr-area-shape-keyword-rectangle title=attr-area-shape-keyword-rectangle><code>rectangle</code></dfn> <td class=impl>Non-conforming </table><p>The attribute may be omitted. The <i>missing value default</i> is the <a href=#attr-area-shape-rect title=attr-area-shape-rect>rectangle</a> state.</p> <p>The <dfn id=attr-area-coords title=attr-area-coords><code>coords</code></dfn> attribute must, if specified, contain a <a href=#valid-list-of-integers>valid list of integers</a>. This attribute gives the coordinates for the shape described by the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute. <span class=impl>The processing for this attribute is described as part of the <a href=#image-map>image map</a> processing model.</span></p> <!-- v2: It was suggested by John S. Urban that coords should support percentages as well as pixels, so that one could use the same image map for images of various sizes. --> <p>In the <dfn id=attr-area-shape-circle title=attr-area-shape-circle>circle state</dfn>, <code><a href=#the-area-element>area</a></code> elements must have a <code title=attr-area-coords><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 CSS pixels from the left edge of the image to the center of the circle, the second integer must be the distance in CSS pixels 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 CSS pixels.</p> <p>In the <dfn id=attr-area-shape-default title=attr-area-shape-default>default state</dfn> state, <code><a href=#the-area-element>area</a></code> elements must not have a <code title=attr-area-coords><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 title=attr-area-shape-poly>polygon state</dfn>, <code><a href=#the-area-element>area</a></code> elements must have a <code title=attr-area-coords><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 CSS pixels 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 title=attr-area-shape-rect>rectangle state</dfn>, <code><a href=#the-area-element>area</a></code> elements must have a <code title=attr-area-coords><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 CSS pixels.</p> <div class=impl> <p>When user agents allow users to <a href=#following-hyperlinks title="following hyperlinks">follow hyperlinks</a> <!--DOWNLOAD--> or <a href=#downloading-hyperlinks title="downloading hyperlinks">download hyperlinks</a> <!--DOWNLOAD--> created using the <code><a href=#the-area-element>area</a></code> element, as described in the next section, the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>, <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>, and <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> <!--DOWNLOAD--><!--PING--> attributes decide how the link is followed. The <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>, <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><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> </div> <p>The <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>, <code title=attr-hyperlink-ping><a href=#ping>ping</a></code>, <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>, <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attributes must be omitted if the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute is not present.</p> <div class=impl> <p>The <a href=#activation-behavior>activation behavior</a> of <code><a href=#the-area-element>area</a></code> elements is to run the following steps:</p> <ol><li><p>If the <code title=event-click><a href=#event-click>click</a></code> event in question is not <a href=#concept-events-trusted title=concept-events-trusted>trusted</a> (i.e. a <code title=dom-click><a href=#dom-click>click()</a></code> method call was the reason for the event being dispatched), and the <code><a href=#the-area-element>area</a></code> <!--DOWNLOAD--> element has a <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute or the <!--DOWNLOAD--> element's <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute is present and applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a>, using the value of the <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute as the browsing context name, would result in there not being a chosen browsing context, then throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these steps.</li> <li><p>Otherwise, the user agent must <a href=#following-hyperlinks title="following hyperlinks">follow the hyperlink</a> <!--DOWNLOAD--> or <a href=#downloading-hyperlinks title="downloading hyperlinks">download the hyperlink</a> <!--DOWNLOAD--> created by the <code><a href=#the-area-element>area</a></code> element, if any, and as determined by <!--DOWNLOAD--> the <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute and <!--DOWNLOAD--> any expressed user preference.</li> </ol><p>The IDL attributes <dfn id=dom-area-alt title=dom-area-alt><code>alt</code></dfn>, <dfn id=dom-area-coords title=dom-area-coords><code>coords</code></dfn>, <dfn id=dom-area-href title=dom-area-href><code>href</code></dfn>, <dfn id=dom-area-target title=dom-area-target><code>target</code></dfn>, <!--DOWNLOAD--><!--PING--> <dfn id=dom-area-download title=dom-area-download><code>download</code></dfn>, <dfn id=dom-area-ping title=dom-area-ping><code>ping</code></dfn>, <!--DOWNLOAD--><!--PING--> <dfn id=dom-area-rel title=dom-area-rel><code>rel</code></dfn>, <dfn id=dom-area-media title=dom-area-media><code>media</code></dfn>, <dfn id=dom-area-hreflang title=dom-area-hreflang><code>hreflang</code></dfn>, and <dfn id=dom-area-type title=dom-area-type><code>type</code></dfn>, each must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The IDL attribute <dfn id=dom-area-shape title=dom-area-shape><code>shape</code></dfn> must <a href=#reflect>reflect</a> the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> content attribute.</p> <p>The IDL attribute <dfn id=dom-area-rellist title=dom-area-rellist><code>relList</code></dfn> must <a href=#reflect>reflect</a> the <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> content attribute.</p> <p>The <code><a href=#the-area-element>area</a></code> element also supports the complement of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, <dfn id=dom-area-protocol title=dom-area-protocol><code>protocol</code></dfn>, <dfn id=dom-area-host title=dom-area-host><code>host</code></dfn>, <dfn id=dom-area-port title=dom-area-port><code>port</code></dfn>, <dfn id=dom-area-hostname title=dom-area-hostname><code>hostname</code></dfn>, <dfn id=dom-area-pathname title=dom-area-pathname><code>pathname</code></dfn>, <dfn id=dom-area-search title=dom-area-search><code>search</code></dfn>, and <dfn id=dom-area-hash title=dom-area-hash><code>hash</code></dfn>. These must follow the rules given for <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, with the <a href=#concept-uda-input title=concept-uda-input>input</a> being the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute relative to the element, if there is such an attribute and resolving it is successful, or the empty string otherwise; and the <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> being the same as setting the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute to the new output value.</p> </div> <h4 id=image-maps><span class=secno>4.8.14 </span>Image maps</h4> <!-- TESTS http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Cimg%20src%3D%22http%3A//hixie.ch/resources/images/smallcats%22%20usemap%3D%23a%20onclick%3Dw%28%27img%27%29%3E%0A%3Cmap%20name%3Da%3E%0A%20%3Carea%20onclick%3Dw%28%271%27%29%20coords%3D%270%25%200%25%20100%25%20100%25%27%20href%3Djavascript%3A%3E%0A%3C/map%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Cbody%20onfocus%3D%22w%28document.activeElement.tagName%29%22%3E%0A%3Cimg%20src%3D%22http%3A//hixie.ch/resources/images/smallcats%22%20usemap%3D%23a%20onclick%3Dw%28%27img%27%29%20onfocus%3D%22w%28document.activeElement.tagName%29%22%3E%0A%3Cimg%20src%3D%22http%3A//hixie.ch/resources/images/sample%22%20usemap%3D%23a%20onclick%3Dw%28%27img%27%29%20onfocus%3D%22w%28document.activeElement.tagName%29%22%3E%0A%3Cmap%20name%3Da%20onfocus%3D%22w%28document.activeElement.tagName%29%22%3E%0A%20%3Carea%20onclick%3Dw%28%271%27%29%20coords%3D%270%200%2050%2050%27%20href%3Djavascript%3A%20onfocus%3D%22w%28document.activeElement.tagName%29%22%3E%0A%3C/map%3E%0A%3Cscript%3E%0A%20var%20x%20%3D%20document.getElementsByTagName%28%27img%27%29%5B0%5D%3B%0A%20x.parentNode.appendChild%28x%29%3B%0A%20document.getElementsByTagName%28%27area%27%29%5B0%5D.focus%28%29%3B%0A%3C/script%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3Ex%3Cmap%3E%3Carea%20shape%3Dpolyg%20coords%3D%221%2C2%203%22%3E%3C/map%3E%0A%3Cscript%3Ex%20%3D%20document.getElementsByTagName%28%27area%27%29%5B0%5D%3B%20w%28x.shape%20+%20%27%20%27%20+%20x.coords%29%3C/script%3E http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Cp%3E%3Cimg%20src%3D%22http%3A//hixie.ch/resources/images/astrophy/128%22%20usemap%3D%23a%3E%0D%0A%3Cmap%20name%3Da%3E%3Carea%20shape%3Dcirc%20coords%3D%2220%2C20%2C10%25%22%20href%3D%23%3E%3Carea%20shape%3Dcirc%20coords%3D%2220%2C20%2C10%22%20href%3D%23%3E%3C/map%3E%0D%0A%3Cscript%3Edocument.write%28document.getElementsByTagName%28%27area%27%29%5B0%5D.coords%29%3C/script%3E --> <div class=impl> <h5 id=authoring><span class=secno>4.8.14.1 </span>Authoring</h5> </div> <p>An <dfn id=image-map>image map</dfn> allows geometric areas on an image to be associated with <a href=#hyperlink title=hyperlink>hyperlinks</a>.</p> <p>An image, in the form of an <code><a href=#the-img-element>img</a></code> element or an <code><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><a href=#the-map-element>map</a></code> element) by specifying a <dfn id=attr-hyperlink-usemap title=attr-hyperlink-usemap><code>usemap</code></dfn> attribute on the <code><a href=#the-img-element>img</a></code> or <code><a href=#the-object-element>object</a></code> element. The <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute, if specified, must be a <a href=#valid-hash-name-reference>valid hash-name reference</a> to a <code><a href=#the-map-element>map</a></code> element.</p> <div class=example> <p>Consider an image that looks as follows:</p> <p><img 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 src=http://images.whatwg.org/sample-usemap.png width=600></p> <p>If we wanted just the colored areas to be clickable, we could do it as follows:</p> <pre><p> Please select a shape: <img src="shapes.png" usemap="#shapes" alt="Four shapes are available: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star."> <map name="shapes"> <area shape=rect coords="50,50,100,100"> <!-- the hole in the red box --> <area shape=rect coords="25,25,125,125" href="red.html" alt="Red box."> <area shape=circle coords="200,75,50" href="green.html" alt="Green circle."> <area shape=poly coords="325,25,262,125,388,125" href="blue.html" alt="Blue triangle."> <area shape=poly coords="450,25,435,60,400,75,435,90,450,125,465,90,500,75,465,60" href="yellow.html" alt="Yellow star."> </map> </p></pre> </div> <div class=impl> <h5 id=processing-model><span class=secno>4.8.14.2 </span>Processing model</h5> <p>If an <code><a href=#the-img-element>img</a></code> element or an <code><a href=#the-object-element>object</a></code> element representing an image has a <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute specified, user agents must process it as follows:</p> <ol><li><p>First, <a href=#rules-for-parsing-a-hash-name-reference>rules for parsing a hash-name reference</a> to a <code><a href=#the-map-element>map</a></code> element must be followed. This will return either an element (the <var title="">map</var>) or null.</li> <li><p>If that returned null, then abort these steps. The image is not associated with an image map after all.</li> <li><p>Otherwise, the user agent must collect all the <code><a href=#the-area-element>area</a></code> elements that are descendants of the <var title="">map</var>. Let those be the <var title="">areas</var>.</li> </ol><p>Having obtained the list of <code><a href=#the-area-element>area</a></code> elements that form the image map (the <var title="">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><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><a href=#the-object-element>object</a></code> elements cannot represent images, and thus this section never applies (the <a href=#fallback-content>fallback content</a> is shown instead). The following steps therefore only apply to <code><a href=#the-img-element>img</a></code> elements.</p> <ol><li><p>Remove all the <code><a href=#the-area-element>area</a></code> elements in <var title="">areas</var> that have no <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute.</li> <li><p>Remove all the <code><a href=#the-area-element>area</a></code> elements in <var title="">areas</var> that have no <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute, or whose <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute's value is the empty string, <em>if</em> there is another <code><a href=#the-area-element>area</a></code> element in <var title="">areas</var> with the same value in the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute and with a non-empty <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code> attribute.</li> <li><p>Each remaining <code><a href=#the-area-element>area</a></code> element in <var title="">areas</var> represents a <a href=#hyperlink>hyperlink</a>. Those hyperlinks should all be made available to the user in a manner associated with the text of the <code><a href=#the-img-element>img</a></code>.</p> <p>In this context, user agents may represent <code><a href=#the-area-element>area</a></code> and <code><a href=#the-img-element>img</a></code> elements with no specified <code title="">alt</code> attributes, or whose <code title="">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.</li> </ol><p>If the user agent intends to show the image and allow interaction with the image to select hyperlinks, then the image must be associated with a set of layered shapes, taken from the <code><a href=#the-area-element>area</a></code> elements in <var title="">areas</var>, in reverse tree order (so the last specified <code><a href=#the-area-element>area</a></code> element in the <var title="">map</var> is the bottom-most shape, and the first element in the <var title="">map</var>, in tree order, is the top-most shape).</p> <p>Each <code><a href=#the-area-element>area</a></code> element in <var title="">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 title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute represents.</li> <li><p>Use the <a href=#rules-for-parsing-a-list-of-integers>rules for parsing a list of integers</a> to parse the element's <code title=attr-area-coords><a href=#attr-area-coords>coords</a></code> attribute, if it is present, and let the result be the <var title="">coords</var> list. If the attribute is absent, let the <var title="">coords</var> list be the empty list.</li> <li><p>If the number of items in the <var title="">coords</var> list is less than the minimum number given for the <code><a href=#the-area-element>area</a></code> element's current state, as per the following table, then the shape is empty; abort these steps.</p> <table><thead><tr><th>State <th>Minimum number of items <tbody><tr><td><a href=#attr-area-shape-circle title=attr-area-shape-circle>Circle state</a> <td>3 <tr><td><a href=#attr-area-shape-default title=attr-area-shape-default>Default state</a> <td>0 <tr><td><a href=#attr-area-shape-poly title=attr-area-shape-poly>Polygon state</a> <td>6 <tr><td><a href=#attr-area-shape-rect title=attr-area-shape-rect>Rectangle state</a> <td>4 </table></li> <li><p>Check for excess items in the <var title="">coords</var> list as per the entry in the following list corresponding to the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute's state:</p> <dl class=switch><dt><a href=#attr-area-shape-circle title=attr-area-shape-circle>Circle state</a></dt> <dd>Drop any items in the list beyond the third.</dd> <dt><a href=#attr-area-shape-default title=attr-area-shape-default>Default state</a></dt> <dd>Drop all items in the list.</dd> <dt><a href=#attr-area-shape-poly title=attr-area-shape-poly>Polygon state</a></dt> <dd>Drop the last item if there's an odd number of items.</dd> <dt><a href=#attr-area-shape-rect title=attr-area-shape-rect>Rectangle state</a></dt> <dd>Drop any items in the list beyond the fourth.</dd> </dl></li> <li><p>If the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute represents the <a href=#attr-area-shape-rect title=attr-area-shape-rect>rectangle state</a>, and the first number in the list is numerically less than the third number in the list, then swap those two numbers around.</li> <li><p>If the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute represents the <a href=#attr-area-shape-rect title=attr-area-shape-rect>rectangle state</a>, and the second number in the list is numerically less than the fourth number in the list, then swap those two numbers around.</li> <li><p>If the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute represents the <a href=#attr-area-shape-circle title=attr-area-shape-circle>circle state</a>, and the third number in the list is less than or equal to zero, then the shape is empty; abort these steps.</li> <li><p>Now, the shape represented by the element is the one described for the entry in the list below corresponding to the state of the <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code> attribute:</p> <dl class=switch><dt><a href=#attr-area-shape-circle title=attr-area-shape-circle>Circle state</a></dt> <dd> <p>Let <var title="">x</var> be the first number in <var title="">coords</var>, <var title="">y</var> be the second number, and <var title="">r</var> be the third number.</p> <p>The shape is a circle whose center is <var title="">x</var> CSS pixels from the left edge of the image and <var title="">y</var> CSS pixels from the top edge of the image, and whose radius is <var title="">r</var> pixels.</p> </dd> <dt><a href=#attr-area-shape-default title=attr-area-shape-default>Default state</a></dt> <dd> <p>The shape is a rectangle that exactly covers the entire image.</p> </dd> <dt><a href=#attr-area-shape-poly title=attr-area-shape-poly>Polygon state</a></dt> <dd> <p>Let <var title="">x<sub title=""><var title="">i</var></sub></var> be the <span title="">(2<var title="">i</var>)</span>th entry in <var title="">coords</var>, and <var title="">y<sub title=""><var title="">i</var></sub></var> be the <span title="">(2<var title="">i</var>+1)</span>th entry in <var title="">coords</var> (the first entry in <var title="">coords</var> being the one with index 0).</p> <p>Let <var title="">the coordinates</var> be (<var title="">x<sub title=""><var title="">i</var></sub></var>, <var title="">y<sub title=""><var title="">i</var></sub></var>), interpreted in CSS pixels measured from the top left of the image, for all integer values of <var title="">i</var> from 0 to <span title="">(<var title="">N</var>/2)-1</span>, where <var title="">N</var> is the number of items in <var title="">coords</var>.</p> <p>The shape is a polygon whose vertices are given by <var title="">the coordinates</var>, and whose interior is established using the even-odd rule. <a href=#refsGRAPHICS>[GRAPHICS]</a></p> <!-- browsers implement the even-odd rule / even winding rule: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Cimg%20usemap%3D%22%23x%22%20src%3D%22/resources/images/sample%22%3E%0A%3Cmap%20name%3D%22x%22%3E%0A%20%20%3Carea%20shape%3Dpolygon%20coords%3D%220%2C0%200%2C100%20100%2C100%20100%2C2%201%2C2%202%2C1%202%2C99%2099%2C99%2099%2C0%22%20href%3Da%3E%0A%3C/map%3E%0A --> </dd> <dt><a href=#attr-area-shape-rect title=attr-area-shape-rect>Rectangle state</a></dt> <dd> <p>Let <var title="">x<sub title="">1</sub></var> be the first number in <var title="">coords</var>, <var title="">y<sub title="">1</sub></var> be the second number, <var title="">x<sub title="">2</sub></var> be the third number, and <var title="">y<sub title="">2</sub></var> be the fourth number.</p> <p>The shape is a rectangle whose top-left corner is given by the coordinate (<var title="">x<sub title="">1</sub></var>, <var title="">y<sub title="">1</sub></var>) and whose bottom right corner is given by the coordinate (<var title="">x<sub title="">2</sub></var>, <var title="">y<sub title="">2</sub></var>), those coordinates being interpreted as CSS pixels from the top left corner of the image.</p> </dd> </dl><p>For historical reasons, the coordinates must be interpreted relative to the <em>displayed</em> image after any stretching caused by the CSS 'width' and 'height' properties (or, for non-CSS browsers, the image element's <code title="">width</code> and <code title="">height</code> attributes — CSS browsers map those attributes to the aforementioned CSS properties).</p> <p class=note>Browser zoom features and transforms applied using CSS or SVG do not affect the coordinates.</p> </li> </ol><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><a href=#the-area-element>area</a></code> elements representing <a href=#hyperlink title=hyperlink>hyperlinks</a> to be selected and activated (e.g. using a keyboard).</p> <p class=note>Because a <code><a href=#the-map-element>map</a></code> element (and its <code><a href=#the-area-element>area</a></code> elements) can be associated with multiple <code><a href=#the-img-element>img</a></code> and <code><a href=#the-object-element>object</a></code> elements, it is possible for an <code><a href=#the-area-element>area</a></code> element to correspond to multiple focusable areas of the document.</p> <p>Image maps are <a href=#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> </div> <h4 id=mathml><span class=secno>4.8.15 </span>MathML</h4> <p>The <dfn id=math><code>math</code></dfn> element from the <a href=#mathml-namespace>MathML namespace</a> falls into the <a href=#embedded-content>embedded content</a>, <a href=#phrasing-content>phrasing content</a>, and <a href=#flow-content>flow content</a> categories for the purposes of the content models in this specification.</p> <div class=impl> <!-- apparently we get to define error handling, so: --> <p>User agents must handle text other than <a href=#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 that text is actually wrapped in an <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a>. (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 an <code title="">merror</code> element in the <a href=#mathml-namespace>MathML namespace</a> 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> </div> <p>The semantics of MathML elements are defined by the MathML specification and <a href=#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><!DOCTYPE html> <html> <head> <title>The quadratic formula</title> </head> <body> <h1>The quadratic formula</h1> <p> <math> <mi>x</mi> <mo>=</mo> <mfrac> <mrow> <mo form="prefix">−</mo> <mi>b</mi> <mo>±</mo> <msqrt> <msup> <mi>b</mi> <mn>2</mn> </msup> <mo>−</mo> <mn>4</mn> <mo>⁢</mo> <mi>a</mi> <mo>⁢</mo> <mi>c</mi> </msqrt> </mrow> <mrow> <mn>2</mn> <mo>⁢</mo> <mi>a</mi> </mrow> </mfrac> </math> </p> </body> </html></pre> </div> <h4 id=svg-0><span class=secno>4.8.16 </span>SVG</h4> <p>The <dfn id=svg><code>svg</code></dfn> element from the <a href=#svg-namespace>SVG namespace</a> falls into the <a href=#embedded-content>embedded content</a>, <a href=#phrasing-content>phrasing content</a>, and <a href=#flow-content>flow content</a> categories for the purposes of the content models in this specification.</p> <div class=impl> <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> </div> <p>When the SVG <code title="">foreignObject</code> element contains elements from the <a href=#html-namespace-0>HTML namespace</a>, such elements must all be <a href=#flow-content>flow content</a>. <a href=#refsSVG>[SVG]</a></p> <p>The content model for <code title="">title</code> elements in the <a href=#svg-namespace>SVG namespace</a> inside <a href=#html-documents>HTML documents</a> is <a href=#phrasing-content>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>other applicable specifications</a>. <a href=#refsSVG>[SVG]</a></p> <!-- The following paragraph is for bug 7510 --> <p>The SVG specification includes requirements regarding the handling of elements in the DOM that are not in the SVG namespace, that are in SVG fragments, and that are not included in a <code title="">foreignObject</code> element. <em>This</em> specification does not define any processing for elements in SVG fragments that are not in the HTML namespace; they are considered neither conforming nor non-conforming from the perspective of this specification.</p> <h4 id=dimension-attributes><span class=secno>4.8.17 </span><dfn>Dimension attributes</dfn></h4> <p><span class=impl><strong>Author requirements</strong>:</span> The <dfn id=attr-dim-width title=attr-dim-width><code>width</code></dfn> and <dfn id=attr-dim-height title=attr-dim-height><code>height</code></dfn> attributes on <code><a href=#the-img-element>img</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-video-element>video</a></code>, and, when their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <code><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 CSS pixels. The attributes, if specified, must have values that are <a href=#valid-non-negative-integer title="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, CSS pixels 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><span title=""><var title="">specified width</var> - 0.5 ≤ <var title="">specified height</var> * <var title="">target ratio</var> ≤ <var title="">specified width</var> + 0.5</span></li> <li><span title=""><var title="">specified height</var> - 0.5 ≤ <var title="">specified width</var> / <var title="">target ratio</var> ≤ <var title="">specified height</var> + 0.5</span></li> <li><span title=""><var title="">specified height</var> = <var title="">specified width</var> = 0</span></li> </ul><p>The <var title="">target ratio</var> is the ratio of the intrinsic width to the intrinsic height in the resource. The <var title="">specified width</var> and <var title="">specified height</var> are the values of the <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> and <code title=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 intrinsic width and an intrinsic height.</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> <div class=impl> <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 title=dom-dim-width><code>width</code></dfn> and <dfn id=dom-dim-height title=dom-dim-height><code>height</code></dfn> IDL attributes on the <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-object-element>object</a></code>, and <code><a href=#the-video-element>video</a></code> elements must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p class=note>For <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-embed-element>embed</a></code>, and <code><a href=#the-object-element>object</a></code> the IDL attributes are <code>DOMString</code>; for <code><a href=#the-video-element>video</a></code> the IDL attributes are <code>unsigned long</code>.</p> <p class=note>The corresponding IDL attributes for <code title=dom-img-height><a href=#dom-img-height>img</a></code> and <code title=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> </div> <h3 id=tabular-data><span class=secno>4.9 </span>Tabular data</h3> <h4 id=the-table-element><span class=secno>4.9.1 </span>The <dfn><code>table</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>In this order: optionally a <code><a href=#the-caption-element>caption</a></code> element, followed by zero or more <code><a href=#the-colgroup-element>colgroup</a></code> elements, followed optionally by a <code><a href=#the-thead-element>thead</a></code> element, followed optionally by a <code><a href=#the-tfoot-element>tfoot</a></code> element, followed by either zero or more <code><a href=#the-tbody-element>tbody</a></code> elements or one or more <code><a href=#the-tr-element>tr</a></code> elements, followed optionally by a <code><a href=#the-tfoot-element>tfoot</a></code> element (but there can only be one <code><a href=#the-tfoot-element>tfoot</a></code> element child in total).</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-table-border><a href=#attr-table-border>border</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltableelement>HTMLTableElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute <a href=#htmltablecaptionelement>HTMLTableCaptionElement</a>? <a href=#dom-table-caption title=dom-table-caption>caption</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-table-createcaption title=dom-table-createCaption>createCaption</a>(); void <a href=#dom-table-deletecaption title=dom-table-deleteCaption>deleteCaption</a>(); attribute <a href=#htmltablesectionelement>HTMLTableSectionElement</a>? <a href=#dom-table-thead title=dom-table-tHead>tHead</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-table-createthead title=dom-table-createTHead>createTHead</a>(); void <a href=#dom-table-deletethead title=dom-table-deleteTHead>deleteTHead</a>(); attribute <a href=#htmltablesectionelement>HTMLTableSectionElement</a>? <a href=#dom-table-tfoot title=dom-table-tFoot>tFoot</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-table-createtfoot title=dom-table-createTFoot>createTFoot</a>(); void <a href=#dom-table-deletetfoot title=dom-table-deleteTFoot>deleteTFoot</a>(); readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-table-tbodies title=dom-table-tBodies>tBodies</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-table-createtbody title=dom-table-createTBody>createTBody</a>(); readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-table-rows title=dom-table-rows>rows</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-table-insertrow title=dom-table-insertRow>insertRow</a>(optional long index); void <a href=#dom-table-deleterow title=dom-table-deleteRow>deleteRow</a>(long index); attribute DOMString <a href=#dom-table-border title=dom-table-border>border</a>; };</pre> </dd> </dl><p>The <code><a href=#the-table-element>table</a></code> element <a href=#represents>represents</a> data with more than one dimension, in the form of a <a href=#concept-table title=concept-table>table</a>.</p> <p><span class=impl>The <code><a href=#the-table-element>table</a></code> element takes part in the <a href=#table-model>table model</a>.</span> 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> <div class=impl> <p class=note>Precise rules for determining whether this conformance requirement is met are described in the description of the <a href=#table-model>table model</a>.</p> </div> <p>Authors are encouraged to provide information describing how to interpret complex tables. Guidance on how <a href=#table-descriptions-techniques>provide such information</a> is given below.</p> <div class=impl> <p>If a <code><a href=#the-table-element>table</a></code> element has a (non-conforming) <code title=attr-table-summary><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> </div> <!--FORK--> <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> <!-- The paragraph below replaces the above one in the W3C copy due to a WG decision. It is not used in the WHATWG copy for the following reasons: * "should not" implies that there may be valid reasons to use tables for layout, which there are not. * The second sentence appears to be grammatically incorrect, and more importantly, does not clearly state that use of tables for layout has always been a misuse. This implies it may have once been correct (even though that is not the case), and that further may reduce the effectiveness of advocacy on this topic. * The third sentence (in the paragraph below) is identical to the fourth one in the paragraph above except for comma usage which seems incorrect (it implies that the users are the screen readers, as opposed to the tools, if I'm reading it right). * The final sentence below flat out legitimizes layout tables. * The paragraph below seems to assume that only ARIA-enabled ATs are a concern, when in fact there are numerous UAs other than ARIA-enabled ATs that are harmed by this use of layout tables. * The paragraph below fails to suggest that UAs will need heuristics to deal with the existing content. * The text below actually contradicts other requirements in this specification (<table>s represent tables, and elements must be used per their semantics, so the requirement that tables not be used for layout is in fact technically redundant, and the paragraph below doesn't change that). * There really is no good reason to use tables for layout anymore, and conformance criteria should support best practices, not obsolete authoring practices. --> <p class=note>There are a variety of alternatives to using HTML tables for layout, primarily using CSS positioning and the CSS table model.</p> <p>The <dfn id=attr-table-border title=attr-table-border><code>border</code></dfn> attribute may be specified on a <code><a href=#the-table-element>table</a></code> element to explicitly indicate that the <code><a href=#the-table-element>table</a></code> element is not being used for layout purposes. If specified, the attribute's value must either be the empty string or the value "<code title="">1</code>". The attribute is used by certain user agents as an indication that borders should be drawn around cells of the table.</p> <!--!--> <!-- http://lists.w3.org/Archives/Public/public-html/2011Apr/0419.html --> <div class=impl> <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 <!--FORK--> (non-conforming) <!--FORK--> layout table.</p> </div> <p class=note>Authors <span class=impl>and implementors</span> are encouraged to consider using some of the <a href=#table-layout-techniques>table layout techniques</a> described below to make tables easier to navigate for users.</p> <div class=impl> <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 title=attr-aria-role>role</code> attribute with the value <code title=attr-aria-role-presentation>presentation</code> <td>Probably a layout table <tr><td>The use of the <code title=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 title=attr-table-cellspacing><a href=#attr-table-cellspacing>cellspacing</a></code> and <code title=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><a href=#the-caption-element>caption</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-th-element>th</a></code> elements <td>Probably a non-layout table <tr><td>The use of the <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> and <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attributes <td>Probably a non-layout table <tr><td>The use of the <code title=attr-table-border><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 title=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> </div> <hr><dl class=domintro><dt><var title="">table</var> . <code title=dom-table-caption><a href=#dom-table-caption>caption</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the table's <code><a href=#the-caption-element>caption</a></code> element.</p> <p>Can be set, to replace the <code><a href=#the-caption-element>caption</a></code> element. If the new value is not a <code><a href=#the-caption-element>caption</a></code> element, throws a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</p> </dd> <dt><var title="">caption</var> = <var title="">table</var> . <code title=dom-table-createCaption><a href=#dom-table-createcaption>createCaption</a></code>()</dt> <dd> <p>Ensures the table has a <code><a href=#the-caption-element>caption</a></code> element, and returns it.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-deleteCaption><a href=#dom-table-deletecaption>deleteCaption</a></code>()</dt> <dd> <p>Ensures the table does not have a <code><a href=#the-caption-element>caption</a></code> element.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-tHead><a href=#dom-table-thead>tHead</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the table's <code><a href=#the-thead-element>thead</a></code> element.</p> <p>Can be set, to replace the <code><a href=#the-thead-element>thead</a></code> element. If the new value is not a <code><a href=#the-thead-element>thead</a></code> element, throws a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</p> </dd> <dt><var title="">thead</var> = <var title="">table</var> . <code title=dom-table-createTHead><a href=#dom-table-createthead>createTHead</a></code>()</dt> <dd> <p>Ensures the table has a <code><a href=#the-thead-element>thead</a></code> element, and returns it.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-deleteTHead><a href=#dom-table-deletethead>deleteTHead</a></code>()</dt> <dd> <p>Ensures the table does not have a <code><a href=#the-thead-element>thead</a></code> element.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-tFoot><a href=#dom-table-tfoot>tFoot</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the table's <code><a href=#the-tfoot-element>tfoot</a></code> element.</p> <p>Can be set, to replace the <code><a href=#the-tfoot-element>tfoot</a></code> element. If the new value is not a <code><a href=#the-tfoot-element>tfoot</a></code> element, throws a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</p> </dd> <dt><var title="">tfoot</var> = <var title="">table</var> . <code title=dom-table-createTFoot><a href=#dom-table-createtfoot>createTFoot</a></code>()</dt> <dd> <p>Ensures the table has a <code><a href=#the-tfoot-element>tfoot</a></code> element, and returns it.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-deleteTFoot><a href=#dom-table-deletetfoot>deleteTFoot</a></code>()</dt> <dd> <p>Ensures the table does not have a <code><a href=#the-tfoot-element>tfoot</a></code> element.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-tBodies><a href=#dom-table-tbodies>tBodies</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-tbody-element>tbody</a></code> elements of the table.</p> </dd> <dt><var title="">tbody</var> = <var title="">table</var> . <code title=dom-table-createTBody><a href=#dom-table-createtbody>createTBody</a></code>()</dt> <dd> <p>Creates a <code><a href=#the-tbody-element>tbody</a></code> element, inserts it into the table, and returns it.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-tr-element>tr</a></code> elements of the table.</p> </dd> <dt><var title="">tr</var> = <var title="">table</var> . <code title=dom-table-insertRow><a href=#dom-table-insertrow>insertRow</a></code>(<var title="">index</var>)</dt> <dd> <p>Creates a <code><a href=#the-tr-element>tr</a></code> element, along with a <code><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><a href=#the-tr-element>tr</a></code>.</p> <p>The position is relative to the rows in the table. The index −1 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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> <dt><var title="">table</var> . <code title=dom-table-deleteRow><a href=#dom-table-deleterow>deleteRow</a></code>(<var title="">index</var>)</dt> <dd> <p>Removes the <code><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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-table-caption title=dom-table-caption><code>caption</code></dfn> IDL attribute must return, on getting, the first <code><a href=#the-caption-element>caption</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, or null otherwise. On setting, if the new value is a <code><a href=#the-caption-element>caption</a></code> element, the first <code><a href=#the-caption-element>caption</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, must be removed, and the new value must be inserted as the first node of the <code><a href=#the-table-element>table</a></code> element. If the new value is not a <code><a href=#the-caption-element>caption</a></code> element, then a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> DOM exception must be raised instead.</p> <p>The <dfn id=dom-table-createcaption title=dom-table-createCaption><code>createCaption()</code></dfn> method must return the first <code><a href=#the-caption-element>caption</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any; otherwise a new <code><a href=#the-caption-element>caption</a></code> element must be created, inserted as the first node of the <code><a href=#the-table-element>table</a></code> element, and then returned.</p> <p>The <dfn id=dom-table-deletecaption title=dom-table-deleteCaption><code>deleteCaption()</code></dfn> method must remove the first <code><a href=#the-caption-element>caption</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any.</p> <p>The <dfn id=dom-table-thead title=dom-table-tHead><code>tHead</code></dfn> IDL attribute must return, on getting, the first <code><a href=#the-thead-element>thead</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, or null otherwise. On setting, if the new value is a <code><a href=#the-thead-element>thead</a></code> element, the first <code><a href=#the-thead-element>thead</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, must be removed, and the new value must be inserted immediately before the first element in the <code><a href=#the-table-element>table</a></code> element that is neither a <code><a href=#the-caption-element>caption</a></code> element nor a <code><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 not a <code><a href=#the-thead-element>thead</a></code> element, then a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> DOM exception must be raised instead.</p> <p>The <dfn id=dom-table-createthead title=dom-table-createTHead><code>createTHead()</code></dfn> method must return the first <code><a href=#the-thead-element>thead</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any; otherwise a new <code><a href=#the-thead-element>thead</a></code> element must be created and inserted immediately before the first element in the <code><a href=#the-table-element>table</a></code> element that is neither a <code><a href=#the-caption-element>caption</a></code> element nor a <code><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 title=dom-table-deleteTHead><code>deleteTHead()</code></dfn> method must remove the first <code><a href=#the-thead-element>thead</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any.</p> <p>The <dfn id=dom-table-tfoot title=dom-table-tFoot><code>tFoot</code></dfn> IDL attribute must return, on getting, the first <code><a href=#the-tfoot-element>tfoot</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, or null otherwise. On setting, if the new value is a <code><a href=#the-tfoot-element>tfoot</a></code> element, the first <code><a href=#the-tfoot-element>tfoot</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any, must be removed, and the new value must be inserted immediately before the first element in the <code><a href=#the-table-element>table</a></code> element that is neither a <code><a href=#the-caption-element>caption</a></code> element, a <code><a href=#the-colgroup-element>colgroup</a></code> element, nor a <code><a href=#the-thead-element>thead</a></code> element, if any, or at the end of the table if there are no such elements. If the new value is not a <code><a href=#the-tfoot-element>tfoot</a></code> element, then a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> DOM exception must be raised instead.</p> <p>The <dfn id=dom-table-createtfoot title=dom-table-createTFoot><code>createTFoot()</code></dfn> method must return the first <code><a href=#the-tfoot-element>tfoot</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any; otherwise a new <code><a href=#the-tfoot-element>tfoot</a></code> element must be created and inserted immediately before the first element in the <code><a href=#the-table-element>table</a></code> element that is neither a <code><a href=#the-caption-element>caption</a></code> element, a <code><a href=#the-colgroup-element>colgroup</a></code> element, nor a <code><a href=#the-thead-element>thead</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-deletetfoot title=dom-table-deleteTFoot><code>deleteTFoot()</code></dfn> method must remove the first <code><a href=#the-tfoot-element>tfoot</a></code> element child of the <code><a href=#the-table-element>table</a></code> element, if any.</p> <p>The <dfn id=dom-table-tbodies title=dom-table-tBodies><code>tBodies</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-table-element>table</a></code> node, whose filter matches only <code><a href=#the-tbody-element>tbody</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <dfn id=dom-table-createtbody title=dom-table-createTBody><code>createTBody()</code></dfn> method must create a new <code><a href=#the-tbody-element>tbody</a></code> element, insert it immediately after the last <code><a href=#the-tbody-element>tbody</a></code> element in the <code><a href=#the-table-element>table</a></code> element, if any, or at the end of the <code><a href=#the-table-element>table</a></code> element if the <code><a href=#the-table-element>table</a></code> element has no <code><a href=#the-tbody-element>tbody</a></code> element children, and then must return the new <code><a href=#the-tbody-element>tbody</a></code> element.</p> <p>The <dfn id=dom-table-rows title=dom-table-rows><code>rows</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-table-element>table</a></code> node, whose filter matches only <code><a href=#the-tr-element>tr</a></code> elements that are either children of the <code><a href=#the-table-element>table</a></code> element, or children of <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, or <code><a href=#the-tfoot-element>tfoot</a></code> elements that are themselves children of the <code><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><a href=#the-thead-element>thead</a></code> are included first, in tree order, followed by those elements whose parent is either a <code><a href=#the-table-element>table</a></code> or <code><a href=#the-tbody-element>tbody</a></code> element, again in tree order, followed finally by those elements whose parent is a <code><a href=#the-tfoot-element>tfoot</a></code> element, still in tree order.</p> <p>The behavior of the <dfn id=dom-table-insertrow title=dom-table-insertRow><code>insertRow(<var title="">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 title="">index</var> argument:</p> <dl class=switch><dt>If <var title="">index</var> is less than −1 or greater than the number of elements in <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection:</dt> <dd>The method must throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</dd> <dt>If the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection has zero elements in it, and the <code><a href=#the-table-element>table</a></code> has no <code><a href=#the-tbody-element>tbody</a></code> elements in it:</dt> <dd>The method must create a <code><a href=#the-tbody-element>tbody</a></code> element, then create a <code><a href=#the-tr-element>tr</a></code> element, then append the <code><a href=#the-tr-element>tr</a></code> element to the <code><a href=#the-tbody-element>tbody</a></code> element, then append the <code><a href=#the-tbody-element>tbody</a></code> element to the <code><a href=#the-table-element>table</a></code> element, and finally return the <code><a href=#the-tr-element>tr</a></code> element.</dd> <dt>If the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection has zero elements in it:</dt> <dd>The method must create a <code><a href=#the-tr-element>tr</a></code> element, append it to the last <code><a href=#the-tbody-element>tbody</a></code> element in the table, and return the <code><a href=#the-tr-element>tr</a></code> element.</dd> <dt>If <var title="">index</var> is missing, equal to −1, or equal to the number of items in <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection:</dt> <dd>The method must create a <code><a href=#the-tr-element>tr</a></code> element, and append it to the parent of the last <code><a href=#the-tr-element>tr</a></code> element in the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection. Then, the newly created <code><a href=#the-tr-element>tr</a></code> element must be returned.</dd> <dt>Otherwise:</dt> <dd>The method must create a <code><a href=#the-tr-element>tr</a></code> element, insert it immediately before the <var title="">index</var>th <code><a href=#the-tr-element>tr</a></code> element in the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection, in the same parent, and finally must return the newly created <code><a href=#the-tr-element>tr</a></code> element.</dd> </dl><p>When the <dfn id=dom-table-deleterow title=dom-table-deleteRow><code>deleteRow(<var title="">index</var>)</code></dfn> method is called, the user agent must run the following steps:</p> <ol><li><p>If <var title="">index</var> is equal to −1, then <var title="">index</var> must be set to the number if items in the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection, minus one.</li> <li><p>Now, if <var title="">index</var> is less than zero, or greater than or equal to the number of elements in the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection, the method must instead throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception, and these steps must be aborted.</li> <li><p>Otherwise, the method must remove the <var title="">index</var>th element in the <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection from its parent.</p> </ol><p>The <dfn id=dom-table-border title=dom-table-border><code>border</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <div class=example> <p>Here is an example of a table being used to mark up a Sudoku puzzle. Observe the lack of headers, which are not necessary in such a table.</p> <pre><section> <style scoped> table { border-collapse: collapse; border: solid thick; } colgroup, tbody { border: solid medium; } td { border: solid thin; height: 1.4em; width: 1.4em; text-align: center; padding: 0; } </style> <h1>Today's Sudoku</h1> <table> <colgroup><col><col><col> <colgroup><col><col><col> <colgroup><col><col><col> <tbody> <tr> <td> 1 <td> <td> 3 <td> 6 <td> <td> 4 <td> 7 <td> <td> 9 <tr> <td> <td> 2 <td> <td> <td> 9 <td> <td> <td> 1 <td> <tr> <td> 7 <td> <td> <td> <td> <td> <td> <td> <td> 6 <tbody> <tr> <td> 2 <td> <td> 4 <td> <td> 3 <td> <td> 9 <td> <td> 8 <tr> <td> <td> <td> <td> <td> <td> <td> <td> <td> <tr> <td> 5 <td> <td> <td> 9 <td> <td> 7 <td> <td> <td> 1 <tbody> <tr> <td> 6 <td> <td> <td> <td> 5 <td> <td> <td> <td> 2 <tr> <td> <td> <td> <td> <td> 7 <td> <td> <td> <td> <tr> <td> 9 <td> <td> <td> 8 <td> <td> 2 <td> <td> <td> 5 </table> </section></pre> </div> <h5 id=table-descriptions-techniques><span class=secno>4.9.1.1 </span>Techniques for describing tables</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> <!--Describing the conclusions of the data in a table is useful to everyone; explaining how to read the table, if not obvious from the headers alone, is useful to everyone; describing the structure of the table, if it is easy to grasp visually, might not be useful to everyone, but it might also not be useful to users who can quickly navigate the table with an accessibility tool.--> <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</dt> <dd> <div class=example><pre><p>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.</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></pre></div> </dd> <dt>In the table's <code><a href=#the-caption-element>caption</a></code></dt> <dd> <div class=example><pre><table> <caption> <strong>Characteristics with positive and negative sides.</strong> <p>Characteristics are given in the second column, with the negative side in the left column and the positive side in the right column.</p> </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></pre></div> </dd> <dt>In the table's <code><a href=#the-caption-element>caption</a></code>, in a <code><a href=#the-details-element>details</a></code> element</dt> <dd> <div class=example><pre><table> <caption> <strong>Characteristics with positive and negative sides.</strong> <details> <summary>Help</summary> <p>Characteristics are given in the second column, with the negative side in the left column and the positive side in the right column.</p> </details> </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></pre></div> </dd> <dt>Next to the table, in the same <code><a href=#the-figure-element>figure</a></code></dt> <dd> <div class=example><pre><figure> <figcaption>Characteristics with positive and negative sides</figcaption> <p>Characteristics are given in the second column, with the negative side in the left column and the positive side in the right column.</p> <table> <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> </figure></pre></div> </dd> <dt>Next to the table, in a <code><a href=#the-figure-element>figure</a></code>'s <code><a href=#the-figcaption-element>figcaption</a></code></dt> <dd> <div class=example><pre><figure> <figcaption> <strong>Characteristics with positive and negative sides</strong> <p>Characteristics are given in the second column, with the negative side in the left column and the positive side in the right column.</p> </figcaption> <table> <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> </figure></pre></div> </dd> </dl><p>Authors may also use other techniques, or combinations of the above techniques, as appropriate.</p> <p>The best option, of course, rather than writing a description explaining the way the table is laid out, is to adjust the table such that no explanation is needed.</p> <div class=example> <p>In the case of the table used in the examples above, a simple rearrangement of the table so that the headers are on the top and left sides removes the need for an explanation as well as removing the need for the use of <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attributes:</p> <pre><table> <caption>Characteristics with positive and negative sides</caption> <thead> <tr> <th> Characteristic <th> Negative <th> Positive <tbody> <tr> <th> Mood <td> Sad <td> Happy <tr> <th> Grade <td> Failing <td> Passing </table></pre> </div> <h5 id=table-layout-techniques><span class=secno>4.9.1.2 </span>Techniques for table layout</h5> <p>Good table layout 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> <div class=impl> <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> </div> <h4 id=the-caption-element><span class=secno>4.9.2 </span>The <dfn><code>caption</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the first element child of a <code><a href=#the-table-element>table</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no descendant <code><a href=#the-table-element>table</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltablecaptionelement>HTMLTableCaptionElement</dfn> : <a href=#htmlelement>HTMLElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-caption-element>caption</a></code> element <a href=#represents>represents</a> the title of the <code><a href=#the-table-element>table</a></code> that is its parent, if it has a parent and that is a <code><a href=#the-table-element>table</a></code> element.</p> <div class=impl> <p>The <code><a href=#the-caption-element>caption</a></code> element takes part in the <a href=#table-model>table model</a>.</p> </div> <p>When a <code><a href=#the-table-element>table</a></code> element is the only content in a <code><a href=#the-figure-element>figure</a></code> element other than the <code><a href=#the-figcaption-element>figcaption</a></code>, the <code><a href=#the-caption-element>caption</a></code> element should be omitted in favor of the <code><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 reference in the main prose) and explaining its use, it makes more sense:</p> <pre><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></pre> <!--HTML4POLICE (hidden in w3c version because w3c version has to be valid HTML4) --><!--FORK--> <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><!--HTML4POLICE--><!--FORK--></div> <h4 id=the-colgroup-element><span class=secno>4.9.3 </span>The <dfn><code>colgroup</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code> elements and before any <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, and <code><a href=#the-tr-element>tr</a></code> elements.</dd> <dt>Content model:</dt> <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is present: Empty.</dd> <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is absent: Zero or more <code><a href=#the-col-element>col</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltablecolelement>HTMLTableColElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute unsigned long <a href=#dom-colgroup-span title=dom-colgroup-span>span</a>; };</pre> </dd> </dl><p>The <code><a href=#the-colgroup-element>colgroup</a></code> element <a href=#represents>represents</a> a <a href=#concept-column-group title=concept-column-group>group</a> of one or more <a href=#concept-column title=concept-column>columns</a> in the <code><a href=#the-table-element>table</a></code> that is its parent, if it has a parent and that is a <code><a href=#the-table-element>table</a></code> element.</p> <p>If the <code><a href=#the-colgroup-element>colgroup</a></code> element contains no <code><a href=#the-col-element>col</a></code> elements, then the element may have a <dfn id=attr-colgroup-span title=attr-colgroup-span><code>span</code></dfn> content attribute specified, whose value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero.</p> <div class=impl> <p>The <code><a href=#the-colgroup-element>colgroup</a></code> element and its <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute take part in the <a href=#table-model>table model</a>.</p> <p>The <dfn id=dom-colgroup-span title=dom-colgroup-span><code>span</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name. The value must be <a href=#limited-to-only-non-negative-numbers-greater-than-zero>limited to only non-negative numbers greater than zero</a>.</p> </div> <h4 id=the-col-element><span class=secno>4.9.4 </span>The <dfn><code>col</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-colgroup-element>colgroup</a></code> element that doesn't have a <code title=attr-col-span><a href=#attr-col-span>span</a></code> attribute.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-col-span><a href=#attr-col-span>span</a></code></dd> <!-- v2: char, to specify the decimal character used in numeric data cells in the column (not header cells) --> <dt>DOM interface:</dt> <dd> <p><code><a href=#htmltablecolelement>HTMLTableColElement</a></code>, same as for <code><a href=#the-colgroup-element>colgroup</a></code> elements. This interface defines one member, <code title=dom-col-span><a href=#dom-col-span>span</a></code>.</p> </dd> </dl><p>If a <code><a href=#the-col-element>col</a></code> element has a parent and that is a <code><a href=#the-colgroup-element>colgroup</a></code> element that itself has a parent that is a <code><a href=#the-table-element>table</a></code> element, then the <code><a href=#the-col-element>col</a></code> element <a href=#represents>represents</a> one or more <a href=#concept-column title=concept-column>columns</a> in the <a href=#concept-column-group title=concept-column-group>column group</a> represented by that <code><a href=#the-colgroup-element>colgroup</a></code>.</p> <p>The element may have a <dfn id=attr-col-span title=attr-col-span><code>span</code></dfn> content attribute specified, whose value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero.</p> <div class=impl> <p>The <code><a href=#the-col-element>col</a></code> element and its <code title=attr-col-span><a href=#attr-col-span>span</a></code> attribute take part in the <a href=#table-model>table model</a>.</p> <p>The <dfn id=dom-col-span title=dom-col-span><code>span</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name. The value must be <a href=#limited-to-only-non-negative-numbers-greater-than-zero>limited to only non-negative numbers greater than zero</a>.</p> </div> <h4 id=the-tbody-element><span class=secno>4.9.5 </span>The <dfn><code>tbody</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, and <code><a href=#the-thead-element>thead</a></code> elements, but only if there are no <code><a href=#the-tr-element>tr</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltablesectionelement>HTMLTableSectionElement</dfn> : <a href=#htmlelement>HTMLElement</a> { readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-tbody-rows title=dom-tbody-rows>rows</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-tbody-insertrow title=dom-tbody-insertRow>insertRow</a>(optional long index); void <a href=#dom-tbody-deleterow title=dom-tbody-deleteRow>deleteRow</a>(long index); };</pre> <p>The <code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> interface is also used for <code><a href=#the-thead-element>thead</a></code> and <code><a href=#the-tfoot-element>tfoot</a></code> elements.</p> </dd> </dl><p>The <code><a href=#the-tbody-element>tbody</a></code> element <a href=#represents>represents</a> a <a href=#concept-row-group title=concept-row-group>block</a> of <a href=#concept-row title=concept-row>rows</a> that consist of a body of data for the parent <code><a href=#the-table-element>table</a></code> element, if the <code><a href=#the-tbody-element>tbody</a></code> element has a parent and it is a <code><a href=#the-table-element>table</a></code>.</p> <div class=impl> <p>The <code><a href=#the-tbody-element>tbody</a></code> element takes part in the <a href=#table-model>table model</a>.</p> </div> <dl class=domintro><dt><var title="">tbody</var> . <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-tr-element>tr</a></code> elements of the table section.</p> </dd> <dt><var title="">tr</var> = <var title="">tbody</var> . <code title=dom-tbody-insertRow><a href=#dom-tbody-insertrow>insertRow</a></code>( [ <var title="">index</var> ] )</dt> <dd> <p>Creates a <code><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><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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> <dt><var title="">tbody</var> . <code title=dom-tbody-deleteRow><a href=#dom-tbody-deleterow>deleteRow</a></code>(<var title="">index</var>)</dt> <dd> <p>Removes the <code><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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-tbody-rows title=dom-tbody-rows><code>rows</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the element, whose filter matches only <code><a href=#the-tr-element>tr</a></code> elements that are children of the element.</p> <p>The <dfn id=dom-tbody-insertrow title=dom-tbody-insertRow><code>insertRow(<var title="">index</var>)</code></dfn> method must, when invoked on an element <var title="">table section</var>, act as follows:</p> <p>If <var title="">index</var> is less than −1 or greater than the number of elements in the <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> collection, the method must throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <p>If <var title="">index</var> is missing, equal to −1, or equal to the number of items in the <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> collection, the method must create a <code><a href=#the-tr-element>tr</a></code> element, append it to the element <var title="">table section</var>, and return the newly created <code><a href=#the-tr-element>tr</a></code> element.</p> <p>Otherwise, the method must create a <code><a href=#the-tr-element>tr</a></code> element, insert it as a child of the <var title="">table section</var> element, immediately before the <var title="">index</var>th <code><a href=#the-tr-element>tr</a></code> element in the <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> collection, and finally must return the newly created <code><a href=#the-tr-element>tr</a></code> element.</p> <p>The <dfn id=dom-tbody-deleterow title=dom-tbody-deleteRow><code>deleteRow(<var title="">index</var>)</code></dfn> method must remove the <var title="">index</var>th element in the <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> collection from its parent. If <var title="">index</var> is less than zero or greater than or equal to the number of elements in the <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> collection, the method must instead throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </div> <h4 id=the-thead-element><span class=secno>4.9.6 </span>The <dfn><code>thead</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code>, and <code><a href=#the-colgroup-element>colgroup</a></code> elements and before any <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, and <code><a href=#the-tr-element>tr</a></code> elements, but only if there are no other <code><a href=#the-thead-element>thead</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code>, as defined for <code><a href=#the-tbody-element>tbody</a></code> elements.</dd> </dl><p>The <code><a href=#the-thead-element>thead</a></code> element <a href=#represents>represents</a> the <a href=#concept-row-group title=concept-row-group>block</a> of <a href=#concept-row title=concept-row>rows</a> that consist of the column labels (headers) for the parent <code><a href=#the-table-element>table</a></code> element, if the <code><a href=#the-thead-element>thead</a></code> element has a parent and it is a <code><a href=#the-table-element>table</a></code>.</p> <div class=impl> <p>The <code><a href=#the-thead-element>thead</a></code> element takes part in the <a href=#table-model>table model</a>.</p> </div> <div class=example> <p>This example shows a <code><a href=#the-thead-element>thead</a></code> element being used. Notice the use of both <code><a href=#the-th-element>th</a></code> and <code><a href=#the-td-element>td</a></code> elements in the <code><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><table> <caption> School auction sign-up sheet </caption> <strong> <thead> <tr> <th><label for=e1>Name</label> <th><label for=e2>Product</label> <th><label for=e3>Picture</label> <th><label for=e4>Price</label> <tr> <td>Your name here <td>What are you selling? <td>Link to a picture <td>Your reserve price </strong> <tbody> <tr> <td>Ms Danus <td>Doughnuts <td><img src="http://example.com/mydoughnuts.png" title="Doughnuts from Ms Danus"> <td>$45 <tr> <td><input id=e1 type=text name=who required form=f> <td><input id=e2 type=text name=what required form=f> <td><input id=e3 type=url name=pic form=f> <td><input id=e4 type=number step=0.01 min=0 value=0 required form=f> </table> <form id=f action="/auction.cgi"> <input type=button name=add value="Submit"> </form></pre> </div> <h4 id=the-tfoot-element><span class=secno>4.9.7 </span>The <dfn><code>tfoot</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, and <code><a href=#the-thead-element>thead</a></code> elements and before any <code><a href=#the-tbody-element>tbody</a></code> and <code><a href=#the-tr-element>tr</a></code> elements, but only if there are no other <code><a href=#the-tfoot-element>tfoot</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</dd> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tr-element>tr</a></code> elements, but only if there are no other <code><a href=#the-tfoot-element>tfoot</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code>, as defined for <code><a href=#the-tbody-element>tbody</a></code> elements.</dd> </dl><p>The <code><a href=#the-tfoot-element>tfoot</a></code> element <a href=#represents>represents</a> the <a href=#concept-row-group title=concept-row-group>block</a> of <a href=#concept-row title=concept-row>rows</a> that consist of the column summaries (footers) for the parent <code><a href=#the-table-element>table</a></code> element, if the <code><a href=#the-tfoot-element>tfoot</a></code> element has a parent and it is a <code><a href=#the-table-element>table</a></code>.</p> <div class=impl> <p>The <code><a href=#the-tfoot-element>tfoot</a></code> element takes part in the <a href=#table-model>table model</a>.</p> </div> <h4 id=the-tr-element><span class=secno>4.9.8 </span>The <dfn><code>tr</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-thead-element>thead</a></code> element.</dd> <dd>As a child of a <code><a href=#the-tbody-element>tbody</a></code> element.</dd> <dd>As a child of a <code><a href=#the-tfoot-element>tfoot</a></code> element.</dd> <dd>As a child of a <code><a href=#the-table-element>table</a></code> element, after any <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, and <code><a href=#the-thead-element>thead</a></code> elements, but only if there are no <code><a href=#the-tbody-element>tbody</a></code> elements that are children of the <code><a href=#the-table-element>table</a></code> element.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> elements</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltablerowelement>HTMLTableRowElement</dfn> : <a href=#htmlelement>HTMLElement</a> { readonly attribute long <a href=#dom-tr-rowindex title=dom-tr-rowIndex>rowIndex</a>; readonly attribute long <a href=#dom-tr-sectionrowindex title=dom-tr-sectionRowIndex>sectionRowIndex</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-tr-cells title=dom-tr-cells>cells</a>; <a href=#htmlelement>HTMLElement</a> <a href=#dom-tr-insertcell title=dom-tr-insertCell>insertCell</a>(optional long index); void <a href=#dom-tr-deletecell title=dom-tr-deleteCell>deleteCell</a>(long index); };</pre> </dd> </dl><p>The <code><a href=#the-tr-element>tr</a></code> element <a href=#represents>represents</a> a <a href=#concept-row title=concept-row>row</a> of <a href=#concept-cell title=concept-cell>cells</a> in a <a href=#concept-table title=concept-table>table</a>.</p> <div class=impl> <p>The <code><a href=#the-tr-element>tr</a></code> element takes part in the <a href=#table-model>table model</a>.</p> </div> <dl class=domintro><dt><var title="">tr</var> . <code title=dom-tr-rowIndex><a href=#dom-tr-rowindex>rowIndex</a></code></dt> <dd> <p>Returns the position of the row in the table's <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> list.</p> <p>Returns −1 if the element isn't in a table.</p> </dd> <dt><var title="">tr</var> . <code title=dom-tr-sectionRowIndex><a href=#dom-tr-sectionrowindex>sectionRowIndex</a></code></dt> <dd> <p>Returns the position of the row in the table section's <code title=dom-tbody-rows><a href=#dom-tbody-rows>rows</a></code> list.</p> <p>Returns −1 if the element isn't in a table section.</p> </dd> <dt><var title="">tr</var> . <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements of the row.</p> </dd> <dt><var title="">cell</var> = <var title="">tr</var> . <code title=dom-tr-insertCell><a href=#dom-tr-insertcell>insertCell</a></code>( [ <var title="">index</var> ] )</dt> <dd> <p>Creates a <code><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><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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> <dt><var title="">tr</var> . <code title=dom-tr-deleteCell><a href=#dom-tr-deletecell>deleteCell</a></code>(<var title="">index</var>)</dt> <dd> <p>Removes the <code><a href=#the-td-element>td</a></code> or <code><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 <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-tr-rowindex title=dom-tr-rowIndex><code>rowIndex</code></dfn> attribute must, if the element has a parent <code><a href=#the-table-element>table</a></code> element, or a parent <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tfoot-element>tfoot</a></code> element and a <em>grandparent</em> <code><a href=#the-table-element>table</a></code> element, return the index of the <code><a href=#the-tr-element>tr</a></code> element in that <code><a href=#the-table-element>table</a></code> element's <code title=dom-table-rows><a href=#dom-table-rows>rows</a></code> collection. If there is no such <code><a href=#the-table-element>table</a></code> element, then the attribute must return −1.</p> <p>The <dfn id=dom-tr-sectionrowindex title=dom-tr-sectionRowIndex><code>sectionRowIndex</code></dfn> attribute must, if the element has a parent <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tfoot-element>tfoot</a></code> element, return the index of the <code><a href=#the-tr-element>tr</a></code> element in the parent element's <code title="">rows</code> collection (for tables, that's the <code title=dom-table-rows><a href=#dom-table-rows>HTMLTableElement.rows</a></code> collection; for table sections, that's the <code title=dom-tbody-rows><a href=#dom-tbody-rows>HTMLTableRowElement.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 title=dom-tr-cells><code>cells</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-tr-element>tr</a></code> element, whose filter matches only <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements that are children of the <code><a href=#the-tr-element>tr</a></code> element.</p> <p>The <dfn id=dom-tr-insertcell title=dom-tr-insertCell><code>insertCell(<var title="">index</var>)</code></dfn> method must act as follows:</p> <p>If <var title="">index</var> is less than −1 or greater than the number of elements in the <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection, the method must throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> <p>If <var title="">index</var> is missing, equal to −1, or equal to the number of items in <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection, the method must create a <code><a href=#the-td-element>td</a></code> element, append it to the <code><a href=#the-tr-element>tr</a></code> element, and return the newly created <code><a href=#the-td-element>td</a></code> element.</p> <p>Otherwise, the method must create a <code><a href=#the-td-element>td</a></code> element, insert it as a child of the <code><a href=#the-tr-element>tr</a></code> element, immediately before the <var title="">index</var>th <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element in the <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection, and finally must return the newly created <code><a href=#the-td-element>td</a></code> element.</p> <p>The <dfn id=dom-tr-deletecell title=dom-tr-deleteCell><code>deleteCell(<var title="">index</var>)</code></dfn> method must remove the <var title="">index</var>th element in the <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection from its parent. If <var title="">index</var> is less than zero or greater than or equal to the number of elements in the <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection, the method must instead throw an <code><a href=#indexsizeerror>IndexSizeError</a></code> exception.</p> </div> <h4 id=the-td-element><span class=secno>4.9.9 </span>The <dfn><code>td</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-tr-element>tr</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code></dd> <dd><code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code></dd> <dd><code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code></dd> <!-- v2 char, to specify the decimal character used in numeric cells --> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltabledatacellelement>HTMLTableDataCellElement</dfn> : <a href=#htmltablecellelement>HTMLTableCellElement</a> {};</pre> </dd> </dl><p>The <code><a href=#the-td-element>td</a></code> element <a href=#represents>represents</a> a data <a href=#concept-cell title=concept-cell>cell</a> in a table.</p> <div class=impl> <p>The <code><a href=#the-td-element>td</a></code> element and its <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>, <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>, and <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attributes take part in the <a href=#table-model>table model</a>.</p> </div> <h4 id=the-th-element><span class=secno>4.9.10 </span>The <dfn><code>th</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-tr-element>tr</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code>, <code><a href=#the-footer-element>footer</a></code>, <a href=#sectioning-content>sectioning content</a>, or <a href=#heading-content>heading content</a> descendants.</dd> <!-- EDITING NOTE: If you remove 'heading content' from the list above, make sure to fix the definition of 'sectioning root' to include <th> --> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code></dd> <dd><code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code></dd> <dd><code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code></dd> <dd><code title=attr-th-scope><a href=#attr-th-scope>scope</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltableheadercellelement>HTMLTableHeaderCellElement</dfn> : <a href=#htmltablecellelement>HTMLTableCellElement</a> { attribute DOMString <a href=#dom-th-scope title=dom-th-scope>scope</a>; };</pre> </dd> </dl><p>The <code><a href=#the-th-element>th</a></code> element <a href=#represents>represents</a> a header <a href=#concept-cell title=concept-cell>cell</a> in a table.</p> <p>The <code><a href=#the-th-element>th</a></code> element may have a <dfn id=attr-th-scope title=attr-th-scope><code>scope</code></dfn> content attribute specified. The <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is an <a href=#enumerated-attribute>enumerated attribute</a> with five states, four of which have explicit keywords:</p> <dl><dt>The <dfn id=attr-th-scope-row title=attr-th-scope-row><code>row</code></dfn> keyword, which maps to the <i>row</i> state</dt> <dd>The <i>row</i> state means the header cell applies to some of the subsequent cells in the same row(s).</dd> <dt>The <dfn id=attr-th-scope-col title=attr-th-scope-col><code>col</code></dfn> keyword, which maps to the <i>column</i> state</dt> <dd>The <i>column</i> state means the header cell applies to some of the subsequent cells in the same column(s).</dd> <dt>The <dfn id=attr-th-scope-rowgroup title=attr-th-scope-rowgroup><code>rowgroup</code></dfn> keyword, which maps to the <i>row group</i> state</dt> <dd>The <i>row group</i> state means the header cell applies to all the remaining cells in the row group. A <code><a href=#the-th-element>th</a></code> element's <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute must not be in the <a href=#attr-th-scope-rowgroup title=attr-th-scope-rowgroup>row group</a> state if the element is not anchored in a <a href=#concept-row-group title=concept-row-group>row group</a>.</dd> <dt>The <dfn id=attr-th-scope-colgroup title=attr-th-scope-colgroup><code>colgroup</code></dfn> keyword, which maps to the <i>column group</i> state</dt> <dd>The <i>column group</i> state means the header cell applies to all the remaining cells in the column group. A <code><a href=#the-th-element>th</a></code> element's <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute must not be in the <a href=#attr-th-scope-colgroup title=attr-th-scope-colgroup>column group</a> state if the element is not anchored in a <a href=#concept-column-group title=concept-column-group>column group</a>.</dd> <dt>The <dfn id=attr-th-scope-auto title=attr-th-scope-auto>auto</dfn> state</dt> <dd>The <i>auto</i> state makes the header cell apply to a set of cells selected based on context.</dd> </dl><p>The <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute's <i>missing value default</i> is the <i>auto</i> state.</p> <div class=impl> <p>The <code><a href=#the-th-element>th</a></code> element and its <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>, <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>, <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code>, and <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attributes take part in the <a href=#table-model>table model</a>.</p> <p>The <dfn id=dom-th-scope title=dom-th-scope><code>scope</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> </div> <div class=example> <p>The following example shows how the <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute's <code title=attr-th-scope-rowgroup><a href=#attr-th-scope-rowgroup>rowgroup</a></code> value affects which data cells a header cell applies to.</p> <p>Here is a markup fragment showing a table:</p> <pre><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></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 title=attr-th-scope><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> <!-- image source: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/151 --> <img alt="" height=256 src=http://images.whatwg.org/table-scope-diagram.png width=459><!-- (alt is empty because the diagram is completely described by the previous paragraphs) --></div> <h4 id=attributes-common-to-td-and-th-elements><span class=secno>4.9.11 </span>Attributes common to <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</h4> <p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements may have a <dfn id=attr-tdth-colspan title=attr-tdth-colspan><code>colspan</code></dfn> content attribute specified, whose value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero.</p> <p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements may also have a <dfn id=attr-tdth-rowspan title=attr-tdth-rowspan><code>rowspan</code></dfn> content attribute specified, whose value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a>.</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<span class=impl>, as described in the description of the <a href=#table-model>table model</a></span>.</p> <!-- conformance criteria for determining when this is violated are given in the processing model --> <hr><p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> element may have a <dfn id=attr-tdth-headers title=attr-tdth-headers><code>headers</code></dfn> content attribute specified. The <code title=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>unordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, each of which must have the value of an <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#the-th-element>th</a></code> element taking part in the same <a href=#concept-table title=concept-table>table</a> as the <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element<span class=impl> (as defined by the <a href=#table-model>table model</a>)</span>.</p> <p>A <code><a href=#the-th-element>th</a></code> element with <a href=#concept-id title=concept-id>ID</a> <var title="">id</var> is said to be <i>directly targeted</i> by all <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements in the same <a href=#concept-table title=concept-table>table</a> that have <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attributes whose values include as one of their tokens the <a href=#concept-id title=concept-id>ID</a> <var title="">id</var>. A <code><a href=#the-th-element>th</a></code> element <var title="">A</var> is said to be <i>targeted</i> by a <code><a href=#the-th-element>th</a></code> or <code><a href=#the-td-element>td</a></code> element <var title="">B</var> if either <var title="">A</var> is <i>directly targeted</i> by <var title="">B</var> or if there exists an element <var title="">C</var> that is itself <i>targeted</i> by the element <var title="">B</var> and <var title="">A</var> is <i>directly targeted</i> by <var title="">C</var>.</p> <p>A <code><a href=#the-th-element>th</a></code> element must not be <i>targeted</i> by itself.</p> <div class=impl> <p>The <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>, <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>, and <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attributes take part in the <a href=#table-model>table model</a>.</p> </div> <hr><p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements implement interfaces that inherit from the <code><a href=#htmltablecellelement>HTMLTableCellElement</a></code> interface:</p> <pre class=idl>interface <dfn id=htmltablecellelement>HTMLTableCellElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute unsigned long <a href=#dom-tdth-colspan title=dom-tdth-colSpan>colSpan</a>; attribute unsigned long <a href=#dom-tdth-rowspan title=dom-tdth-rowSpan>rowSpan</a>; [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-tdth-headers title=dom-tdth-headers>headers</a>; readonly attribute long <a href=#dom-tdth-cellindex title=dom-tdth-cellIndex>cellIndex</a>; };</pre> <dl class=domintro><dt><var title="">cell</var> . <code title=dom-tdth-cellIndex><a href=#dom-tdth-cellindex>cellIndex</a></code></dt> <dd> <p>Returns the position of the cell in the row's <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> list. This does not necessarily correspond to the <var title="">x</var>-position of the cell in the table, since earlier cells might cover multiple rows or columns.</p> <p>Returns 0 if the element isn't in a row.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-tdth-colspan title=dom-tdth-colSpan><code>colSpan</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code> content attribute. The value must be <a href=#limited-to-only-non-negative-numbers-greater-than-zero>limited to only non-negative numbers greater than zero</a>.</p> <p>The <dfn id=dom-tdth-rowspan title=dom-tdth-rowSpan><code>rowSpan</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code> content attribute. Its default value, which must be used if <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">parsing the attribute as a non-negative integer</a> returns an error, is 1.</p> <p>The <dfn id=dom-tdth-headers title=dom-tdth-headers><code>headers</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-tdth-cellindex title=dom-tdth-cellIndex><code>cellIndex</code></dfn> IDL attribute must, if the element has a parent <code><a href=#the-tr-element>tr</a></code> element, return the index of the cell's element in the parent element's <code title=dom-tr-cells><a href=#dom-tr-cells>cells</a></code> collection. If there is no such parent element, then the attribute must return 0.</p> </div> <div class=impl> <h4 id=processing-model-0><span class=secno>4.9.12 </span>Processing model</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 title=concept-table>table</dfn> consists of cells aligned on a two-dimensional grid of <dfn id=concept-slots title=concept-slots>slots</dfn> with coordinates (<var title="">x</var>, <var title="">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 title="">x</var> coordinates are always in the range <span title="">0 ≤ <var title="">x</var> < <var title="">x<sub title="">width</sub></var></span>, and the <var title="">y</var> coordinates are always in the range <span title="">0 ≤ <var title="">y</var> < <var title="">y<sub title="">height</sub></var></span>. If one or both of <var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var> are zero, then the table is empty (has no slots). Tables correspond to <code><a href=#the-table-element>table</a></code> elements.</p> <p>A <dfn id=concept-cell title=concept-cell>cell</dfn> is a set of slots anchored at a slot (<var title="">cell<sub title="">x</sub></var>, <var title="">cell<sub title="">y</sub></var>), and with a particular <var title="">width</var> and <var title="">height</var> such that the cell covers all the slots with coordinates (<var title="">x</var>, <var title="">y</var>) where <span title=""><var title="">cell<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">cell<sub title="">x</sub></var>+<var title="">width</var></span> and <span title=""><var title="">cell<sub title="">y</sub></var> ≤ <var title="">y</var> < <var title="">cell<sub title="">y</sub></var>+<var title="">height</var></span>. Cells can either be <em>data cells</em> or <em>header cells</em>. Data cells correspond to <code><a href=#the-td-element>td</a></code> elements, and header cells correspond to <code><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 title=concept-row>row</dfn> is a complete set of slots from <span title=""><var title="">x</var>=0</span> to <span title=""><var title="">x</var>=<var title="">x<sub title="">width</sub></var>-1</span>, for a particular value of <var title="">y</var>. Rows correspond to <code><a href=#the-tr-element>tr</a></code> elements.</p> <p>A <dfn id=concept-column title=concept-column>column</dfn> is a complete set of slots from <span title=""><var title="">y</var>=0</span> to <span title=""><var title="">y</var>=<var title="">y<sub title="">height</sub></var>-1</span>, for a particular value of <var title="">x</var>. Columns can correspond to <code><a href=#the-col-element>col</a></code> elements. In the absence of <code><a href=#the-col-element>col</a></code> elements, columns are implied.</p> <p>A <dfn id=concept-row-group title=concept-row-group>row group</dfn> is a set of <a href=#concept-row title=concept-row>rows</a> anchored at a slot (0, <var title="">group<sub title="">y</sub></var>) with a particular <var title="">height</var> such that the row group covers all the slots with coordinates (<var title="">x</var>, <var title="">y</var>) where <span title="">0 ≤ <var title="">x</var> < <var title="">x<sub title="">width</sub></var></span> and <span title=""><var title="">group<sub title="">y</sub></var> ≤ <var title="">y</var> < <var title="">group<sub title="">y</sub></var>+<var title="">height</var></span>. Row groups correspond to <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><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 title=concept-column-group>column group</dfn> is a set of <a href=#concept-column title=concept-column>columns</a> anchored at a slot (<var title="">group<sub title="">x</sub></var>, 0) with a particular <var title="">width</var> such that the column group covers all the slots with coordinates (<var title="">x</var>, <var title="">y</var>) where <span title=""><var title="">group<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">group<sub title="">x</sub></var>+<var title="">width</var></span> and <span title="">0 ≤ <var title="">y</var> < <var title="">y<sub title="">height</sub></var></span>. Column groups correspond to <code><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 title=concept-row-group>Row groups</a> cannot overlap each other. Similarly, <a href=#concept-column-group title=concept-column-group>column groups</a> cannot overlap each other.</p> <p>A <a href=#concept-cell title=concept-cell>cell</a> cannot cover slots that are from two or more <a href=#concept-row-group title=concept-row-group>row groups</a>. It is, however, possible for a cell to be in multiple <a href=#concept-column-group title=concept-column-group>column groups</a>. All the slots that form part of one cell are part of zero or one <a href=#concept-row-group title=concept-row-group>row groups</a> and zero or more <a href=#concept-column-group title=concept-column-group>column groups</a>.</p> <p>In addition to <a href=#concept-cell title=concept-cell>cells</a>, <a href=#concept-column title=concept-column>columns</a>, <a href=#concept-row title=concept-row>rows</a>, <a href=#concept-row-group title=concept-row-group>row groups</a>, and <a href=#concept-column-group title=concept-column-group>column groups</a>, <a href=#concept-table title=concept-table>tables</a> can have a <code><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><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</h5> <p>To determine which elements correspond to which slots in a <a href=#concept-table title=concept-table>table</a> associated with a <code><a href=#the-table-element>table</a></code> element, to determine the dimensions of the table (<var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var>), and to determine if there are any <a href=#table-model-error title="table model error">table model errors</a>, user agents must use the following algorithm:</p> <ol><li> <p>Let <var title="">x<sub title="">width</sub></var> be zero.</p> </li> <li> <p>Let <var title="">y<sub title="">height</sub></var> be zero.</p> </li> <li> <p>Let <var title="">pending <code><a href=#the-tfoot-element>tfoot</a></code> elements</var> be a list of <code><a href=#the-tfoot-element>tfoot</a></code> elements, initially empty.</p> </li> <li> <p>Let <var title="">the table</var> be the <a href=#concept-table title=concept-table>table</a> represented by the <code><a href=#the-table-element>table</a></code> element. The <var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var> variables give <var title="">the table</var>'s dimensions. <var title="">The table</var> is initially empty.</p> </li> <li> <!-- this step is here just so that we can be sure to have a first element in the next step, so that we can set up the "advance" exception-handling thingy below; otherwise it'd be more complicated. it's not a perf optimization per se. --> <p>If the <code><a href=#the-table-element>table</a></code> element has no children elements, then return <var title="">the table</var> (which will be empty), and abort these steps.</p> </li> <li> <p>Associate the first <code><a href=#the-caption-element>caption</a></code> element child of the <code><a href=#the-table-element>table</a></code> element with <var title="">the table</var>. If there are no such children, then it has no associated <code><a href=#the-caption-element>caption</a></code> element.</p> </li> <li> <p>Let the <var title="">current element</var> be the first element child of the <code><a href=#the-table-element>table</a></code> element.</p> <p>If a step in this algorithm ever requires the <var title="">current element</var> to be <dfn id=concept-table-advance title=concept-table-advance>advanced to the next child of the <code>table</code></dfn> when there is no such next child, then the user agent must jump to the step labeled <i>end</i>, near the end of this algorithm.</p> </li> <li> <p>While the <var title="">current element</var> is not one of the following elements, <a href=#concept-table-advance title=concept-table-advance>advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>:</p> <ul class=brief><li><code><a href=#the-colgroup-element>colgroup</a></code></li> <li><code><a href=#the-thead-element>thead</a></code></li> <li><code><a href=#the-tbody-element>tbody</a></code></li> <li><code><a href=#the-tfoot-element>tfoot</a></code></li> <li><code><a href=#the-tr-element>tr</a></code></li> </ul></li> <li> <p>If the <var title="">current element</var> is a <code><a href=#the-colgroup-element>colgroup</a></code>, follow these substeps:</p> <ol><li> <p><i>Column groups</i>: Process the <var title="">current element</var> according to the appropriate case below:</p> <dl class=switch><dt>If the <var title="">current element</var> has any <code><a href=#the-col-element>col</a></code> element children</dt> <dd> <p>Follow these steps:</p> <ol><li> <p>Let <var title="">x<sub title="">start</sub></var> have the value of <span title=""><var title="">x<sub title="">width</sub></var></span>.</p> </li> <li> <p>Let the <var title="">current column</var> be the first <code><a href=#the-col-element>col</a></code> element child of the <code><a href=#the-colgroup-element>colgroup</a></code> element.</p> </li> <li> <p><i>Columns</i>: If the <var title="">current column</var> <code><a href=#the-col-element>col</a></code> element has a <code title=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>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 title="">span</var> be that value.</p> <p>Otherwise, if the <code><a href=#the-col-element>col</a></code> element has no <code title=attr-col-span><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 title="">span</var> be 1.</p> </li> <li> <p>Increase <var title="">x<sub title="">width</sub></var> by <var title="">span</var>.</p> </li> <li> <p>Let the last <var title="">span</var> <a href=#concept-column title=concept-column>columns</a> in <var title="">the table</var> correspond to the <var title="">current column</var> <code><a href=#the-col-element>col</a></code> element.</p> </li> <li> <p>If <var title="">current column</var> is not the last <code><a href=#the-col-element>col</a></code> element child of the <code><a href=#the-colgroup-element>colgroup</a></code> element, then let the <var title="">current column</var> be the next <code><a href=#the-col-element>col</a></code> element child of the <code><a href=#the-colgroup-element>colgroup</a></code> element, and return to the step labeled <i>columns</i>.</p> </li> <li> <p>Let all the last <a href=#concept-column title=concept-column>columns</a> in <var title="">the table</var> from <span title="">x=<var title="">x<sub title="">start</sub></var></span> to <span title="">x=<var title="">x<sub title="">width</sub></var>-1</span> form a new <a href=#concept-column-group title=concept-column-group>column group</a>, anchored at the slot (<var title="">x<sub title="">start</sub></var>, 0), with width <span title=""><var title="">x<sub title="">width</sub></var>-<var title="">x<sub title="">start</sub></var></span>, corresponding to the <code><a href=#the-colgroup-element>colgroup</a></code> element.</p> </li> </ol></dd> <dt>If the <var title="">current element</var> has no <code><a href=#the-col-element>col</a></code> element children</dt> <dd> <ol><li> <p>If the <code><a href=#the-colgroup-element>colgroup</a></code> element has a <code title=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>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 title="">span</var> be that value.</p> <p>Otherwise, if the <code><a href=#the-colgroup-element>colgroup</a></code> element has no <code title=attr-colgroup-span><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 title="">span</var> be 1.</p> </li> <li> <p>Increase <var title="">x<sub title="">width</sub></var> by <var title="">span</var>.</p> </li> <li> <p>Let the last <var title="">span</var> <a href=#concept-column title=concept-column>columns</a> in <var title="">the table</var> form a new <a href=#concept-column-group title=concept-column-group>column group</a>, anchored at the slot (<span title=""><var title="">x<sub title="">width</sub></var>-<var title="">span</var></span>, 0), with width <var title="">span</var>, corresponding to the <code><a href=#the-colgroup-element>colgroup</a></code> element.</p> </li> </ol></dd> </dl></li> <li> <p><a href=#concept-table-advance title=concept-table-advance>Advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>.</p> </li> <li> <p>While the <var title="">current element</var> is not one of the following elements, <a href=#concept-table-advance title=concept-table-advance>advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>:</p> <ul class=brief><li><code><a href=#the-colgroup-element>colgroup</a></code></li> <li><code><a href=#the-thead-element>thead</a></code></li> <li><code><a href=#the-tbody-element>tbody</a></code></li> <li><code><a href=#the-tfoot-element>tfoot</a></code></li> <li><code><a href=#the-tr-element>tr</a></code></li> </ul></li> <li> <p>If the <var title="">current element</var> is a <code><a href=#the-colgroup-element>colgroup</a></code> element, jump to the step labeled <i>column groups</i> above.</p> </li> </ol></li> <li> <p>Let <var title="">y<sub title="">current</sub></var> be zero.</p> </li> <li> <p>Let the <var title="">list of downward-growing cells</var> be an empty list.</p> </li> <li> <p><i>Rows</i>: While the <var title="">current element</var> is not one of the following elements, <a href=#concept-table-advance title=concept-table-advance>advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>:</p> <ul class=brief><li><code><a href=#the-thead-element>thead</a></code></li> <li><code><a href=#the-tbody-element>tbody</a></code></li> <li><code><a href=#the-tfoot-element>tfoot</a></code></li> <li><code><a href=#the-tr-element>tr</a></code></li> </ul></li> <li> <p>If the <var title="">current element</var> is a <code><a href=#the-tr-element>tr</a></code>, then run the <a href=#algorithm-for-processing-rows>algorithm for processing rows</a>, <a href=#concept-table-advance title=concept-table-advance>advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>, and return to the step labeled <i>rows</i>.</p> </li> <li> <p>Run the <a href=#algorithm-for-ending-a-row-group>algorithm for ending a row group</a>.</p> </li> <li> <p>If the <var title="">current element</var> is a <code><a href=#the-tfoot-element>tfoot</a></code>, then add that element to the list of <var title="">pending <code><a href=#the-tfoot-element>tfoot</a></code> elements</var>, <a href=#concept-table-advance title=concept-table-advance>advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>, and return to the step labeled <i>rows</i>.</p> </li> <li> <p>The <var title="">current element</var> is either a <code><a href=#the-thead-element>thead</a></code> or a <code><a href=#the-tbody-element>tbody</a></code>.</p> <p>Run the <a href=#algorithm-for-processing-row-groups>algorithm for processing row groups</a>.</p> </li> <li> <p><a href=#concept-table-advance title=concept-table-advance>Advance</a> the <var title="">current element</var> to the next child of the <code><a href=#the-table-element>table</a></code>.</p> </li> <li> <p>Return to the step labeled <i>rows</i>.</p> </li> <li> <p><i>End</i>: For each <code><a href=#the-tfoot-element>tfoot</a></code> element in the list of <var title="">pending <code><a href=#the-tfoot-element>tfoot</a></code> elements</var>, in tree order, run the <a href=#algorithm-for-processing-row-groups>algorithm for processing row groups</a>.</p> </li> <li> <p>If there exists a <a href=#concept-row title=concept-row>row</a> or <a href=#concept-column title=concept-column>column</a> in <var title="">the table</var> containing only <a href=#concept-slots title=concept-slots>slots</a> that do not have a <a href=#concept-cell title=concept-cell>cell</a> anchored to them, then this is a <a href=#table-model-error>table model error</a>.</p> </li> <li> <p>Return <var title="">the table</var>.</p> </li> </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><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements, is:</p> <ol><li> <p>Let <var title="">y<sub title="">start</sub></var> have the value of <var title="">y<sub title="">height</sub></var>.</p> </li> <li> <p>For each <code><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>algorithm for processing rows</a>.</p> </li> <li> <!-- if we added any rows, make them part of a row group --> <p>If <span title=""><var title="">y<sub title="">height</sub></var> > <var title="">y<sub title="">start</sub></var></span>, then let all the last <a href=#concept-row title=concept-row>rows</a> in <var title="">the table</var> from <span title="">y=<var title="">y<sub title="">start</sub></var></span> to <span title="">y=<var title="">y<sub title="">height</sub></var>-1</span> form a new <a href=#concept-row-group title=concept-row-group>row group</a>, anchored at the slot with coordinate (0, <var title="">y<sub title="">start</sub></var>), with height <span title=""><var title="">y<sub title="">height</sub></var>-<var title="">y<sub title="">start</sub></var></span>, corresponding to the element being processed.</p> </li> <li> <p>Run the <a href=#algorithm-for-ending-a-row-group>algorithm for ending a row group</a>.</p> </li> </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 title="">y<sub title="">current</sub></var> is less than <var title="">y<sub title="">height</sub></var>, follow these steps:</p> <ol><li> <p>Run the <a href=#algorithm-for-growing-downward-growing-cells>algorithm for growing downward-growing cells</a>.</p> </li> <li> <p>Increase <var title="">y<sub title="">current</sub></var> by 1.</p> </li> </ol></li> <li> <p>Empty the <var title="">list of downward-growing cells</var>.</p> </li> </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><a href=#the-tr-element>tr</a></code> elements, is:</p> <ol><li> <p>If <var title="">y<sub title="">height</sub></var> is equal to <var title="">y<sub title="">current</sub></var>, then increase <var title="">y<sub title="">height</sub></var> by 1. (<var title="">y<sub title="">current</sub></var> is never <em>greater</em> than <var title="">y<sub title="">height</sub></var>.)</p> </li> <li> <p>Let <var title="">x<sub title="">current</sub></var> be 0.</p> </li> <li> <p>Run the <a href=#algorithm-for-growing-downward-growing-cells>algorithm for growing downward-growing cells</a>.</p> </li> <li> <p>If the <code><a href=#the-tr-element>tr</a></code> element being processed has no <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element children, then increase <var title="">y<sub title="">current</sub></var> by 1, abort this set of steps, and return to the algorithm above.</p> </li> <li> <p>Let <var title="">current cell</var> be the first <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element in the <code><a href=#the-tr-element>tr</a></code> element being processed.</p> </li> <li> <p><i>Cells</i>: While <var title="">x<sub title="">current</sub></var> is less than <var title="">x<sub title="">width</sub></var> and the slot with coordinate (<var title="">x<sub title="">current</sub></var>, <var title="">y<sub title="">current</sub></var>) already has a cell assigned to it, increase <var title="">x<sub title="">current</sub></var> by 1.</p> </li> <li> <p>If <var title="">x<sub title="">current</sub></var> is equal to <var title="">x<sub title="">width</sub></var>, increase <var title="">x<sub title="">width</sub></var> by 1. (<var title="">x<sub title="">current</sub></var> is never <em>greater</em> than <var title="">x<sub title="">width</sub></var>.)</p> </li> <li> <p>If the <var title="">current cell</var> has a <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code> attribute, then <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">parse that attribute's value</a>, and let <var title="">colspan</var> be the result.</p> <p>If parsing that value failed, or returned zero, or if the attribute is absent, then let <var title="">colspan</var> be 1, instead.</p> </li> <li> <p>If the <var title="">current cell</var> has a <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code> attribute, then <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">parse that attribute's value</a>, and let <var title="">rowspan</var> be the result.</p> <p>If parsing that value failed or if the attribute is absent, then let <var title="">rowspan</var> be 1, instead.</p> </li> <li> <p>If <var title="">rowspan</var> is zero, then let <var title="">cell grows downward</var> be true, and set <var title="">rowspan</var> to 1. Otherwise, let <var title="">cell grows downward</var> be false.</p> </li> <li> <p>If <span title=""><var title="">x<sub title="">width</sub></var> < <var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span>, then let <var title="">x<sub title="">width</sub></var> be <span title=""><var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span>.</p> </li> <li> <p>If <span title=""><var title="">y<sub title="">height</sub></var> < <var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span>, then let <var title="">y<sub title="">height</sub></var> be <span title=""><var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span>.</p> </li> <li> <p>Let the slots with coordinates (<var title="">x</var>, <var title="">y</var>) such that <span title=""><var title="">x<sub title="">current</sub></var> ≤ <var title="">x</var> < <var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span> and <span title=""><var title="">y<sub title="">current</sub></var> ≤ <var title="">y</var> < <var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span> be covered by a new <a href=#concept-cell title=concept-cell>cell</a> <var title="">c</var>, anchored at (<var title="">x<sub title="">current</sub></var>, <var title="">y<sub title="">current</sub></var>), which has width <var title="">colspan</var> and height <var title="">rowspan</var>, corresponding to the <var title="">current cell</var> element.</p> <p>If the <var title="">current cell</var> element is a <code><a href=#the-th-element>th</a></code> element, let this new cell <var title="">c</var> be a header cell; otherwise, let it be a data cell.</p> <p>To establish which header cells apply to the <var title="">current cell</var> element, use the <a href=#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 title=concept-cell>cell</a> covering them, then this is a <a href=#table-model-error>table model error</a>. Those slots now have two cells overlapping.</p> </li> <li> <p>If <var title="">cell grows downward</var> is true, then add the tuple {<var title="">c</var>, <var title="">x<sub title="">current</sub></var>, <var title="">colspan</var>} to the <var title="">list of downward-growing cells</var>.</p> </li> <li> <p>Increase <var title="">x<sub title="">current</sub></var> by <var title="">colspan</var>.</p> </li> <li> <p>If <var title="">current cell</var> is the last <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element in the <code><a href=#the-tr-element>tr</a></code> element being processed, then increase <var title="">y<sub title="">current</sub></var> by 1, abort this set of steps, and return to the algorithm above.</p> </li> <li> <p>Let <var title="">current cell</var> be the next <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element in the <code><a href=#the-tr-element>tr</a></code> element being processed.</p> </li> <li> <p>Return to the step labelled <i>cells</i>.</p> </li> </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 title="">cell</var>, <var title="">cell<sub title="">x</sub></var>, <var title="">width</var>} tuple in the <var title="">list of downward-growing cells</var>, if any, extend the <a href=#concept-cell title=concept-cell>cell</a> <var title="">cell</var> so that it also covers the slots with coordinates (<var title="">x</var>, <var title="">y<sub title="">current</sub></var>), where <span title=""><var title="">cell<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">cell<sub title="">x</sub></var>+<var title="">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</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 title="">principal cell</var> is as follows.</p> <ol><!-- INITIALIZATION --><li> <p>Let <var title="">header list</var> be an empty list of cells.</p> </li> <li> <p>Let (<var title="">principal<sub title="">x</sub></var>, <var title="">principal<sub title="">y</sub></var>) be the coordinate of the slot to which the <var title="">principal cell</var> is anchored.</p> </li> <li> <dl class=switch><dt>If the <var title="">principal cell</var> has a <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attribute specified</dt> <dd> <!-- HEADERS="" --> <ol><li> <p>Take the value of the <var title="">principal cell</var>'s <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attribute and <a href=#split-a-string-on-spaces title="split a string on spaces">split it on spaces</a>, letting <var title="">id list</var> be the list of tokens obtained.</p> </li> <li> <!-- support headers="" to <td> for legacy compat --> <!-- note that it's not conforming though --> <p>For each token in the <var title="">id list</var>, if the first element in the <code><a href=#document>Document</a></code> with an <a href=#concept-id title=concept-id>ID</a> equal to the token is a cell in the same <a href=#concept-table title=concept-table>table</a>, and that cell is not the <var title="">principal cell</var>, then add that cell to <var title="">header list</var>.</p> </li> </ol></dd> <dt>If <var title="">principal cell</var> does not have a <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> attribute specified</dt> <dd> <ol><li> <p>Let <var title="">principal<sub title="">width</sub></var> be the width of the <var title="">principal cell</var>.</p> </li> <li> <p>Let <var title="">principal<sub title="">height</sub></var> be the height of the <var title="">principal cell</var>.</p> </li> <!-- HORIZONTAL --> <li> <p>For each value of <var title="">y</var> from <var title="">principal<sub title="">y</sub></var> to <span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span>, run the <a href=#internal-algorithm-for-scanning-and-assigning-header-cells>internal algorithm for scanning and assigning header cells</a>, with the <var title="">principal cell</var>, the <var title="">header list</var>, the initial coordinate (<var title="">principal<sub title="">x</sub></var>,<var title="">y</var>), and the increments <span title="">Δ<var title="">x</var>=−1</span> and <span title="">Δ<var title="">y</var>=0</span>.</p> </li> <!-- VERTICAL --> <li> <p>For each value of <var title="">x</var> from <var title="">principal<sub title="">x</sub></var> to <span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span>, run the <a href=#internal-algorithm-for-scanning-and-assigning-header-cells>internal algorithm for scanning and assigning header cells</a>, with the <var title="">principal cell</var>, the <var title="">header list</var>, the initial coordinate (<var title="">x</var>,<var title="">principal<sub title="">y</sub></var>), and the increments <span title="">Δ<var title="">x</var>=0</span> and <span title="">Δ<var title="">y</var>=−1</span>.</p> </li> <!-- ROW GROUP HEADERS --> <li> <p>If the <var title="">principal cell</var> is anchored in a <a href=#concept-row-group title=concept-row-group>row group</a>, then add all header cells that are <a href=#row-group-header title="row group header">row group headers</a> and are anchored in the same row group with an <var title="">x</var>-coordinate less than or equal to <span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span> and a <var title="">y</var>-coordinate less than or equal to <span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span> to <var title="">header list</var>.</p> <!-- this might introduce principal accidentally; fixed below --> </li> <!-- COLUMN GROUP HEADERS --> <li> <p>If the <var title="">principal cell</var> is anchored in a <a href=#concept-column-group title=concept-column-group>column group</a>, then add all header cells that are <a href=#column-group-header title="column group header">column group headers</a> and are anchored in the same column group with an <var title="">x</var>-coordinate less than or equal to <span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span> and a <var title="">y</var>-coordinate less than or equal to <span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span> to <var title="">header list</var>.</p> <!-- this might introduce principal accidentally; fixed below --> </li> </ol></dd> </dl></li> <!-- CLEANUP --> <li> <p>Remove all the <a href=#empty-cell title="empty cell">empty cells</a> from the <var title="">header list</var>.</p> </li> <li> <p>Remove any duplicates from the <var title="">header list</var>.</p> </li> <li> <p>Remove <var title="">principal cell</var> from the <var title="">header list</var> if it is there.</p> <!-- see "might introduce principal accidentally" above --> </li> <li> <p>Assign the headers in the <var title="">header list</var> to the <var title="">principal cell</var>.</p> </li> </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 title="">principal cell</var>, a <var title="">header list</var>, an initial coordinate (<var title="">initial<sub title="">x</sub></var>, <var title="">initial<sub title="">y</sub></var>), and Δ<var title="">x</var> and Δ<var title="">y</var> increments, is as follows:</p> <ol><li> <p>Let <var title="">x</var> equal <var title="">initial<sub title="">x</sub></var>.</p> </li> <li> <p>Let <var title="">y</var> equal <var title="">initial<sub title="">y</sub></var>.</p> </li> <li> <p>Let <var title="">opaque headers</var> be an empty list of cells.</p> </li> <li> <dl class=switch><dt>If <var title="">principal cell</var> is a header cell</dt> <dd><p>Let <var title="">in header block</var> be true, and let <var title="">headers from current header block</var> be a list of cells containing just the <var title="">principal cell</var>.</dd> <dt>Otherwise</dt> <dd><p>Let <var title="">in header block</var> be false and let <var title="">headers from current header block</var> be an empty list of cells.</p> </dl></li> <li> <p><i>Loop</i>: Increment <var title="">x</var> by Δ<var title="">x</var>; increment <var title="">y</var> by Δ<var title="">y</var>.</p> <p class=note>For each invocation of this algorithm, one of Δ<var title="">x</var> and Δ<var title="">y</var> will be −1, and the other will be 0.</p> </li> <li> <p>If either <var title="">x</var> or <var title="">y</var> is less than 0, then abort this internal algorithm.</p> </li> <li> <p>If there is no cell covering slot (<var title="">x</var>, <var title="">y</var>), or if there is more than one cell covering slot (<var title="">x</var>, <var title="">y</var>), return to the substep labeled <i>loop</i>.</p> </li> <li> <p>Let <var title="">current cell</var> be the cell covering slot (<var title="">x</var>, <var title="">y</var>).</p> </li> <li> <dl class=switch><dt>If <var title="">current cell</var> is a header cell</dt> <dd> <ol><li><p>Set <var title="">in header block</var> to true.</li> <li><p>Add <var title="">current cell</var> to <var title="">headers from current header block</var>.</li> <li><p>Let <var title="">blocked</var> be false.</li> <li> <dl class=switch><dt>If Δ<var title="">x</var> is 0</dt> <dd> <p>If there are any cells in the <var title="">opaque headers</var> list anchored with the same <var title="">x</var>-coordinate as the <var title="">current cell</var>, and with the same width as <var title="">current cell</var>, then let <var title="">blocked</var> be true.</p> <p>If the <var title="">current cell</var> is not a <a href=#column-header>column header</a>, then let <var title="">blocked</var> be true.</p> </dd> <dt>If Δ<var title="">y</var> is 0</dt> <dd> <p>If there are any cells in the <var title="">opaque headers</var> list anchored with the same <var title="">y</var>-coordinate as the <var title="">current cell</var>, and with the same height as <var title="">current cell</var>, then let <var title="">blocked</var> be true.</p> <p>If the <var title="">current cell</var> is not a <a href=#row-header>row header</a>, then let <var title="">blocked</var> be true.</p> </dd> </dl></li> <li><p>If <var title="">blocked</var> is false, then add the <var title="">current cell</var> to the <var title="">headers list</var>.</li> </ol></dd> <dt>If <var title="">current cell</var> is a data cell and <var title="">in header block</var> is true</dt> <dd><p>Set <var title="">in header block</var> to false. Add all the cells in <var title="">headers from current header block</var> to the <var title="">opaque headers</var> list, and empty the <var title="">headers from current header block</var> list.</p> </dl></li> <li> <p>Return to the step labeled <i>loop</i>.</p> </li> </ol><p>A header cell anchored at the slot with coordinate (<var title="">x</var>, <var title="">y</var>) with width <var title="">width</var> and height <var title="">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 title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-col title=attr-th-scope-col>column</a> state, or</li> <li>The cell's <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-auto title=attr-th-scope-auto>auto</a> state, and there are no data cells in any of the cells covering slots with <var title="">y</var>-coordinates <var title="">y</var> .. <span title=""><var title="">y</var>+<var title="">height</var>-1</span>.</li> </ul><p>A header cell anchored at the slot with coordinate (<var title="">x</var>, <var title="">y</var>) with width <var title="">width</var> and height <var title="">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 title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-row title=attr-th-scope-row>row</a> state, or</li> <li>The cell's <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-auto title=attr-th-scope-auto>auto</a> state, the cell is not a <a href=#column-header>column header</a>, and there are no data cells in any of the cells covering slots with <var title="">x</var>-coordinates <var title="">x</var> .. <span title=""><var title="">x</var>+<var title="">width</var>-1</span>.</li> </ul><p>A header cell is said to be a <dfn id=column-group-header>column group header</dfn> if its <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-colgroup title=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 title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute is in the <a href=#attr-th-scope-rowgroup title=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>White_Space</a> characters.</p> </div> <h4 id=examples-0><span class=secno>4.9.13 </span>Examples</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> <!-- Smithsonian physical tables, Volume 71: By Smithsonian Institution, Frederick Eugene Fowle; page 76 --> <!-- from the reprint of the seventh revised edition; publication 2539, published 1921 --> <pre><table> <caption>Specification values: <b>Steel</b>, <b>Castings</b>, Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.</caption> <thead> <tr> <th rowspan=2>Grade.</th> <th rowspan=2>Yield Point.</th> <th colspan=2>Ultimate tensile strength</th> <th rowspan=2>Per cent elong. 50.8mm or 2 in.</th> <th rowspan=2>Per cent reduct. area.</th> </tr> <tr> <th>kg/mm<sup>2</sup></th> <th>lb/in<sup>2</sup></th> </tr> </thead> <tbody> <tr> <td>Hard</td> <td>0.45 ultimate</td> <td>56.2</td> <td>80,000</td> <td>15</td> <td>20</td> </tr> <tr> <td>Medium</td> <td>0.45 ultimate</td> <td>49.2</td> <td>70,000</td> <td>18</td> <td>25</td> </tr> <tr> <td>Soft</td> <td>0.45 ultimate</td> <td>42.2</td> <td>60,000</td> <td>22</td> <td>30</td> </tr> </tbody> </table></pre> <p>This table could look like this:</p> <table id=table-example-1><caption>Specification values: <b>Steel</b>, <b>Castings</b>, Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.</caption> <thead><tr><th rowspan=2>Grade.</th> <th rowspan=2>Yield Point.</th> <th colspan=2>Ultimate tensile strength</th> <th rowspan=2>Per cent elong. 50.8 mm or 2 in.</th> <th rowspan=2>Per cent reduct. area.</th> <tr><th>kg/mm<sup>2</sup></th> <th>lb/in<sup>2</sup></th> <tbody><tr><td>Hard</td> <td>0.45 ultimate</td> <td>56.2</td> <td>80,000</td> <td>15</td> <td>20</td> <tr><td>Medium</td> <td>0.45 ultimate</td> <td>49.2</td> <td>70,000</td> <td>18</td> <td>25</td> <tr><td>Soft</td> <td>0.45 ultimate</td> <td>42.2</td> <td>60,000</td> <td>22</td> <td>30</td> </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><table> <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></pre> <!--HTML4POLICE--><!--FORK--> <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><!--HTML4POLICE--><!--FORK--><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><table> <colgroup> <col> <colgroup> <col> <col> <col> <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></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</h3> <h4 id=introduction-2><span class=secno>4.10.1 </span>Introduction</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 fields, buttons, checkboxes, range controls, or color pickers. 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</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><a href=#the-form-element>form</a></code> element, inside which are placed the controls. Most controls are represented by the <code><a href=#the-input-element>input</a></code> element, which by default provides a one-line text field. To label a control, the <code><a href=#the-label-element>label</a></code> element is used; the label text and the control itself go inside the <code><a href=#the-label-element>label</a></code> element. Each part of a form is considered a <a href=#paragraph>paragraph</a>, and is typically separated from other parts using <code><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><strong><form> <p><label>Customer name: <input></label></p> </form></strong></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><a href=#the-input-element>input</a></code> element, this time with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute with the value <code title=attr-input-type-radio><a href=#radio-button-state>radio</a></code>. To make the radio buttons work as a group, they are given a common name using the <code title=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><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><a href=#the-fieldset-element>fieldset</a></code>, which has to be a <code><a href=#the-legend-element>legend</a></code> element.</p> <pre><form> <p><label>Customer name: <input></label></p> <strong> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset></strong> </form></pre> <p class=note>Changes from the previous step are highlighted.</p> <p>To pick toppings, we can use checkboxes. These use the <code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute with the value <code title=attr-input-type-checkbox><a href=#checkbox-state>checkbox</a></code>:</p> <pre><form> <p><label>Customer name: <input></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset> <strong> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox> Bacon </label></p> <p><label> <input type=checkbox> Extra Cheese </label></p> <p><label> <input type=checkbox> Onion </label></p> <p><label> <input type=checkbox> Mushroom </label></p> </fieldset></strong> </form></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><a href=#the-input-element>input</a></code> elements with their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute set to <code title=attr-input-type-tel><a href=#telephone-state>tel</a></code>) and e-mail addresses (<code><a href=#the-input-element>input</a></code> elements with their <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute set to <code title=attr-input-type-email><a href=#e-mail-state>email</a></code>):</p> <pre><form> <p><label>Customer name: <input></label></p> <strong> <p><label>Telephone: <input type=tel></label></p> <p><label>E-mail address: <input type=email></label></p></strong> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox> Bacon </label></p> <p><label> <input type=checkbox> Extra Cheese </label></p> <p><label> <input type=checkbox> Onion </label></p> <p><label> <input type=checkbox> Mushroom </label></p> </fieldset> </form></pre> <p>We can use an <code><a href=#the-input-element>input</a></code> element with its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute set to <code title=attr-input-type-time><a href=#time-state>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 title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, and <code title=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><form> <p><label>Customer name: <input></label></p> <p><label>Telephone: <input type=tel></label></p> <p><label>E-mail address: <input type=email></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox> Bacon </label></p> <p><label> <input type=checkbox> Extra Cheese </label></p> <p><label> <input type=checkbox> Onion </label></p> <p><label> <input type=checkbox> Mushroom </label></p> </fieldset> <strong> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p></strong> </form></pre> <p>The <code><a href=#the-textarea-element>textarea</a></code> element can be used to provide a free-form text field. In this instance, we are going to use it to provide a space for the customer to give delivery instructions:</p> <pre><form> <p><label>Customer name: <input></label></p> <p><label>Telephone: <input type=tel></label></p> <p><label>E-mail address: <input type=email></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox> Bacon </label></p> <p><label> <input type=checkbox> Extra Cheese </label></p> <p><label> <input type=checkbox> Onion </label></p> <p><label> <input type=checkbox> Mushroom </label></p> </fieldset> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p> <strong> <p><label>Delivery instructions: <textarea></textarea></label></p></strong> </form></pre> <p>Finally, to make the form submittable we use the <code><a href=#the-button-element>button</a></code> element:</p> <pre><form> <p><label>Customer name: <input></label></p> <p><label>Telephone: <input type=tel></label></p> <p><label>E-mail address: <input type=email></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size> Small </label></p> <p><label> <input type=radio name=size> Medium </label></p> <p><label> <input type=radio name=size> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox> Bacon </label></p> <p><label> <input type=checkbox> Extra Cheese </label></p> <p><label> <input type=checkbox> Onion </label></p> <p><label> <input type=checkbox> Mushroom </label></p> </fieldset> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p> <p><label>Delivery instructions: <textarea></textarea></label></p> <strong> <p><button>Submit order</button></p></strong> </form></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</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 title="">https://pizza.example.com/order.cgi</code> is configured to accept submissions using the <code title=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 title="">custname</code></dt> <dd>Customer's name</dd> <dt><code title="">custtel</code></dt> <dd>Customer's telephone number</dd> <dt><code title="">custemail</code></dt> <dd>Customer's e-mail address</dd> <dt><code title="">size</code></dt> <dd>The pizza size, either <code title="">small</code>, <code title="">medium</code>, or <code title="">large</code></dd> <dt><code title="">toppings</code></dt> <dd>The topping, specified once for each selected topping, with the allowed values being <code title="">bacon</code>, <code title="">cheese</code>, <code title="">onion</code>, and <code title="">mushroom</code></dd> <dt><code title="">delivery</code></dt> <dd>The requested delivery time</dd> <dt><code title="">comments</code></dt> <dd>The delivery instructions</dd> </dl><h5 id=configuring-a-form-to-communicate-with-a-server><span class=secno>4.10.1.3 </span>Configuring a form to communicate with a server</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 title=attr-fs-method><a href=#attr-fs-method>method</a></code> attribute is specified on the <code><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 title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code> attribute. You also have to specify the <a href=#url>URL</a> of the service that will handle the submitted data, using the <code title=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 title=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 title=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 title=attr-input-value><a href=#attr-input-value>value</a></code> attribute.</p> <p>Given the settings in the previous section, this all becomes:</p> <pre><form<strong> method="post" enctype="application/x-www-form-urlencoded" action="https://pizza.example.com/order.cgi"</strong>> <p><label>Customer name: <input<strong> name="custname"</strong>></label></p> <p><label>Telephone: <input type=tel<strong> name="custtel"</strong>></label></p> <p><label>E-mail address: <input type=email<strong> name="custemail"</strong>></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size<strong> value="small"</strong>> Small </label></p> <p><label> <input type=radio name=size<strong> value="medium"</strong>> Medium </label></p> <p><label> <input type=radio name=size<strong> value="large"</strong>> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox<strong> name="topping" value="bacon"</strong>> Bacon </label></p> <p><label> <input type=checkbox<strong> name="topping" value="cheese"</strong>> Extra Cheese </label></p> <p><label> <input type=checkbox<strong> name="topping" value="onion"</strong>> Onion </label></p> <p><label> <input type=checkbox<strong> name="topping" value="mushroom"</strong>> Mushroom </label></p> </fieldset> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"<strong> name="delivery"</strong>></label></p> <p><label>Delivery instructions: <textarea<strong> name="comments"</strong>></textarea></label></p> <p><button>Submit order</button></p> </form></pre> <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 field blank, the user agent would submit the following to the online Web service:</p> <pre>custname=Denise+Lawrence&custtel=555-321-8624&custemail=&size=medium&topping=cheese&topping=mushroom&delivery=19%3A00&comments=</pre> <h5 id=client-side-form-validation><span class=secno>4.10.1.4 </span>Client-side form validation</h5> <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 title=attr-input-required><a href=#attr-input-required>required</a></code> attribute, which can be specified on <code><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 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><form method="post" enctype="application/x-www-form-urlencoded" action="https://pizza.example.com/order.cgi"> <p><label>Customer name: <input name="custname"<strong> required</strong>></label></p> <p><label>Telephone: <input type=tel name="custtel"></label></p> <p><label>E-mail address: <input type=email name="custemail"></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size value="small"> Small </label></p> <p><label> <input type=radio name=size value="medium"> Medium </label></p> <p><label> <input type=radio name=size value="large"> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox name="topping" value="bacon"> Bacon </label></p> <p><label> <input type=checkbox name="topping" value="cheese"> Extra Cheese </label></p> <p><label> <input type=checkbox name="topping" value="onion"> Onion </label></p> <p><label> <input type=checkbox name="topping" value="mushroom"> Mushroom </label></p> </fieldset> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900" name="delivery"<strong> required</strong>></label></p> <p><label>Delivery instructions: <textarea name="comments"></textarea></label></p> <p><button>Submit order</button></p> </form></pre> <p>It is also possible to limit the length of the input, using the <code title=attr-fe-maxlength><a href=#attr-fe-maxlength>maxlength</a></code> attribute. By adding this to the <code><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><form method="post" enctype="application/x-www-form-urlencoded" action="https://pizza.example.com/order.cgi"> <p><label>Customer name: <input name="custname" required></label></p> <p><label>Telephone: <input type=tel name="custtel"></label></p> <p><label>E-mail address: <input type=email name="custemail"></label></p> <fieldset> <legend> Pizza Size </legend> <p><label> <input type=radio name=size value="small"> Small </label></p> <p><label> <input type=radio name=size value="medium"> Medium </label></p> <p><label> <input type=radio name=size value="large"> Large </label></p> </fieldset> <fieldset> <legend> Pizza Toppings </legend> <p><label> <input type=checkbox name="topping" value="bacon"> Bacon </label></p> <p><label> <input type=checkbox name="topping" value="cheese"> Extra Cheese </label></p> <p><label> <input type=checkbox name="topping" value="onion"> Onion </label></p> <p><label> <input type=checkbox name="topping" value="mushroom"> Mushroom </label></p> </fieldset> <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900" name="delivery" required></label></p> <p><label>Delivery instructions: <textarea name="comments"<strong> maxlength=1000</strong>></textarea></label></p> <p><button>Submit order</button></p> </form></pre> <h4 id=categories><span class=secno>4.10.2 </span>Categories</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>flow content</a>, <a href=#phrasing-content>phrasing content</a>, and <a href=#interactive-content>interactive content</a>.</p> <p>A number of the elements are <dfn id=form-associated-element title="form-associated element">form-associated elements</dfn>, which means they can have a <a href=#form-owner>form owner</a> and, to expose this, have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> content attribute with a matching <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-fieldset-element>fieldset</a></code></li> <li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-label-element>label</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> </ul><p>The <a href=#form-associated-element title="form-associated element">form-associated elements</a> fall into several subcategories:</p> <dl><dt><dfn id=category-listed title=category-listed>Listed elements</dfn></dt> <dd> <p>Denotes elements that are listed in the <code title=dom-form-elements><a href=#dom-form-elements><var title="">form</var>.elements</a></code> and <code title=dom-fieldset-elements><a href=#dom-fieldset-elements><var title="">fieldset</var>.elements</a></code> APIs.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-fieldset-element>fieldset</a></code></li> <li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> </ul></dd> <dt><dfn id=category-submit title=category-submit>Submittable elements</dfn></dt> <dd> <p>Denotes elements that can be used for <a href=#constructing-form-data-set>constructing the form data set</a> when a <code><a href=#the-form-element>form</a></code> element is <a href=#concept-form-submit title=concept-form-submit>submitted</a>.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-object-element>object</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> </ul><p>Some <a href=#category-submit title=category-submit>submittable elements</a> can be, depending on their attributes, <dfn id=concept-button title=concept-button>buttons</dfn>. The prose below defines when an element is a button. Some buttons are specifically <dfn id=concept-submit-button title=concept-submit-button>submit buttons</dfn>.</p> </dd> <dt><dfn id=category-reset title=category-reset>Resettable elements</dfn></dt> <dd> <p>Denotes elements that can be affected when a <code><a href=#the-form-element>form</a></code> element is <a href=#concept-form-reset title=concept-form-reset>reset</a>.</p> <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-input-element>input</a></code></li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> </ul></dd> </dl><p>Some elements, not all of them <a href=#form-associated-element title="form-associated element">form-associated</a>, are categorized as <dfn id=category-label title=category-label>labelable elements</dfn>. These are elements that can be associated with a <code><a href=#the-label-element>label</a></code> element. <!-- when updating this also update the category index --> <ul class="brief category-list"><li><code><a href=#the-button-element>button</a></code></li> <li><code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state)</li> <li><code><a href=#the-keygen-element>keygen</a></code></li> <li><code><a href=#the-meter-element>meter</a></code></li> <li><code><a href=#the-output-element>output</a></code></li> <li><code><a href=#the-progress-element>progress</a></code></li> <li><code><a href=#the-select-element>select</a></code></li> <li><code><a href=#the-textarea-element>textarea</a></code></li> </ul><h4 id=the-form-element><span class=secno>4.10.3 </span>The <dfn><code>form</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-form-element>form</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code></dd> <dd><code title=attr-fs-action><a href=#attr-fs-action>action</a></code></dd> <dd><code title=attr-form-autocomplete><a href=#attr-form-autocomplete>autocomplete</a></code></dd> <dd><code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code></dd> <dd><code title=attr-fs-method><a href=#attr-fs-method>method</a></code></dd> <dd><code title=attr-form-name><a href=#attr-form-name>name</a></code></dd> <dd><code title=attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code></dd> <dd><code title=attr-fs-target><a href=#attr-fs-target>target</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>[OverrideBuiltins] interface <dfn id=htmlformelement>HTMLFormElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-form-acceptcharset title=dom-form-acceptCharset>acceptCharset</a>; attribute DOMString <a href=#dom-fs-action title=dom-fs-action>action</a>; attribute DOMString <a href=#dom-form-autocomplete title=dom-form-autocomplete>autocomplete</a>; attribute DOMString <a href=#dom-fs-enctype title=dom-fs-enctype>enctype</a>; attribute DOMString <a href=#dom-fs-encoding title=dom-fs-encoding>encoding</a>;<!-- historical artefact --> attribute DOMString <a href=#dom-fs-method title=dom-fs-method>method</a>; attribute DOMString <a href=#dom-form-name title=dom-form-name>name</a>; attribute boolean <a href=#dom-fs-novalidate title=dom-fs-noValidate>noValidate</a>; attribute DOMString <a href=#dom-fs-target title=dom-fs-target>target</a>; readonly attribute <a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a> <a href=#dom-form-elements title=dom-form-elements>elements</a>; readonly attribute long <a href=#dom-form-length title=dom-form-length>length</a>; <a href=#dom-form-item title=dom-form-item>getter</a> <a href=#element>Element</a> (unsigned long index); <a href=#dom-form-nameditem title=dom-form-namedItem>getter</a> object (DOMString name); void <a href=#dom-form-submit title=dom-form-submit>submit</a>(); void <a href=#dom-form-reset title=dom-form-reset>reset</a>(); boolean <a href=#dom-form-checkvalidity title=dom-form-checkValidity>checkValidity</a>(); };</pre> </dd> </dl><p>The <code><a href=#the-form-element>form</a></code> element <a href=#represents>represents</a> a collection of <a href=#form-associated-element title="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 title=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>ordered set of unique space-separated tokens</a> that are <a href=#ascii-case-insensitive>ASCII case-insensitive</a>, and each token must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the <a href=#preferred-mime-name>preferred MIME name</a> of an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>. <a href=#refsIANACHARSET>[IANACHARSET]</a></p> <p>The <dfn id=attr-form-name title=attr-form-name><code>name</code></dfn> attribute represents the <code><a href=#the-form-element>form</a></code>'s name within the <code title=dom-document-forms><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><a href=#the-form-element>form</a></code> elements in the <code title=dom-document-forms><a href=#dom-document-forms>forms</a></code> collection that it is in, if any.</p> <p>The <dfn id=attr-form-autocomplete title=attr-form-autocomplete><code>autocomplete</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a>. The attribute has two states. The <code title=attr-form-autocomplete-on>on</code> keyword maps to the <dfn id=attr-form-autocomplete-on-state title=attr-form-autocomplete-on-state>on</dfn> state, and the <code title=attr-form-autocomplete-off>off</code> keyword maps to the <dfn id=attr-form-autocomplete-off-state title=attr-form-autocomplete-off-state>off</dfn> state. The attribute may also be omitted. The <i>missing value default</i> is the <a href=#attr-form-autocomplete-on-state title=attr-form-autocomplete-on-state>on</a> state. The <a href=#attr-form-autocomplete-off-state title=attr-form-autocomplete-off-state>off</a> state indicates that by default, <code><a href=#the-input-element>input</a></code> elements in the form will have their <a href=#resulting-autocompletion-state>resulting autocompletion state</a> set to <i title="">off</i>; the <a href=#attr-form-autocomplete-on-state title=attr-form-autocomplete-on-state>on</a> state indicates that by default, <code><a href=#the-input-element>input</a></code> elements in the form will have their <a href=#resulting-autocompletion-state>resulting autocompletion state</a> set to <i title="">on</i>.</p> <p>The <code title=attr-fs-action><a href=#attr-fs-action>action</a></code>, <code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code>, <code title=attr-fs-method><a href=#attr-fs-method>method</a></code>, <code title=attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code>, and <code title=attr-fs-target><a href=#attr-fs-target>target</a></code> attributes are <a href=#attributes-for-form-submission>attributes for form submission</a>.</p> <dl class=domintro><dt><var title="">form</var> . <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the form controls in the form (excluding image buttons for historical reasons).</p> </dd> <dt><var title="">form</var> . <code title=dom-form-length><a href=#dom-form-length>length</a></code></dt> <dd> <p>Returns the number of form controls in the form (excluding image buttons for historical reasons).</p> </dd> <dt><var title="">form</var>[<var title="">index</var>]</dt> <dt><var title="">form</var>(<var title="">index</var>)</dt> <dd> <p>Returns the <var title="">index</var>th element in the form (excluding image buttons for historical reasons).</p> </dd> <dt><var title="">form</var>[<var title="">name</var>]</dt> <dt><var title="">form</var>(<var title="">name</var>)</dt> <dd> <p>Returns the form control (or, if there are several, a <code><a href=#nodelist>NodeList</a></code> of the form controls) in the form with the given <a href=#concept-id title=concept-id>ID</a> or <code title=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><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=#concept-id title=concept-id>ID</a> or <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> changes, for as long as the element remains in the <code><a href=#document>Document</a></code>.</p> <p>If there are multiple matching items, then a <code><a href=#nodelist>NodeList</a></code> object containing all those elements is returned.</p> </dd> <dt><var title="">form</var> . <code title=dom-form-submit><a href=#dom-form-submit>submit</a></code>()</dt> <dd> <p>Submits the form.</p> </dd> <dt><var title="">form</var> . <code title=dom-form-reset><a href=#dom-form-reset>reset</a></code>()</dt> <dd> <p>Resets the form.</p> </dd> <dt><var title="">form</var> . <code title=dom-form-checkValidity><a href=#dom-form-checkvalidity>checkValidity</a></code>()</dt> <dd> <p>Returns true if the form's controls are all valid; otherwise, returns false.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-form-autocomplete title=dom-form-autocomplete><code>autocomplete</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> <p>The <dfn id=dom-form-name title=dom-form-name><code>name</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-form-acceptcharset title=dom-form-acceptCharset><code>acceptCharset</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> content attribute.</p> <hr><p>The <dfn id=dom-form-elements title=dom-form-elements><code>elements</code></dfn> IDL attribute must return an <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches <a href=#category-listed title=category-listed>listed elements</a> whose <a href=#form-owner>form owner</a> is the <code><a href=#the-form-element>form</a></code> element, with the exception of <code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-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 title=dom-form-length><code>length</code></dfn> IDL attribute must return the number of nodes <a href=#represented-by-the-collection title="represented by the collection">represented</a> by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection.</p> <p>The <a href=#supported-property-indices>supported property indices</a> at any instant are the indices supported by the object returned by the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> attribute at that instant.</p> <p>When a <code><a href=#the-form-element>form</a></code> element is <dfn id=dom-form-item title=dom-form-item>indexed for indexed property retrieval</dfn>, the user agent must return the value returned by the <code title=dom-HTMLFormControlsCollection-item>item</code> method on the <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code> collection, when invoked with the given index as its argument.</p> <hr><!-- Welcome to crazy town. Population: The Web. --><p>Each <code><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 href=#supported-property-names>supported property names</a> consist of the values of all the <code title=attr-id><a href=#the-id-attribute>id</a></code> and <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attributes of all the <a href=#category-listed title=category-listed>listed elements</a> and <code><a href=#the-img-element>img</a></code> elements that are descendants of the <code><a href=#the-form-element>form</a></code> element, and all the names currently in the <a href=#past-names-map>past names map</a>.</p> <p>When a <code><a href=#the-form-element>form</a></code> element is <dfn id=dom-form-nameditem title=dom-form-namedItem>indexed for named property retrieval</dfn>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">candidates</var> be a <a href=#live>live</a> <code><a href=#nodelist>NodeList</a></code> object containing all the <a href=#category-listed title=category-listed>listed elements</a> that are descendants of the <code><a href=#the-form-element>form</a></code> element and that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute equal to <var title="">name</var>, in <a href=#tree-order>tree order</a>.</li> <li><p>If <var title="">candidates</var> is empty, let <var title="">candidates</var> be a <a href=#live>live</a> <code><a href=#nodelist>NodeList</a></code> object containing all the <code><a href=#the-img-element>img</a></code> elements that are descendants of the <code><a href=#the-form-element>form</a></code> element and that have either an <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute or a <code title=attr-img-name><a href=#attr-img-name>name</a></code> attribute equal to <var title="">name</var>, in <a href=#tree-order>tree order</a>.</li> <li><p>If <var title="">candidates</var> is empty, <var title="">name</var> is the name of one of the entries in the <code><a href=#the-form-element>form</a></code> element's <a href=#past-names-map>past names map</a>: return the object associated with <var title="">name</var> in that map.</li> <li><p>If <var title="">candidates</var> contains more than one node, return <var title="">candidates</var> and abort these steps.</li> <li><p>Otherwise, <var title="">candidates</var> contains exactly one node. Add a mapping from <var title="">name</var> to the node in <var title="">candidates</var> in the <code><a href=#the-form-element>form</a></code> element's <a href=#past-names-map>past names map</a>, replacing the previous entry with the same name, if any.</li> <li><p>Return the node in <var title="">candidates</var>.</li> </ol><p>If an element listed in the <code><a href=#the-form-element>form</a></code> element's <a href=#past-names-map>past names map</a> is removed from the <code><a href=#document>Document</a></code>, then its entries must be removed from the map.</p> <!-- This ridiculous setup is intended to do as much of the right thing while still supporting code written to work in IE7. IE versions prior to IE8 do not update the names on the <form> element collection to match new names when elements are renamed, and there are enough pages that rename elements and then access them by their old name that we have to support this. But we still want to expose them using the new names, so as far as possible we pretend the legacy names aren't there except if there's no other element actually named that way. Removing the element did remove the legacy name in IE7: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Dsubmit%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w(document.forms%5B0%5D.submit)%3B%0A%20w(document.forms%5B0%5D.removeChild(document.getElementsByTagName('input')%5B0%5D))%3B%0A%20w(document.forms%5B0%5D.length)%3B%0A%20try%20%7B%20document.forms%5B0%5D.submit()%3B%20%7D%20catch%20(e)%20%20%7B%20w(e.message)%20%7D%0A%3C%2Fscript%3E There's no interop on what happens when the name was originally a duplicate name, so we don't persist such accesses - at the time of writing, Safari returned the first element, Firefox returned null (as we do), and IE7 returned the original collection: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Da%20id%3Dfirst%3E%3Cinput%20name%3Da%20id%3Dsecond%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w%28document.forms[0].a%29%3B%0A%20document.getElementsByTagName%28%27input%27%29[0].name%20%3D%20%27b%27%3B%0A%20document.getElementsByTagName%28%27input%27%29[1].name%20%3D%20%27b%27%3B%0A%20w%28document.forms[0].length%29%3B%0A%20w%28document.forms[0].a.id%29%3B%0A%3C%2Fscript%3E In addition, the <img> fallback nonsense is similarly here for legacy reasons. As is the exclusion of <input type=image>. Also, check this out: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1220 --> <!-- Now leaving crazy town. --> <hr><p>The <dfn id=dom-form-submit title=dom-form-submit><code>submit()</code></dfn> method, when invoked, must <a href=#concept-form-submit title=concept-form-submit>submit</a> the <code><a href=#the-form-element>form</a></code> element from the <code><a href=#the-form-element>form</a></code> element itself, with the <var title="">submitted from <code title=dom-form-submit><a href=#dom-form-submit>submit()</a></code> method</var> flag set.</p> <p>The <dfn id=dom-form-reset title=dom-form-reset><code>reset()</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>If the <code><a href=#the-form-element>form</a></code> element is marked as <i><a href=#locked-for-reset>locked for reset</a></i>, then abort these steps.</li> <li><p>Mark the <code><a href=#the-form-element>form</a></code> element as <dfn id=locked-for-reset>locked for reset</dfn>.</li> <li><p><a href=#concept-form-reset title=concept-form-reset>Reset</a> the <code><a href=#the-form-element>form</a></code> element.</li> <li><p>Unmark the <code><a href=#the-form-element>form</a></code> element as <i><a href=#locked-for-reset>locked for reset</a></i>.</li> </ol><p>If the <dfn id=dom-form-checkvalidity title=dom-form-checkValidity><code>checkValidity()</code></dfn> method is invoked, the user agent must <a href=#statically-validate-the-constraints>statically validate the constraints</a> of the <code><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> <div class=example> <p>This example shows two search forms:</p> <pre><form action="http://www.google.com/search" method="get"> <label>Google: <input type="search" name="q"></label> <input type="submit" value="Search..."> </form> <form action="http://www.bing.com/search" method="get"> <label>Bing: <input type="search" name="q"></label> <input type="submit" value="Search..."> </form></pre> </div> <h4 id=the-fieldset-element><span class=secno>4.10.4 </span>The <dfn><code>fieldset</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Optionally a <code><a href=#the-legend-element>legend</a></code> element, followed by <a href=#flow-content>flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlfieldsetelement>HTMLFieldSetElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-fieldset-disabled title=dom-fieldset-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; readonly attribute DOMString <a href=#dom-fieldset-type title=dom-fieldset-type>type</a>; readonly attribute <a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a> <a href=#dom-fieldset-elements title=dom-fieldset-elements>elements</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); };</pre> </dd> </dl><p>The <code><a href=#the-fieldset-element>fieldset</a></code> element <a href=#represents>represents</a> a set of form controls optionally grouped under a common name.</p> <p>The name of the group is given by the first <code><a href=#the-legend-element>legend</a></code> element that is a child of the <code><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 title=attr-fieldset-disabled><code>disabled</code></dfn> attribute, when specified, causes all the form control descendants of the <code><a href=#the-fieldset-element>fieldset</a></code> element, excluding those that are descendants of the <code><a href=#the-fieldset-element>fieldset</a></code> element's first <code><a href=#the-legend-element>legend</a></code> element child, if any, to be <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>.</p> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-fieldset-element>fieldset</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name.</p> <dl class=domintro><dt><var title="">fieldset</var> . <code title=dom-fieldset-type><a href=#dom-fieldset-type>type</a></code></dt> <dd> <p>Returns the string "fieldset".</p> </dd> <dt><var title="">fieldset</var> . <code title=dom-form-elements><a href=#dom-form-elements>elements</a></code></dt> <dd> <p>Returns an <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code> of the form controls in the element.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-fieldset-disabled title=dom-fieldset-disabled><code>disabled</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-fieldset-type title=dom-fieldset-type><code>type</code></dfn> IDL attribute must return the string "<code title="">fieldset</code>".</p> <p>The <dfn id=dom-fieldset-elements title=dom-fieldset-elements><code>elements</code></dfn> IDL attribute must return an <code><a href=#htmlformcontrolscollection>HTMLFormControlsCollection</a></code> rooted at the <code><a href=#the-fieldset-element>fieldset</a></code> element, whose filter matches <a href=#category-listed title=category-listed>listed elements</a>.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> <p><strong>Constraint validation</strong>: <code><a href=#the-fieldset-element>fieldset</a></code> elements are always <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <div class=example> <p>This example shows a <code><a href=#the-fieldset-element>fieldset</a></code> element being used to group a set of related controls:</p> <pre><fieldset> <legend>Display</legend> <p><label><input type=radio name=c value=0 checked> Black on White</label> <p><label><input type=radio name=c value=1> White on Black</label> <p><label><input type=checkbox name=g> Use grayscale</label> <p><label>Enhance contrast <input type=range name=e list=contrast min=0 max=100 value=0 step=1></label> <datalist id=contrast> <option label=Normal value=0> <option label=Maximum value=100> </datalist> </fieldset></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 fields and an optional year/month control.</p> <pre><fieldset name="clubfields" disabled> <legend> <label> <input type=checkbox name=club onchange="form.clubfields.disabled = !checked"> Use Club Card </label> </legend> <p><label>Name on card: <input name=clubname required></label></p> <p><label>Card number: <input name=clubnum required pattern="[-0-9]+"></label></p> <p><label>Expiry date: <input name=clubexp type=month></label></p> </fieldset></pre> </div> <div class=example> <p>You can also nest <code><a href=#the-fieldset-element>fieldset</a></code> elements. Here is an example expanding on the previous one that does so:</p> <pre><fieldset name="clubfields" disabled> <legend> <label> <input type=checkbox name=club onchange="form.clubfields.disabled = !checked"> Use Club Card </label> </legend> <p><label>Name on card: <input name=clubname required></label></p> <fieldset name="numfields"> <legend> <label> <input type=radio checked name=clubtype onchange="form.numfields.disabled = !checked"> My card has numbers on it </label> </legend> <p><label>Card number: <input name=clubnum required pattern="[-0-9]+"></label></p> </fieldset> <fieldset name="letfields" disabled> <legend> <label> <input type=radio name=clubtype onchange="form.letfields.disabled = !checked"> My card has letters on it </label> </legend> <p><label>Card code: <input name=clublet required pattern="[A-Za-z]+"></label></p> </fieldset> </fieldset></pre> <p>In this example, if the outer "Use Club Card" checkbox is not checked, everything inside the outer <code><a href=#the-fieldset-element>fieldset</a></code>, including the two radio buttons in the legends of the two nested <code><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><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.5 </span>The <dfn><code>legend</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the first child of a <code><a href=#the-fieldset-element>fieldset</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmllegendelement>HTMLLegendElement</dfn> : <a href=#htmlelement>HTMLElement</a> { readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-legend-form title=dom-legend-form>form</a>; };</pre> </dd> </dl><p>The <code><a href=#the-legend-element>legend</a></code> element <a href=#represents>represents</a> a caption for the rest of the contents of the <code><a href=#the-legend-element>legend</a></code> element's parent <code><a href=#the-fieldset-element>fieldset</a></code> element<span class=impl>, if any</span>.</p> <dl class=domintro><dt><var title="">legend</var> . <code title=dom-legend-form><a href=#dom-legend-form>form</a></code></dt> <dd> <p>Returns the element's <code><a href=#the-form-element>form</a></code> element, if any, or null otherwise.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-legend-form title=dom-legend-form><code>form</code></dfn> IDL attribute's behavior depends on whether the <code><a href=#the-legend-element>legend</a></code> element is in a <code><a href=#the-fieldset-element>fieldset</a></code> element or not. If the <code><a href=#the-legend-element>legend</a></code> has a <code><a href=#the-fieldset-element>fieldset</a></code> element as its parent, then the <code title=dom-legend-form><a href=#dom-legend-form>form</a></code> IDL attribute must return the same value as the <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute on that <code><a href=#the-fieldset-element>fieldset</a></code> element. Otherwise, it must return null.</p> </div> <h4 id=the-label-element><span class=secno>4.10.6 </span>The <dfn><code>label</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#form-associated-element>Form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>, but with no descendant <a href=#category-label title=category-label>labelable elements</a> unless it is the element's <a href=#labeled-control>labeled control</a>, and no descendant <code><a href=#the-label-element>label</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-label-for><a href=#attr-label-for>for</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmllabelelement>HTMLLabelElement</dfn> : <a href=#htmlelement>HTMLElement</a> { readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-label-htmlfor title=dom-label-htmlFor>htmlFor</a>; readonly attribute <a href=#htmlelement>HTMLElement</a>? <a href=#dom-label-control title=dom-label-control>control</a>; };</pre> </dd> </dl><p>The <code><a href=#the-label-element>label</a></code> <a href=#represents>represents</a> a caption in a user interface. The caption can be associated with a specific form control<span class=impl>, known as the <code><a href=#the-label-element>label</a></code> element's <dfn id=labeled-control>labeled control</dfn></span>, either using <code title=attr-label-for><a href=#attr-label-for>for</a></code> attribute, or by putting the form control inside the <code><a href=#the-label-element>label</a></code> element itself.</p> <div class=impl> <p>Except where otherwise specified by the following rules, a <code><a href=#the-label-element>label</a></code> element has no <a href=#labeled-control>labeled control</a>.</p> </div> <p>The <dfn id=attr-label-for title=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=#concept-id title=concept-id>ID</a> of a <a href=#category-label title=category-label>labelable element</a> in the same <code><a href=#document>Document</a></code> as the <code><a href=#the-label-element>label</a></code> element. <span class=impl>If the attribute is specified and there is an element in the <code><a href=#document>Document</a></code> whose <a href=#concept-id title=concept-id>ID</a> is equal to the value of the <code title=attr-label-for><a href=#attr-label-for>for</a></code> attribute, and the first such element is a <a href=#category-label title=category-label>labelable element</a>, then that element is the <code><a href=#the-label-element>label</a></code> element's <a href=#labeled-control>labeled control</a>.</span></p> <div class=impl> <p>If the <code title=attr-label-for><a href=#attr-label-for>for</a></code> attribute is not specified, but the <code><a href=#the-label-element>label</a></code> element has a <a href=#category-label title=category-label>labelable element</a> descendant, then the first such descendant in <a href=#tree-order>tree order</a> is the <code><a href=#the-label-element>label</a></code> element's <a href=#labeled-control>labeled control</a>.</p> <p>The <code><a href=#the-label-element>label</a></code> element's exact default presentation and behavior, in particular what its <a href=#activation-behavior>activation behavior</a> might be, if anything, should match the platform's label behavior. The <a href=#activation-behavior>activation behavior</a> of a <code><a href=#the-label-element>label</a></code> element for events targetted at <a href=#interactive-content>interactive content</a> descendants of a <code><a href=#the-label-element>label</a></code> element, and any descendants of those <a href=#interactive-content>interactive content</a> descendants, must be to do nothing.</p> <!-- activation behaviour need not be dependent on whether the labeled control is being rendered: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/371 --> <div class=example> <p>For example, on platforms where clicking a checkbox label checks the checkbox, clicking the <code><a href=#the-label-element>label</a></code> in the following snippet could trigger the user agent to <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the <code><a href=#the-input-element>input</a></code> element, as if the element itself had been triggered by the user:</p> <pre><label><input type=checkbox name=lost> Lost</label></pre> <p>On other platforms, the behavior might be just to focus the control, or do nothing.</p> </div> </div> <dl class=domintro><dt><var title="">label</var> . <code title=dom-label-control><a href=#dom-label-control>control</a></code></dt> <dd> <p>Returns the form control that is associated with this element.</p> </dd> </dl><p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-label-element>label</a></code> element with its <a href=#form-owner>form owner</a>.</p> <div class=impl> <p>The <dfn id=dom-label-htmlfor title=dom-label-htmlFor><code>htmlFor</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-label-for><a href=#attr-label-for>for</a></code> content attribute.</p> <p>The <dfn id=dom-label-control title=dom-label-control><code>control</code></dfn> IDL attribute must return the <code><a href=#the-label-element>label</a></code> element's <a href=#labeled-control>labeled control</a>, if any, or null if there isn't one.</p> </div> <hr><dl class=domintro><dt><var title="">control</var> . <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code></dt> <dd> <p>Returns a <code><a href=#nodelist>NodeList</a></code> of all the <code><a href=#the-label-element>label</a></code> elements that the form control is associated with.</p> </dd> </dl><div class=impl> <p><a href=#category-label title=category-label>Labelable elements</a> have a <code><a href=#nodelist>NodeList</a></code> object associated with them that represents the list of <code><a href=#the-label-element>label</a></code> elements, in <a href=#tree-order>tree order</a>, whose <a href=#labeled-control>labeled control</a> is the element in question. The <dfn id=dom-lfe-labels title=dom-lfe-labels><code>labels</code></dfn> IDL attribute of <a href=#category-label title=category-label>labelable elements</a>, on getting, must return that <code><a href=#nodelist>NodeList</a></code> object.</p> <p>The <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute is part of the element's forms API.</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><p><label>Full name: <input name=fn> <small>Format: First Last</small></label></p> <p><label>Age: <input name=age type=number min=0></label></p> <p><label>Post code: <input name=pc> <small>Format: AB12 3CD</small></label></p></pre> </div> <h4 id=the-input-element><span class=secno>4.10.7 </span>The <dfn><code>input</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd>If the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state: <a href=#interactive-content>Interactive content</a>.</dd> <dd>If the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state: <a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, <a href=#category-submit title=category-submit>submittable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd>If the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state: <a href=#category-listed title=category-listed>Listed</a>, <a href=#category-submit title=category-submit>submittable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd>If the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-input-accept><a href=#attr-input-accept>accept</a></code></dd> <dd><code title=attr-input-alt><a href=#attr-input-alt>alt</a></code></dd> <dd><code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code></dd> <dd><code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code></dd> <dd><code title=attr-input-checked><a href=#attr-input-checked>checked</a></code></dd> <dd><code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code></dd> <dd><code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code></dd> <dd><code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code></dd> <dd><code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code></dd> <dd><code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code></dd> <dd><code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code></dd> <dd><code title=attr-dim-height><a href=#attr-dim-height>height</a></code></dd> <dd><code title=attr-input-list><a href=#attr-input-list>list</a></code></dd> <dd><code title=attr-input-max><a href=#attr-input-max>max</a></code></dd> <dd><code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code></dd> <dd><code title=attr-input-min><a href=#attr-input-min>min</a></code></dd> <dd><code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dd><code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code></dd> <dd><code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code></dd> <dd><code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code></dd> <dd><code title=attr-input-required><a href=#attr-input-required>required</a></code></dd> <dd><code title=attr-input-size><a href=#attr-input-size>size</a></code></dd> <dd><code title=attr-input-src><a href=#attr-input-src>src</a></code></dd> <dd><code title=attr-input-step><a href=#attr-input-step>step</a></code></dd> <dd><code title=attr-input-type><a href=#attr-input-type>type</a></code></dd> <dd><code title=attr-input-value><a href=#attr-input-value>value</a></code></dd> <dd><code title=attr-dim-width><a href=#attr-dim-width>width</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlinputelement>HTMLInputElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-input-accept title=dom-input-accept>accept</a>; attribute DOMString <a href=#dom-input-alt title=dom-input-alt>alt</a>; attribute DOMString <a href=#dom-input-autocomplete title=dom-input-autocomplete>autocomplete</a>; attribute boolean <a href=#dom-fe-autofocus title=dom-fe-autofocus>autofocus</a>; attribute boolean <a href=#dom-input-defaultchecked title=dom-input-defaultChecked>defaultChecked</a>; attribute boolean <a href=#dom-input-checked title=dom-input-checked>checked</a>; attribute DOMString <a href=#dom-input-dirname title=dom-input-dirName>dirName</a>; attribute boolean <a href=#dom-fe-disabled title=dom-fe-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; readonly attribute <a href=#filelist>FileList</a>? <a href=#dom-input-files title=dom-input-files>files</a>; attribute DOMString <a href=#dom-fs-formaction title=dom-fs-formAction>formAction</a>; attribute DOMString <a href=#dom-fs-formenctype title=dom-fs-formEnctype>formEnctype</a>; attribute DOMString <a href=#dom-fs-formmethod title=dom-fs-formMethod>formMethod</a>; attribute boolean <a href=#dom-fs-formnovalidate title=dom-fs-formNoValidate>formNoValidate</a>; attribute DOMString <a href=#dom-fs-formtarget title=dom-fs-formTarget>formTarget</a>; attribute unsigned long <a href=#dom-input-height title=dom-input-height>height</a>; attribute boolean <a href=#dom-input-indeterminate title=dom-input-indeterminate>indeterminate</a>; readonly attribute <a href=#htmlelement>HTMLElement</a>? <a href=#dom-input-list title=dom-input-list>list</a>; attribute DOMString <a href=#dom-input-max title=dom-input-max>max</a>; attribute long <a href=#dom-input-maxlength title=dom-input-maxLength>maxLength</a>; attribute DOMString <a href=#dom-input-min title=dom-input-min>min</a>; attribute boolean <a href=#dom-input-multiple title=dom-input-multiple>multiple</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; attribute DOMString <a href=#dom-input-pattern title=dom-input-pattern>pattern</a>; attribute DOMString <a href=#dom-input-placeholder title=dom-input-placeholder>placeholder</a>; attribute boolean <a href=#dom-input-readonly title=dom-input-readOnly>readOnly</a>; attribute boolean <a href=#dom-input-required title=dom-input-required>required</a>; attribute unsigned long <a href=#dom-input-size title=dom-input-size>size</a>; attribute DOMString <a href=#dom-input-src title=dom-input-src>src</a>; attribute DOMString <a href=#dom-input-step title=dom-input-step>step</a>; attribute DOMString <a href=#dom-input-type title=dom-input-type>type</a>; attribute DOMString <a href=#dom-input-defaultvalue title=dom-input-defaultValue>defaultValue</a>; attribute DOMString <a href=#dom-input-value title=dom-input-value>value</a>; attribute <span>Date</span> <a href=#dom-input-valueasdate title=dom-input-valueAsDate>valueAsDate</a>; attribute double <a href=#dom-input-valueasnumber title=dom-input-valueAsNumber>valueAsNumber</a>; attribute unsigned long <a href=#dom-input-width title=dom-input-width>width</a>; void <a href=#dom-input-stepup title=dom-input-stepUp>stepUp</a>(optional long n); void <a href=#dom-input-stepdown title=dom-input-stepDown>stepDown</a>(optional long n); readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; void <a href=#dom-textarea/input-select title=dom-textarea/input-select>select</a>(); attribute unsigned long <a href=#dom-textarea/input-selectionstart title=dom-textarea/input-selectionStart>selectionStart</a>; attribute unsigned long <a href=#dom-textarea/input-selectionend title=dom-textarea/input-selectionEnd>selectionEnd</a>; attribute DOMString <a href=#dom-textarea/input-selectiondirection title=dom-textarea/input-selectionDirection>selectionDirection</a>; void <a href=#dom-textarea/input-setselectionrange title=dom-textarea/input-setSelectionRange>setSelectionRange</a>(unsigned long start, unsigned long end, optional DOMString direction); };</pre> </dd> </dl><p>The <code><a href=#the-input-element>input</a></code> element <a href=#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 title=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>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 title=attr-input-type-hidden-keyword><code>hidden</code></dfn> <td> <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> <td> An arbitrary string <td> n/a <tr><td> <dfn id=attr-input-type-text-keyword title=attr-input-type-text-keyword><code>text</code></dfn> <td> <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> <td> Text with no line breaks <td> Text field <tr><td> <dfn id=attr-input-type-search-keyword title=attr-input-type-search-keyword><code>search</code></dfn> <td> <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> <td> Text with no line breaks <td> Search field <tr><td> <dfn id=attr-input-type-tel-keyword title=attr-input-type-tel-keyword><code>tel</code></dfn> <td> <a href=#telephone-state title=attr-input-type-tel>Telephone</a> <td> Text with no line breaks <td> A text field <tr><td> <dfn id=attr-input-type-url-keyword title=attr-input-type-url-keyword><code>url</code></dfn> <td> <a href=#url-state title=attr-input-type-url>URL</a> <td> An absolute IRI <td> A text field <tr><td> <dfn id=attr-input-type-email-keyword title=attr-input-type-email-keyword><code>email</code></dfn> <td> <a href=#e-mail-state title=attr-input-type-email>E-mail</a> <td> An e-mail address or list of e-mail addresses <td> A text field <tr><td> <dfn id=attr-input-type-password-keyword title=attr-input-type-password-keyword><code>password</code></dfn> <td> <a href=#password-state title=attr-input-type-password>Password</a> <td> Text with no line breaks (sensitive information) <td> Text field that obscures data entry <tr><td> <dfn id=attr-input-type-datetime-keyword title=attr-input-type-datetime-keyword><code>datetime</code></dfn> <td> <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> <td> A date and time (year, month, day, hour, minute, second, fraction of a second) with the time zone set to UTC <td> A date and time control <tr><td> <dfn id=attr-input-type-date-keyword title=attr-input-type-date-keyword><code>date</code></dfn> <td> <a href=#date-state title=attr-input-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 title=attr-input-type-month-keyword><code>month</code></dfn> <td> <a href=#month-state title=attr-input-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 title=attr-input-type-week-keyword><code>week</code></dfn> <td> <a href=#week-state title=attr-input-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 title=attr-input-type-time-keyword><code>time</code></dfn> <td> <a href=#time-state title=attr-input-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 title=attr-input-type-datetime-local-keyword><code>datetime-local</code></dfn> <td> <a href=#local-date-and-time-state title=attr-input-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 title=attr-input-type-number-keyword><code>number</code></dfn> <td> <a href=#number-state title=attr-input-type-number>Number</a> <td> A numerical value <td> A text field or spinner control <tr><td> <dfn id=attr-input-type-range-keyword title=attr-input-type-range-keyword><code>range</code></dfn> <td> <a href=#range-state title=attr-input-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 title=attr-input-type-color-keyword><code>color</code></dfn> <td> <a href=#color-state title=attr-input-type-color>Color</a> <td> An sRGB color with 8-bit red, green, and blue components <td> A color well <tr><td> <dfn id=attr-input-type-checkbox-keyword title=attr-input-type-checkbox-keyword><code>checkbox</code></dfn> <td> <a href=#checkbox-state title=attr-input-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 title=attr-input-type-radio-keyword><code>radio</code></dfn> <td> <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> <td> An enumerated value <td> A radio button <tr><td> <dfn id=attr-input-type-file-keyword title=attr-input-type-file-keyword><code>file</code></dfn> <td> <a href=#file-upload-state title=attr-input-type-file>File Upload</a> <td> Zero or more files each with a <a href=#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 title=attr-input-type-submit-keyword><code>submit</code></dfn> <td> <a href=#submit-button-state title=attr-input-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 title=attr-input-type-image-keyword><code>image</code></dfn> <td> <a href=#image-button-state title=attr-input-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 title=attr-input-type-reset-keyword><code>reset</code></dfn> <td> <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a> <td> n/a <td> A button <tr><td> <dfn id=attr-input-type-button-keyword title=attr-input-type-button-keyword><code>button</code></dfn> <td> <a href=#button-state title=attr-input-type-button>Button</a> <td> n/a <td> A button </table><p>The <i>missing value default</i> is the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state.</p> <p>Which of the <code title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, <code title=attr-input-size><a href=#attr-input-size>size</a></code>, <code title=attr-input-src><a href=#attr-input-src>src</a></code>, <code title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> content attributes, the <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code title=dom-input-files><a href=#dom-input-files>files</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code>, and <code title=dom-input-list><a href=#dom-input-list>list</a></code> IDL attributes, the <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> method, the <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, IDL attributes, the <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> method, the <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> and <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> methods, and the <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply to an <code><a href=#the-input-element>input</a></code> element depends on the state of its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute. The following table <span class=impl>is non-normative and</span> summarizes which of those content attributes, IDL attributes, methods, and events apply to each state:</p> <table class=applies id=input-type-attr-summary><thead><tr><th> <th> <span title=""><a href=#hidden-state title=attr-input-type-hidden>Hidden</a></span> <th> <span title=""><a href=#text-state-and-search-state title=attr-input-type-text>Text</a>,</span> <span title=""><a href=#text-state-and-search-state title=attr-input-type-search>Search</a></span> <th> <span title=""><a href=#url-state title=attr-input-type-url>URL</a>,</span> <span title=""><a href=#telephone-state title=attr-input-type-tel>Telephone</a></span> <th> <span title=""><a href=#e-mail-state title=attr-input-type-email>E-mail</a></span> <th> <span title=""><a href=#password-state title=attr-input-type-password>Password</a></span> <th> <span title=""><a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a>,</span> <span title=""><a href=#date-state title=attr-input-type-date>Date</a>,</span> <span title=""><a href=#month-state title=attr-input-type-month>Month</a>,</span> <span title=""><a href=#week-state title=attr-input-type-week>Week</a>,</span> <span title=""><a href=#time-state title=attr-input-type-time>Time</a></span> <th> <span title=""><a href=#local-date-and-time-state title=attr-input-type-datetime-local>Local Date and Time</a></span> <th> <span title=""><a href=#number-state title=attr-input-type-number>Number</a></span> <th> <span title=""><a href=#range-state title=attr-input-type-range>Range</a></span> <th> <span title=""><a href=#color-state title=attr-input-type-color>Color</a></span> <th> <span title=""><a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a>,</span> <span title=""><a href=#radio-button-state title=attr-input-type-radio>Radio Button</a></span> <th> <span title=""><a href=#file-upload-state title=attr-input-type-file>File Upload</a></span> <th> <span title=""><a href=#submit-button-state title=attr-input-type-submit>Submit Button</a></span> <th> <span title=""><a href=#image-button-state title=attr-input-type-image>Image Button</a></span> <th> <span title=""><a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>,</span> <span title=""><a href=#button-state title=attr-input-type-button>Button</a></span> <tbody><tr><th colspan=16 scope=rowgroup>Content attributes <tr><th> <code title=attr-input-accept><a href=#attr-input-accept>accept</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=yes> Yes <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=yes> Yes <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=yes> Yes <!-- Checkbox --> <!-- <td class="yes"> Yes Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=yes> Yes <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=yes> Yes <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=yes> Yes <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=yes> Yes <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=yes> Yes <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-list><a href=#attr-input-list>list</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=yes> Yes <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-max><a href=#attr-input-max>max</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-min><a href=#attr-input-min>min</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <!-- if you change this, you can merge this line with the next to save room on the chart --> <td class=yes> Yes <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=yes> Yes <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-required><a href=#attr-input-required>required</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=yes> Yes <!-- Checkbox --> <!-- <td class="yes"> Yes Radio Button --> <td class=yes> Yes <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-size><a href=#attr-input-size>size</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-src><a href=#attr-input-src>src</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-input-step><a href=#attr-input-step>step</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=yes> Yes <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tbody><tr><th colspan=16 scope=rowgroup>IDL attributes and methods <tr><th> <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=yes> Yes <!-- Checkbox --> <!-- <td class="yes"> Yes Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-input-files><a href=#dom-input-files>files</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=yes> Yes <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr class=impl><th> <code title=dom-input-value><a href=#dom-input-value>value</a></code> <td class=yes> <a href=#dom-input-value-default title=dom-input-value-default>default</a> <!-- Hidden --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Text --> <!-- <td class="yes"> <span title="dom-input-value-value">value</span> Search --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- URL, Telephone --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- E-mail --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Password --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Date and Time --> <!-- <td class="yes"> <span title="dom-input-value-value">value</span> Date --> <!-- <td class="yes"> <span title="dom-input-value-value">value</span> Month --> <!-- <td class="yes"> <span title="dom-input-value-value">value</span> Week --> <!-- <td class="yes"> <span title="dom-input-value-value">value</span> Time --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Local Date and Time --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Number --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Range --> <td class=yes> <a href=#dom-input-value-value title=dom-input-value-value>value</a> <!-- Color --> <td class=yes> <a href=#dom-input-value-default-on title=dom-input-value-default-on>default/on</a> <!-- Checkbox --> <!-- <td class="yes"> <span title="dom-input-value-default-on">default/on</span> Radio Button --> <td class=yes> <a href=#dom-input-value-filename title=dom-input-value-filename>filename</a> <!-- File Upload --> <td class=yes> <a href=#dom-input-value-default title=dom-input-value-default>default</a> <!-- Submit Button --> <td class=yes> <a href=#dom-input-value-default title=dom-input-value-default>default</a> <!-- Image Button --> <td class=yes> <a href=#dom-input-value-default title=dom-input-value-default>default</a> <!-- Reset Button --> <!-- <td class="yes"> <span title="dom-input-value-default">default</span> Button --> <tr><th> <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-input-list><a href=#dom-input-list>list</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=yes> Yes <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=no> · <!-- Date and Time --> <!-- <td class="no"> · Date --> <!-- <td class="no"> · Month --> <!-- <td class="no"> · Week --> <!-- <td class="no"> · Time --> <td class=no> · <!-- Local Date and Time --> <td class=no> · <!-- Number --> <td class=no> · <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> <td class=no> · <!-- Hidden --> <td class=no> · <!-- Text --> <!-- <td class="no"> · Search --> <td class=no> · <!-- URL, Telephone --> <td class=no> · <!-- E-mail --> <td class=no> · <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=no> · <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tbody><tr><th colspan=16 scope=rowgroup>Events <tr><th> <span title=""><code title=event-input-input><a href=#event-input-input>input</a></code> event</span> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=yes> Yes <!-- Color --> <td class=no> · <!-- Checkbox --> <!-- <td class="no"> · Radio Button --> <td class=no> · <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> <tr><th> <span title=""><code title=event-input-change><a href=#event-input-change>change</a></code> event</span> <td class=no> · <!-- Hidden --> <td class=yes> Yes <!-- Text --> <!-- <td class="yes"> Yes Search --> <td class=yes> Yes <!-- URL, Telephone --> <td class=yes> Yes <!-- E-mail --> <td class=yes> Yes <!-- Password --> <td class=yes> Yes <!-- Date and Time --> <!-- <td class="yes"> Yes Date --> <!-- <td class="yes"> Yes Month --> <!-- <td class="yes"> Yes Week --> <!-- <td class="yes"> Yes Time --> <td class=yes> Yes <!-- Local Date and Time --> <td class=yes> Yes <!-- Number --> <td class=yes> Yes <!-- Range --> <td class=yes> Yes <!-- Color --> <td class=yes> Yes <!-- Checkbox --> <!-- <td class="yes"> Yes Radio Button --> <td class=yes> Yes <!-- File Upload --> <td class=no> · <!-- Submit Button --> <td class=no> · <!-- Image Button --> <td class=no> · <!-- Reset Button --> <!-- <td class="no"> · Button --> </table><p class=note>† The dagger symbol (†) indicates that the feature only applies when the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is not specified.</p> <div class=impl> <p>Some states of the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute define a <dfn id=value-sanitization-algorithm>value sanitization algorithm</dfn>.</p> <p>Each <code><a href=#the-input-element>input</a></code> element has a <a href=#concept-fe-value title=concept-fe-value>value</a>, which is exposed by the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute. Some states define an <dfn id=concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</dfn>, an <dfn id=concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</dfn>, an <dfn id=concept-input-value-string-date title=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 title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</dfn>, which are used by <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-step><a href=#attr-input-step>step</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code>, <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code>.</p> <p>Each <code><a href=#the-input-element>input</a></code> element has a boolean <dfn id=concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</dfn>. The <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value 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-value title=concept-fe-value>value</a>. (It is also set to true when the value is programmatically changed, as described in the definition of the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute.)</p> </div> <p>The <dfn id=attr-input-value title=attr-input-value><code>value</code></dfn> content attribute gives the default <a href=#concept-fe-value title=concept-fe-value>value</a> of the <code><a href=#the-input-element>input</a></code> element. <span class=impl>When the <code title=attr-input-value><a href=#attr-input-value>value</a></code> content attribute is added, set, or removed, if the control's <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a> is false, the user agent must set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to the value of the <code title=attr-input-value><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>value sanitization algorithm</a>, if one is defined.</span></p> <div class=impl> <p>Each <code><a href=#the-input-element>input</a></code> element has a <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a>, which is exposed by the <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code> IDL attribute.</p> <p>Each <code><a href=#the-input-element>input</a></code> element has a boolean <dfn id=concept-input-checked-dirty-flag title=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 title=concept-input-checked-dirty><i>dirty checkedness</i></dfn>. The <a href=#concept-input-checked-dirty-flag title=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 title=concept-fe-checked>checkedness</a>.</p> </div> <p>The <dfn id=attr-input-checked title=attr-input-checked><code>checked</code></dfn> content attribute is a <a href=#boolean-attribute>boolean attribute</a> that gives the default <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> of the <code><a href=#the-input-element>input</a></code> element. <span class=impl>When the <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> content attribute is added, if the control does not have <i title=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 title=concept-fe-checked>checkedness</a> of the element to true; when the <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> content attribute is removed, if the control does not have <i title=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 title=concept-fe-checked>checkedness</a> of the element to false.</span></p> <div class=impl> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-input-element>input</a></code> elements is to set the <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a> and <a href=#concept-input-checked-dirty-flag title=concept-input-checked-dirty-flag>dirty checkedness flag</a> back to false, set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to the value of the <code title=attr-input-value><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 title=concept-fe-checked>checkedness</a> of the element to true if the element has a <code title=attr-input-checked><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 title=concept-input-type-file-selected>selected files</a>, and then invoke the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>, if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state defines one.</p> <p>Each <code><a href=#the-input-element>input</a></code> element is either <dfn id=concept-input-mutable title=concept-input-mutable><i>mutable</i></dfn> or <dfn id=concept-input-immutable title=concept-input-immutable><i>immutable</i></dfn>. Except where otherwise specified, an <code><a href=#the-input-element>input</a></code> element is always <i title=concept-input-mutable><a href=#concept-input-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 title=concept-fe-value>value</a> or <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a>.</p> <p>When an <code><a href=#the-input-element>input</a></code> element is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, it is <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i>.</p> <p>When an <code><a href=#the-input-element>input</a></code> element does not have a <code><a href=#document>Document</a></code> node as one of its ancestors (i.e. when it is not in the document), it is <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i>.</p> <!-- XBL2 spec point --> <p class=note>The <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute can also in some cases (e.g. for the <a href=#date-state title=attr-input-type-date>Date</a> state, but not the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state) make an <code><a href=#the-input-element>input</a></code> element <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i>.</p> <p>The <a href=#concept-node-clone-ext title=concept-node-clone-ext>cloning steps</a> for <code><a href=#the-input-element>input</a></code> elements must propagate the <a href=#concept-fe-value title=concept-fe-value>value</a>, <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a>, <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a>, and <a href=#concept-input-checked-dirty-flag title=concept-input-checked-dirty-flag>dirty checkedness flag</a> from the node being cloned to the copy.</p> <hr><p>When an <code><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 title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's state, and the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>, if one is defined for the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's state, must be invoked.</p> </div> <div class=impl id=input-type-change> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute changes state, the user agent must run the following steps:</p> <ol><!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/602 --><li><p>If the previous state of the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute put the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute in the <i title=dom-input-value-value><a href=#dom-input-value-value>value</a></i> mode, and the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is not the empty string, and the new state of the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute puts the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute in either the <i title=dom-input-value-default><a href=#dom-input-value-default>default</a></i> mode or the <i title=dom-input-value-default-on><a href=#dom-input-value-default-on>default/on</a></i> mode, then set the element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> content attribute to the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</li> <li><p>Otherwise, if the previous state of the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute put the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute in any mode other than the <i title=dom-input-value-value><a href=#dom-input-value-value>value</a></i> mode, and the new state of the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute puts the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute in the <i title=dom-input-value-value><a href=#dom-input-value-value>value</a></i> mode, then set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to the value of the <code title=attr-input-value><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-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a> to false.</li> <li><p>Update the element's rendering and behavior to the new state's.</li> <li><p>Invoke the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>, if one is defined for the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's new state.</li> </ol></div> <hr><p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-input-element>input</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name. The <code title=attr-fe-disabled><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 title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.</p> <div class=impl> <p>The <dfn id=dom-input-indeterminate title=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 title=attr-input-type-checkbox>checkbox</a> controls.</p> <p>The <dfn id=dom-input-accept title=dom-input-accept><code>accept</code></dfn>, <dfn id=dom-input-alt title=dom-input-alt><code>alt</code></dfn>, <dfn id=dom-input-max title=dom-input-max><code>max</code></dfn>, <dfn id=dom-input-min title=dom-input-min><code>min</code></dfn>, <dfn id=dom-input-multiple title=dom-input-multiple><code>multiple</code></dfn>, <dfn id=dom-input-pattern title=dom-input-pattern><code>pattern</code></dfn>, <dfn id=dom-input-placeholder title=dom-input-placeholder><code>placeholder</code></dfn>, <dfn id=dom-input-required title=dom-input-required><code>required</code></dfn>, <dfn id=dom-input-size title=dom-input-size><code>size</code></dfn>, <dfn id=dom-input-src title=dom-input-src><code>src</code></dfn>, and <dfn id=dom-input-step title=dom-input-step><code>step</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <dfn id=dom-input-dirname title=dom-input-dirName><code>dirName</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code> content attribute. The <dfn id=dom-input-readonly title=dom-input-readOnly><code>readOnly</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> content attribute. The <dfn id=dom-input-defaultchecked title=dom-input-defaultChecked><code>defaultChecked</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> content attribute. The <dfn id=dom-input-defaultvalue title=dom-input-defaultValue><code>defaultValue</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-input-value><a href=#attr-input-value>value</a></code> content attribute.</p> <p>The <dfn id=dom-input-autocomplete title=dom-input-autocomplete><code>autocomplete</code></dfn> and <dfn id=dom-input-type title=dom-input-type><code>type</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>. The <dfn id=dom-input-maxlength title=dom-input-maxLength><code>maxLength</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> content attribute, <a href=#limited-to-only-non-negative-numbers>limited to only non-negative numbers</a>.</p> <p>The IDL attributes <dfn id=dom-input-width title=dom-input-width><code>width</code></dfn> and <dfn id=dom-input-height title=dom-input-height><code>height</code></dfn> must return the rendered width and height of the image, in CSS pixels, if an image is <a href=#being-rendered>being rendered</a>, and is being rendered to a visual medium; or else the intrinsic width and height of the image, in CSS pixels, if an image is <i title=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 title=input-img-available><a href=#input-img-available>available</a></i>. When the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is not in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, then no image is <i title=input-img-available><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 title=reflect>reflected</a> the respective content attributes of the same name.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods and attributes expose the element's text selection. The <code title=dom-fe-autofocus><a href=#dom-fe-autofocus>autofocus</a></code>, <code title=dom-fe-disabled><a href=#dom-fe-disabled>disabled</a></code>, <code title=dom-fae-form><a href=#dom-fae-form>form</a></code>, and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> </div> <h5 id=states-of-the-type-attribute><span class=secno>4.10.7.1 </span>States of the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute</h5> <h6 id=hidden-state><span class=secno>4.10.7.1.1 </span><dfn title=attr-input-type-hidden>Hidden</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a value that is not intended to be examined or manipulated by the user.</p> <div class=impl> <p><strong>Constraint validation</strong>: If an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state, it is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <p>If the <code title=attr-input-value><a href=#attr-input-value>name</a></code> attribute is present and has a value that is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>", then the element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute must be omitted.</p> <div class=bookkeeping> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute applies to this element and is in mode <a href=#dom-input-value-default title=dom-input-value-default>default</a>.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> and <code class=no-backref title=event-input-change><a href=#event-input-change>change</a></code> events do not apply.</p> </div> <h6 id=text-state-and-search-state><span class=secno>4.10.7.1.2 </span><dfn title=attr-input-type-text>Text</dfn> state and <dfn title=attr-input-type-search>Search</dfn> state</h6> <!-- v2 idea: applying input masks to <input>, e.g. for entering data with slashes and dashes (ack Greg Kilwein) --> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state or the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a one line plain text edit control for the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <p class=note>The difference between the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state and the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state is primarily stylistic: on platforms where search fields are distinguished from regular text fields, the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state might result in an appearance consistent with the platform's search fields rather than appearing like a regular text field.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, its <a href=#concept-fe-value title=concept-fe-value>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 title=concept-fe-value>value</a>.</p> <!-- this next bit is also in the <textarea> section --> <!-- and something similar is in the session history section --> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-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 title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute to "<code title=attr-dir-ltr><a href=#attr-dir-ltr>ltr</a></code>" if the user selected a left-to-right writing direction, and "<code title=attr-dir-rtl><a href=#attr-dir-rtl>rtl</a></code>" if the user selected a right-to-left writing direction.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-input>input</code> at the <code><a href=#the-input-element>input</a></code> element.</li> </ol></div> <p>The <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: <a href=#strip-line-breaks>Strip line breaks</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-size><a href=#attr-input-size>size</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes; <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <h6 id=telephone-state><span class=secno>4.10.7.1.3 </span><dfn title=attr-input-type-tel>Telephone</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#telephone-state title=attr-input-type-tel>Telephone</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for editing a telephone number given in the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, its <a href=#concept-fe-value title=concept-fe-value>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 title=concept-fe-value>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 title=concept-fe-value>value</a>.</p> </div> <p>The <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: <a href=#strip-line-breaks>Strip line breaks</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> </div> <p class=note>Unlike the <a href=#url-state title=attr-input-type-url>URL</a> and <a href=#e-mail-state title=attr-input-type-email>E-mail</a> types, the <a href=#telephone-state title=attr-input-type-tel>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 title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute or the <code title=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><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-size><a href=#attr-input-size>size</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes; <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <h6 id=url-state><span class=secno>4.10.7.1.4 </span><dfn title=attr-input-type-url>URL</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#url-state title=attr-input-type-url>URL</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for editing a single <a href=#absolute-url>absolute URL</a> given in the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the URL represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>. User agents may allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to a string that is not a <a href=#valid-url title="valid URL">valid</a> <a href=#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 title=concept-fe-value>value</a> is always a <a href=#valid-url title="valid URL">valid</a> <a href=#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 title=concept-fe-value>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 title=concept-fe-value>value</a>.</p> </div> <p>The <code title=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>valid URL potentially surrounded by spaces</a> that is also an <a href=#absolute-url>absolute URL</a>.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: <a href=#strip-line-breaks>Strip line breaks</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>, then <a href=#strip-leading-and-trailing-whitespace>strip leading and trailing whitespace</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <p><strong>Constraint validation</strong>: While the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is neither the empty string nor a <a href=#valid-url title="valid URL">valid</a> <a href=#absolute-url>absolute URL</a>, the element is <a href=#suffering-from-a-type-mismatch>suffering from a type mismatch</a>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-size><a href=#attr-input-size>size</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes; <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <div class=example> <p>If a document contained the following markup:</p> <pre><input type="url" name="location" list="urls"> <datalist id="urls"> <option label="MIME: Format of Internet Message Bodies" value="http://tools.ietf.org/html/rfc2045"> <option label="HTML 4.01 Specification" value="http://www.w3.org/TR/html4/"> <option label="Form Controls" value="http://www.w3.org/TR/xforms/slice8.html#ui-commonelems-hint"> <option label="Scalable Vector Graphics (SVG) 1.1 Specification" value="http://www.w3.org/TR/SVG/"> <option label="Feature Sets - SVG 1.1 - 20030114" value="http://www.w3.org/TR/SVG/feature.html"> <option label="The Single UNIX Specification, Version 3" value="http://www.unix-systems.org/version3/"> </datalist> </pre> <p>...and the user had typed "<kbd>www.w3</kbd>", and the user agent had also found that the user had visited <code>http://www.w3.org/Consortium/#membership</code> and <code>http://www.w3.org/TR/XForms/</code> in the recent past, then the rendering might look like this:</p> <p><img alt='A text box with an icon on the left followed by the text "www.w3" 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 drow down box, indicating further values are available.' height=134 src=http://images.whatwg.org/sample-url.png width=472></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><span class=secno>4.10.7.1.5 </span><dfn title=attr-input-type-email>E-mail</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#e-mail-state title=attr-input-type-email>E-mail</a> state, the rules in this section apply.</p> </div> <p>How the <a href=#e-mail-state title=attr-input-type-email>E-mail</a> state operates depends on whether the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is specified or not.</p> <dl class=switch><dt>When the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is not specified on the element</dt> <dd> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for editing an e-mail address given in the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-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 title=concept-fe-value>value</a>. User agents may allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to a string that is not a <a href=#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 title=concept-fe-value>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 title=concept-fe-value>value</a>. User agents may transform the <a href=#concept-fe-value title=concept-fe-value>value</a> for display and editing; in particular, user agents should convert punycode in the <a href=#concept-fe-value title=concept-fe-value>value</a> to IDN in the display and vice versa.</p> </div> <p>The <code title=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>valid e-mail address</a>.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: <a href=#strip-line-breaks>Strip line breaks</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>, then <a href=#strip-leading-and-trailing-whitespace>strip leading and trailing whitespace</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> <p>When the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is removed, the user agent must run the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>.</p> <p><strong>Constraint validation</strong>: While the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is neither the empty string nor a single <a href=#valid-e-mail-address>valid e-mail address</a>, the element is <a href=#suffering-from-a-type-mismatch>suffering from a type mismatch</a>.</p> </div> </dd> <dt>When the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute <em>is</em> specified on the element</dt> <dd> <div class=impl> <p>The element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a> are the result of <a href=#split-a-string-on-commas title="split a string on commas">splitting on commas</a> the element's <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for adding, removing, and editing the e-mail addresses given in the element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-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 title=concept-fe-values>value<em>s</em></a>. User agents may allow the user to set any individual value in the list of <a href=#concept-fe-value title=concept-fe-value>value<em>s</em></a> to a string that is not a <a href=#valid-e-mail-address>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 title=concept-fe-values>value<em>s</em></a>. User agents may transform the <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a> for display and editing; in particular, user agents should convert punycode in the <a href=#concept-fe-value title=concept-fe-value>value</a> to IDN in the display and vice versa.</p> <p>Whenever the user changes the element's <a href=#concept-fe-value title=concept-fe-value>value<em>s</em></a>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">latest values</var> be a copy of the element's <a href=#concept-fe-value title=concept-fe-value>value<em>s</em></a>.</li> <!-- It's a copy because /values/ might include leading and trailing spaces that we don't necessarily want to remove from the UI but that we do want to remove before serialising. --> <li><p><a href=#strip-leading-and-trailing-whitespace>Strip leading and trailing whitespace</a> from each value in <var title="">latest values</var>.</li> <li><p>Let the element's <a href=#concept-fe-value title=concept-fe-value>value</a> be the result of concatenating all the values in <var title="">latest values</var>, separating each value from the next by a single U+002C COMMA character (,), maintaining the list's order.</li> </ol></div> <p>The <code title=attr-input-value><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>valid e-mail address list</a>.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>:</p> <ol><li><p><a href=#split-a-string-on-commas title="split a string on commas">Split on commas</a> the element's <a href=#concept-fe-value title=concept-fe-value>value</a>, <a href=#strip-leading-and-trailing-whitespace>strip leading and trailing whitespace</a> from each resulting token, if any, and let the element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a> be the (possibly empty) resulting list of (possibly empty) tokens, maintaining the original order.</li> <li><p>Let the element's <a href=#concept-fe-value title=concept-fe-value>value</a> be the result of concatenating the element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a>, separating each value from the next by a single U+002C COMMA character (,), maintaining the list's order.</li> </ol><p>When the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is set, the user agent must run the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>.</p> <p><strong>Constraint validation</strong>: While the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-e-mail-address-list>valid e-mail address list</a>, the element is <a href=#suffering-from-a-type-mismatch>suffering from a type mismatch</a>.</p> </div> </dd> </dl><p>A <dfn id=valid-e-mail-address>valid e-mail address</dfn> is a string that matches the ABNF production <code title="">1*( atext / "." ) "@" ldh-str *( "." ldh-str )</code> where <code title="">atext</code> is defined in <a href=http://tools.ietf.org/html/rfc5322#section-3.2.3>RFC 5322 section 3.2.3</a>, and <code title="">ldh-str</code> is defined in <a href=http://tools.ietf.org/html/rfc1034#section-3.5>RFC 1034 section 3.5</a>. <a href=#refsABNF>[ABNF]</a> <a href=#refsRFC5322>[RFC5322]</a> <a href=#refsRFC1034>[RFC1034]</a></p> <!-- Domain syntax based on section 3.5 of [RFC1034] and section 2.1 of [RFC1123] --> <p class=note>This requirement is a <a href=#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> <p>A <dfn id=valid-e-mail-address-list>valid e-mail address list</dfn> is a <a href=#set-of-comma-separated-tokens>set of comma-separated tokens</a>, where each token is itself a <a href=#valid-e-mail-address>valid e-mail address</a>. <span class=impl>To obtain the list of tokens from a <a href=#valid-e-mail-address-list>valid e-mail address list</a>, and implementation must <a href=#split-a-string-on-commas title="split a string on commas">split the string on commas</a>.</span></p> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-size><a href=#attr-input-size>size</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code> and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes.</p> <!-- <p>The following common <code>input</code> element content attributes, IDL attributes, and methods apply to the element when the <code title="attr-input-multiple">multiple</code> attribute is not specified: .</p> --> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <h6 id=password-state><span class=secno>4.10.7.1.6 </span><dfn title=attr-input-type-password>Password</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#password-state title=attr-input-type-password>Password</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a one line plain text edit control for the element's <a href=#concept-fe-value title=concept-fe-value>value</a>. The user agent should obscure the value so that people other than the user cannot see it.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, its <a href=#concept-fe-value title=concept-fe-value>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 title=concept-fe-value>value</a>.</p> </div> <p>The <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: <a href=#strip-line-breaks>Strip line breaks</a> from the <a href=#concept-fe-value title=concept-fe-value>value</a>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-size><a href=#attr-input-size>size</a></code> content attributes; <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes; <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <h6 id=date-and-time-state><span class=secno>4.10.7.1.7 </span><dfn title=attr-input-type-datetime>Date and Time</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a specific <a href=#concept-datetime title=concept-datetime>global date and time</a>. <span class=impl>User agents may display the date and time in whatever time zone is appropriate for the user.</span></p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-datetime title=concept-datetime>global date and time</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-global-date-and-time-string title="parse a global date and time string">parsing a global date and time</a> from it. User agents must not allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-forced-utc-global-date-and-time-string>valid forced-UTC global date and time string</a>, though user agents may allow the user to set and view the time in another time zone and silently translate the time to and from the UTC time zone in the <a href=#concept-fe-value title=concept-fe-value>value</a>. If the user agent provides a user interface for selecting a <a href=#concept-datetime title=concept-datetime>global date and time</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-forced-utc-global-date-and-time-string>valid forced-UTC global date and time string</a> representing the user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present dates and times according to the conventions of the user's preferred locale.</p> <p>The <code title=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-global-date-and-time-string>valid global date and time string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input; also ok to be non-UTC, we convert it --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>, then adjust the time so that the <a href=#concept-fe-value title=concept-fe-value>value</a> represents the same point in time but expressed in the UTC time zone as a <a href=#valid-forced-utc-global-date-and-time-string>valid forced-UTC global date and time string</a>, otherwise, set it to the empty string instead.</p> </div> <p>The <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute, if specified, must have a value that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>. The <code title=attr-input-max><a href=#attr-input-max>max</a></code> attribute, if specified, must have a value that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in seconds. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1000 (which converts the seconds to milliseconds, as used in the other algorithms).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 60 seconds.</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-datetime title=concept-datetime>global date and time</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-global-date-and-time-string title="parse a global date and time string">parsing a global date and time</a> from <var title="">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 title="">1970-01-01T00:00:00.0Z</code>") to the parsed <a href=#concept-datetime title=concept-datetime>global date and time</a>, ignoring leap seconds.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-global-date-and-time-string>valid global date and time string</a> expressed in UTC that represents the <a href=#concept-datetime title=concept-datetime>global date and time</a> that is <var title="">input</var> milliseconds after midnight UTC on the morning of 1970-01-01 (the time represented by the value "<code title="">1970-01-01T00:00:00.0Z</code>").</p> <p><strong>The <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-global-date-and-time-string title="parse a global date and time string">parsing a global date and time</a> from <var title="">input</var> results in an error, then return an error; otherwise, return a <code>Date</code> object representing the parsed <a href=#concept-datetime title=concept-datetime>global date and time</a>, expressed in UTC.</p> <p><strong>The <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a>, given a <code>Date</code> object <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-global-date-and-time-string>valid global date and time string</a> expressed in UTC that represents the <a href=#concept-datetime title=concept-datetime>global date and time</a> that is represented by <var title="">input</var>.</p> </div> <div class=note id=only-contemporary-times> <p>The <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</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-and-time-state title=attr-input-type-datetime>Date and Time</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><a href=#the-select-element>select</a></code> element and <code><a href=#the-input-element>input</a></code> elements with the <a href=#number-state title=attr-input-type-number>Number</a> state.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <div class=example> <p>The following fragment shows part of a calendar application. A user can specify a date and time for a meeting (in his local time zone, probably, though the user agent can allow the user to change that), and since the submitted data includes the time-zone offset, the application can ensure that the meeting is shown at the correct time regardless of the time zones used by all the participants.</p> <pre><fieldset> <legend>Add Meeting</legend> <p><label>Meeting name: <input type=text name="meeting.label"></label> <p><label>Meeting time: <input type=datetime name="meeting.start"></label> </fieldset></pre> <p>Had the application used the <code title=attr-input-type-datetime-local><a href=#local-date-and-time-state>datetime-local</a></code> type instead, the calendar application would have also had to explicitly determine which time zone the user intended.</p> </div> <h6 id=date-state><span class=secno>4.10.7.1.8 </span><dfn title=attr-input-type-date>Date</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#date-state title=attr-input-type-date>Date</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a specific <a href=#concept-date title=concept-date>date</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-date title=concept-date>date</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-date-string title="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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-date-string>valid date string</a>. If the user agent provides a user interface for selecting a <a href=#concept-date title=concept-date>date</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-date-string>valid date string</a> representing the user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present dates according to the conventions of the user's preferred locale.</p> <p>The <code title=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>valid date string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-date-string>valid date string</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid date string</a>. The <code title=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>valid date string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in days. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 86,400,000 (which converts the days to milliseconds, as used in the other algorithms).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 1 day.</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-date title=concept-date>date</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-date-string title="parse a date string">parsing a date</a> from <var title="">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 title="">1970-01-01T00:00:00.0Z</code>") to midnight UTC on the morning of the parsed <a href=#concept-date title=concept-date>date</a>, ignoring leap seconds.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-date-string>valid date string</a> that represents the <a href=#concept-date title=concept-date>date</a> that, in UTC, is current <var title="">input</var> milliseconds after midnight UTC on the morning of 1970-01-01 (the time represented by the value "<code title="">1970-01-01T00:00:00.0Z</code>").</p> <p><strong>The <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-date-string title="parse a date string">parsing a date</a> from <var title="">input</var> results in an error, then return an error; otherwise, return a <code>Date</code> object representing midnight UTC on the morning of the parsed <a href=#concept-date title=concept-date>date</a>.</p> <p><strong>The <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a>, given a <code>Date</code> object <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-date-string>valid date string</a> that represents the <a href=#concept-date title=concept-date>date</a> current at the time represented by <var title="">input</var> in the UTC time zone.</p> </div> <p class=note>See <a href=#only-contemporary-times>the note on historical dates</a> in the <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> state section.</p> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <h6 id=month-state><span class=secno>4.10.7.1.9 </span><dfn title=attr-input-type-month>Month</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#month-state title=attr-input-type-month>Month</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a specific <a href=#concept-month title=concept-month>month</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-month title=concept-month>month</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-month-string title="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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-month-string>valid month string</a>. If the user agent provides a user interface for selecting a <a href=#concept-month title=concept-month>month</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-month-string>valid month string</a> representing the user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present months according to the conventions of the user's preferred locale.</p> <p>The <code title=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>valid month string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-month-string>valid month string</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid month string</a>. The <code title=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>valid month string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in months. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1 (there is no conversion needed as the algorithms use months).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 1 month.</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-month title=concept-month>month</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-month-string title="parse a month string">parsing a month</a> from <var title="">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 title=concept-month>month</a>.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-month-string>valid month string</a> that represents the <a href=#concept-month title=concept-month>month</a> that has <var title="">input</var> months between it and January 1970.</p> <!-- note - it doesn't matter exactly how many months are "between" two months, so long as the UA implements this consistently. The number is never actually exposed. --> <p><strong>The <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-month-string title="parse a month string">parsing a month</a> from <var title="">input</var> results in an error, then return an error; otherwise, return a <code>Date</code> object representing midnight UTC on the morning of the first day of the parsed <a href=#concept-month title=concept-month>month</a>.</p> <p><strong>The <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a>, given a <code>Date</code> object <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-month-string>valid month string</a> that represents the <a href=#concept-month title=concept-month>month</a> current at the time represented by <var title="">input</var> in the UTC time zone.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <h6 id=week-state><span class=secno>4.10.7.1.10 </span><dfn title=attr-input-type-week>Week</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#week-state title=attr-input-type-week>Week</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a specific <a href=#concept-week title=concept-week>week</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-week title=concept-week>week</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-week-string title="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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-week-string>valid week string</a>. If the user agent provides a user interface for selecting a <a href=#concept-week title=concept-week>week</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-week-string>valid week string</a> representing the user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present weeks according to the conventions of the user's preferred locale.</p> <p>The <code title=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>valid week string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-week-string>valid week string</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid week string</a>. The <code title=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>valid week string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in weeks. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 604,800,000 (which converts the weeks to milliseconds, as used in the other algorithms).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 1 week. <span class=impl>The <a href=#concept-input-step-default-base title=concept-input-step-default-base>default step base</a> is −259,200,000 (the start of week 1970-W01).</span></p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-week title=concept-week>week</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-week-string title="parse a week string">parsing a week string</a> from <var title="">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 title="">1970-01-01T00:00:00.0Z</code>") to midnight UTC on the morning of the Monday of the parsed <a href=#concept-week title=concept-week>week</a>, ignoring leap seconds.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-week-string>valid week string</a> that represents the <a href=#concept-week title=concept-week>week</a> that, in UTC, is current <var title="">input</var> milliseconds after midnight UTC on the morning of 1970-01-01 (the time represented by the value "<code title="">1970-01-01T00:00:00.0Z</code>").</p> <p><strong>The <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-week-string title="parse a week string">parsing a week</a> from <var title="">input</var> results in an error, then return an error; otherwise, return a <code>Date</code> object representing midnight UTC on the morning of the Monday of the parsed <a href=#concept-week title=concept-week>week</a>.</p> <p><strong>The <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a>, given a <code>Date</code> object <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-week-string>valid week string</a> that represents the <a href=#concept-week title=concept-week>week</a> current at the time represented by <var title="">input</var> in the UTC time zone.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <h6 id=time-state><span class=secno>4.10.7.1.11 </span><dfn title=attr-input-type-time>Time</dfn> state</h6> <!-- v2: allow min="" and max="" to be set such that the range crosses midnight, as in <input type=time min="23:00" max="02:00"> (from http://www.w3.org/Bugs/Public/show_bug.cgi?id=7688) --> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#time-state title=attr-input-type-time>Time</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a specific <a href=#concept-time title=concept-time>time</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-time title=concept-time>time</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-time-string title="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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-time-string>valid time string</a>. If the user agent provides a user interface for selecting a <a href=#concept-time title=concept-time>time</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-time-string>valid time string</a> representing the user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present times according to the conventions of the user's preferred locale.</p> <p>The <code title=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>valid time string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-time-string>valid time string</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid time string</a>. The <code title=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>valid time string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in seconds. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1000 (which converts the seconds to milliseconds, as used in the other algorithms).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 60 seconds.</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-time title=concept-time>time</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-time-string title="parse a time string">parsing a time</a> from <var title="">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 title=concept-time>time</a> on a day with no time changes.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-time-string>valid time string</a> that represents the <a href=#concept-time title=concept-time>time</a> that is <var title="">input</var> milliseconds after midnight on a day with no time changes.</p> <p><strong>The <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-time-string title="parse a time string">parsing a time</a> from <var title="">input</var> results in an error, then return an error; otherwise, return a <code>Date</code> object representing the parsed <a href=#concept-time title=concept-time>time</a> in UTC on 1970-01-01.</p> <p><strong>The <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a>, given a <code>Date</code> object <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-time-string>valid time string</a> that represents the UTC <a href=#concept-time title=concept-time>time</a> component that is represented by <var title="">input</var>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <h6 id=local-date-and-time-state><span class=secno>4.10.7.1.12 </span><dfn title=attr-input-type-datetime-local>Local Date and Time</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#local-date-and-time-state title=attr-input-type-datetime-local>Local Date and Time</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a <a href=#concept-datetime-local title=concept-datetime-local>local date and time</a>, with no time-zone offset information.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the <a href=#concept-datetime-local title=concept-datetime-local>date and time</a> represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained by <a href=#parse-a-local-date-and-time-string title="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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#valid-local-date-and-time-string>valid local date and time string</a>. If the user agent provides a user interface for selecting a <a href=#concept-datetime-local title=concept-datetime-local>local date and time</a>, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-local-date-and-time-string>valid 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 title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>The format shown to the user is independent of the format used for form submission. Browsers are encouraged to use user interfaces that present dates and times according to the conventions of the user's preferred locale.</p> <p>The <code title=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>valid local date and time string</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-local-date-and-time-string>valid local date and time string</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid local date and time string</a>. The <code title=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>valid local date and time string</a>.</p> <p>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute is expressed in seconds. <span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1000 (which converts the seconds to milliseconds, as used in the other algorithms).</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 60 seconds.</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest <a href=#concept-datetime-local title=concept-datetime-local>local date and time</a> for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If <a href=#parse-a-local-date-and-time-string title="parse a local date and time string">parsing a date and time</a> from <var title="">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 title="">1970-01-01T00:00:00.0</code>") to the parsed <a href=#concept-datetime-local title=concept-datetime-local>local date and time</a>, ignoring leap seconds.</p> <p><strong>The <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-local-date-and-time-string>valid local date and time string</a> that represents the date and time that is <var title="">input</var> milliseconds after midnight on the morning of 1970-01-01 (the time represented by the value "<code title="">1970-01-01T00:00:00.0</code>").</p> </div> <p class=note>See <a href=#only-contemporary-times>the note on historical dates</a> in the <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> state section.</p> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <div class=example> <p>The following example shows part of a flight booking application. The application uses an <code><a href=#the-input-element>input</a></code> element with its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute set to <code title=attr-input-type-datetime-local><a href=#local-date-and-time-state>datetime-local</a></code>, and it then interprets the given date and time in the time zone of the selected airport.</p> <pre><fieldset> <legend>Destination</legend> <p><label>Airport: <input type=text name=to list=airports></label></p> <p><label>Departure time: <input type=datetime-local name=totime step=3600></label></p> </fieldset> <datalist id=airports> <option value=ATL label="Atlanta"> <option value=MEM label="Memphis"> <option value=LHR label="London Heathrow"> <option value=LAX label="Los Angeles"> <option value=FRA label="Frankfurt"> </datalist></pre> <p>If the application instead used the <code title=attr-input-type-datetime><a href=#date-and-time-state>datetime</a></code> type, then the user would have to work out the time-zone conversions himself, which is clearly not a good user experience!</p> </div> <h6 id=number-state><span class=secno>4.10.7.1.13 </span><dfn title=attr-input-type-number>Number</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#number-state title=attr-input-type-number>Number</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a number.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the number represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained from applying the <a href=#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 title=concept-fe-value>value</a> to a non-empty string that is not a <a href=#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 title=concept-fe-value>value</a> must be set to the <a href=#best-representation-of-the-number-as-a-floating-point-number title="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 title=concept-fe-value>value</a> to the empty string.</p> </div> <p class=note>This specification does not define what user interface user agents are to use; user agent vendors are encouraged to consider what would best serve their users' needs. For example, a user agent in Persian or Arabic markets might support Persian and Arabic numeric input (converting it to the format required for submission as described above). <!--Similarly, a user agent designed for Romans might display the value in Roman numerals rather than in decimal.--></p> <p>The <code title=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>valid floating point number</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-floating-point-number>valid floating point number</a>, then set it to the empty string instead.</p> </div> <p>The <code title=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>valid floating point number</a>. The <code title=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>valid floating point number</a>.</p> <p><span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1.</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 1 (allowing only integers, unless the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute has a non-integer value).</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent may round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest number for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">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 title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If applying the <a href=#rules-for-parsing-floating-point-number-values>rules for parsing floating point number values</a> to <var title="">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 title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-floating-point-number>valid floating point number</a> that represents <var title="">input</var>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code title=attr-input-required><a href=#attr-input-required>required</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <h6 id=range-state><span class=secno>4.10.7.1.14 </span><dfn title=attr-input-type-range>Range</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#range-state title=attr-input-type-range>Range</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control for setting the element's <a href=#concept-fe-value title=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 title=attr-input-type-number>Number</a> state.</p> <div class=impl> <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>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the number represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained from applying the <a href=#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 title=concept-fe-value>value</a> to a string that is not a <a href=#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 title=concept-fe-value>value</a> must be set to a <a href=#best-representation-of-the-number-as-a-floating-point-number title="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 title=concept-fe-value>value</a> to the empty string.</p> </div> <p>The <code title=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>valid floating point number</a>.</p> <!-- ok to set out-of-range value, we never know when we might have to represent bogus input; not ok to not have a value if the attribute is present, since you can't not have a value (attribute missing is treated as implying a default value) --> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is not a <a href=#valid-floating-point-number>valid floating point number</a>, then set it to a <a href=#valid-floating-point-number>valid floating point number</a> that represents the <a href=#concept-input-value-default-range title=concept-input-value-default-range>default value</a>.</p> </div> <p>The <code title=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>valid floating point number</a>. The <a href=#concept-input-min-default title=concept-input-min-default>default minimum</a> is 0. The <code title=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>valid floating point number</a>. The <a href=#concept-input-max-default title=concept-input-max-default>default maximum</a> is 100.</p> <p>The <dfn id=concept-input-value-default-range title=concept-input-value-default-range>default value</dfn> is the <a href=#concept-input-min title=concept-input-min>minimum</a> plus half the difference between the <a href=#concept-input-min title=concept-input-min>minimum</a> and the <a href=#concept-input-max title=concept-input-max>maximum</a>, unless the <a href=#concept-input-max title=concept-input-max>maximum</a> is less than the <a href=#concept-input-min title=concept-input-min>minimum</a>, in which case the <a href=#concept-input-value-default-range title=concept-input-value-default-range>default value</a> is the <a href=#concept-input-min title=concept-input-min>minimum</a>.</p> <div class=impl> <p>When the element is <a href=#suffering-from-an-underflow>suffering from an underflow</a>, the user agent must set the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a <a href=#valid-floating-point-number>valid floating point number</a> that represents the <a href=#concept-input-min title=concept-input-min>minimum</a>.</p> <p>When the element is <a href=#suffering-from-an-overflow>suffering from an overflow</a>, if the <a href=#concept-input-max title=concept-input-max>maximum</a> is not less than the <a href=#concept-input-min title=concept-input-min>minimum</a>, the user agent must set the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a <a href=#valid-floating-point-number>valid floating point number</a> that represents the <a href=#concept-input-max title=concept-input-max>maximum</a>.</p> </div> <p><span class=impl>The <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a> is 1.</span> The <a href=#concept-input-step-default title=concept-input-step-default>default step</a> is 1 (allowing only integers, unless the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute has a non-integer value).</p> <div class=impl> <p>When the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>, the user agent must round the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the nearest number for which the element would not <a href=#suffering-from-a-step-mismatch title="suffering from a step mismatch">suffer from a step mismatch</a>, and which is greater than or equal to the <a href=#concept-input-min title=concept-input-min>minimum</a>, and, if the <a href=#concept-input-max title=concept-input-max>maximum</a> is not less than the <a href=#concept-input-min title=concept-input-min>minimum</a>, which is less than or equal to the <a href=#concept-input-max title=concept-input-max>maximum</a>. 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><input type="range" min=0 max=100 step=20 value=50></code> results in a range control whose initial value is 60.</p> <p><strong>The <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a>, given a string <var title="">input</var>, is as follows</strong>: If applying the <a href=#rules-for-parsing-floating-point-number-values>rules for parsing floating point number values</a> to <var title="">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 title=concept-input-value-number-string>algorithm to convert a number to a string</a>, given a number <var title="">input</var>, is as follows</strong>: Return a <a href=#valid-floating-point-number>valid floating point number</a> that represents <var title="">input</var>.</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code title=attr-input-list><a href=#attr-input-list>list</a></code>, <code title=attr-input-max><a href=#attr-input-max>max</a></code>, <code title=attr-input-min><a href=#attr-input-min>min</a></code>, and <code title=attr-input-step><a href=#attr-input-step>step</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code>, <code title=dom-input-value><a href=#dom-input-value>value</a></code>, and <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code> and <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods.</p> </div> <div class=example> <p>Here is an example of a range control using an autocomplete list with the <code title=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><input type="range" min="-100" max="100" value="0" step="10" name="power" list="powers"> <datalist id="powers"> <option value="0"> <option value="-30"> <option value="30"> <option value="+50"> </datalist> </pre> <p>...with the following style sheet applied:</p> <pre>input { height: 75px; width: 49px; background: #D5CCBB; color: black; }</pre> <p>...might render as:</p> <p><img 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 src=http://images.whatwg.org/sample-range.png width=49><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 similiarly derived from the style sheet. The tick marks, however, were derived from the markup. In particular, the <code title=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 title="">+50</code> was completely ignored.</p> </div> <div class=example> <p>For another example, consider the following markup fragment:</p> <pre><input name=x type=range min=100 max=700 step=9.09090909 value=509.090909></pre> <p>A user agent could display in a variety of ways, for instance:</p> <p><img alt="As a dial." height=57 src=http://images.whatwg.org/sample-range-2a.png width=231></p> <p>Or, alternatively, for instance:</p> <p><img alt="As a long horizontal slider with tick marks." height=56 src=http://images.whatwg.org/sample-range-2b.png width=445></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> <h6 id=color-state><span class=secno>4.10.7.1.15 </span><dfn title=attr-input-type-color>Color</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#color-state title=attr-input-type-color>Color</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a color well control, for setting the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to a string representing a <a href=#simple-color>simple color</a>.</p> <div class=impl> <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 title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the color represented by its <a href=#concept-fe-value title=concept-fe-value>value</a>, as obtained from applying the <a href=#rules-for-parsing-simple-color-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 title=concept-fe-value>value</a> to a string that is not a <a href=#valid-lowercase-simple-color>valid lowercase simple color</a>. If the user agent provides a user interface for selecting a color, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to the result of using the <a href=#rules-for-serializing-simple-color-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 title=concept-fe-value>value</a> to the empty string.</p> </div> <p>The <code title=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-color>valid simple color</a>.</p> <div class=impl> <p><strong>The <a href=#value-sanitization-algorithm>value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element is a <a href=#valid-simple-color>valid simple color</a>, then set it to the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>; otherwise, set it to the string "<code title="">#000000</code>".</p> </div> <div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes, IDL attributes, and methods apply to the element: <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> and <code title=attr-input-list><a href=#attr-input-list>list</a></code> content attributes; <code title=dom-input-list><a href=#dom-input-list>list</a></code> and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>.</p> <p>The <code title=event-input-input><a href=#event-input-input>input</a></code> and <code title=event-input-change><a href=#event-input-change>change</a></code> events apply.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> </div> <h6 id=checkbox-state><span class=secno>4.10.7.1.16 </span><dfn title=attr-input-type-checkbox>Checkbox</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a two-state control that represents the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state. If the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state is true, the control represents a positive selection, and if it is false, a negative selection. If the element's <code title=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 title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute is set to true. The <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute only gives the appearance of a third state.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, then: The <a href=#pre-click-activation-steps>pre-click activation steps</a> consist of setting the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> to its opposite value (i.e. true if it is false, false if it is true), and of setting the element's <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute to false. The <a href=#canceled-activation-steps>canceled activation steps</a> consist of setting the <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> and the element's <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute back to the values they had before the <a href=#pre-click-activation-steps>pre-click activation steps</a> were run. The <a href=#activation-behavior>activation behavior</a> is to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the element. <!-- It's not cancelable. Once this fires, the control is checked, end of story. --></p> <p><strong>Constraint validation</strong>: If the element is <i title=concept-input-required><a href=#concept-input-required>required</a></i> and its <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is false, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </div> <dl class=domintro><dt><var title="">input</var> . <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>When set, overrides the rendering of <a href=#checkbox-state title=attr-input-type-checkbox>checkbox</a> controls so that the current value is not visible.</p> </dd> </dl><div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes and IDL attributes apply to the element: <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, and <code title=attr-input-required><a href=#attr-input-required>required</a></code> content attributes; <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code> and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-default-on title=dom-input-value-default-on>default/on</a>.</p> <p>The <code title=event-input-change><a href=#event-input-change>change</a></code> event applies.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> event does not apply.</p> </div> <h6 id=radio-button-state><span class=secno>4.10.7.1.17 </span><dfn title=attr-input-type-radio>Radio Button</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a control that, when used in conjunction with other <code><a href=#the-input-element>input</a></code> elements, forms a <i><a href=#radio-button-group>radio button group</a></i> in which only one control can have its <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state set to true. If the element's <a href=#concept-fe-checked title=concept-fe-checked>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><a href=#the-input-element>input</a></code> element <var title="">a</var> also contains all the other <code><a href=#the-input-element>input</a></code> elements <var title="">b</var> that fulfill all of the following conditions:</p> <ul><li>The <code><a href=#the-input-element>input</a></code> element <var title="">b</var>'s <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state.</li> <li>Either <var title="">a</var> and <var title="">b</var> have the same <a href=#form-owner>form owner</a>, or they both have no <a href=#form-owner>form owner</a>.</li> <li>They both have a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute, their <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attributes are not empty, and the value of <var title="">a</var>'s <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute is a <a href=#compatibility-caseless>compatibility caseless</a> match for the value of <var title="">b</var>'s <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute.</li> </ul><p>A document must not contain an <code><a href=#the-input-element>input</a></code> element whose <i><a href=#radio-button-group>radio button group</a></i> contains only that element.</p> <div class=impl> <p>When any of the following phenomena occur, if the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state is true after the occurrence, the <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state of all the other elements in the same <i><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 title=concept-fe-checked>checkedness</a> state is set to true (for whatever reason).</li> <li>The element's <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute is set, changed, or removed.</li> <li>The element's <a href=#form-owner>form owner</a> changes.</li> </ul><p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, then: The <a href=#pre-click-activation-steps>pre-click activation steps</a> consist of setting the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> to true. The <a href=#canceled-activation-steps>canceled activation steps</a> consist of setting the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> to false. The <a href=#activation-behavior>activation behavior</a> is to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the element. <!-- It's not cancelable. Once this fires, the control is checked, end of story. -->.</p> <p><strong>Constraint validation</strong>: If an element in the <i><a href=#radio-button-group>radio button group</a></i> is <i title=concept-input-required><a href=#concept-input-required>required</a></i>, and all of the <code><a href=#the-input-element>input</a></code> elements in the <i><a href=#radio-button-group>radio button group</a></i> have a <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> that is false, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </div> <p class=note>If none of the radio buttons in a <a href=#radio-button-group>radio button group</a> are checked when they are inserted into the document, 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><a href=#the-input-element>input</a></code> element content attributes and IDL attributes apply to the element: <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> and <code title=attr-input-required><a href=#attr-input-required>required</a></code> content attributes; <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code> and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-default-on title=dom-input-value-default-on>default/on</a>.</p> <p>The <code title=event-input-change><a href=#event-input-change>change</a></code> event applies.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> event does not apply.</p> </div> <h6 id=file-upload-state><span class=secno>4.10.7.1.18 </span><dfn title=attr-input-type-file>File Upload</dfn> state</h6> <!-- v2 ideas: * maximum height/width or required ratio for image uploads? - Leons Petrazickis * maximum per-file upload size - Alfonso Martínez de Lizarrondo --> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#file-upload-state title=attr-input-type-file>File Upload</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a list of <dfn id=concept-input-type-file-selected title=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> <div class=impl> <p>File names may contain partial paths, e.g. in the case that a user has selected an entire directory hierarchy. Path components should be separated from each other using U+005C REVERSE SOLIDUS character (\).</p> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to change the files on the list, e.g. adding or removing files. Files can be from the filesystem or created on the fly, e.g. a picture taken from a camera connected to the user's device.</p> <p>File names must be exposed in Unicode normalization Form C (NFC), whether in the DOM (e.g. in <code><a href=#file>File</a></code> objects) or in form submission, regardless of the conventions of the user agent's platform's file system.</p> <p><strong>Constraint validation</strong>: If the element is <i title=concept-input-required><a href=#concept-input-required>required</a></i> and the list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a> is empty, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> <p>Unless the <code title=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 title=concept-input-type-file-selected>selected files</a>.</p> </div> <hr><p>The <dfn id=attr-input-accept title=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.</p> <p>If specified, the attribute must consist of a <a href=#set-of-comma-separated-tokens>set of comma-separated tokens</a>, each of which must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for one of the following:</p> <dl><dt>The string <code title="">audio/*</code></dt> <dd>Indicates that sound files are accepted.</dd> <dt>The string <code title="">video/*</code></dt> <dd>Indicates that video files are accepted.</dd> <dt>The string <code title="">image/*</code></dt> <dd>Indicates that image files are accepted.</dd> <dt>A <a href=#valid-mime-type-with-no-parameters>valid MIME type with no parameters</a></dt> <dd>Indicates that files of the specified type are accepted.</dd> </dl><p>The tokens must not be <a href=#ascii-case-insensitive>ASCII case-insensitive</a> matches for any of the other tokens (i.e. duplicates are not allowed). <span class=impl>To obtain the list of tokens from the attribute, the user agent must <a href=#split-a-string-on-commas title="split a string on commas">split the attribute value on commas</a>.</span></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 title="">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 title="">audio/*</code>, a user agent could offer the user the option of recording a clip using a headset microphone.</p> <div class=impl> <p>User agents should prevent the user from selecting files that are not accepted by one (or more) of these tokens.</p> </div> <div class=example id=fakepath-srsly> <p>For historical reasons, the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute prefixes the filename with the string "<code title="">C:\fakepath\</code>". Some legacy user agents actually included the full path (which was a security vulnerability). As a result of this, obtaining the filename from the <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute in a backwards-compatible way is non-trivial. The following function extracts the filename in a suitably compatible manner:</p> <pre>function extractFilename(path) { if (path.substr(0, 12) == "C:\\fakepath\\") return path.substr(12); // modern browser var x; x = path.lastIndexOf('/'); if (x >= 0) // Unix-based path return path.substr(x+1); x = path.lastIndexOf('\\'); if (x >= 0) // Windows-based path return path.substr(x+1); return path; // just the filename }</pre> <p>This can be used as follows:</p> <pre><p><input type=file name=image onchange="updateFilename(this.value)"></p> <p>The name of the file you picked is: <span id="filename">(none)</span></p> <script> function updateFilename(path) { var name = extractFilename(path); document.getElementById('filename').textContent = name; } </script></pre> <!-- How useful this actually is... is unclear. --> </div> <hr><div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes apply to the element: <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes and IDL attributes apply to the element: <code title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, and <code title=attr-input-required><a href=#attr-input-required>required</a></code>; <code title=dom-input-files><a href=#dom-input-files>files</a></code> and <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attributes.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-filename title=dom-input-value-filename>filename</a>.</p> <p>The <code title=event-input-change><a href=#event-input-change>change</a></code> event applies.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute must be omitted.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> event does not apply.</p> </div> <h6 id=submit-button-state><span class=secno>4.10.7.1.19 </span><dfn title=attr-input-type-submit>Submit Button</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a button that, when activated, submits the form. <span class=impl>If the element has a <code title=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.</span> The element is a <a href=#concept-button title=concept-button>button</a>, specifically a <a href=#concept-submit-button title=concept-submit-button>submit button</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to activate the element.</p> <p>The element's <a href=#activation-behavior>activation behavior</a>, if the element has a <a href=#form-owner>form owner</a>, is to <a href=#concept-form-submit title=concept-form-submit>submit</a> the <a href=#form-owner>form owner</a> from the <code><a href=#the-input-element>input</a></code> element; otherwise, it is to do nothing.</p> </div> <p>The <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> attributes are <a href=#attributes-for-form-submission>attributes for form submission</a>.</p> <p class=note>The <code title=attr-fs-formnovalidate><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><a href=#the-input-element>input</a></code> element content attributes and IDL attributes apply to the element: <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> content attributes; <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-default title=dom-input-value-default>default</a>.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> and <code class=no-backref title=event-input-change><a href=#event-input-change>change</a></code> events do not apply.</p> </div> <h6 id=image-button-state><span class=secno>4.10.7.1.20 </span><dfn title=attr-input-type-image>Image Button</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#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 title=concept-button>button</a>, specifically a <a href=#concept-submit-button title=concept-submit-button>submit button</a>.</p> <p class=note>The coordinate is sent to the server <a href=#constructing-the-form-data-set title="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 title="">.x</code>" and "<code title="">.y</code>" appended to the name with the <var title="">x</var> and <var title="">y</var> components of the coordinate respectively.</p> <hr><p>The image is given by the <dfn id=attr-input-src title=attr-input-src><code>src</code></dfn> attribute. The <code title=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>valid non-empty URL potentially surrounded by spaces</a> referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted.</p> <div class=impl> <p>When any of the following events occur, unless the user agent cannot support images, or its support for images has been disabled, or the user agent only fetches elements on demand, or the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute's value is the empty string, the user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute, relative to the element, and if that is successful, must <a href=#fetch>fetch</a> the resulting <a href=#absolute-url>absolute URL</a>:</p> <!-- Note how this does NOT happen when the base URL changes. --> <!-- http-origin privacy sensitive --> <ul><li>The <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is first set to the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state (possibly when the element is first created), and the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute is present.</li> <li>The <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is changed back to the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, and the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute is present, and its value has changed since the last time the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute was in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state.</li> <li>The <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, and the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute is set or changed.</li> </ul><!-- same text in <img> section and similar text elsewhere --><p>Fetching the image must <a href=#delay-the-load-event>delay the load event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> (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 title=input-img-available><i>available</i></dfn>. If this is true before the image is completely downloaded, each <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> while the image is being <a href=#fetch title=fetch>fetched</a> must update the presentation of the image appropriately.</p> <p>The user agents should apply the <a href=#content-type-sniffing:-image title="Content-Type sniffing: image">image sniffing rules</a> to determine the type of the image, with the image's <a href=#content-type title=Content-Type>associated Content-Type headers</a> giving the <var title="">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 title=Content-Type>associated Content-Type headers</a>.</p> <p>User agents must not support non-image resources with the <code><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 title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task source</a> once the resource has been <a href=#fetch title=fetch>fetched</a>, must, if the download was successful and the image is <i title=input-img-available><a href=#input-img-available>available</a></i>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><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>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> on the <code><a href=#the-input-element>input</a></code> element.</p> <hr></div> <p>The <dfn id=attr-input-alt title=attr-input-alt><code>alt</code></dfn> attribute provides the textual label for the alternative button for users and user agents who cannot use the image. The <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code> attribute must also be present, and must contain a non-empty string.</p> <p>The <code><a href=#the-input-element>input</a></code> element supports <a href=#dimension-attributes>dimension attributes</a>.</p> <div class=impl> <hr><p>If the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute is set, and the image is <i title=input-img-available><a href=#input-img-available>available</a></i> and the user agent is configured to display that image, then: The element <a href=#represents>represents</a> a control for selecting a <a href=#concept-input-type-image-coordinate title=concept-input-type-image-coordinate>coordinate</a> from the image specified by the <code title=attr-input-src><a href=#attr-input-src>src</a></code> attribute; if the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to select this <a href=#concept-input-type-image-coordinate title=concept-input-type-image-coordinate>coordinate</a>. The <a href=#activation-behavior>activation behavior</a> in this case consists of taking the user's selected <a href=#concept-input-type-image-coordinate title=concept-input-type-image-coordinate>coordinate</a>, and then, if the element has a <a href=#form-owner>form owner</a>, <a href=#concept-form-submit title=concept-form-submit>submitting</a> the <code><a href=#the-input-element>input</a></code> element's <a href=#form-owner>form owner</a> from the <code><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>represents</a> a submit button whose label is given by the value of the <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code> attribute; if the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to activate the button. The <a href=#activation-behavior>activation behavior</a> in this case consists of setting the <a href=#concept-input-type-image-coordinate title=concept-input-type-image-coordinate>selected coordinate</a> to (0,0), and then, if the element has a <a href=#form-owner>form owner</a>, <a href=#concept-form-submit title=concept-form-submit>submitting</a> the <code><a href=#the-input-element>input</a></code> element's <a href=#form-owner>form owner</a> from the <code><a href=#the-input-element>input</a></code> element.</p> <p>The <dfn id=concept-input-type-image-coordinate title=concept-input-type-image-coordinate>selected coordinate</dfn> must consist of an <var title="">x</var>-component and a <var title="">y</var>-component. The coordinates represent the position relative to the edge of the image, with the coordinate space having the positive <var title="">x</var> direction to the right, and the positive <var title="">y</var> direction downwards.</p> <p>The <var title="">x</var>-component must be a <a href=#valid-integer>valid integer</a> representing a number <var title="">x</var> in the range <span title="">−(<var title="">border<sub title="">left</sub></var>+<var title="">padding<sub title="">left</sub></var>) ≤ <var title="">x</var> ≤ <var title="">width</var>+<var title="">border<sub title="">right</sub></var>+<var title="">padding<sub title="">right</sub></var></span>, where <var title="">width</var> is the rendered width of the image, <var title="">border<sub title="">left</sub></var> is the width of the border on the left of the image, <var title="">padding<sub title="">left</sub></var> is the width of the padding on the left of the image, <var title="">border<sub title="">right</sub></var> is the width of the border on the right of the image, and <var title="">padding<sub title="">right</sub></var> is the width of the padding on the right of the image, with all dimensions given in CSS pixels.</p> <p>The <var title="">y</var>-component must be a <a href=#valid-integer>valid integer</a> representing a number <var title="">y</var> in the range <span title="">−(<var title="">border<sub title="">top</sub></var>+<var title="">padding<sub title="">top</sub></var>) ≤ <var title="">y</var> ≤ <var title="">height</var>+<var title="">border<sub title="">bottom</sub></var>+<var title="">padding<sub title="">bottom</sub></var></span>, where <var title="">height</var> is the rendered height of the image, <var title="">border<sub title="">top</sub></var> is the width of the border above the image, <var title="">padding<sub title="">top</sub></var> is the width of the padding above the image, <var title="">border<sub title="">bottom</sub></var> is the width of the border below the image, and <var title="">padding<sub title="">bottom</sub></var> is the width of the padding below the image, with all dimensions given in CSS pixels.</p> <p>Where a border or padding is missing, its width is zero CSS pixels.</p> <hr></div> <p>The <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> attributes are <a href=#attributes-for-form-submission>attributes for form submission</a>.</p> <dl class=domintro><dt><var title="">image</var> . <code title=dom-input-width><a href=#dom-input-width>width</a></code> [ = <var title="">value</var> ]</dt> <dt><var title="">image</var> . <code title=dom-input-height><a href=#dom-input-height>height</a></code> [ = <var title="">value</var> ]</dt> <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> </dd> </dl><div class=bookkeeping> <p>The following common <code><a href=#the-input-element>input</a></code> element content attributes and IDL attributes apply to the element: <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code title=attr-input-src><a href=#attr-input-src>src</a></code>, and <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> content attributes; <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute.</p> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute is in mode <a href=#dom-input-value-default title=dom-input-value-default>default</a>.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, and <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>.</p> <p>The element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute must be omitted.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> and <code class=no-backref title=event-input-change><a href=#event-input-change>change</a></code> events do not apply.</p> </div> <p class=note>Many aspects of this state's behavior are similar to the behavior of the <code><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><form action="process.cgi"> <input type=image src=map.png name=where> </form></pre> <p>If the user clicked on the image at coordinate (127,40) then the URL used to submit the form would be "<code title="">process.cgi?where.x=127&where.y=40</code>".</p> </div> <h6 id=reset-button-state><span class=secno>4.10.7.1.21 </span><dfn title=attr-input-type-reset>Reset Button</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a button that, when activated, resets the form. <span class=impl>If the element has a <code title=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.</span> The element is a <a href=#concept-button title=concept-button>button</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to activate the element.</p> <p>The element's <a href=#activation-behavior>activation behavior</a>, if the element has a <a href=#form-owner>form owner</a>, is to <a href=#concept-form-reset title=concept-form-reset>reset</a> the <a href=#form-owner>form owner</a>; otherwise, it is to do nothing.</p> <p><strong>Constraint validation</strong>: The element is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <div class=bookkeeping> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute applies to this element and is in mode <a href=#dom-input-value-default title=dom-input-value-default>default</a>.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> and <code class=no-backref title=event-input-change><a href=#event-input-change>change</a></code> events do not apply.</p> </div> <h6 id=button-state><span class=secno>4.10.7.1.22 </span><dfn title=attr-input-type-button>Button</dfn> state</h6> <div class=impl> <p>When an <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#button-state title=attr-input-type-button>Button</a> state, the rules in this section apply.</p> </div> <p>The <code><a href=#the-input-element>input</a></code> element <a href=#represents>represents</a> a button with no default behavior. A label for the button must be provided in the <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, though it may be the empty string. <span class=impl>If the element has a <code title=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 the empty string.</span> The element is a <a href=#concept-button title=concept-button>button</a>.</p> <div class=impl> <p>If the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, the user agent should allow the user to activate the element. The element's <a href=#activation-behavior>activation behavior</a> is to do nothing.</p> <p><strong>Constraint validation</strong>: The element is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <div class=bookkeeping> <p>The <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute applies to this element and is in mode <a href=#dom-input-value-default title=dom-input-value-default>default</a>.</p> <p>The following content attributes must not be specified and do not apply to the element: <code class=no-backref title=attr-input-accept><a href=#attr-input-accept>accept</a></code>, <code class=no-backref title=attr-input-alt><a href=#attr-input-alt>alt</a></code>, <code class=no-backref title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>, <code class=no-backref title=attr-input-checked><a href=#attr-input-checked>checked</a></code>, <code class=no-backref title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>, <code class=no-backref title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code class=no-backref title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code class=no-backref title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code class=no-backref title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, <code class=no-backref title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>, <code class=no-backref title=attr-dim-height><a href=#attr-dim-height>height</a></code>, <code class=no-backref title=attr-input-list><a href=#attr-input-list>list</a></code>, <code class=no-backref title=attr-input-max><a href=#attr-input-max>max</a></code>, <code class=no-backref title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code class=no-backref title=attr-input-min><a href=#attr-input-min>min</a></code>, <code class=no-backref title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>, <code class=no-backref title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>, <code class=no-backref title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>, <code class=no-backref title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>, <code class=no-backref title=attr-input-required><a href=#attr-input-required>required</a></code>, <code class=no-backref title=attr-input-size><a href=#attr-input-size>size</a></code>, <code class=no-backref title=attr-input-src><a href=#attr-input-src>src</a></code>, <code class=no-backref title=attr-input-step><a href=#attr-input-step>step</a></code>, and <code class=no-backref title=attr-dim-width><a href=#attr-dim-width>width</a></code>.</p> <p>The following IDL attributes and methods do not apply to the element: <code class=no-backref title=dom-input-checked><a href=#dom-input-checked>checked</a></code>, <code class=no-backref title=dom-input-files><a href=#dom-input-files>files</a></code>, <code class=no-backref title=dom-input-list><a href=#dom-input-list>list</a></code>, <code class=no-backref title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code class=no-backref title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code class=no-backref title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, <code class=no-backref title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code>, and <code class=no-backref title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes; <code class=no-backref title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code class=no-backref title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>, <code class=no-backref title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code>, and <code class=no-backref title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods.</p> <p>The <code class=no-backref title=event-input-input><a href=#event-input-input>input</a></code> and <code class=no-backref title=event-input-change><a href=#event-input-change>change</a></code> events do not apply.</p> </div> <h5 id=common-input-element-attributes><span class=secno>4.10.7.2 </span>Common <code><a href=#the-input-element>input</a></code> element attributes</h5> <div class=impl> <p>These attributes only apply to an <code><a href=#the-input-element>input</a></code> element if its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in a state whose definition declares that the attribute applies. When an attribute doesn't apply to an <code><a href=#the-input-element>input</a></code> element, user agents must <a href=#ignore>ignore</a> the attribute, regardless of the requirements and definitions below.</p> </div> <h6 id=the-autocomplete-attribute><span class=secno>4.10.7.2.1 </span>The <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> attribute</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.</p> <p>The <dfn id=attr-input-autocomplete title=attr-input-autocomplete><code>autocomplete</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a>. The attribute has three states. The <code title=attr-input-autocomplete-on>on</code> keyword maps to the <dfn id=attr-input-autocomplete-on-state title=attr-input-autocomplete-on-state>on</dfn> state, and the <code title=attr-input-autocomplete-off>off</code> keyword maps to the <dfn id=attr-input-autocomplete-off-state title=attr-input-autocomplete-off-state>off</dfn> state. The attribute may also be omitted. The <i>missing value default</i> is the <dfn id=attr-input-autocomplete-default-state title=attr-input-autocomplete-default-state>default</dfn> state.</p> <p>The <a href=#attr-input-autocomplete-off-state title=attr-input-autocomplete-off-state>off</a> state 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 him; or that the document provides its own autocomplete mechanism and does not want the user agent to provide autocompletion values.</p> <p>Conversely, the <a href=#attr-input-autocomplete-on-state title=attr-input-autocomplete-on-state>on</a> state indicates that the value is not particularly sensitive and the user can expect to be able to rely on his user agent to remember values he has entered for that control.</p> <p>The <a href=#attr-input-autocomplete-default-state title=attr-input-autocomplete-default-state>default</a> state indicates that the user agent is to use the <code title=attr-form-autocomplete><a href=#attr-form-autocomplete>autocomplete</a></code> attribute on the element's <a href=#form-owner>form owner</a> instead. (By default, the <code title=attr-form-autocomplete><a href=#attr-form-autocomplete>autocomplete</a></code> attribute of <code><a href=#the-form-element>form</a></code> elements is in the <a href=#attr-form-autocomplete-on-state title=attr-form-autocomplete-on-state>on</a> state.)</p> <div class=impl> <p>Each <code><a href=#the-input-element>input</a></code> element has a <dfn id=resulting-autocompletion-state>resulting autocompletion state</dfn>, which is either <i title="">on</i> or <i title="">off</i>.</p> <p>When an <code><a href=#the-input-element>input</a></code> element is in one of the following conditions, the <code><a href=#the-input-element>input</a></code> element's <a href=#resulting-autocompletion-state>resulting autocompletion state</a> is <i title="">on</i>; otherwise, the <code><a href=#the-input-element>input</a></code> element's <a href=#resulting-autocompletion-state>resulting autocompletion state</a> is <i title="">off</i>:</p> <ul class=brief><li>Its <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> attribute is in the <a href=#attr-input-autocomplete-on-state title=attr-input-autocomplete-on-state>on</a> state.</li> <li>Its <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> attribute is in the <a href=#attr-input-autocomplete-default-state title=attr-input-autocomplete-default-state>default</a> state, and the element has no <a href=#form-owner>form owner</a>.</li> <li>Its <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code> attribute is in the <a href=#attr-input-autocomplete-default-state title=attr-input-autocomplete-default-state>default</a> state, and the element's <a href=#form-owner>form owner</a>'s <code title=attr-form-autocomplete><a href=#attr-form-autocomplete>autocomplete</a></code> attribute is in the <a href=#attr-form-autocomplete-on-state title=attr-form-autocomplete-on-state>on</a> state.</li> </ul><p>When an <code><a href=#the-input-element>input</a></code> element's <a href=#resulting-autocompletion-state>resulting autocompletion state</a> is <i title="">on</i>, the user agent may store the value entered by the user so that if the user returns to the page, the UA can prefill the form. Otherwise, the user agent should not remember the control's <a href=#concept-fe-value title=concept-fe-value>value</a>, and should not offer past values to the user.</p> <p>In addition, if the <a href=#resulting-autocompletion-state>resulting autocompletion state</a> is <i title="">off</i>, <a href=#history-autocomplete>values are reset</a> when <a href=#traverse-the-history title="traverse the history">traversing the history</a>.</p> <p>The autocompletion mechanism must be implemented by the user agent acting as if the user had modified the element's <a href=#concept-fe-value title=concept-fe-value>value</a>, and must be done at a time where the element is <i title=concept-input-mutable><a href=#concept-input-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 title="stop parsing">stops parsing</a>).</p> </div> <div class=example> <p>Banks frequently do not want UAs to prefill login information:</p> <pre><p><label>Account: <input type="text" name="ac" autocomplete="off"></label></p> <p><label>PIN: <input type="password" name="pin" autocomplete="off"></label></p></pre> </div> <div class=impl> <p>A user agent may allow the user to override the <a href=#resulting-autocompletion-state>resulting autocompletion state</a> and set it to always <i title="">on</i>, always allowing values to be remembered and prefilled, or always <i title="">off</i>, never remembering values. However, user agents should not allow users to trivially override the <a href=#resulting-autocompletion-state>resulting autocompletion state</a> to <i title="">on</i>, as there are significant security implications for the user if all values are always remembered, regardless of the site's preferences.</p> </div> <h6 id=the-dirname-attribute><span class=secno>4.10.7.2.2 </span>The <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code> attribute</h6> <p>The <dfn id=attr-input-dirname title=attr-input-dirname><code>dirname</code></dfn> attribute, when it applies, is a <a href=#form-control-dirname-attribute>form control <code title="">dirname</code> attribute</a>.</p> <div class=example> <p>In this example, a form contains a text field and a submission button:</p> <pre><form action="addcomment.cgi" method=post> <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required></label></p> <p><button name="mode" type=submit value="add">Post Comment</button></p> </form></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&<strong>comment.dir=ltr</strong>&mode=add</pre> <p>If the user manually switches to a right-to-left writing direction and enters "<span dir=rtl lang=ar title="">مرحبًا</span>", the submission body might be something like:</p> <pre>comment=%D9%85%D8%B1%D8%AD%D8%A8%D9%8B%D8%A7&<strong>comment.dir=rtl</strong>&mode=add</pre> </div> <h6 id=the-list-attribute><span class=secno>4.10.7.2.3 </span>The <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute</h6> <p>The <dfn id=attr-input-list title=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=#concept-id title=concept-id>ID</a> of a <code><a href=#the-datalist-element>datalist</a></code> element in the same document.</p> <div class=impl> <p>The <dfn id=concept-input-list title=concept-input-list>suggestions source element</dfn> is the first element in the document in <a href=#tree-order>tree order</a> to have an <a href=#concept-id title=concept-id>ID</a> equal to the value of the <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute, if that element is a <code><a href=#the-datalist-element>datalist</a></code> element. If there is no <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute, or if there is no element with that <a href=#concept-id title=concept-id>ID</a>, or if the first element with that <a href=#concept-id title=concept-id>ID</a> is not a <code><a href=#the-datalist-element>datalist</a></code> element, then there is no <a href=#concept-input-list title=concept-input-list>suggestions source element</a>.</p> <p>If there is a <a href=#concept-input-list title=concept-input-list>suggestions source element</a>, then, when the user agent is allowing the user to edit the <code><a href=#the-input-element>input</a></code> element's <a href=#concept-fe-value title=concept-fe-value>value</a>, the user agent should offer the suggestions represented by the <a href=#concept-input-list title=concept-input-list>suggestions source element</a> to the user in a manner suitable for the type of control used. The user agent may use the suggestion's <a href=#concept-option-label title=concept-option-label>label</a> to identify the suggestion if appropriate.</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 title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute specified or if the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute does not apply</dt> <dd> <p>When the user selects a suggestion, the <code><a href=#the-input-element>input</a></code> element's <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to the selected suggestion's <a href=#concept-option-value title=concept-option-value>value</a>, as if the user had written that value himself.</p> </dd> <dt>If the element <em>does</em> have a <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute specified, and the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute does apply</dt> <dd> <p>When the user selects a suggestion, the user agent must either add a new entry to the <code><a href=#the-input-element>input</a></code> element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a>, whose value is the selected suggestion's <a href=#concept-option-value title=concept-option-value>value</a>, or change an existing entry in the <code><a href=#the-input-element>input</a></code> element's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a> to have the value given by the selected suggestion's <a href=#concept-option-value title=concept-option-value>value</a>, as if the user had himself 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> </dd> </dl><hr><p>If the <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute does not apply, there is no <a href=#concept-input-list title=concept-input-list>suggestions source element</a>.</p> </div> <div class=example> <p>This URL field offers some suggestions.</p> <pre><label>Homepage: <input name=hp type=url list=hpurls></label> <datalist id=hpurls> <option value="http://www.google.com/" label="Google"> <option value="http://www.reddit.com/" label="Reddit"> </datalist></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><a href=#the-datalist-element>datalist</a></code> element with children <code><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 title=attr-option-value><a href=#attr-option-value>value</a></code> attribute instead of inline.</p> <pre><p> <label> Enter a breed: <input type="text" name="breed" list="breeds"> <datalist id="breeds"> <option value="Abyssinian"> <option value="Alpaca"> <!-- ... --> </datalist> </label> </p></pre> <p>However, if the values need to be shown in legacy UAs, then fallback content can be placed inside the <code><a href=#the-datalist-element>datalist</a></code> element, as follows:</p> <pre><p> <label> Enter a breed: <input type="text" name="breed" list="breeds"> </label> <datalist id="breeds"> <label> or select one from the list: <select name="breed"> <option value=""> (none selected) <option>Abyssinian <option>Alpaca <!-- ... --> </select> </label> </datalist> </p> </pre> <p>The fallback content will only be shown in UAs that don't support <code><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><a href=#the-datalist-element>datalist</a></code> element.</p> <p>Note that if an <code><a href=#the-option-element>option</a></code> element used in a <code><a href=#the-datalist-element>datalist</a></code> is <code title=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><a href=#the-select-element>select</a></code>), but it will not have any effect on the <code><a href=#the-input-element>input</a></code> element in UAs that support <code><a href=#the-datalist-element>datalist</a></code>.</p> </div> <h6 id=the-readonly-attribute><span class=secno>4.10.7.2.4 </span>The <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute</h6> <p>The <dfn id=attr-input-readonly title=attr-input-readonly><code>readonly</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> that controls whether or not the user can edit the form control. <span class=impl>When specified, the element is <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i>.</span></p> <div class=impl> <p><strong>Constraint validation</strong>: If the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute is specified on an <code><a href=#the-input-element>input</a></code> element, the element is <a href=#barred-from-constraint-validation>barred from constraint validation</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><form action="products.cgi" method=post enctype="multipart/form-data"> <table> <tr> <th> Product ID <th> Product name <th> Price <th> Action <tr> <td> <input readonly name="1.pid" value="H412"> <td> <input required name="1.pname" value="Floor lamp Ulke"> <td> $<input required type=number min=0 step=0.01 name="1.pprice" value="49.99"> <td> <button formnovalidate name="action" value="delete:1">Delete</button> <tr> <td> <input readonly name="2.pid" value="FG28"> <td> <input required name="2.pname" value="Table lamp Ulke"> <td> $<input required type=number min=0 step=0.01 name="2.pprice" value="24.99"> <td> <button formnovalidate name="action" value="delete:2">Delete</button> <tr> <td> <input required name="3.pid" value="" pattern="[A-Z0-9]+"> <td> <input required name="3.pname" value=""> <td> $<input required type=number min=0 step=0.01 name="3.pprice" value=""> <td> <button formnovalidate name="action" value="delete:3">Delete</button> </table> <p> <button formnovalidate name="action" value="add">Add</button> </p> <p> <button name="action" value="update">Save</button> </p> </form></pre> </div> <h6 id=the-size-attribute><span class=secno>4.10.7.2.5 </span>The <code title=attr-input-size><a href=#attr-input-size>size</a></code> attribute</h6> <p>The <dfn id=attr-input-size title=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 title=concept-fe-value>value</a>.</p> <p>The <code title=attr-input-size><a href=#attr-input-size>size</a></code> attribute, if specified, must have a value that is a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero.</p> <div class=impl> <p>If the attribute is present, then its value must be parsed using the <a href=#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 title=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>limited to only non-negative numbers greater than zero</a> and has a default value of 20.</p> </div> <h6 id=the-required-attribute><span class=secno>4.10.7.2.6 </span>The <code title=attr-input-required><a href=#attr-input-required>required</a></code> attribute</h6> <p>The <dfn id=attr-input-required title=attr-input-required><code>required</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When specified, the element is <dfn id=concept-input-required title=concept-input-required><i>required</i></dfn>.</p> <div class=impl> <p><strong>Constraint validation</strong>: If the element is <i title=concept-input-required><a href=#concept-input-required>required</a></i>, and its <code title=dom-input-value><a href=#dom-input-value>value</a></code> IDL attribute applies and is in the mode <a href=#dom-input-value-value title=dom-input-value-value>value</a>, and the element is <i title=concept-input-mutable><a href=#concept-input-mutable>mutable</a></i>, and the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is the empty string, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </div> <div class=example> <p>The following form has two required fields, one for an e-mail address and one for a password. It also has a third field that is only considerd valid if the user types the same password in the password field and this third field.</p> <pre><h1>Create new account</h1> <form action="/newaccount" method=post oninput="up2.setCustomValidity(up2.value != up.value ? 'Passwords do not match.' : '')"> <p> <label for="username">E-mail address:</label> <input id="username" type=email required name=un> <p> <label for="password1">Password:</label> <input id="password1" type=password required name=up> <p> <label for="password2">Confirm password:</label> <input id="password2" type=password name=up2> <p> <input type=submit value="Create account"> </form></pre> </div> <h6 id=the-multiple-attribute><span class=secno>4.10.7.2.7 </span>The <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute</h6> <p>The <dfn id=attr-input-multiple title=attr-input-multiple><code>multiple</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> that indicates whether the user is to be allowed to specify more than one value.</p> <div class=example> <p>The following extract shows how an e-mail client's "Cc" field could accept multiple e-mail addresses.</p> <pre><label>Cc: <input type=email multiple name=cc></label></pre> <p>If the user had, amongst many friends in his user contacts database, two friends "Arthur Dent" (with address "art@example.net") and "Adam Josh" (with address "adamjosh@example.net"), then, after the user has typed "a", the user agent might suggest these two e-mail addresses to the user.</p> <p><img alt="" height=140 src=http://images.whatwg.org/sample-email-1.png width=500></p> <p>The page could also link in the user's contacts database from the site:</p> <pre><label>Cc: <input type=email multiple name=cc list=contacts></label> ... <datalist id="contacts"> <option value="hedral@damowmow.com"> <option value="pillar@example.com"> <option value="astrophy@cute.example"> <option value="astronomy@science.example.org"> </datalist></pre> <p>Suppose the user had entered "bob@example.net" into this text field, and then started typing a second e-mail address starting with "a". The user agent might show both the two friends mentioned earlier, as well as the "astrophy" and "astronomy" values given in the <code><a href=#the-datalist-element>datalist</a></code> element.</p> <p><img alt="" height=171 src=http://images.whatwg.org/sample-email-2.png width=500></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><label>Attachments: <input type=file multiple name=att></label></pre> </div> <h6 id=the-maxlength-attribute><span class=secno>4.10.7.2.8 </span>The <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> attribute</h6> <p>The <dfn id=attr-input-maxlength title=attr-input-maxlength><code>maxlength</code></dfn> attribute<span class=impl>, when it applies,</span> is a <a href=#attr-fe-maxlength title=attr-fe-maxlength>form control <code title="">maxlength</code> attribute</a><span class=impl> controlled by the <code><a href=#the-input-element>input</a></code> element's <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a></span>.</p> <p>If the <code><a href=#the-input-element>input</a></code> element has a <a href=#maximum-allowed-value-length>maximum allowed value length</a>, then the <a href=#code-point-length>code-point length</a> of the value of the element's <code title=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>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><label>What are you doing? <input name=status maxlength=140></label></pre> </div> <h6 id=the-pattern-attribute><span class=secno>4.10.7.2.9 </span>The <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute</h6> <p>The <dfn id=attr-input-pattern title=attr-input-pattern><code>pattern</code></dfn> attribute specifies a regular expression against which the control's <a href=#concept-fe-value title=concept-fe-value>value</a>, or, when the <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute applies and is set, the control's <a href=#concept-fe-values title=concept-fe-values>value<em>s</em></a>, are to be checked.</p> <p>If specified, the attribute's value must match the JavaScript <i title="">Pattern</i> production. <a href=#refsECMA262>[ECMA262]</a></p> <div class=impl> <p>If an <code><a href=#the-input-element>input</a></code> element has a <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute specified, and the attribute's value, when compiled as a JavaScript regular expression with the <code title="">global</code>, <code title="">ignoreCase</code>, and <code title="">multiline</code> flags <em>disabled</em> (see ECMA262 Edition 5, sections 15.10.7.2 through 15.10.7.4), 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>compiled pattern regular expression</a>. <a href=#refsECMA262>[ECMA262]</a></p> <p><strong>Constraint validation</strong>: If the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is not the empty string, and either the element's <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is not specified or it does not apply to the <code><a href=#the-input-element>input</a></code> element given its <code title=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>compiled pattern regular expression</a> but that regular expression does not match the entirety of the element's <a href=#concept-fe-value title=concept-fe-value>value</a>, then the element is <a href=#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 title=concept-fe-value>value</a> is not the empty string, and the element's <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute is specified and applies to the <code><a href=#the-input-element>input</a></code> element, and the element has a <a href=#compiled-pattern-regular-expression>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 title=concept-fe-values>value<em>s</em></a>, then the element is <a href=#suffering-from-a-pattern-mismatch>suffering from a pattern mismatch</a>.</p> <p>The <a href=#compiled-pattern-regular-expression>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 title=attr-input-pattern><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 title="">^(?:</code> at the start of the pattern and a <code title="">)$</code> at the end).</p> </div> <p>When an <code><a href=#the-input-element>input</a></code> element has a <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute specified, authors should include a <code title=attr-title><a href=#the-title-attribute>title</a></code> 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 gains focus.</p> <div class=example> <p>For example, the following snippet:</p> <pre><label> Part number: <input pattern="[0-9][A-Z]{3}" name="part" title="A part number is a digit followed by three uppercase letters."/> </label></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 title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute, the <code title=attr-title><a href=#the-title-attribute>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><a href=#the-title-element>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><a href=#the-title-element>title</a></code>s as if an error has necessarily occurred.</p> <h6 id=the-min-and-max-attributes><span class=secno>4.10.7.2.10 </span>The <code title=attr-input-min><a href=#attr-input-min>min</a></code> and <code title=attr-input-max><a href=#attr-input-max>max</a></code> attributes</h6> <p>The <dfn id=attr-input-min title=attr-input-min><code>min</code></dfn> and <dfn id=attr-input-max title=attr-input-max><code>max</code></dfn> attributes indicate the allowed range of values for the element.</p> <div class=impl> <p>Their syntax is defined by the section that defines the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state.</p> <p>If the element has a <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute, and the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the value of the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute is a number, then that number is the element's <dfn id=concept-input-min title=concept-input-min>minimum</dfn>; otherwise, if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state defines a <dfn id=concept-input-min-default title=concept-input-min-default>default minimum</dfn>, then that is the <a href=#concept-input-min title=concept-input-min>minimum</a>; otherwise, the element has no <a href=#concept-input-min title=concept-input-min>minimum</a>.</p> <p><strong>Constraint validation</strong>: When the element has a <a href=#attr-input-min title=attr-input-min>minimum</a>, and the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the string given by the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is a number, and the number obtained from that algorithm is less than the <a href=#attr-input-min title=attr-input-min>minimum</a>, the element is <a href=#suffering-from-an-underflow>suffering from an underflow</a>.</p> <p>The <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute also defines the <a href=#concept-input-min-zero title=concept-input-min-zero>step base</a>.</p> <p>If the element has a <code title=attr-input-max><a href=#attr-input-max>max</a></code> attribute, and the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the value of the <code title=attr-input-max><a href=#attr-input-max>max</a></code> attribute is a number, then that number is the element's <dfn id=concept-input-max title=concept-input-max>maximum</dfn>; otherwise, if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state defines a <dfn id=concept-input-max-default title=concept-input-max-default>default maximum</dfn>, then that is the <a href=#concept-input-max title=concept-input-max>maximum</a>; otherwise, the element has no <a href=#concept-input-max title=concept-input-max>maximum</a>.</p> <p><strong>Constraint validation</strong>: When the element has a <a href=#attr-input-max title=attr-input-max>maximum</a>, and the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the string given by the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is a number, and the number obtained from that algorithm is more than the <a href=#attr-input-max title=attr-input-max>maximum</a>, the element is <a href=#suffering-from-an-overflow>suffering from an overflow</a>.</p> </div> <p>The <code title=attr-input-max><a href=#attr-input-max>max</a></code> attribute's value (the <a href=#concept-input-max title=concept-input-max>maximum</a>) must not be less than the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute's value (its <a href=#concept-input-min title=concept-input-min>minimum</a>).</p> <div class=impl> <p class=note>If an element has a <a href=#attr-input-max title=attr-input-max>maximum</a> that is less than its <a href=#attr-input-min title=attr-input-min>minimum</a>, then so long as the element has a <a href=#concept-fe-value title=concept-fe-value>value</a>, it will either be <a href=#suffering-from-an-underflow>suffering from an underflow</a> or <a href=#suffering-from-an-overflow>suffering from an overflow</a>.</p> </div> <p>An element <dfn id=have-range-limitations title="have range limitations">has range limitations</dfn> if it has a defined <a href=#concept-input-min title=concept-input-min>minimum</a> or a defined <a href=#concept-input-max title=concept-input-max>maximum</a>.</p> <div class=example> <p>The following date control limits input to dates that are before the 1980s:</p> <pre><input name=bday type=date max="1979-12-31"></pre> </div> <div class=example> <p>The following number control limits input to whole numbers greater than zero:</p> <pre><input name=quantity required type=number min=1 value=1></pre> </div> <h6 id=the-step-attribute><span class=secno>4.10.7.2.11 </span>The <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute</h6> <p>The <dfn id=attr-input-step title=attr-input-step><code>step</code></dfn> attribute indicates the granularity that is expected (and required) of the <a href=#concept-fe-value title=concept-fe-value>value</a>, by limiting the allowed values. <span class=impl>The section that defines the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state also defines the <dfn id=concept-input-step-default title=concept-input-step-default>default step</dfn>, the <dfn id=concept-input-step-scale title=concept-input-step-scale>step scale factor</dfn>, and in some cases the <dfn id=concept-input-step-default-base title=concept-input-step-default-base>default step base</dfn>, which are used in processing the attribute as described below.</span></p> <p>The <code title=attr-input-step><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>valid floating point number</a> that <a href=#rules-for-parsing-floating-point-number-values title="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 href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">any</code>".</p> <div class=impl> <p>The attribute provides the <dfn id=concept-input-step title=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 title=concept-input-step>allowed value step</a> is the <a href=#concept-input-step-default title=concept-input-step-default>default step</a> multiplied by the <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a>.</li> <li>Otherwise, if the attribute's value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">any</code>", then there is no <a href=#concept-input-step title=concept-input-step>allowed value step</a>.</li> <li>Otherwise, if the <a href=#rules-for-parsing-floating-point-number-values>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 title=concept-input-step>allowed value step</a> is the <a href=#concept-input-step-default title=concept-input-step-default>default step</a> multiplied by the <a href=#concept-input-step-scale title=concept-input-step-scale>step scale factor</a>.</li> <li>Otherwise, the <a href=#concept-input-step title=concept-input-step>allowed value step</a> is the number returned by the <a href=#rules-for-parsing-floating-point-number-values>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 title=concept-input-step-scale>step scale factor</a>.</li> </ol><p>The <dfn id=concept-input-min-zero title=concept-input-min-zero>step base</dfn> is the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the value of the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute, unless the element does not have a <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute specified or the result of applying that algorithm is an error, in which case the <a href=#concept-input-min-zero title=concept-input-min-zero>step base</a> is the <a href=#concept-input-step-default-base title=concept-input-step-default-base>default step base</a>, if one is defined, or zero, if not.</p> <p><strong>Constraint validation</strong>: When the element has an <a href=#concept-input-step title=concept-input-step>allowed value step</a>, and the result of applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the string given by the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is a number, and that number subtracted from the <a href=#concept-input-min-zero title=concept-input-min-zero>step base</a> is not an integral multiple of the <a href=#concept-input-step title=concept-input-step>allowed value step</a>, the element is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>.</p> </div> <div class=example> <p>The following range control only accepts values in the range 0..1, and allows 256 steps in that range:</p> <pre><input name=opacity type=range min=0 max=1 step=0.00392156863></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><input name=favtime type=time step=any></pre> <p>Normally, time controls are limited to an accuracy of one minute.</p> </div> <h6 id=the-placeholder-attribute><span class=secno>4.10.7.2.12 </span>The <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code> attribute</h6> <!-- similar text in the <textarea> section --> <p>The <dfn id=attr-input-placeholder title=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. A hint could be a sample value or a brief description of the expected format. The attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p> <p class=note>For a longer hint or other advisory text, the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute is more appropriate.</p> <p>The <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code> attribute should not be used as an alternative to a <code><a href=#the-label-element>label</a></code>.</p> <div class=impl> <p>User agents should present this hint to the user, after having <a href=#strip-line-breaks title="strip line breaks">stripped line breaks</a> from it, when the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is the empty string and/or the control is not focused (e.g. by displaying it inside a blank unfocused control and hiding it otherwise).</p> </div> <div class=example> <p>Here is an example of a mail configuration user interface that uses the <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code> attribute:</p> <pre><fieldset> <legend>Mail Account</legend> <p><label>Name: <input type="text" name="fullname" placeholder="John Ratzenberger"></label></p> <p><label>Address: <input type="email" name="address" placeholder="john@example.net"></label></p> <p><label>Password: <input type="password" name="password"></label></p> <p><label>Description: <input type="text" name="desc" placeholder="My Email Account"></label></p> </fieldset></pre> </div> <h5 id=common-input-element-apis><span class=secno>4.10.7.3 </span>Common <code><a href=#the-input-element>input</a></code> element APIs</h5> <dl class=domintro><dt><var title="">input</var> . <code title=dom-input-value><a href=#dom-input-value>value</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current <a href=#concept-fe-value title=concept-fe-value>value</a> of the form control.</p> <p>Can be set, to change the value.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if it is set to any value other than the empty string when the control is a file upload control.</p> </dd> <dt><var title="">input</var> . <code title=dom-input-checked><a href=#dom-input-checked>checked</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> of the form control.</p> <p>Can be set, to change the <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a>.</p> </dd> <dt><var title="">input</var> . <code title=dom-input-files><a href=#dom-input-files>files</a></code></dt> <dd> <p>Returns a <code><a href=#filelist>FileList</a></code> object listing the <a href=#concept-input-type-file-selected title=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> </dd> <dt><var title="">input</var> . <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns a <code>Date</code> object representing the form control's <a href=#concept-fe-value title=concept-fe-value>value</a>, if applicable; otherwise, returns null.</p> <p>Can be set, to change the value.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if the control isn't date- or time-based.</p> </dd> <dt><var title="">input</var> . <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns a number representing the form control's <a href=#concept-fe-value title=concept-fe-value>value</a>, if applicable; otherwise, returns null.</p> <p>Can be set, to change the value.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if the control is neither date- or time-based nor numeric.</p> </dd> <dt><var title="">input</var> . <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp</a></code>( [ <var title="">n</var> ] )</dt> <dt><var title="">input</var> . <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown</a></code>( [ <var title="">n</var> ] )</dt> <dd> <p>Changes the form control's <a href=#concept-fe-value title=concept-fe-value>value</a> by the value given in the <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute, multiplied by <var title="">n</var>. The default value for <var title="">n</var> is 1.</p> <p>Throws <code><a href=#invalidstateerror>InvalidStateError</a></code> exception if the control is neither date- or time-based nor numeric, if the <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute's value is "<code title="">any</code>", if the current <a href=#concept-fe-value title=concept-fe-value>value</a> could not be parsed, or if stepping in the given direction by the given amount would take the value out of range.</p> </dd> <dt><var title="">input</var> . <code title=dom-input-list><a href=#dom-input-list>list</a></code></dt> <dd> <p>Returns the <code><a href=#the-datalist-element>datalist</a></code> element indicated by the <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-input-value title=dom-input-value><code>value</code></dfn> IDL attribute allows scripts to manipulate the <a href=#concept-fe-value title=concept-fe-value>value</a> of an <code><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 title=dom-input-value-value>value</dfn> <dd> <p>On getting, it must return the current <a href=#concept-fe-value title=concept-fe-value>value</a> of the element. On setting, it must set the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to the new value, set the element's <a href=#concept-input-value-dirty-flag title=concept-input-value-dirty-flag>dirty value flag</a> to true, invoke the <a href=#value-sanitization-algorithm>value sanitization algorithm</a>, if the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state defines one, and then, if the element has a text entry cursor position, should move the text entry cursor position to the end of the text field, unselecting any selected text and resetting the selection direction to <i>none</i>.</p> </dd> <dt><dfn id=dom-input-value-default title=dom-input-value-default>default</dfn> <dd> <p>On getting, if the element has a <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, it must return that attribute's value; otherwise, it must return the empty string. On setting, it must set the element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute to the new value.</p> </dd> <dt><dfn id=dom-input-value-default-on title=dom-input-value-default-on>default/on</dfn> <dd> <p>On getting, if the element has a <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, it must return that attribute's value; otherwise, it must return the string "<code title="">on</code>". On setting, it must set the element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute to the new value.</p> </dd> <dt><dfn id=dom-input-value-filename title=dom-input-value-filename>filename</dfn> <dd id=fakepath-orly> <p>On getting, it must return the string "<code title="">C:\fakepath\</code>" followed by the filename of the first file in the list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>, if any, or the empty string if the list is empty. On setting, if the new value is the empty string, it must empty the list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>; otherwise, it must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</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> </dd> </dl><hr><p>The <dfn id=dom-input-checked title=dom-input-checked><code>checked</code></dfn> IDL attribute allows scripts to manipulate the <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> of an <code><a href=#the-input-element>input</a></code> element. On getting, it must return the current <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> of the element; and on setting, it must set the element's <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> to the new value and set the element's <a href=#concept-input-checked-dirty-flag title=concept-input-checked-dirty-flag>dirty checkedness flag</a> to true.</p> <hr><p>The <dfn id=dom-input-files title=dom-input-files><code>files</code></dfn> IDL attribute allows scripts to access the element's <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>. On getting, if the IDL attribute applies, it must return a <code><a href=#filelist>FileList</a></code> object that represents the current <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>. The same object must be returned until the list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a> changes. If the IDL attribute does not apply, then it must instead return null. <a href=#refsFILEAPI>[FILEAPI]</a></p> <hr><p>The <dfn id=dom-input-valueasdate title=dom-input-valueAsDate><code>valueAsDate</code></dfn> IDL attribute represents the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element, interpreted as a date.</p> <p>On getting, if the <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> attribute does not apply, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><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 title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a> defined for that state; if the algorithm returned a <code>Date</code> object, then return it, otherwise, return null.</p> <p>On setting, if the <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAsDate</a></code> attribute does not apply, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception; otherwise, if the new value is null, then set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to the empty string; otherwise, run the <a href=#concept-input-value-date-string title=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 title=concept-fe-value>value</a> of the element to resulting string.</p> <hr><p>The <dfn id=dom-input-valueasnumber title=dom-input-valueAsNumber><code>valueAsNumber</code></dfn> IDL attribute represents the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element, interpreted as a number.</p> <p>On getting, if the <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> attribute does not apply, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state, then return a Not-a-Number (NaN) value. Otherwise, if the <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAs<em>Date</em></a></code> attribute applies, run the <a href=#concept-input-value-string-date title=concept-input-value-string-date>algorithm to convert a string to a <code>Date</code> object</a> defined for that state; if the algorithm returned a <code>Date</code> object, then return the <i>time value</i> of the object (the number of milliseconds from midnight UTC the morning of 1970-01-01 to the time represented by the <code>Date</code> object), otherwise, return a Not-a-Number (NaN) value. Otherwise, run the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> defined for that state; if the algorithm returned a number, then return it, otherwise, return a Not-a-Number (NaN) value.</p> <p>On setting, if the <code title=dom-input-valueAsNumber><a href=#dom-input-valueasnumber>valueAsNumber</a></code> attribute does not apply, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. Otherwise, if the <code title=dom-input-valueAsDate><a href=#dom-input-valueasdate>valueAs<em>Date</em></a></code> attribute applies, run the <a href=#concept-input-value-date-string title=concept-input-value-date-string>algorithm to convert a <code>Date</code> object to a string</a> defined for that state, passing it a <code>Date</code> object whose <i>time value</i> is the new value, and set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to resulting string. Otherwise, run the <a href=#concept-input-value-number-string title=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 title=concept-fe-value>value</a> of the element to resulting string.</p> <hr><p>The <dfn id=dom-input-stepdown title=dom-input-stepDown><code>stepDown(<var title="">n</var>)</code></dfn> and <dfn id=dom-input-stepup title=dom-input-stepUp><code>stepUp(<var title="">n</var>)</code></dfn> methods, when invoked, must run the following algorithm:</p> <ol><li><p>If the <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> and <code title=dom-input-stepUp><a href=#dom-input-stepup>stepUp()</a></code> methods do not apply, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception, and abort these steps.</li> <li><p>If the element has no <a href=#concept-input-step title=concept-input-step>allowed value step</a>, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception, and abort these steps.</li> <li><p>If applying the <a href=#concept-input-value-string-number title=concept-input-value-string-number>algorithm to convert a string to a number</a> to the string given by the element's <a href=#concept-fe-value title=concept-fe-value>value</a> results in an error, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception, and abort these steps; otherwise, let <var title="">value</var> be the result of that algorithm.</li> <li><p>Let <var title="">n</var> be the argument, or 1 if the argument was omitted.</li> <li><p>Let <var title="">delta</var> be the <a href=#concept-input-step title=concept-input-step>allowed value step</a> multiplied by <var title="">n</var>.</li> <li><p>If the method invoked was the <code title=dom-input-stepDown><a href=#dom-input-stepdown>stepDown()</a></code> method, negate <var title="">delta</var>.</li> <li><p>Let <var title="">value</var> be the result of adding <var title="">delta</var> to <var title="">value</var>.</li> <li><p>If the element has a <a href=#concept-input-min title=concept-input-min>minimum</a>, and the <var title="">value</var> is less than that <a href=#concept-input-min title=concept-input-min>minimum</a>, then throw a <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>If the element has a <a href=#concept-input-max title=concept-input-max>maximum</a>, and the <var title="">value</var> is greater than that <a href=#concept-input-max title=concept-input-max>maximum</a>, then throw a <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>Let <var title="">value as string</var> be the result of running the <a href=#concept-input-value-number-string title=concept-input-value-number-string>algorithm to convert a number to a string</a>, as defined for the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute's current state, on <var title="">value</var>.</li> <li><p>Set the <a href=#concept-fe-value title=concept-fe-value>value</a> of the element to <var title="">value as string</var>.</li> </ol><hr><p>The <dfn id=dom-input-list title=dom-input-list><code>list</code></dfn> IDL attribute must return the current <a href=#concept-input-list title=concept-input-list>suggestions source element</a>, if any, or null otherwise.</p> </div> <div class=impl> <h5 id=common-event-behaviors><span class=secno>4.10.7.4 </span>Common event behaviors</h5> <p>When the <dfn id=event-input-input title=event-input-input><code>input</code></dfn> event applies, any time the user causes the element's <a href=#concept-fe-value title=concept-fe-value>value</a> to change, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-input>input</code> at the <code><a href=#the-input-element>input</a></code> element. 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> <!-- same text is present in the <textarea> section --> <p class=example>Examples of a user changing the element's <a href=#concept-fe-value title=concept-fe-value>value</a> would include the user typing into a text field, pasting a new value into the field, or undoing an edit in that field. Some user interactions do not cause changes to the value, e.g. hitting the "delete" key in an empty text field, or replacing some text in the field with text from the clipboard that happens to be exactly the same text.</p> <p>When the <dfn id=event-input-change title=event-input-change><code>change</code></dfn> event applies, if the element does not have an <a href=#activation-behavior>activation behavior</a> defined but uses a user interface that involves an explicit commit action, then any time the user commits a change to the element's <a href=#concept-fe-value title=concept-fe-value>value</a> or list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the <code><a href=#the-input-element>input</a></code> element.</p> <p class=example>An example of a user interface with a commit action would be a <a href=#file-upload-state title=attr-input-type-file>File Upload</a> control that consists of a single button that brings up a file selection dialog: when the dialog is closed, if that the <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>file selection</a> changed as a result, then the user has committed a new <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>file selection</a>.</p> <p class=example>Another example of a user interface with a commit action would be a <a href=#date-state title=attr-input-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>When the user agent changes the element's <a href=#concept-fe-value title=concept-fe-value>value</a> on behalf of the user (e.g. as part of a form prefilling feature), the user agent must follow these steps:</p> <ol><li>If the <code title=event-input-input><a href=#event-input-input>input</a></code> event applies, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-input>input</code> at the <code><a href=#the-input-element>input</a></code> element.</li> <li>If the <code title=event-input-change><a href=#event-input-change>change</a></code> event applies, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the <code><a href=#the-input-element>input</a></code> element.</li> </ol><p class=note>In addition, when the <code title=event-input-change><a href=#event-input-change>change</a></code> event applies, <code title=event-change>change</code> events can also be fired as part of the element's <a href=#activation-behavior>activation behavior</a> and as part of the <a href=#unfocusing-steps>unfocusing steps</a>.</p> <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#user-interaction-task-source>user interaction task source</a>.</p> </div> <h4 id=the-button-element><span class=secno>4.10.8 </span>The <dfn><code>button</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, and <a href=#category-submit title=category-submit>submittable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>, but there must be no <a href=#interactive-content>interactive content</a> descendant.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code></dd> <dd><code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code></dd> <dd><code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code></dd> <dd><code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code></dd> <dd><code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code></dd> <dd><code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dd><code title=attr-button-type><a href=#attr-button-type>type</a></code></dd> <dd><code title=attr-button-value><a href=#attr-button-value>value</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlbuttonelement>HTMLButtonElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-fe-autofocus title=dom-fe-autofocus>autofocus</a>; attribute boolean <a href=#dom-fe-disabled title=dom-fe-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-fs-formaction title=dom-fs-formAction>formAction</a>; attribute DOMString <a href=#dom-fs-formenctype title=dom-fs-formEnctype>formEnctype</a>; attribute DOMString <a href=#dom-fs-formmethod title=dom-fs-formMethod>formMethod</a>; attribute boolean <a href=#dom-fs-formnovalidate title=dom-fs-formNoValidate>formNoValidate</a>; attribute DOMString <a href=#dom-fs-formtarget title=dom-fs-formTarget>formTarget</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; attribute DOMString <a href=#dom-button-type title=dom-button-type>type</a>; attribute DOMString <a href=#dom-button-value title=dom-button-value>value</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><p>The <code><a href=#the-button-element>button</a></code> element <a href=#represents>represents</a> a button. <span class=impl>If the element is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the user to activate the button.</span></p> <p>The element is a <a href=#concept-button title=concept-button>button</a>.</p> <p>The <dfn id=attr-button-type title=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>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 title=attr-button-type-submit><code>submit</code></dfn> <td><a href=#attr-button-type-submit-state title=attr-button-type-submit-state>Submit Button</a> <td>Submits the form. <tr><td><dfn id=attr-button-type-reset title=attr-button-type-reset><code>reset</code></dfn> <td><a href=#attr-button-type-reset-state title=attr-button-type-reset-state>Reset Button</a> <td>Resets the form. <tr><td><dfn id=attr-button-type-button title=attr-button-type-button><code>button</code></dfn> <td><a href=#attr-button-type-button-state title=attr-button-type-button-state>Button</a> <td>Does nothing. </table><p>The <i>missing value default</i> is the <a href=#attr-button-type-submit-state title=attr-button-type-submit-state>Submit Button</a> state.</p> <p>If the <code title=attr-button-type><a href=#attr-button-type>type</a></code> attribute is in the <a href=#attr-button-type-submit-state title=attr-button-type-submit-state>Submit Button</a> state, the element is specifically a <a href=#concept-submit-button title=concept-submit-button>submit button</a>.</p> <div class=impl> <p><strong>Constraint validation</strong>: If the <code title=attr-button-type><a href=#attr-button-type>type</a></code> attribute is in the <a href=#attr-button-type-reset-state title=attr-button-type-reset-state>Reset Button</a> state or the <a href=#attr-button-type-button-state title=attr-button-type-button-state>Button</a> state, the element is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> <p>If the element is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, the <a href=#activation-behavior>activation behavior</a> of the <code><a href=#the-button-element>button</a></code> element is to run the steps defined in the following list for the current state of the element's <code title=attr-button-type><a href=#attr-button-type>type</a></code> attribute.</p> <dl><dt> <dfn id=attr-button-type-submit-state title=attr-button-type-submit-state>Submit Button</dfn> </dt> <dd><p>If the element has a <a href=#form-owner>form owner</a>, the element must <a href=#concept-form-submit title=concept-form-submit>submit</a> the <a href=#form-owner>form owner</a> from the <code><a href=#the-button-element>button</a></code> element.</dd> <dt> <dfn id=attr-button-type-reset-state title=attr-button-type-reset-state>Reset Button</dfn> </dt> <dd><p>If the element has a <a href=#form-owner>form owner</a>, the element must <a href=#concept-form-reset title=concept-form-reset>reset</a> the <a href=#form-owner>form owner</a>.</dd> <dt> <dfn id=attr-button-type-button-state title=attr-button-type-button-state>Button</dfn> <dd><p>Do nothing.</dd> </dl></div> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-button-element>button</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name. The <code title=attr-fe-disabled><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 title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus. The <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> attributes are <a href=#attributes-for-form-submission>attributes for form submission</a>.</p> <p class=note>The <code title=attr-fs-formnovalidate><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 title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> must not be specified if the element's <code title=attr-button-type><a href=#attr-button-type>type</a></code> attribute is not in the <a href=#attr-button-type-submit-state title=attr-button-type-submit-state>Submit Button</a> state.</p> <p>The <dfn id=attr-button-value title=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 title=concept-fe-value>value</a> is the value of the element's <code title=attr-button-value><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> <div class=impl> <p>The <dfn id=dom-button-value title=dom-button-value><code>value</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-button-type title=dom-button-type><code>type</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-fe-autofocus><a href=#dom-fe-autofocus>autofocus</a></code>, <code title=dom-fe-disabled><a href=#dom-fe-disabled>disabled</a></code>, <code title=dom-fae-form><a href=#dom-fae-form>form</a></code>, and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> </div> <div class=example> <p>The following button is labeled "Show hint" and pops up a dialog box when activated:</p> <pre><button type=button onclick="alert('This 15-20 minute piece was composed by George Gershwin.')"> Show hint </button></pre> </div> <h4 id=the-select-element><span class=secno>4.10.9 </span>The <dfn><code>select</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, <a href=#category-submit title=category-submit>submittable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-option-element>option</a></code> or <code><a href=#the-optgroup-element>optgroup</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code></dd> <dd><code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dd><code title=attr-select-required><a href=#attr-select-required>required</a></code></dd> <dd><code title=attr-select-size><a href=#attr-select-size>size</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlselectelement>HTMLSelectElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-fe-autofocus title=dom-fe-autofocus>autofocus</a>; attribute boolean <a href=#dom-fe-disabled title=dom-fe-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute boolean <a href=#dom-select-multiple title=dom-select-multiple>multiple</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; attribute boolean <a href=#dom-select-required title=dom-select-required>required</a>; attribute unsigned long <a href=#dom-select-size title=dom-select-size>size</a>; readonly attribute DOMString <a href=#dom-select-type title=dom-select-type>type</a>; readonly attribute <a href=#htmloptionscollection>HTMLOptionsCollection</a> <a href=#dom-select-options title=dom-select-options>options</a>; attribute unsigned long <a href=#dom-select-length title=dom-select-length>length</a>; getter <a href=#element>Element</a> <a href=#dom-select-item title=dom-select-item>item</a>(unsigned long index); object <a href=#dom-select-nameditem title=dom-select-namedItem>namedItem</a>(DOMString name); void <a href=#dom-select-add title=dom-select-add>add</a>(<a href=#htmloptionelement>HTMLOptionElement</a> element, optional <a href=#htmlelement>HTMLElement</a>? before); void <a href=#dom-select-add title=dom-select-add>add</a>(<a href=#htmloptgroupelement>HTMLOptGroupElement</a> element, optional <a href=#htmlelement>HTMLElement</a>? before); void <a href=#dom-select-add title=dom-select-add>add</a>(<a href=#htmloptionelement>HTMLOptionElement</a> element, long before); void <a href=#dom-select-add title=dom-select-add>add</a>(<a href=#htmloptgroupelement>HTMLOptGroupElement</a> element, long before); void <a href=#dom-select-remove title=dom-select-remove>remove</a>(long index); <a href=#dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>setter creator</a> void (unsigned long index, <a href=#htmloptionelement>HTMLOptionElement</a> option); readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-select-selectedoptions title=dom-select-selectedOptions>selectedOptions</a>; attribute long <a href=#dom-select-selectedindex title=dom-select-selectedIndex>selectedIndex</a>; attribute DOMString <a href=#dom-select-value title=dom-select-value>value</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><!-- Proposals for v2: * <select value=""> as an alternative to <option selected> http://developers.slashdot.org/comments.pl?sid=426306&cid=22142072 <Philip`> http://www.ipiao.com.cn/ does <select size="1" name="to"><script>City_Default="PEK"</script><SCRIPT language=javascript src="/js/flightcity.js"></SCRIPT></select> which is the kind of thing that could be much simpler with <select value="PEK"> --><p>The <code><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 title=attr-select-multiple><code>multiple</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. If the attribute is present, then the <code><a href=#the-select-element>select</a></code> element <a href=#represents>represents</a> a control for selecting zero or more options from the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>. If the attribute is absent, then the <code><a href=#the-select-element>select</a></code> element <a href=#represents>represents</a> a control for selecting a single option from the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>.</p> <p>The <dfn id=attr-select-size title=attr-select-size><code>size</code></dfn> attribute gives the number of options to show to the user. The <code title=attr-select-size><a href=#attr-select-size>size</a></code> attribute, if specified, must have a value that is a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero.</p> <div class=impl> <p>The <dfn id=concept-select-size title=concept-select-size>display size</dfn> of a <code><a href=#the-select-element>select</a></code> element is the result of applying the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> to the value of element's <code title=attr-select-size><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 title=attr-select-size><a href=#attr-select-size>size</a></code> attribute is absent, then the element's <a href=#concept-select-size title=concept-select-size>display size</a> is 4 if the element's <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> content attribute is present, and 1 otherwise.</p> </div> <p>The <dfn id=concept-select-option-list title=concept-select-option-list>list of options</dfn> for a <code><a href=#the-select-element>select</a></code> element consists of all the <code><a href=#the-option-element>option</a></code> element children of the <code><a href=#the-select-element>select</a></code> element, and all the <code><a href=#the-option-element>option</a></code> element children of all the <code><a href=#the-optgroup-element>optgroup</a></code> element children of the <code><a href=#the-select-element>select</a></code> element, in <a href=#tree-order>tree order</a>.</p> <p>The <dfn id=attr-select-required title=attr-select-required><code>required</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When specified, the user will be required to select a value before submitting the form.</p> <p>If a <code><a href=#the-select-element>select</a></code> element has a <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute specified, does not have a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute specified, and has a <a href=#concept-select-size title=concept-select-size>display size</a> of 1; and if the <a href=#concept-option-value title=concept-option-value>value</a> of the first <code><a href=#the-option-element>option</a></code> element in the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> (if any) is the empty string, and that <code><a href=#the-option-element>option</a></code> element's parent node is the <code><a href=#the-select-element>select</a></code> element (and not an <code><a href=#the-optgroup-element>optgroup</a></code> element), then that <code><a href=#the-option-element>option</a></code> is the <code><a href=#the-select-element>select</a></code> element's <dfn id=placeholder-label-option>placeholder label option</dfn>.</p> <p>If a <code><a href=#the-select-element>select</a></code> element has a <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute specified, does not have a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute specified, and has a <a href=#concept-select-size title=concept-select-size>display size</a> of 1, then the <code><a href=#the-select-element>select</a></code> element must have a <a href=#placeholder-label-option>placeholder label option</a>.</p> <div class=impl> <p><strong>Constraint validation</strong>: If the element has its <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute specified, and either none of the <code><a href=#the-option-element>option</a></code> elements in the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> have their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, or the only <code><a href=#the-option-element>option</a></code> element in the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> with its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true is the <a href=#placeholder-label-option>placeholder label option</a>, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </div> <div class=impl> <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the user to pick an <code><a href=#the-option-element>option</a></code> element in its <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that is itself not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>. Upon this <code><a href=#the-option-element>option</a></code> element being <dfn id=concept-select-pick title=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 title=option-command>menu command</a>, or through any other mechanism), and before the relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the <code title=event-click><a href=#event-click>click</a></code> event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the picked <code><a href=#the-option-element>option</a></code> element to true and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task source.</p> <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, whenever an <code><a href=#the-option-element>option</a></code> element in the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, and whenever an <code><a href=#the-option-element>option</a></code> element with its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true is added to the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the other <code><a href=#the-option-element>option</a></code> element in its <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false.</p> <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent and the element's <a href=#concept-select-size title=concept-select-size>display size</a> is greater than 1, then the user agent should also allow the user to request that the <code><a href=#the-option-element>option</a></code> whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, if any, be unselected. Upon this request being conveyed to the user agent, and before the relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the <code title=event-click><a href=#event-click>click</a></code> event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of that <code><a href=#the-option-element>option</a></code> element to false and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task source.</p> <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent and the element's <a href=#concept-select-size title=concept-select-size>display size</a> is 1, then whenever there are no <code><a href=#the-option-element>option</a></code> elements in the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that have their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> in <a href=#tree-order>tree order</a> that is not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>, if any, to true.</p> <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is present, and the element is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the user to <dfn id=concept-select-toggle title=concept-select-toggle>toggle</dfn> the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the <code><a href=#the-option-element>option</a></code> elements in its <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that are themselves not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a> (either through a click, or through a <a href=#using-the-option-element-to-define-a-command title=option-command>menu command</a>, or any other mechanism). Upon the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of one or more <code><a href=#the-option-element>option</a></code> elements being changed by the user, and before the relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before a related <code title=event-click><a href=#event-click>click</a></code> event), the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task source.</p> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-select-element>select</a></code> elements is to go through all the <code><a href=#the-option-element>option</a></code> elements in the element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, and set their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to true if the <code><a href=#the-option-element>option</a></code> element has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute, and false otherwise.</p> </div> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-select-element>select</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name. The <code title=attr-fe-disabled><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 title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.</p> <dl class=domintro><dt><var title="">select</var> . <code title=dom-select-type><a href=#dom-select-type>type</a></code></dt> <dd> <p>Returns "<code title="">select-multiple</code>" if the element has a <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute, and "<code title="">select-one</code>" otherwise.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-options><a href=#dom-select-options>options</a></code></dt> <dd> <p>Returns an <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> of the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-length><a href=#dom-select-length>length</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the number of elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>.</p> <p>When set to a smaller number, truncates the number of <code><a href=#the-option-element>option</a></code> elements in the <code><a href=#the-select-element>select</a></code>.</p> <p>When set to a greater number, adds new blank <code><a href=#the-option-element>option</a></code> elements to the <code><a href=#the-select-element>select</a></code>.</p> </dd> <dt><var title="">element</var> = <var title="">select</var> . <code title=dom-select-item><a href=#dom-select-item>item</a></code>(<var title="">index</var>)</dt> <dt><var title="">select</var>[<var title="">index</var>]</dt> <dd> <p>Returns the item with index <var title="">index</var> from the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>. The items are sorted in <a href=#tree-order>tree order</a>.</p> </dd> <dt><var title="">element</var> = <var title="">select</var> . <code title=dom-select-item><a href=#dom-select-item>namedItem</a></code>(<var title="">name</var>)</dt> <dd> <p>Returns the item with <a href=#concept-id title=concept-id>ID</a> or <code title=attr-option-name><a href=#attr-option-name>name</a></code> <var title="">name</var> from the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>.</p> <p>If there are multiple matching items, then a <code><a href=#nodelist>NodeList</a></code> object containing all those elements is returned.</p> <p>Returns null if no element with that <a href=#concept-id title=concept-id>ID</a> could be found.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-add><a href=#dom-select-add>add</a></code>(<var title="">element</var> [, <var title="">before</var> ])</dt> <dd> <p>Inserts <var title="">element</var> before the node given by <var title="">before</var>.</p> <p>The <var title="">before</var> argument can be a number, in which case <var title="">element</var> is inserted before the item with that number, or an element from the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, in which case <var title="">element</var> is inserted before that element.</p> <p>If <var title="">before</var> is omitted, null, or a number out of range, then <var title="">element</var> will be added at the end of the list.</p> <p>This method will throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception if <var title="">element</var> is an ancestor of the element into which it is to be inserted.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-selectedOptions><a href=#dom-select-selectedoptions>selectedOptions</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that are selected.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-selectedIndex><a href=#dom-select-selectedindex>selectedIndex</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the index of the first selected item, if any, or −1 if there is no selected item.</p> <p>Can be set, to change the selection.</p> </dd> <dt><var title="">select</var> . <code title=dom-select-value><a href=#dom-select-value>value</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the <a href=#concept-fe-value title=concept-fe-value>value</a> of the first selected item, if any, or the empty string if there is no selected item.</p> <p>Can be set, to change the selection.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-select-type title=dom-select-type><code>type</code></dfn> IDL attribute, on getting, must return the string "<code title="">select-one</code>" if the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the string "<code title="">select-multiple</code>" if the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is present.</p> <p>The <dfn id=dom-select-options title=dom-select-options><code>options</code></dfn> IDL attribute must return an <code><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> rooted at the <code><a href=#the-select-element>select</a></code> node, whose filter matches the elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>.</p> <p>The <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection is also mirrored on the <code><a href=#htmlselectelement>HTMLSelectElement</a></code> object. The <a href=#supported-property-indices>supported property indices</a> at any instant are the indices supported by the object returned by the <code title=dom-select-options><a href=#dom-select-options>options</a></code> attribute at that instant.</p> <p>The <dfn id=dom-select-length title=dom-select-length><code>length</code></dfn> IDL attribute must return the number of nodes <a href=#represented-by-the-collection title="represented by the collection">represented</a> by the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection. On setting, it must act like the attribute of the same name on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection.</p> <p>The <dfn id=dom-select-item title=dom-select-item><code>item(<var title="">index</var>)</code></dfn> method must return the value returned by the method of the same name on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection, when invoked with the same argument.</p> <p>The <dfn id=dom-select-nameditem title=dom-select-namedItem><code>namedItem(<var title="">name</var>)</code></dfn> method must return the value returned by the method of the same name on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection, when invoked with the same argument.</p> <p>When the user agent is to <dfn id=dom-htmlselectelement-setter title=dom-HTMLSelectElement-setter>set the value of a new indexed property</dfn> for a given property index <var title="">index</var> to a new value <var title="">value</var>, it must instead <a href=#dom-htmloptionscollection-setter title=dom-HTMLOptionsCollection-setter>set the value of a new indexed property</a> with the given property index <var title="">index</var> to the new value <var title="">value</var> on the <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection.</p> <p>Similarly, the <dfn id=dom-select-add title=dom-select-add><code>add()</code></dfn> and <dfn id=dom-select-remove title=dom-select-remove><code>remove()</code></dfn> methods must act like their namesake methods on that same <code title=dom-select-options><a href=#dom-select-options>options</a></code> collection.</p> <p>The <dfn id=dom-select-selectedoptions title=dom-select-selectedOptions><code>selectedOptions</code></dfn> IDL attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-select-element>select</a></code> node, whose filter matches the elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that have their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true.</p> <p>The <dfn id=dom-select-selectedindex title=dom-select-selectedIndex><code>selectedIndex</code></dfn> IDL attribute, on getting, must return the <a href=#concept-option-index title=concept-option-index>index</a> of the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> in <a href=#tree-order>tree order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, if any. If there isn't one, then it must return −1.</p> <p>On setting, the <code title=dom-select-selectedIndex><a href=#dom-select-selectedindex>selectedIndex</a></code> attribute must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code> elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then the <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> whose <a href=#concept-option-index title=concept-option-index>index</a> is the given new value, if any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true.</p> <p>The <dfn id=dom-select-value title=dom-select-value><code>value</code></dfn> IDL attribute, on getting, must return the <a href=#concept-option-value title=concept-option-value>value</a> of the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> in <a href=#tree-order>tree order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>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 title=dom-select-value><a href=#dom-select-value>value</a></code> attribute must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code> elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, in <a href=#tree-order>tree order</a>, whose <a href=#concept-option-value title=concept-option-value>value</a> is equal to the given new value, if any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true.</p> <p>The <dfn id=dom-select-multiple title=dom-select-multiple><code>multiple</code></dfn>, <dfn id=dom-select-required title=dom-select-required><code>required</code></dfn>, and <dfn id=dom-select-size title=dom-select-size><code>size</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <code title=dom-select-size><a href=#dom-select-size>size</a></code> IDL attribute has a default value of zero.</p> <!-- see bug 12288 for compat reasons why .size allows zero (it's not limited to values greater than zero) even though that value really makes no sense --> <p class=note>For historical reasons, the default value of the <code title=dom-select-size><a href=#dom-select-size>size</a></code> IDL attribute does not return the actual size used, which, in the absence of the <code title=attr-select-size><a href=#attr-select-size>size</a></code> content attribute, is either 1 or 4 depending on the presence of the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-fe-autofocus><a href=#dom-fe-autofocus>autofocus</a></code>, <code title=dom-fe-disabled><a href=#dom-fe-disabled>disabled</a></code>, <code title=dom-fae-form><a href=#dom-fae-form>form</a></code>, and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> </div> <div class=example> <p>The following example shows how a <code><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><p> <label for="unittype">Select unit type:</label> <select id="unittype" name="unittype"> <option value="1"> Miner </option> <option value="2"> Puffer </option> <option value="3" selected> Snipey </option> <option value="4"> Max </option> <option value="5"> Firebot </option> </select> </p></pre> <p>When there is no default option, a placeholder can be used instead:</p> <pre><select name="unittype" <strong>required</strong>> <strong><option value=""> Select unit type </option></strong> <option value="1"> Miner </option> <option value="2"> Puffer </option> <option value="3"> Snipey </option> <option value="4"> Max </option> <option value="5"> Firebot </option> </select></pre> </div> <div class=example> <p>Here, the user is offered a set of options from which he can select any number. By default, all five options are selected.</p> <pre><p> <label for="allowedunits">Select unit types to enable on this map:</label> <select id="allowedunits" name="allowedunits" multiple> <option value="1" selected> Miner </option> <option value="2" selected> Puffer </option> <option value="3" selected> Snipey </option> <option value="4" selected> Max </option> <option value="5" selected> Firebot </option> </select> </p></pre> </div> <div class=example> <p>Sometimes, a user has to select one or more items. This example shows such an interface.</p> <pre><p>Select the songs from that you would like on your Act II Mix Tape:</p> <select multiple required name="act2"> <option value="s1">It Sucks to Be Me (Reprise) <option value="s2">There is Life Outside Your Apartment <option value="s3">The More You Ruv Someone <option value="s4">Schadenfreude <option value="s5">I Wish I Could Go Back to College <option value="s6">The Money Song <option value="s7">School for Monsters <option value="s8">The Money Song (Reprise) <option value="s9">There's a Fine, Fine Line (Reprise) <option value="s10">What Do You Do With a B.A. in English? (Reprise) <option value="s11">For Now </select></pre> </div> <h4 id=the-datalist-element><span class=secno>4.10.10 </span>The <dfn><code>datalist</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Either: <a href=#phrasing-content>phrasing content</a>.</dd> <dd>Or: Zero or more <code><a href=#the-option-element>option</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmldatalistelement>HTMLDataListElement</dfn> : <a href=#htmlelement>HTMLElement</a> { readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-datalist-options title=dom-datalist-options>options</a>; };</pre> </dd> </dl><p>The <code><a href=#the-datalist-element>datalist</a></code> element represents a set of <code><a href=#the-option-element>option</a></code> elements that represent predefined options for other controls. The contents of the element represents fallback content for legacy user agents, intermixed with <code><a href=#the-option-element>option</a></code> elements that represent the predefined options. In the rendering, the <code><a href=#the-datalist-element>datalist</a></code> element <a href=#represents>represents</a> nothing<span class=impl> and it, along with its children, should be hidden</span>.</p> <p>The <code><a href=#the-datalist-element>datalist</a></code> element is hooked up to an <code><a href=#the-input-element>input</a></code> element using the <code title=attr-input-list><a href=#attr-input-list>list</a></code> attribute on the <code><a href=#the-input-element>input</a></code> element.</p> <p>Each <code><a href=#the-option-element>option</a></code> element that is a descendant of the <code><a href=#the-datalist-element>datalist</a></code> element, that is not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>, and whose <a href=#concept-option-value title=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 title=concept-option-value>value</a> and a <a href=#concept-option-label title=concept-option-label>label</a>. <dl class=domintro><dt><var title="">datalist</var> . <code title=dom-datalist-options><a href=#dom-datalist-options>options</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the <code>options</code> elements of the table.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-datalist-options title=dom-datalist-options><code>options</code></dfn> IDL attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#the-datalist-element>datalist</a></code> node, whose filter matches <code><a href=#the-option-element>option</a></code> elements.</p> <p><strong>Constraint validation</strong>: If an element has a <code><a href=#the-datalist-element>datalist</a></code> element ancestor, it is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <h4 id=the-optgroup-element><span class=secno>4.10.11 </span>The <dfn><code>optgroup</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd> <dt>Content model:</dt> <dd>Zero or more <code><a href=#the-option-element>option</a></code> elements.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code></dd> <dd><code title=attr-optgroup-label><a href=#attr-optgroup-label>label</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmloptgroupelement>HTMLOptGroupElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-optgroup-disabled title=dom-optgroup-disabled>disabled</a>; attribute DOMString <a href=#dom-optgroup-label title=dom-optgroup-label>label</a>; };</pre> </dd> </dl><!-- v2: make optgroups selectable if they have a value. --><p>The <code><a href=#the-optgroup-element>optgroup</a></code> element <a href=#represents>represents</a> a group of <code><a href=#the-option-element>option</a></code> elements with a common label.</p> <p>The element's group of <code><a href=#the-option-element>option</a></code> elements consists of the <code><a href=#the-option-element>option</a></code> elements that are children of the <code><a href=#the-optgroup-element>optgroup</a></code> element.</p> <div class=impl> <p>When showing <code><a href=#the-option-element>option</a></code> elements in <code><a href=#the-select-element>select</a></code> elements, user agents should show the <code><a href=#the-option-element>option</a></code> elements of such groups as being related to each other and separate from other <code><a href=#the-option-element>option</a></code> elements.</p> </div> <p>The <dfn id=attr-optgroup-disabled title=attr-optgroup-disabled><code>disabled</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> and can be used to <a href=#concept-option-disabled title=concept-option-disabled>disable</a> a group of <code><a href=#the-option-element>option</a></code> elements together.</p> <p>The <dfn id=attr-optgroup-label title=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. <span class=impl>User agents should use this attribute's value when labelling the group of <code><a href=#the-option-element>option</a></code> elements in a <code><a href=#the-select-element>select</a></code> element.</span></p> <div class=impl> <p>The <dfn id=dom-optgroup-disabled title=dom-optgroup-disabled><code>disabled</code></dfn> and <dfn id=dom-optgroup-label title=dom-optgroup-label><code>label</code></dfn> attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <div class=example> <p>The following snippet shows how a set of lessons from three courses could be offered in a <code><a href=#the-select-element>select</a></code> drop-down widget:</p> <pre><form action="courseselector.dll" method="get"> <p>Which course would you like to watch today? <p><label>Course: <select name="c"> <optgroup label="8.01 Physics I: Classical Mechanics"> <option value="8.01.1">Lecture 01: Powers of Ten <option value="8.01.2">Lecture 02: 1D Kinematics <option value="8.01.3">Lecture 03: Vectors <optgroup label="8.02 Electricity and Magnestism"> <option value="8.02.1">Lecture 01: What holds our world together? <option value="8.02.2">Lecture 02: Electric Field <option value="8.02.3">Lecture 03: Electric Flux <optgroup label="8.03 Physics III: Vibrations and Waves"> <option value="8.03.1">Lecture 01: Periodic Phenomenon <option value="8.03.2">Lecture 02: Beats <option value="8.03.3">Lecture 03: Forced Oscillations with Damping </select> </label> <p><input type=submit value="▶ Play"> </form></pre> </div> <h4 id=the-option-element><span class=secno>4.10.12 </span>The <dfn><code>option</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd> <dd>As a child of a <code><a href=#the-datalist-element>datalist</a></code> element.</dd> <dd>As a child of an <code><a href=#the-optgroup-element>optgroup</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#text-content title="text content">Text</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code></dd> <dd><code title=attr-option-label><a href=#attr-option-label>label</a></code></dd> <dd><code title=attr-option-selected><a href=#attr-option-selected>selected</a></code></dd> <dd><code title=attr-option-value><a href=#attr-option-value>value</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>[NamedConstructor=<a href=#dom-option title=dom-option>Option</a>(), NamedConstructor=<a href=#dom-option-t title=dom-option-t>Option</a>(DOMString text), NamedConstructor=<a href=#dom-option-tv title=dom-option-tv>Option</a>(DOMString text, DOMString value), NamedConstructor=<a href=#dom-option-tvd title=dom-option-tvd>Option</a>(DOMString text, DOMString value, boolean defaultSelected), NamedConstructor=<a href=#dom-option-tvds title=dom-option-tvds>Option</a>(DOMString text, DOMString value, boolean defaultSelected, boolean selected)] interface <dfn id=htmloptionelement>HTMLOptionElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-option-disabled title=dom-option-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-option-form title=dom-option-form>form</a>; attribute DOMString <a href=#dom-option-label title=dom-option-label>label</a>; attribute boolean <a href=#dom-option-defaultselected title=dom-option-defaultSelected>defaultSelected</a>; attribute boolean <a href=#dom-option-selected title=dom-option-selected>selected</a>; attribute DOMString <a href=#dom-option-value title=dom-option-value>value</a>; attribute DOMString <a href=#dom-option-text title=dom-option-text>text</a>; readonly attribute long <a href=#dom-option-index title=dom-option-index>index</a>; };</pre> </dd> </dl><p>The <code><a href=#the-option-element>option</a></code> element <a href=#represents>represents</a> an option in a <code><a href=#the-select-element>select</a></code> element or as part of a list of suggestions in a <code><a href=#the-datalist-element>datalist</a></code> element.</p> <p>In certain circumstances described in the definition of the <code><a href=#the-select-element>select</a></code> element, an <code><a href=#the-option-element>option</a></code> element can be a <code><a href=#the-select-element>select</a></code> element's <a href=#placeholder-label-option>placeholder label option</a>. A <a href=#placeholder-label-option>placeholder label option</a> does not represent an actual option, but instead represents a label for the <code><a href=#the-select-element>select</a></code> control.</p> <p>The <dfn id=attr-option-disabled title=attr-option-disabled><code>disabled</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. An <code><a href=#the-option-element>option</a></code> element is <dfn id=concept-option-disabled title=concept-option-disabled>disabled</dfn> if its <code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code> attribute is present or if it is a child of an <code><a href=#the-optgroup-element>optgroup</a></code> element whose <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code> attribute is present.</p> <div class=impl> <p>An <code><a href=#the-option-element>option</a></code> element that is <a href=#attr-option-disabled title=attr-option-disabled>disabled</a> must prevent any <code title=event-click><a href=#event-click>click</a></code> events that are <a href=#queue-a-task title="queue a task">queued</a> on the <a href=#user-interaction-task-source>user interaction task source</a> from being dispatched on the element.</p> </div> <p>The <dfn id=attr-option-label title=attr-option-label><code>label</code></dfn> attribute provides a label for element. The <dfn id=concept-option-label title=concept-option-label>label</dfn> of an <code><a href=#the-option-element>option</a></code> element is the value of the <code title=attr-option-label><a href=#attr-option-label>label</a></code> content attribute, if there is one, or, if there is not, the value of the element's <code title=dom-option-text><a href=#dom-option-text>text</a></code> IDL attribute.</p> <p>The <dfn id=attr-option-value title=attr-option-value><code>value</code></dfn> attribute provides a value for element. The <dfn id=concept-option-value title=concept-option-value>value</dfn> of an <code><a href=#the-option-element>option</a></code> element is the value of the <code title=attr-option-value><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 title=dom-option-text><a href=#dom-option-text>text</a></code> IDL attribute.</p> <p>The <dfn id=attr-option-selected title=attr-option-selected><code>selected</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. It represents the default <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the element.</p> <div class=impl> <p>The <dfn id=concept-option-selectedness title=concept-option-selectedness>selectedness</dfn> of an <code><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 title=concept-option-selectedness>selectedness</a> must be set to true if the element has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute. Whenever an <code><a href=#the-option-element>option</a></code> element's <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is added, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to true.</p> <p class=note>The <code title=dom-option-tvd><a href=#dom-option-tvd>Option()</a></code> constructor with three or fewer arguments overrides the initial state of the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> state to always be false even if the third argument is true (implying that a <code title=attr-option-selected><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 title=concept-option-selectedness>selectedness</a> state when using the constructor.</p> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/604 --> </div> <p>A <code><a href=#the-select-element>select</a></code> element whose <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is not specified must not have more than one descendant <code><a href=#the-option-element>option</a></code> element with its <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set.</p> <div class=impl> <p>An <code><a href=#the-option-element>option</a></code> element's <dfn id=concept-option-index title=concept-option-index>index</dfn> is the number of <code><a href=#the-option-element>option</a></code> element that are in the same <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> but that come before it in <a href=#tree-order>tree order</a>. If the <code><a href=#the-option-element>option</a></code> element is not in a <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, then the <code><a href=#the-option-element>option</a></code> element's <a href=#concept-option-index title=concept-option-index>index</a> is zero.</p> </div> <dl class=domintro><dt><var title="">option</var> . <code title=dom-option-selected><a href=#dom-option-selected>selected</a></code></dt> <dd> <p>Returns true if the element is selected, and false otherwise.</p> <p>Can be set, to override the current state of the element.</p> </dd> <dt><var title="">option</var> . <code title=dom-option-index><a href=#dom-option-index>index</a></code></dt> <dd> <p>Returns the index of the element in its <code><a href=#the-select-element>select</a></code> element's <code title=dom-select-options><a href=#dom-select-options>options</a></code> list.</p> </dd> <dt><var title="">option</var> . <code title=dom-option-form><a href=#dom-option-form>form</a></code></dt> <dd> <p>Returns the element's <code><a href=#the-form-element>form</a></code> element, if any, or null otherwise.</p> </dd> <dt><var title="">option</var> . <code title=dom-option-text><a href=#dom-option-text>text</a></code></dt> <dd> <p>Same as <code><a href=#textcontent>textContent</a></code>, except that spaces are collapsed.</p> </dd> <dt><var title="">option</var> = new <code title=dom-option><a href=#dom-option>Option</a></code>( [ <var title="">text</var> [, <var title="">value</var> [, <var title="">defaultSelected</var> [, <var title="">selected</var> ] ] ] ] )</dt> <dd> <p>Returns a new <code><a href=#the-option-element>option</a></code> element.</p> <p>The <var title="">text</var> argument sets the contents of the element.</p> <p>The <var title="">value</var> argument sets the <code title=attr-option-value><a href=#attr-option-value>value</a></code> attribute.</p> <p>The <var title="">defaultSelected</var> argument sets the <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute.</p> <p>The <var title="">selected</var> argument sets whether or not the element is selected. If it is omitted, even if the <var title="">defaultSelected</var> argument is true, the element is not selected.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-option-disabled title=dom-option-disabled><code>disabled</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name. The <dfn id=dom-option-defaultselected title=dom-option-defaultSelected><code>defaultSelected</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> content attribute.</p> <p>The <dfn id=dom-option-label title=dom-option-label><code>label</code></dfn> IDL attribute, on getting, must return the value of the element's <code title=attr-option-label><a href=#attr-option-label>label</a></code> content attribute, if it has one, or else the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute. On setting, the element's <code title=attr-option-label><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 title=dom-option-value><code>value</code></dfn> IDL attribute, on getting, must return the value of the element's <code title=attr-option-value><a href=#attr-option-value>value</a></code> content attribute, if it has one, or else the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute. On setting, the element's <code title=attr-option-value><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 title=dom-option-selected><code>selected</code></dfn> IDL attribute, on getting, must return true if the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, and false otherwise. On setting, it must set the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to the new value.</p> <p>The <dfn id=dom-option-index title=dom-option-index><code>index</code></dfn> IDL attribute must return the element's <a href=#concept-option-index title=concept-option-index>index</a>.</p> <p>The <dfn id=dom-option-text title=dom-option-text><code>text</code></dfn> IDL attribute, on getting, must return the value of the <code><a href=#textcontent>textContent</a></code> IDL attribute on the element, with <a href=#strip-leading-and-trailing-whitespace title="strip leading and trailing whitespace">leading and trailing whitespace stripped</a>, and with any sequences of two or more <a href=#space-character title="space character">space characters</a> replaced by a single U+0020 SPACE character. On setting, it must act as if the <code><a href=#textcontent>textContent</a></code> IDL attribute on the element had been set to the new value.</p> <p>The <dfn id=dom-option-form title=dom-option-form><code>form</code></dfn> IDL attribute's behavior depends on whether the <code><a href=#the-option-element>option</a></code> element is in a <code><a href=#the-select-element>select</a></code> element or not. If the <code><a href=#the-option-element>option</a></code> has a <code><a href=#the-select-element>select</a></code> element as its parent, or has an <code><a href=#the-optgroup-element>optgroup</a></code> element as its parent and that <code><a href=#the-optgroup-element>optgroup</a></code> element has a <code><a href=#the-select-element>select</a></code> element as its parent, then the <code title=dom-option-form><a href=#dom-option-form>form</a></code> IDL attribute must return the same value as the <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute on that <code><a href=#the-select-element>select</a></code> element. Otherwise, it must return null.</p> <p>Several constructors are provided for creating <code><a href=#htmloptionelement>HTMLOptionElement</a></code> objects (in addition to the factory methods from DOM Core such as <code title="">createElement()</code>): <dfn id=dom-option title=dom-option><code>Option()</code></dfn>, <dfn id=dom-option-t title=dom-option-t><code>Option(<var title="">text</var>)</code></dfn>, <dfn id=dom-option-tv title=dom-option-tv><code>Option(<var title="">text</var>, <var title="">value</var>)</code></dfn>, <dfn id=dom-option-tvd title=dom-option-tvd><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>)</code></dfn>, and <dfn id=dom-option-tvds title=dom-option-tvds><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>, <var title="">selected</var>)</code></dfn>. When invoked as constructors, these must return a new <code><a href=#htmloptionelement>HTMLOptionElement</a></code> object (a new <code><a href=#the-option-element>option</a></code> element). If the <var title="">text</var> argument is present, the new object must have as its only child a <code><a href=#node>Node</a></code> with node type <code title="">TEXT_NODE</code> (3) whose data is the value of that argument<!-- we mention TEXT_NODE and all that explicitly here because we redefine "text node" in this spec to also include CDATA sections -->. If the <var title="">value</var> argument is present, the new object must have a <code title=attr-option-value><a href=#attr-option-value>value</a></code> attribute set with the value of the argument as its value. If the <var title="">defaultSelected</var> argument is present and true, the new object must have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set with no value. If the <var title="">selected</var> argument is present and true, the new object must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true; otherwise the fourth argument is absent or false, and the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to false, even if the <var title="">defaultSelected</var> argument is present and true. The element's document must be the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> of the <code><a href=#window>Window</a></code> object on which the interface object of the invoked constructor is found.</p> </div> <h4 id=the-textarea-element><span class=secno>4.10.13 </span>The <dfn><code>textarea</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, <a href=#category-submit title=category-submit>submittable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#text-content title="text content">Text</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code></dd> <dd><code title=attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code></dd> <dd><code title=attr-textarea-dirname><a href=#attr-textarea-dirname>dirname</a></code></dd> <dd><code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dd><code title=attr-textarea-placeholder><a href=#attr-textarea-placeholder>placeholder</a></code></dd> <dd><code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code></dd> <dd><code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code></dd> <dd><code title=attr-textarea-rows><a href=#attr-textarea-rows>rows</a></code></dd> <dd><code title=attr-textarea-wrap><a href=#attr-textarea-wrap>wrap</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmltextareaelement>HTMLTextAreaElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-fe-autofocus title=dom-fe-autofocus>autofocus</a>; attribute unsigned long <a href=#dom-textarea-cols title=dom-textarea-cols>cols</a>; attribute DOMString <a href=#dom-textarea-dirname title=dom-textarea-dirName>dirName</a>; attribute boolean <a href=#dom-fe-disabled title=dom-fe-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute long <a href=#dom-textarea-maxlength title=dom-textarea-maxLength>maxLength</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; attribute DOMString <a href=#dom-textarea-placeholder title=dom-textarea-placeholder>placeholder</a>; attribute boolean <a href=#dom-textarea-readonly title=dom-textarea-readOnly>readOnly</a>; attribute boolean <a href=#dom-textarea-required title=dom-textarea-required>required</a>; attribute unsigned long <a href=#dom-textarea-rows title=dom-textarea-rows>rows</a>; attribute DOMString <a href=#dom-textarea-wrap title=dom-textarea-wrap>wrap</a>; readonly attribute DOMString <a href=#dom-textarea-type title=dom-textarea-type>type</a>; attribute DOMString <a href=#dom-textarea-defaultvalue title=dom-textarea-defaultValue>defaultValue</a>; attribute DOMString <a href=#dom-textarea-value title=dom-textarea-value>value</a>; readonly attribute unsigned long <a href=#dom-textarea-textlength title=dom-textarea-textLength>textLength</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; void <a href=#dom-textarea/input-select title=dom-textarea/input-select>select</a>(); attribute unsigned long <a href=#dom-textarea/input-selectionstart title=dom-textarea/input-selectionStart>selectionStart</a>; attribute unsigned long <a href=#dom-textarea/input-selectionend title=dom-textarea/input-selectionEnd>selectionEnd</a>; attribute DOMString <a href=#dom-textarea/input-selectiondirection title=dom-textarea/input-selectionDirection>selectionDirection</a>; void <a href=#dom-textarea/input-setselectionrange title=dom-textarea/input-setSelectionRange>setSelectionRange</a>(unsigned long start, unsigned long end, optional DOMString direction); };</pre> </dd> </dl><p>The <code><a href=#the-textarea-element>textarea</a></code> element <a href=#represents>represents</a> a multiline plain text edit control<span class=impl> for the element's <dfn id=concept-textarea-raw-value title=concept-textarea-raw-value>raw value</dfn></span>. The contents of the control represent the control's default value.</p> <div class=impl> <p>The <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> of a <code><a href=#the-textarea-element>textarea</a></code> control must be initially the empty string.</p> <p>A newline in a <code><a href=#the-textarea-element>textarea</a></code> element, and in its <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a>, should separate paragraphs for the purposes of the Unicode bidirectional algorithm. This requirement may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements by implementing the CSS 'unicode-bidi' property. <a href=#refsBIDI>[BIDI]</a> <a href=#refsCSS>[CSS]</a></p> </div> <p>The <dfn id=attr-textarea-readonly title=attr-textarea-readonly><code>readonly</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> used to control whether the text can be edited by the user or not.</p> <div class=impl> <p><strong>Constraint validation</strong>: If the <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute is specified on a <code><a href=#the-textarea-element>textarea</a></code> element, the element is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> <p>A <code><a href=#the-textarea-element>textarea</a></code> element is <dfn id=concept-textarea-mutable title=concept-textarea-mutable>mutable</dfn> if it is neither <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a> nor has a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute specified.</p> <p>When a <code><a href=#the-textarea-element>textarea</a></code> is <a href=#concept-textarea-mutable title=concept-textarea-mutable>mutable</a>, its <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>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 title=concept-textarea-raw-value>raw value</a> to change, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-input>input</code> at the <code><a href=#the-textarea-element>textarea</a></code> element. 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> <!-- same text is present in the <input> section --> <p>A <code><a href=#the-textarea-element>textarea</a></code> element has a <dfn id=concept-textarea-dirty title=concept-textarea-dirty>dirty value flag</dfn>, which must be initially set to false, and must be set to true whenever the user interacts with the control in a way that changes the <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a>.</p> <p>When the <code><a href=#the-textarea-element>textarea</a></code> element's <code><a href=#textcontent>textContent</a></code> IDL attribute changes value, if the element's <a href=#concept-textarea-dirty title=concept-textarea-dirty>dirty value flag</a> is false, then the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> must be set to the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-textarea-element>textarea</a></code> elements is to set the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>value</a> to the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <!-- this next bit is also in the <input> Text/Search section --> <!-- and something similar is in the session history section --> <p>If the element is <a href=#concept-textarea-mutable title=concept-textarea-mutable>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 title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute to "<code title=attr-dir-ltr><a href=#attr-dir-ltr>ltr</a></code>" if the user selected a left-to-right writing direction, and "<code title=attr-dir-rtl><a href=#attr-dir-rtl>rtl</a></code>" if the user selected a right-to-left writing direction.</li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-input>input</code> at the <code><a href=#the-textarea-element>textarea</a></code> element.</li> </ol></div> <p>The <dfn id=attr-textarea-cols title=attr-textarea-cols><code>cols</code></dfn> attribute specifies the expected maximum number of characters per line. If the <code title=attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code> attribute is specified, its value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero. <span class=impl>If applying the <a href=#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 title=attr-textarea-cols-value>character width</dfn> is that value; otherwise, it is 20.</span></p> <div class=impl> <p>The user agent may use the <code><a href=#the-textarea-element>textarea</a></code> element's <a href=#attr-textarea-cols-value title=attr-textarea-cols-value>character width</a> as a hint to the user as to how many characters the server prefers per line (e.g. for visual user agents by making the width of the control be that many characters). In visual renderings, the user agent should wrap the user's input in the rendering so that each line is no wider than this number of characters.</p> </div> <p>The <dfn id=attr-textarea-rows title=attr-textarea-rows><code>rows</code></dfn> attribute specifies the number of lines to show. If the <code title=attr-textarea-rows><a href=#attr-textarea-rows>rows</a></code> attribute is specified, its value must be a <a href=#valid-non-negative-integer>valid non-negative integer</a> greater than zero. <span class=impl>If applying the <a href=#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-rows-value title=attr-textarea-rows-value>character height</dfn> is that value; otherwise, it is 2.</span></p> <div class=impl> <p>Visual user agents should set the height of the control to the number of lines given by <a href=#attr-textarea-rows-value title=attr-textarea-rows-value>character height</a>.</p> </div> <p>The <dfn id=attr-textarea-wrap title=attr-textarea-wrap><code>wrap</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a> with two keywords and states: the <dfn id=attr-textarea-wrap-soft title=attr-textarea-wrap-soft><code>soft</code></dfn> keyword which maps to the <a href=#attr-textarea-wrap-soft-state title=attr-textarea-wrap-soft-state>Soft</a> state, and the <dfn id=attr-textarea-wrap-hard title=attr-textarea-wrap-hard><code>hard</code></dfn> keyword which maps to the <a href=#attr-textarea-wrap-hard-state title=attr-textarea-wrap-hard-state>Hard</a> state. The <i>missing value default</i> is the <a href=#attr-textarea-wrap-soft-state title=attr-textarea-wrap-soft-state>Soft</a> state.</p> <p>The <dfn id=attr-textarea-wrap-soft-state title=attr-textarea-wrap-soft-state>Soft</dfn> state indicates that the text in the <code><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 title=attr-textarea-wrap-hard-state>Hard</dfn> state indicates that the text in the <code><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 title=attr-textarea-wrap><a href=#attr-textarea-wrap>wrap</a></code> attribute is in the <a href=#attr-textarea-wrap-hard-state title=attr-textarea-wrap-hard-state>Hard</a> state, the <code title=attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code> attribute must be specified.</p> <!-- attr-textarea-wrap-off (attr-textarea-wrap-off-state): not conforming; turns off the rendering of wrapping but otherwise acts like 'soft' --> <div class=impl> <p>For historical reasons, the element's value is normalised in three different ways for three different purposes. The <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> is the value as it was originally set. It is not normalized. The <a href=#concept-textarea-api-value title=concept-textarea-api-value>API value</a> is the value used in the <code title=dom-textarea-value><a href=#dom-textarea-value>value</a></code> IDL attribute. It is normalized so that line breaks use U+000A LINE FEED (LF) characters. Finally, there is the form submission <a href=#concept-fe-value title=concept-fe-value>value</a>. 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 title=attr-textarea-wrap><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 element's <dfn id=concept-textarea-api-value title=concept-textarea-api-value>API value</dfn> is defined to be the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> with the following transformation applied:</p> <ol><li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair from the <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> with a single U+000A LINE FEED (CRLF) character.</li> <li><p>Replace every remaining U+000D CARRIAGE RETURN character from the <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> with a single U+000A LINE FEED (CRLF) character.</li> </ol><p>The element's <a href=#concept-fe-value title=concept-fe-value>value</a> is defined to be the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> with the following transformation applied:</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> <li><p>If the element's <code title=attr-textarea-wrap><a href=#attr-textarea-wrap>wrap</a></code> attribute is in the <a href=#attr-textarea-wrap-hard-state title=attr-textarea-wrap-hard-state>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 title=attr-textarea-cols-value>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.</li> </ol></div> <p>The <dfn id=attr-textarea-maxlength title=attr-textarea-maxlength><code>maxlength</code></dfn> attribute is a <a href=#attr-fe-maxlength title=attr-fe-maxlength>form control <code title="">maxlength</code> attribute</a> controlled by the <code><a href=#the-textarea-element>textarea</a></code> element's <a href=#concept-textarea-dirty title=concept-textarea-dirty>dirty value flag</a>.</p> <p>If the <code><a href=#the-textarea-element>textarea</a></code> element has a <a href=#maximum-allowed-value-length>maximum allowed value length</a>, then the element's children must be such that the <a href=#code-point-length>code-point length</a> of the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute is equal to or less than the element's <a href=#maximum-allowed-value-length>maximum allowed value length</a>.</p> <p>The <dfn id=attr-textarea-required title=attr-textarea-required><code>required</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When specified, the user will be required to enter a value before submitting the form.</p> <div class=impl> <p><strong>Constraint validation</strong>: If the element has its <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute specified, and the element is <a href=#concept-textarea-mutable title=concept-textarea-mutable>mutable</a>, and the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is the empty string, then the element is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </div> <!-- similar text in the <input> section --> <p>The <dfn id=attr-textarea-placeholder title=attr-textarea-placeholder><code>placeholder</code></dfn> attribute represents a hint (a word or short phrase) intended to aid the user with data entry. A hint could be a sample value or a brief description of the expected format. The attribute, if specified, must have a value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.</p> <p class=note>For a longer hint or other advisory text, the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute is more appropriate.</p> <p>The <code title=attr-textarea-placeholder><a href=#attr-textarea-placeholder>placeholder</a></code> attribute should not be used as an alternative to a <code><a href=#the-label-element>label</a></code>.</p> <div class=impl> <p>User agents should present this hint to the user, after having <a href=#strip-line-breaks title="strip line breaks">stripped line breaks</a> from it, when the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is the empty string and the control is not focused (e.g. by displaying it inside a blank unfocused control).</p> </div> <p>The <dfn id=attr-textarea-dirname title=attr-textarea-dirname><code>dirname</code></dfn> attribute is a <a href=#form-control-dirname-attribute>form control <code title="">dirname</code> attribute</a>.</p> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-textarea-element>textarea</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name. The <code title=attr-fe-disabled><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 title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.</p> <dl class=domintro><dt><var title="">textarea</var> . <code title=attr-textarea-type>type</code></dt> <dd> <p>Returns the string "<code title="">textarea</code>".</p> </dd> <dt><var title="">textarea</var> . <code title=attr-textarea-value>value</code></dt> <dd> <p>Returns the current value of the element.</p> <p>Can be set, to change the value.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-textarea-cols title=dom-textarea-cols><code>cols</code></dfn>, <dfn id=dom-textarea-placeholder title=dom-textarea-placeholder><code>placeholder</code></dfn>, <dfn id=dom-textarea-required title=dom-textarea-required><code>required</code></dfn>, <dfn id=dom-textarea-rows title=dom-textarea-rows><code>rows</code></dfn>, and <dfn id=dom-textarea-wrap title=dom-textarea-wrap><code>wrap</code></dfn> attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. The <code title=dom-textarea-cols><a href=#dom-textarea-cols>cols</a></code> and <code title=dom-textarea-rows><a href=#dom-textarea-rows>rows</a></code> attributes are <a href=#limited-to-only-non-negative-numbers-greater-than-zero>limited to only non-negative numbers greater than zero</a>. The <code title=dom-textarea-cols><a href=#dom-textarea-cols>cols</a></code> attribute's default value is 20. The <code title=dom-textarea-rows><a href=#dom-textarea-rows>rows</a></code> attribute's default value is 2. The <dfn id=dom-textarea-dirname title=dom-textarea-dirName><code>dirName</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-textarea-dirname><a href=#attr-textarea-dirname>dirname</a></code> content attribute. The <dfn id=dom-textarea-maxlength title=dom-textarea-maxLength><code>maxLength</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code> content attribute, <a href=#limited-to-only-non-negative-numbers>limited to only non-negative numbers</a>. The <dfn id=dom-textarea-readonly title=dom-textarea-readOnly><code>readOnly</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> content attribute.</p> <p>The <dfn id=dom-textarea-type title=dom-textarea-type><code>type</code></dfn> IDL attribute must return the value "<code title="">textarea</code>".</p> <p>The <dfn id=dom-textarea-defaultvalue title=dom-textarea-defaultValue><code>defaultValue</code></dfn> IDL attribute must act like the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <dfn id=dom-textarea-value title=dom-textarea-value><code>value</code></dfn> attribute must, on getting, return the element's <a href=#concept-textarea-api-value title=concept-textarea-api-value>API value</a>; on setting, it must set the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> to the new value, set the element's <a href=#concept-textarea-dirty title=concept-textarea-dirty>dirty value flag</a> to true, and should then move the text entry cursor position to the end of the text field, unselecting any selected text and resetting the selection direction to <i>none</i>.</p> <p>The <dfn id=dom-textarea-textlength title=dom-textarea-textLength><code>textLength</code></dfn> IDL attribute must return the <a href=#code-point-length>code-point length</a> of the element's <a href=#concept-textarea-api-value title=concept-textarea-api-value>API value</a>.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select()</a></code>, <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>, <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> methods and attributes expose the element's text selection. The <code title=dom-fe-autofocus><a href=#dom-fe-autofocus>autofocus</a></code>, <code title=dom-fe-disabled><a href=#dom-fe-disabled>disabled</a></code>, <code title=dom-fae-form><a href=#dom-fae-form>form</a></code>, and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> </div> <div class=example> <p>Here is an example of a <code><a href=#the-textarea-element>textarea</a></code> being used for unrestricted free-form text input in a form:</p> <pre><p>If you have any comments, please let us know: <textarea cols=80 name=comments></textarea></p></pre> <p>To specify a maximum length for the comments, one can use the <code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code> attribute:</p> <pre><p>If you have any short comments, please let us know: <textarea cols=80 name=comments maxlength=200></textarea></p></pre> <p>To give a default value, text can be included inside the element:</p> <pre><p>If you have any comments, please let us know: <textarea cols=80 name=comments>You rock!</textarea></p></pre> <p>To have the browser submit <a href=#the-directionality>the directionality</a> of the element along with the value, the <code title=attr-textarea-dirname><a href=#attr-textarea-dirname>dirname</a></code> attribute can be specified:</p> <pre><p>If you have any comments, please let us know (you may use either English or Hebrew for your comments): <textarea cols=80 name=comments dirname=comments.dir></textarea></p></pre> </div> <h4 id=the-keygen-element><span class=secno>4.10.14 </span>The <dfn><code>keygen</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, <a href=#category-submit title=category-submit>submittable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code></dd> <dd><code title=attr-keygen-challenge><a href=#attr-keygen-challenge>challenge</a></code></dd> <dd><code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-keygen-keytype><a href=#attr-keygen-keytype>keytype</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlkeygenelement>HTMLKeygenElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-fe-autofocus title=dom-fe-autofocus>autofocus</a>; attribute DOMString <a href=#dom-keygen-challenge title=dom-keygen-challenge>challenge</a>; attribute boolean <a href=#dom-fe-disabled title=dom-fe-disabled>disabled</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-keygen-keytype title=dom-keygen-keytype>keytype</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; readonly attribute DOMString <a href=#dom-keygen-type title=dom-keygen-type>type</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><p>The <code><a href=#the-keygen-element>keygen</a></code> element <a href=#represents>represents</a> a key pair generator control. When the control's form is submitted, the private key is stored in the local keystore, and the public key is packaged and sent to the server.</p> <p>The <dfn id=attr-keygen-challenge title=attr-keygen-challenge><code>challenge</code></dfn> attribute may be specified. Its value will be packaged with the submitted key.</p> <p>The <dfn id=attr-keygen-keytype title=attr-keygen-keytype><code>keytype</code></dfn> attribute is an <a href=#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 listed in the cell in the second column on the same row as the keyword. User agents are not required to support these values, and must only recognize values whose corresponding algorithms they support.</p> <table><thead><tr><th> Keyword <th> State <tbody><tr><td> <code title="">rsa</code> <td> <i title="">RSA</i> <!-- v2 (see below) <tr> <td> <code title="">ec</code> <td> <i title="">EC</i> --> </table><p>The <i>invalid value default</i> state is the <i title="">unknown</i> state. The <i>missing value default</i> state is the <i title="">RSA</i> state, if it is supported, or the <i title="">unknown</i> state otherwise.</p> <p class=note>This specification does not specify what key types user agents are to support — it is possible for a user agent to not support any key types at all.</p> <div class=impl> <p>The user agent may expose a user interface for each <code><a href=#the-keygen-element>keygen</a></code> element to allow the user to configure settings of the element's key pair generator, e.g. the key length.</p> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-keygen-element>keygen</a></code> elements is to set these various configuration settings back to their defaults.</p> <p>The element's <a href=#concept-fe-value title=concept-fe-value>value</a> is the string returned from the following algorithm:</p> <ol><li> <p>Use the appropriate step from the following list:</p> <dl class=switch><!-- v2 (see above) <dt>If the <code title="attr-keygen-keytype">keytype</code> attribute is in the <i title="">EC</i> state</dt> <dd> <p>... http://www.mail-archive.com/dev-tech-crypto@lists.mozilla.org/msg05902.html </dd> --><dt>If the <code title=attr-keygen-keytype><a href=#attr-keygen-keytype>keytype</a></code> attribute is in the <i title="">RSA</i> state</dt> <dd> <p>Generate an RSA key pair using the settings given by the user, if appropriate, using the <code title="">md5WithRSAEncryption</code> RSA signature algorithm (the signature algorithm with MD5 and the RSA encryption algorithm) referenced in section 2.2.1 ("RSA Signature Algorithm") of RFC 3279, and defined in RFC 2313. <a href=#refsRFC3279>[RFC3279]</a> <a href=#refsRFC2313>[RFC2313]</a></p> </dd> <dt>Otherwise, the <code title=attr-keygen-keytype><a href=#attr-keygen-keytype>keytype</a></code> attribute is in the <i title="">unknown</i> state</dt> <dd> <p>The given key type is not supported. Return the empty string and abort this algorithm.</p> </dd> </dl><p>Let <var title="">private key</var> be the generated private key.</p> <p>Let <var title="">public key</var> be the generated public key.</p> <p>Let <var title="">signature algorithm</var> be the selected signature algorithm.</p> </li> <li> <p>If the element has a <code title=attr-keygen-challenge><a href=#attr-keygen-challenge>challenge</a></code> attribute, then let <var title="">challenge</var> be that attribute's value. Otherwise, let <var title="">challenge</var> be the empty string.</p> </li> <li> <p>Let <var title="">algorithm</var> be an ASN.1 <code title="">AlgorithmIdentifier</code> structure as defined by RFC 5280, with the <code title="">algorithm</code> field giving the ASN.1 OID used to identify <var title="">signature algorithm</var>, using the OIDs defined in section 2.2 ("Signature Algorithms") of RFC 3279, and the <code title="">parameters</code> field set up as required by RFC 3279 for <code title="">AlgorithmIdentifier</code> structures for that algorithm. <a href=#refsX690>[X690]</a> <a href=#refsRFC5280>[RFC5280]</a> <a href=#refsRFC3279>[RFC3279]</a></p> </li> <li> <p>Let <var title="">spki</var> be an ASN.1 <code title="">SubjectPublicKeyInfo</code> structure as defined by RFC 5280, with the <code title="">algorithm</code> field set to the <var title="">algorithm</var> structure from the previous step, and the <code title="">subjectPublicKey</code> field set to the BIT STRING value resulting from ASN.1 DER encoding the <var title="">public key</var>. <a href=#refsX690>[X690]</a> <a href=#refsRFC5280>[RFC5280]</a></p> </li> <li> <p>Let <var title="">publicKeyAndChallenge</var> be an ASN.1 <code><a href=#publickeyandchallenge>PublicKeyAndChallenge</a></code> structure as defined below, with the <code title="">spki</code> field set to the <var title="">spki</var> structure from the previous step, and the <code title="">challenge</code> field set to the string <var title="">challenge</var> obtained earlier. <a href=#refsX690>[X690]</a></p> </li> <li> <p>Let <var title="">signature</var> be the BIT STRING value resulting from ASN.1 DER encoding the signature generated by applying the <var title="">signature algorithm</var> to the byte string obtained by ASN.1 DER encoding the <var title="">publicKeyAndChallenge</var> structure, using <var title="">private key</var> as the signing key. <a href=#refsX690>[X690]</a></p> </li> <li> <p>Let <var title="">signedPublicKeyAndChallenge</var> be an ASN.1 <code><a href=#signedpublickeyandchallenge>SignedPublicKeyAndChallenge</a></code> structure as defined below, with the <code title="">publicKeyAndChallenge</code> field set to the <var title="">publicKeyAndChallenge</var> structure, the <code title="">signatureAlgorithm</code> field set to the <var title="">algorithm</var> structure, and the <code title="">signature</code> field set to the BIT STRING <var title="">signature</var> from the previous step. <a href=#refsX690>[X690]</a></p> </li> <li> <p>Return the result of base64 encoding the result of ASN.1 DER encoding the <var title="">signedPublicKeyAndChallenge</var> structure. <a href=#refsRFC4648>[RFC4648]</a><!--base64--> <a href=#refsX690>[X690]</a></p> </li> </ol><p>The data objects used by the above algorithm are defined as follows. These definitions use the same "ASN.1-like" syntax defined by RFC 5280. <a href=#refsRFC5280>[RFC5280]</a></p> <pre class=asn><dfn id=publickeyandchallenge>PublicKeyAndChallenge</dfn> ::= SEQUENCE { spki <span>SubjectPublicKeyInfo</span>, challenge IA5STRING } <dfn id=signedpublickeyandchallenge>SignedPublicKeyAndChallenge</dfn> ::= SEQUENCE { publicKeyAndChallenge <a href=#publickeyandchallenge>PublicKeyAndChallenge</a>, signatureAlgorithm <span>AlgorithmIdentifier</span>, signature BIT STRING }</pre> <hr><p><strong>Constraint validation</strong>: The <code><a href=#the-keygen-element>keygen</a></code> element is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-keygen-element>keygen</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name. The <code title=attr-fe-disabled><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 title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.</p> <dl class=domintro><dt><var title="">keygen</var> . <code title=attr-keygen-type>type</code></dt> <dd> <p>Returns the string "<code title="">keygen</code>".</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-keygen-challenge title=dom-keygen-challenge><code>challenge</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-keygen-keytype title=dom-keygen-keytype><code>keytype</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> <p>The <dfn id=dom-keygen-type title=dom-keygen-type><code>type</code></dfn> IDL attribute must return the value "<code title="">keygen</code>".</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-fe-autofocus><a href=#dom-fe-autofocus>autofocus</a></code>, <code title=dom-fe-disabled><a href=#dom-fe-disabled>disabled</a></code>, <code title=dom-fae-form><a href=#dom-fae-form>form</a></code>, and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> </div> <p class=note>This specification does not specify how the private key generated is to be used. It is expected that after receiving the <code><a href=#signedpublickeyandchallenge>SignedPublicKeyAndChallenge</a></code> (SPKAC) structure, the server will generate a client certificate and offer it back to the user for download; this certificate, once downloaded and stored in the key store along with the private key, can then be used to authenticate to services that use TLS and certificate authentication.</p> <!-- how does the UA know which private key is associated with a certificate it gets back after the server has taken the public key created by <keygen> and turned it into a client cert? --> <div class=example> <p>To generate a key pair, add the private key to the user's key store, and submit the public key to the server, markup such as the following can be used:</p> <pre><form action="processkey.cgi" method="post" enctype="multipart/form-data"> <p><keygen name="key"></p> <p><input type=submit value="Submit key..."></p> </form></pre> <p>The server will then receive a form submission with a packaged RSA public key as the value of "<code title="">key</code>". This can then be used for various purposes, such as generating a client certificate, as mentioned above.</p> </div> <h4 id=the-output-element><span class=secno>4.10.15 </span>The <dfn><code>output</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#category-listed title=category-listed>Listed</a>, <a href=#category-label title=category-label>labelable</a>, and <a href=#category-reset title=category-reset>resettable</a> <a href=#form-associated-element>form-associated element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-output-for><a href=#attr-output-for>for</a></code></dd> <dd><code title=attr-fae-form><a href=#attr-fae-form>form</a></code></dd> <dd><code title=attr-fe-name><a href=#attr-fe-name>name</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmloutputelement>HTMLOutputElement</dfn> : <a href=#htmlelement>HTMLElement</a> { [PutForwards=<span title=dom-DOMSettableTokenList-value>value</span>] readonly attribute <a href=#domsettabletokenlist>DOMSettableTokenList</a> <a href=#dom-output-htmlfor title=dom-output-htmlFor>htmlFor</a>; readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-fae-form title=dom-fae-form>form</a>; attribute DOMString <a href=#dom-fe-name title=dom-fe-name>name</a>; readonly attribute DOMString <a href=#dom-output-type title=dom-output-type>type</a>; attribute DOMString <a href=#dom-output-defaultvalue title=dom-output-defaultValue>defaultValue</a>; attribute DOMString <a href=#dom-output-value title=dom-output-value>value</a>; readonly attribute boolean <a href=#dom-cva-willvalidate title=dom-cva-willValidate>willValidate</a>; readonly attribute <a href=#validitystate>ValidityState</a> <a href=#dom-cva-validity title=dom-cva-validity>validity</a>; readonly attribute DOMString <a href=#dom-cva-validationmessage title=dom-cva-validationMessage>validationMessage</a>; boolean <a href=#dom-cva-checkvalidatity title=dom-cva-checkValidatity>checkValidity</a>(); void <a href=#dom-cva-setcustomvalidity title=dom-cva-setCustomValidity>setCustomValidity</a>(DOMString error); readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><p>The <code><a href=#the-output-element>output</a></code> element <a href=#represents>represents</a> the result of a calculation.</p> <p>The <dfn id=attr-output-for title=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 title=attr-output-for><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>unordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, each of which must have the value of an <a href=#concept-id title=concept-id>ID</a> of an element in the same <code><a href=#document>Document</a></code>.</p> <p>The <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute is used to explicitly associate the <code><a href=#the-output-element>output</a></code> element with its <a href=#form-owner>form owner</a>. The <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute represents the element's name.</p> <div class=impl> <p>The element has a <dfn id=concept-output-mode title=concept-output-mode>value mode flag</dfn> which is either <i title=concept-output-mode-value>value</i> or <i title=concept-output-mode-default>default</i>. Initially, the <a href=#concept-output-mode title=concept-output-mode>value mode flag</a> must be set to <i title=concept-output-mode-default>default</i>.</p> <p>The element also has a <dfn id=concept-output-defaultvalue title=concept-output-defaultValue>default value</dfn>. Initially, the <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a> must be the empty string.</p> <p>When the <a href=#concept-output-mode title=concept-output-mode>value mode flag</a> is in mode <i title=concept-output-mode-default>default</i>, the contents of the element represent both the value of the element and its <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a>. When the <a href=#concept-output-mode title=concept-output-mode>value mode flag</a> is in mode <i title=concept-output-mode-value>value</i>, the contents of the element represent the value of the element only, and the <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a> is only accessible using the <code title=dom-output-defaultValue><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 title=concept-output-mode>value mode flag</a> is in mode <i title=concept-output-mode-default>default</i>, the element's <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a> must be set to the value of the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-output-element>output</a></code> elements is to set the element's <a href=#concept-output-mode title=concept-output-mode>value mode flag</a> to <i title=concept-output-mode-default>default</i> and then to set the element's <code><a href=#textcontent>textContent</a></code> IDL attribute to the value of the element's <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a> (thus replacing the element's child nodes).</p> </div> <dl class=domintro><dt><var title="">output</var> . <code title=dom-output-value><a href=#dom-output-value>value</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the element's current value.</p> <p>Can be set, to change the value.</p> </dd> <dt><var title="">output</var> . <code title=dom-output-defaultValue><a href=#dom-output-defaultvalue>defaultValue</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the element's current default value.</p> <p>Can be set, to change the default value.</p> </dd> <dt><var title="">output</var> . <code title=dom-output-type><a href=#dom-output-type>type</a></code></dt> <dd> <p>Returns the string "<code title="">output</code>".</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-output-value title=dom-output-value><code>value</code></dfn> IDL attribute must act like the element's <code><a href=#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 title=concept-output-mode>value mode flag</a> must be set to <i title=concept-output-mode-value>value</i>.</p> <p>The <dfn id=dom-output-defaultvalue title=dom-output-defaultValue><code>defaultValue</code></dfn> IDL attribute, on getting, must return the element's <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a>. On setting, the attribute must set the element's <a href=#concept-output-defaultvalue title=concept-output-defaultValue>default value</a>, and, if the element's <a href=#concept-output-mode title=concept-output-mode>value mode flag</a> is in the mode <i title=concept-output-mode-default>default</i>, set the element's <code><a href=#textcontent>textContent</a></code> IDL attribute as well.</p> <p>The <dfn id=dom-output-type title=dom-output-type><code>type</code></dfn> attribute must return the string "<code title="">output</code>".</p> <p>The <dfn id=dom-output-htmlfor title=dom-output-htmlFor><code>htmlFor</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-output-for><a href=#attr-output-for>for</a></code> content attribute.</p> <p>The <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code>, <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code>, and <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code> attributes, and the <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity()</a></code> and <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> methods, are part of the <a href=#the-constraint-validation-api>constraint validation API</a>. The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s. The <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> and <code title=dom-fe-name><a href=#dom-fe-name>name</a></code> IDL attributes are part of the element's forms API.</p> <p><strong>Constraint validation</strong>: <code><a href=#the-output-element>output</a></code> elements are always <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> </div> <div class=example> <p>A simple calculator could use <code><a href=#the-output-element>output</a></code> for its display of calculated results:</p> <pre><form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber"> <input name=a type=number step=any> + <input name=b type=number step=any> = <output name=o></output> </form></pre> </div> <h4 id=the-progress-element><span class=secno>4.10.16 </span>The <dfn><code>progress</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#category-label title=category-label>Labelable element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>, but there must be no <code><a href=#the-progress-element>progress</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-progress-value><a href=#attr-progress-value>value</a></code></dd> <dd><code title=attr-progress-max><a href=#attr-progress-max>max</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlprogresselement>HTMLProgressElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute double <a href=#dom-progress-value title=dom-progress-value>value</a>; attribute double <a href=#dom-progress-max title=dom-progress-max>max</a>; readonly attribute double <a href=#dom-progress-position title=dom-progress-position>position</a>; readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><p>The <code><a href=#the-progress-element>progress</a></code> element <a href=#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 title=attr-progress-value><code>value</code></dfn> attribute specifies how much of the task has been completed, and the <dfn id=attr-progress-max title=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 title=attr-progress-value><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 title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute is specified, a number from 0 to the value of the <code title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute). To make an indeterminate progress bar, remove the <code title=attr-progress-value><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><section> <h2>Task Progress</h2> <p>Progress: <progress id="p" max=100><span>0</span>%</progress></p> <script> var progressBar = document.getElementById('p'); function updateProgress(newValue) { progressBar.value = newValue; progressBar.getElementsByTagName('span')[0].textContent = newValue; } </script> </section></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 title=attr-progress-value><a href=#attr-progress-value>value</a></code> and <code title=attr-progress-max><a href=#attr-progress-max>max</a></code> attributes, when present, must have values that are <a href=#valid-floating-point-number title="valid floating point number">valid floating point numbers</a>. The <code title=attr-progress-value><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 title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute, if present, or 1.0, otherwise. The <code title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute, if present, must have a value greater than zero.</p> <p class=note>The <code><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><a href=#the-progress-element>progress</a></code> would be inappropriate. Instead, the <code><a href=#the-meter-element>meter</a></code> element is available for such use cases.</p> <div class=impl> <p><strong>User agent requirements</strong>: If the <code title=attr-progress-value><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 title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute, the user agent must parse the <code title=attr-progress-max><a href=#attr-progress-max>max</a></code> attribute's value according to the <a href=#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 title=concept-progress-maximum>maximum value</dfn> of the progress bar is that value. Otherwise, if the element has no <code title=attr-progress-max><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 title=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 title=attr-progress-value><a href=#attr-progress-value>value</a></code> attribute's value according to the <a href=#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 less than the <a href=#concept-progress-maximum title=concept-progress-maximum>maximum value</a> and greater than zero, then the <dfn id=concept-progress-value title=concept-progress-value>current value</dfn> of the progress bar is that parsed value. Otherwise, if the parsed value was greater than or equal to the <a href=#concept-progress-maximum title=concept-progress-maximum>maximum value</a>, then the <a href=#concept-progress-value title=concept-progress-value>current value</a> of the progress bar is the <a href=#concept-progress-maximum title=concept-progress-maximum>maximum value</a> of the progress bar. Otherwise, if parsing the <code title=attr-progress-value><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 title=concept-progress-value>current value</a> of the progress bar is zero.</p> <p><strong>UA requirements for showing the progress bar</strong>: When representing a <code><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-value title=concept-progress-value>current value</a> relative to the <a href=#concept-progress-maximum title=concept-progress-maximum>maximum value</a>.</p> </div> <dl class=domintro><dt><var title="">progress</var> . <code title=dom-progress-position><a href=#dom-progress-position>position</a></code></dt> <dd> <p>For a determinate progress bar (one with known current and maximum values), returns the result of dividing the current value by the maximum value.</p> <p>For an indeterminate progress bar, returns −1.</p> </dd> </dl><div class=impl> <p>If the progress bar is an indeterminate progress bar, then the <dfn id=dom-progress-position title=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-value title=concept-progress-value>current value</a> by the <a href=#concept-progress-maximum title=concept-progress-maximum>maximum value</a>.</p> <p>If the progress bar is an indeterminate progress bar, then the <dfn id=dom-progress-value title=dom-progress-value><code>value</code></dfn> IDL attribute, on getting, must return 0. Otherwise, it must return the <a href=#concept-progress-value title=concept-progress-value>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>best representation of the number as a floating point number</a> and then the <code title=dom-progress-value><a href=#dom-progress-value>value</a></code> content attribute must be set to that string.</p> <p class=note>Setting the <code title=dom-progress-value><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 title=dom-progress-max><code>max</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-numbers-greater-than-zero>limited to numbers greater than zero</a>. The default value for <code title=dom-progress-max><a href=#dom-progress-max>max</a></code> is 1.0.</p> <p>The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s.</p> </div> <h4 id=the-meter-element><span class=secno>4.10.17 </span>The <dfn><code>meter</code></dfn> element</h4> <!-- Keep this after <progress> and NOT close to <time> --> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dd><a href=#category-label title=category-label>Labelable element</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>, but there must be no <code><a href=#the-meter-element>meter</a></code> element descendants.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-meter-value><a href=#attr-meter-value>value</a></code></dd> <dd><code title=attr-meter-min><a href=#attr-meter-min>min</a></code></dd> <dd><code title=attr-meter-max><a href=#attr-meter-max>max</a></code></dd> <dd><code title=attr-meter-low><a href=#attr-meter-low>low</a></code></dd> <dd><code title=attr-meter-high><a href=#attr-meter-high>high</a></code></dd> <dd><code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlmeterelement>HTMLMeterElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute double <a href=#dom-meter-value title=dom-meter-value>value</a>; attribute double <a href=#dom-meter-min title=dom-meter-min>min</a>; attribute double <a href=#dom-meter-max title=dom-meter-max>max</a>; attribute double <a href=#dom-meter-low title=dom-meter-low>low</a>; attribute double <a href=#dom-meter-high title=dom-meter-high>high</a>; attribute double <a href=#dom-meter-optimum title=dom-meter-optimum>optimum</a>; readonly attribute <a href=#nodelist>NodeList</a> <a href=#dom-lfe-labels title=dom-lfe-labels>labels</a>; };</pre> </dd> </dl><p>The <code><a href=#the-meter-element>meter</a></code> element <a href=#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 class=note>The <code><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><a href=#the-progress-element>progress</a></code> element.</p> <p class=note>The <code><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 title=attr-meter-min><code>min</code></dfn> attribute specifies the lower bound of the range, and the <dfn id=attr-meter-max title=attr-meter-max><code>max</code></dfn> attribute specifies the upper bound. The <dfn id=attr-meter-value title=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 title=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 title=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 title=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><span class=impl><strong>Authoring requirements</strong>:</span> The <code title=attr-meter-value><a href=#attr-meter-value>value</a></code> attribute must be specified. The <code title=attr-meter-value><a href=#attr-meter-value>value</a></code>, <code title=attr-meter-min><a href=#attr-meter-min>min</a></code>, <code title=attr-meter-low><a href=#attr-meter-low>low</a></code>, <code title=attr-meter-high><a href=#attr-meter-high>high</a></code>, <code title=attr-meter-max><a href=#attr-meter-max>max</a></code>, and <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> attributes, when present, must have values that are <a href=#valid-floating-point-number title="valid floating point number">valid floating point numbers</a>.</p> <p>In addition, the attributes' values are further constrained:</p> <p>Let <var title="">value</var> be the <code title=attr-meter-value><a href=#attr-meter-value>value</a></code> attribute's number.</p> <p>If the <code title=attr-meter-min><a href=#attr-meter-min>min</a></code> attribute attribute is specified, then let <var title="">minimum</var> be that attribute's value; otherwise, let it be zero.</p> <p>If the <code title=attr-meter-max><a href=#attr-meter-max>max</a></code> attribute attribute is specified, then let <var title="">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 title="">minimum</var> ≤ <var title="">value</var> ≤ <var title="">maximum</var></li> <li><var title="">minimum</var> ≤ <code title=attr-meter-low><a href=#attr-meter-low>low</a></code> ≤ <var title="">maximum</var> (if <code title=attr-meter-low><a href=#attr-meter-low>low</a></code> is specified)</li> <li><var title="">minimum</var> ≤ <code title=attr-meter-high><a href=#attr-meter-high>high</a></code> ≤ <var title="">maximum</var> (if <code title=attr-meter-high><a href=#attr-meter-high>high</a></code> is specified)</li> <li><var title="">minimum</var> ≤ <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> ≤ <var title="">maximum</var> (if <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> is specified)</li> <li><code title=attr-meter-low><a href=#attr-meter-low>low</a></code> ≤ <code title=attr-meter-high><a href=#attr-meter-high>high</a></code> (if both <code title=attr-meter-low><a href=#attr-meter-low>low</a></code> and <code title=attr-meter-high><a href=#attr-meter-high>high</a></code> are specified)</li> </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><a href=#the-meter-element>meter</a></code> element.</p> <div class=example> <p>The following examples show three gauges that would all be three-quarters full:</p> <pre>Storage space usage: <meter value=6 max=8>6 blocks used (out of 8 total)</meter> Voter turnout: <meter value=0.75><img alt="75%" src="graph75.png"></meter> Tickets sold: <meter min="0" max="100" value="75"></meter></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><p>The grapefruit pie had a radius of <meter value=12>12cm</meter> and a height of <meter value=2>2cm</meter>.</p> <!-- <strong>BAD!</strong> --></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><p>The grapefruit pie had a radius of 12cm and a height of 2cm.</p> <dl> <dt>Radius: <dd> <meter min=0 max=20 value=12>12cm</meter> <dt>Height: <dd> <meter min=0 max=10 value=2>2cm</meter> </dl></pre> </div> <p>There is no explicit way to specify units in the <code><a href=#the-meter-element>meter</a></code> element, but the units may be specified in the <code title=attr-title><a href=#the-title-attribute>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><dl> <dt>Radius: <dd> <meter min=0 max=20 value=12 title="centimeters">12cm</meter> <dt>Height: <dd> <meter min=0 max=10 value=2 title="centimeters">2cm</meter> </dl></pre> </div> <div class=impl> <p><strong>User agent requirements</strong>: User agents must parse the <code title=attr-meter-min><a href=#attr-meter-min>min</a></code>, <code title=attr-meter-max><a href=#attr-meter-max>max</a></code>, <code title=attr-meter-value><a href=#attr-meter-value>value</a></code>, <code title=attr-meter-low><a href=#attr-meter-low>low</a></code>, <code title=attr-meter-high><a href=#attr-meter-high>high</a></code>, and <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> attributes using the <a href=#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 title=concept-meter-minimum>minimum value</dfn></dt> <dd> <p>If the <code title=attr-meter-min><a href=#attr-meter-min>min</a></code> attribute is specified and a value could be parsed out of it, then the minimum value is that value. Otherwise, the minimum value is zero.</p> </dd> <dt>The <dfn id=concept-meter-maximum title=concept-meter-maximum>maximum value</dfn></dt> <dd> <p>If the <code title=attr-meter-max><a href=#attr-meter-max>max</a></code> attribute is specified and a value could be parsed out of it, then the candidate maximum value is that value. Otherwise, the candidate maximum value is 1.0.</p> <p>If the candidate maximum value is greater than or equal to the minimum value, then the maximum value is the candidate maximum value. Otherwise, the maximum value is the same as the minimum value.</p> </dd> <dt>The <dfn id=concept-meter-actual title=concept-meter-actual>actual value</dfn></dt> <dd> <p>If the <code title=attr-meter-value><a href=#attr-meter-value>value</a></code> attribute is specified and a value could be parsed out of it, then that value is the candidate actual value. Otherwise, the candidate actual value is zero.</p> <p>If the candidate actual value is less than the minimum value, then the actual value is the minimum value.</p> <p>Otherwise, if the candidate actual value is greater than the maximum value, then the actual value is the maximum value.</p> <p>Otherwise, the actual value is the candidate actual value.</p> </dd> <dt>The <dfn id=concept-meter-low title=concept-meter-low>low boundary</dfn></dt> <dd> <p>If the <code title=attr-meter-low><a href=#attr-meter-low>low</a></code> attribute is specified and a value could be parsed out of it, then the candidate low boundary is that value. Otherwise, the candidate low boundary is the same as the minimum value.</p> <p>If the candidate low boundary is less than the minimum value, then the low boundary is the minimum value.</p> <p>Otherwise, if the candidate low boundary is greater than the maximum value, then the low boundary is the maximum value.</p> <p>Otherwise, the low boundary is the candidate low boundary.</p> </dd> <dt>The <dfn id=concept-meter-high title=concept-meter-high>high boundary</dfn></dt> <dd> <p>If the <code title=attr-meter-high><a href=#attr-meter-high>high</a></code> attribute is specified and a value could be parsed out of it, then the candidate high boundary is that value. Otherwise, the candidate high boundary is the same as the maximum value.</p> <p>If the candidate high boundary is less than the low boundary, then the high boundary is the low boundary.</p> <p>Otherwise, if the candidate high boundary is greater than the maximum value, then the high boundary is the maximum value.</p> <p>Otherwise, the high boundary is the candidate high boundary.</p> </dd> <dt>The <dfn id=concept-meter-optimum title=concept-meter-optimum>optimum point</dfn></dt> <dd> <p>If the <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> attribute is specified and a value could be parsed out of it, then the candidate optimum point is that value. Otherwise, the candidate optimum point is the midpoint between the minimum value and the maximum value.</p> <p>If the candidate optimum point is less than the minimum value, then the optimum point is the minimum value.</p> <p>Otherwise, if the candidate optimum point is greater than the maximum value, then the optimum point is the maximum value.</p> <p>Otherwise, the optimum point is the candidate optimum point.</p> </dd> </dl><p>All of which will result in the following inequalities all being true:</p> <ul class=brief><li>minimum value ≤ actual value ≤ maximum value</li> <li>minimum value ≤ low boundary ≤ high boundary ≤ maximum value</li> <li>minimum value ≤ optimum point ≤ maximum value</li> </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><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> <div class=example> <p>The following markup:</p> <pre><h3>Suggested groups</h3> <menu type="toolbar"> <a href="?cmd=hsg" onclick="hideSuggestedGroups()">Hide suggested groups</a> </menu> <ul> <li> <p><a href="/group/comp.infosystems.www.authoring.stylesheets/view">comp.infosystems.www.authoring.stylesheets</a> - <a href="/group/comp.infosystems.www.authoring.stylesheets/subscribe">join</a></p> <p>Group description: <strong>Layout/presentation on the WWW.</strong></p> <p><strong><meter value="0.5">Moderate activity,</meter></strong> Usenet, 618 subscribers</p> </li> <li> <p><a href="/group/netscape.public.mozilla.xpinstall/view">netscape.public.mozilla.xpinstall</a> - <a href="/group/netscape.public.mozilla.xpinstall/subscribe">join</a></p> <p>Group description: <strong>Mozilla XPInstall discussion.</strong></p> <p><strong><meter value="0.25">Low activity,</meter></strong> Usenet, 22 subscribers</p> </li> <li> <p><a href="/group/mozilla.dev.general/view">mozilla.dev.general</a> - <a href="/group/mozilla.dev.general/subscribe">join</a></p> <p><strong><meter value="0.25">Low activity,</meter></strong> Usenet, 66 subscribers</p> </li> </ul></pre> <p>Might be rendered as follows:</p> <p><img alt="With the <meter> elements rendered as inline green bars of varying lengths." height=178 src=http://images.whatwg.org/sample-meter.png width=332></p> </div> <p>User agents <span class=impl>may</span> combine the value of the <code title=attr-title><a href=#the-title-attribute>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><meter min=0 max=60 value=23.2 title=seconds></meter></pre> <p>...might cause the user agent to display a gauge with a tooltip saying "Value: 23.2 out of 60." on one line and "seconds" on a second line.</p> </div> <div class=impl> <p>The <dfn id=dom-meter-value title=dom-meter-value><code>value</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-actual title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-value><a href=#dom-meter-value>value</a></code> content attribute must be set to that string.</p> <p>The <dfn id=dom-meter-min title=dom-meter-min><code>min</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-minimum title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-min><a href=#dom-meter-min>min</a></code> content attribute must be set to that string.</p> <p>The <dfn id=dom-meter-max title=dom-meter-max><code>max</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-maximum title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-max><a href=#dom-meter-max>max</a></code> content attribute must be set to that string.</p> <p>The <dfn id=dom-meter-low title=dom-meter-low><code>low</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-low title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-low><a href=#dom-meter-low>low</a></code> content attribute must be set to that string.</p> <p>The <dfn id=dom-meter-high title=dom-meter-high><code>high</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-high title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-high><a href=#dom-meter-high>high</a></code> content attribute must be set to that string.</p> <p>The <dfn id=dom-meter-optimum title=dom-meter-optimum><code>optimum</code></dfn> IDL attribute, on getting, must return the <a href=#concept-meter-optimum title=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>best representation of the number as a floating point number</a> and then the <code title=dom-meter-optimum><a href=#dom-meter-optimum>optimum</a></code> content attribute must be set to that string.</p> <p>The <code title=dom-lfe-labels><a href=#dom-lfe-labels>labels</a></code> attribute provides a list of the element's <code><a href=#the-label-element>label</a></code>s.</p> </div> <div class=example> <p>The following example shows how a gauge could fall back to localized or pretty-printed text.</p> <pre><p>Disk usage: <meter min=0 value=170261928 max=233257824>170 261 928 bytes used out of 233 257 824 bytes available</meter></p></pre> </div> <h4 id=association-of-controls-and-forms><span class=secno>4.10.18 </span>Association of controls and forms</h4> <p>A <a href=#form-associated-element>form-associated element</a> can have a relationship with a <code><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>form-associated element</a> is not associated with a <code><a href=#the-form-element>form</a></code> element, its <a href=#form-owner>form owner</a> is said to be null.</p> <p>A <a href=#form-associated-element>form-associated element</a> is, by default, associated with its <span class=impl>nearest</span> ancestor <code><a href=#the-form-element>form</a></code> element<span class=impl> (as described below)</span>, but may have a <dfn id=attr-fae-form title=attr-fae-form><code>form</code></dfn> attribute specified to override this.</p> <p class=note>This feature allows authors to work around the lack of support for nested <code><a href=#the-form-element>form</a></code> elements.</p> <p>If a <a href=#form-associated-element>form-associated element</a> has a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute specified, then that attribute's value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#the-form-element>form</a></code> element in the element's owner <code><a href=#document>Document</a></code>.</p> <div class=impl> <p class=note>The rules in this section are complicated by the fact that although conforming documents will never contain nested <code><a href=#the-form-element>form</a></code> elements, it is quite possible (e.g. using a script that performs DOM manipulation) to generate documents 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>form-associated element</a> being associated with a <code><a href=#the-form-element>form</a></code> element that is not its ancestor.</p> <p>When a <a href=#form-associated-element>form-associated element</a> is created, its <a href=#form-owner>form owner</a> must be initialized to null (no owner).</p> <p>When a <a href=#form-associated-element>form-associated element</a> is to be <dfn id=concept-form-association title=concept-form-association>associated</dfn> with a form, its <a href=#form-owner>form owner</a> must be set to that form.</p> <p>When a <a href=#form-associated-element>form-associated element</a>'s ancestor chain changes, e.g. because it or one of its ancestors was <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted</a> or <a href=#remove-an-element-from-a-document title="remove an element from a document">removed</a> from a <code><a href=#document>Document</a></code>, then the user agent must <a href=#reset-the-form-owner>reset the form owner</a> of that element. <span class=note>The <a href=#html-parser>HTML parser</a> overrides this requirement when inserting form controls.</span></p> <p>When a <a href=#form-associated-element>form-associated element</a>'s <code title=attr-fae-form><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>reset the form owner</a> of that element.</p> <p>When a <a href=#form-associated-element>form-associated element</a> has a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute and the <a href=#concept-id title=concept-id>ID</a> of any of the elements in the <code><a href=#document>Document</a></code> changes, then the user agent must <a href=#reset-the-form-owner>reset the form owner</a> of that <a href=#form-associated-element>form-associated element</a>.</p> <p>When a <a href=#form-associated-element>form-associated element</a> has a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute and an element with an <a href=#concept-id title=concept-id>ID</a> is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into</a> or <a href=#remove-an-element-from-a-document title="remove an element from a document">removed from</a> the <code><a href=#document>Document</a></code>, then the user agent must <a href=#reset-the-form-owner>reset the form owner</a> of that <a href=#form-associated-element>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>form-associated element</a>, it must run the following steps:</p> <ol><li><p>If the element's <a href=#form-owner>form owner</a> is not null, and the element's <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> content attribute is not present, and the element's <a href=#form-owner>form owner</a> is its nearest <code><a href=#the-form-element>form</a></code> element ancestor after the change to the ancestor chain, then do nothing, and abort these steps.</li> <li><p>Let the element's <a href=#form-owner>form owner</a> be null.</li> <li> <p>If the element has a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> content attribute, then run these substeps:</p> <ol><!-- note that this ignores the name="" attribute and is unaffected by quirks mode (it's always case sensitive) --><li><p>If the first element <a href=#in-a-document title="in a Document">in the <code>Document</code></a> to have an <a href=#concept-id title=concept-id>ID</a> that is <a href=#case-sensitive title=case-sensitive>case-sensitively</a> equal to the element's <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> content attribute's value is a <code><a href=#the-form-element>form</a></code> element, then <a href=#concept-form-association title=concept-form-association>associate</a> the <a href=#form-associated-element>form-associated element</a> with that <code><a href=#the-form-element>form</a></code> element.</li> <li><p>Abort the "reset the form owner" steps.</li> </ol></li> <li><p>Otherwise, if the <a href=#form-associated-element>form-associated element</a> in question has an ancestor <code><a href=#the-form-element>form</a></code> element, then <a href=#concept-form-association title=concept-form-association>associate</a> the <a href=#form-associated-element>form-associated element</a> with the nearest such ancestor <code><a href=#the-form-element>form</a></code> element.</li> <li><p>Otherwise, the element is left unassociated.</li> </ol><div class=example> <p>In the following non-conforming snippet:</p> <pre class=bad>... <form id="a"> <div id="b"></div> </form> <script> document.getElementById('b').innerHTML = '<table><tr><td><form id="c"><input id="d"></table>' + '<input id="e">'; </script> ...</pre> <p>The <a href=#form-owner>form owner</a> of "d" would be the inner nested form "c", while the <a href=#form-owner>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>HTML parser</a>. Then, the <code title=dom-innerHTML><a href=#dom-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><a href=#the-form-element>form</a></code> elements.</p> </div> </div> <dl class=domintro><dt><var title="">element</var> . <code title=dom-fae-form><a href=#dom-fae-form>form</a></code></dt> <dd> <p>Returns the element's <a href=#form-owner>form owner</a>.</p> <p>Returns null if there isn't one.</p> </dd> </dl><div class=impl> <p><a href=#form-associated-element title="form-associated element">Form-associated elements</a> have a <dfn id=dom-fae-form title=dom-fae-form><code>form</code></dfn> IDL attribute, which, on getting, must return the element's <a href=#form-owner>form owner</a>, or null if there isn't one.</p> </div> <h4 id=attributes-common-to-form-controls><span class=secno>4.10.19 </span><dfn>Attributes common to form controls</dfn></h4> <h5 id=naming-form-controls><span class=secno>4.10.19.1 </span>Naming form controls</h5> <p>The <dfn id=attr-fe-name title=attr-fe-name><code>name</code></dfn> content attribute gives the name of the form control, as used in <a href=#form-submission>form submission</a> and in the <code><a href=#the-form-element>form</a></code> element's <code title=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.</p> <p>Any non-empty value for <code title=attr-form-name><a href=#attr-form-name>name</a></code> is allowed, but the names "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>" are special:</p> <dl><dt><dfn id=attr-fe-name-isindex title=attr-fe-name-isindex><code>isindex</code></dfn></dt> <dd> <p>This value, if used as the name of a <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> control that is the first control in a form that is submitted using the <code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code> mechanism, causes the submission to only include the value of this control, with no name.</p> </dd> <dt><dfn id=attr-fe-name-charset title=attr-fe-name-charset><code>_charset_</code></dfn></dt> <dd> <p>This value, if used as the name of a <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> control with no <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, is automatically given a value during submission consisting of the submission character encoding.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-fe-name title=dom-fe-name><code>name</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> content attribute.</p> </div> <h5 id=enabling-and-disabling-form-controls><span class=secno>4.10.19.2 </span>Enabling and disabling form controls</h5> <p>The <dfn id=attr-fe-disabled title=attr-fe-disabled><code>disabled</code></dfn> content attribute is a <a href=#boolean-attribute>boolean attribute</a>.</p> <p>A form control is <dfn id=concept-fe-disabled title=concept-fe-disabled>disabled</dfn> if its <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> attribute is set, or if it is a descendant of a <code><a href=#the-fieldset-element>fieldset</a></code> element whose <code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>disabled</a></code> attribute is set and is <em>not</em> a descendant of that <code><a href=#the-fieldset-element>fieldset</a></code> element's first <code><a href=#the-legend-element>legend</a></code> element child, if any.</p> <div class=impl> <p>A form control that is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a> must prevent any <code title=event-click><a href=#event-click>click</a></code> events that are <a href=#queue-a-task title="queue a task">queued</a> on the <a href=#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 title=concept-fe-disabled>disabled</a>, it is <a href=#barred-from-constraint-validation>barred from constraint validation</a>.</p> <p>The <dfn id=dom-fe-disabled title=dom-fe-disabled><code>disabled</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> content attribute.</p> </div> <div class=impl> <h5 id="a-form-control's-value"><span class=secno>4.10.19.3 </span>A form control's value</h5> <p>Form controls have a <dfn id=concept-fe-value title=concept-fe-value>value</dfn> and a <dfn id=concept-fe-checked title=concept-fe-checked>checkedness</dfn>. (The latter is only used by <code><a href=#the-input-element>input</a></code> elements.) These are used to describe how the user interacts with the control.</p> <p>To define the behaviour of constraint validation in the face of the <code><a href=#the-input-element>input</a></code> element's <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute, <code><a href=#the-input-element>input</a></code> elements can also have separately defined <dfn id=concept-fe-values title=concept-fe-values>value<em>s</em></dfn>.</p> </div> <h5 id=autofocusing-a-form-control><span class=secno>4.10.19.4 </span>Autofocusing a form control</h5> <!-- v2: Apply this to contentEditable elements --> <p>The <dfn id=attr-fe-autofocus title=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, allowing the user to just start typing without having to manually focus the main control.</p> <p>The <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute is a <a href=#boolean-attribute>boolean attribute</a>.</p> <p>There must not be more than one element in the document with the <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute specified.</p> <div class=impl> <p>When an element with the <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute specified is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a document</a>, user agents should run the following steps:</p> <ol><li><p>Let <var title="">target</var> be the element's <code><a href=#document>Document</a></code>.</li> <li><p>If <var title="">target</var> has no <a href=#browsing-context>browsing context</a>, abort these steps.</li> <li><p>If <var title="">target</var>'s <a href=#browsing-context>browsing context</a> has no <a href=#top-level-browsing-context>top-level browsing context</a> (e.g. it is a <a href=#nested-browsing-context>nested browsing context</a> with no <a href=#parent-browsing-context>parent browsing context</a>), abort these steps.</li> <li><p>If <var title="">target</var>'s <a href=#browsing-context>browsing context</a> had the <a href=#sandboxed-automatic-features-browsing-context-flag>sandboxed automatic features browsing context flag</a> set when <var title="">target</var> was created, abort these steps.</li> <li><p>If <var title="">target</var>'s <a href=#origin>origin</a> is not the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of the currently focused element in <var title="">target</var>'s <a href=#top-level-browsing-context>top-level browsing context</a>, abort these steps.</li> <li><p>If <var title="">target</var>'s <a href=#origin>origin</a> is not the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <a href=#active-document>active document</a> of <var title="">target</var>'s <a href=#top-level-browsing-context>top-level browsing context</a>, abort these steps.</li> <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 title="insert an element into a document">inserted</a> into a <code><a href=#document>Document</a></code> whose <a href=#top-level-browsing-context>top-level browsing context</a>'s <a href=#active-document>active document</a> is the same as <var title="">target</var>'s <a href=#top-level-browsing-context>top-level browsing context</a>'s <a href=#active-document>active document</a>, abort these steps.</li> <li><p>If the user has indicated (for example, by starting to type in a form control) that he does not wish focus to be changed, then optionally abort these steps.</li> <li><p><a href=#queue-a-task>Queue a task</a> that checks to see if the element is <a href=#focusable>focusable</a>, and if so, runs the <a href=#focusing-steps>focusing steps</a> for that 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. The <a href=#task-source>task source</a> for this task is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</li> </ol><p class=note>Focusing the control does not imply that the user agent must focus the browser window if it has lost focus.</p> <p>The <dfn id=dom-fe-autofocus title=dom-fe-autofocus><code>autofocus</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <div class=example> <p>In the following snippet, the text control would be focused when the document was loaded.</p> <pre><input maxlength="256" name="q" value="" autofocus> <input type="submit" value="Search"></pre> </div> <h5 id=limiting-user-input-length><span class=secno>4.10.19.5 </span>Limiting user input length</h5> <p>A <dfn id=attr-fe-maxlength title=attr-fe-maxlength>form control <code title="">maxlength</code> attribute</dfn>, controlled by a <var title="">dirty value flag</var>, declares a limit on the number of characters a user can input.</p> <p>If an element has its <a href=#attr-fe-maxlength title=attr-fe-maxlength>form control <code title="">maxlength</code> attribute</a> specified, the attribute's value must be a <a href=#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>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>maximum allowed value length</a>.</p> <div class=impl> <p><strong>Constraint validation</strong>: If an element has a <a href=#maximum-allowed-value-length>maximum allowed value length</a>, its <var title="">dirty value flag</var> is true, its <a href=#concept-fe-value title=concept-fe-value>value</a> was last changed by a user edit (as opposed to a change made by a script), and the <a href=#code-point-length>code-point length</a> of the element's <a href=#concept-fe-value title=concept-fe-value>value</a> is greater than the element's <a href=#maximum-allowed-value-length>maximum allowed value length</a>, then the element is <a href=#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-value title=concept-fe-value>value</a> to be set to a value whose <a href=#code-point-length>code-point length</a> is greater than the element's <a href=#maximum-allowed-value-length>maximum allowed value length</a>.</p> </div> <h5 id=form-submission-0><span class=secno>4.10.19.6 </span>Form submission</h5> <p><dfn id=attributes-for-form-submission>Attributes for form submission</dfn> can be specified both on <code><a href=#the-form-element>form</a></code> elements and on <a href=#concept-submit-button title=concept-submit-button>submit buttons</a> (elements that represent buttons that submit forms, e.g. an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a> state). <p>The <a href=#attributes-for-form-submission>attributes for form submission</a> that may be specified on <code><a href=#the-form-element>form</a></code> elements are <code title=attr-fs-action><a href=#attr-fs-action>action</a></code>, <code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code>, <code title=attr-fs-method><a href=#attr-fs-method>method</a></code>, <code title=attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code>, and <code title=attr-fs-target><a href=#attr-fs-target>target</a></code>.</p> <p>The corresponding <a href=#attributes-for-form-submission>attributes for form submission</a> that may be specified on <a href=#concept-submit-button title=concept-submit-button>submit buttons</a> are <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code title=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><a href=#the-form-element>form</a></code> element.</p> <hr><p>The <dfn id=attr-fs-action title=attr-fs-action><code>action</code></dfn> and <dfn id=attr-fs-formaction title=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>valid non-empty URL potentially surrounded by spaces</a>.</p> <p>The <dfn id=concept-fs-action title=concept-fs-action>action</dfn> of an element is the value of the element's <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code> attribute, if the element is a <a href=#concept-submit-button title=concept-submit-button>submit button</a> and has such an attribute, or the value of its <a href=#form-owner>form owner</a>'s <code title=attr-fs-action><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 title=attr-fs-method><code>method</code></dfn> and <dfn id=attr-fs-formmethod title=attr-fs-formmethod><code>formmethod</code></dfn> content attributes are <a href=#enumerated-attribute title="enumerated attribute">enumerated attributes</a> with the following keywords and states:</p> <ul><li>The keyword <dfn id=attr-fs-method-get-keyword title=attr-fs-method-GET-keyword><code>get</code></dfn>, mapping to the state <dfn id=attr-fs-method-get title=attr-fs-method-GET>GET</dfn>, indicating the HTTP GET method.</li> <li>The keyword <dfn id=attr-fs-method-post-keyword title=attr-fs-method-POST-keyword><code>post</code></dfn>, mapping to the state <dfn id=attr-fs-method-post title=attr-fs-method-POST>POST</dfn>, indicating the HTTP POST method.</li> </ul><p>The <i>missing value default</i> for these attributes is the <a href=#attr-fs-method-get title=attr-fs-method-GET>GET</a> state.</p> <p>The <dfn id=concept-fs-method title=concept-fs-method>method</dfn> of an element is one of those states. If the element is a <a href=#concept-submit-button title=concept-submit-button>submit button</a> and has a <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code> attribute, then the element's <a href=#concept-fs-method title=concept-fs-method>method</a> is that attribute's state; otherwise, it is the <a href=#form-owner>form owner</a>'s <code title=attr-fs-method><a href=#attr-fs-method>method</a></code> attribute's state.</p> <hr><p>The <dfn id=attr-fs-enctype title=attr-fs-enctype><code>enctype</code></dfn> and <dfn id=attr-fs-formenctype title=attr-fs-formenctype><code>formenctype</code></dfn> content attributes are <a href=#enumerated-attribute title="enumerated attribute">enumerated attributes</a> with the following keywords and states:</p> <ul><li>The "<dfn id=attr-fs-enctype-urlencoded title=attr-fs-enctype-urlencoded><code>application/x-www-form-urlencoded</code></dfn>" keyword and corresponding state.</li> <li>The "<dfn id=attr-fs-enctype-formdata title=attr-fs-enctype-formdata><code>multipart/form-data</code></dfn>" keyword and corresponding state.</li> <li>The "<dfn id=attr-fs-enctype-text title=attr-fs-enctype-text><code>text/plain</code></dfn>" keyword and corresponding state.</li> </ul><p>The <i>missing value default</i> for these attributes is the <code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code> state.</p> <p>The <dfn id=concept-fs-enctype title=concept-fs-enctype>enctype</dfn> of an element is one of those three states. If the element is a <a href=#concept-submit-button title=concept-submit-button>submit button</a> and has a <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code> attribute, then the element's <a href=#concept-fs-enctype title=concept-fs-enctype>enctype</a> is that attribute's state; otherwise, it is the <a href=#form-owner>form owner</a>'s <code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code> attribute's state.</p> <hr><p>The <dfn id=attr-fs-target title=attr-fs-target><code>target</code></dfn> and <dfn id=attr-fs-formtarget title=attr-fs-formtarget><code>formtarget</code></dfn> content attributes, if specified, must have values that are <a href=#valid-browsing-context-name-or-keyword title="valid browsing context name or keyword">valid browsing context names or keywords</a>.</p> <p>The <dfn id=concept-fs-target title=concept-fs-target>target</dfn> of an element is the value of the element's <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> attribute, if the element is a <a href=#concept-submit-button title=concept-submit-button>submit button</a> and has such an attribute; or the value of its <a href=#form-owner>form owner</a>'s <code title=attr-fs-target><a href=#attr-fs-target>target</a></code> attribute, if <em>it</em> has such an attribute; or, if the <code><a href=#document>Document</a></code> contains a <code><a href=#the-base-element>base</a></code> element with a <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute, then the value of the <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute of the first such <code><a href=#the-base-element>base</a></code> element; or, if there is no such element, the empty string.</p> <!-- c.f. hyperlink following --> <hr><p>The <dfn id=attr-fs-novalidate title=attr-fs-novalidate><code>novalidate</code></dfn> and <dfn id=attr-fs-formnovalidate title=attr-fs-formnovalidate><code>formnovalidate</code></dfn> content attributes are <a href=#boolean-attribute title="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 title=concept-fs-novalidate>no-validate state</dfn> of an element is true if the element is a <a href=#concept-submit-button title=concept-submit-button>submit button</a> and the element's <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code> attribute is present, or if the element's <a href=#form-owner>form owner</a>'s <code title=attr-fs-novalidate><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><form action="editor.cgi" method="post"> <p><label>Name: <input required name=fn></label></p> <p><label>Essay: <textarea required name=essay></textarea></label></p> <p><input type=submit name=submit value="Submit essay"></p> <p><input type=submit formnovalidate name=save value="Save essay"></p> <p><input type=submit formnovalidate name=cancel value="Cancel"></p> </form></pre> </div> <div class=impl> <hr><p>The <dfn id=dom-fs-action title=dom-fs-action><code>action</code></dfn> IDL attribute must <a href=#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, <a href="#the-document's-address">the document's address</a> must be returned instead. The <dfn id=dom-fs-target title=dom-fs-target><code>target</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name. The <dfn id=dom-fs-method title=dom-fs-method><code>method</code></dfn> and <dfn id=dom-fs-enctype title=dom-fs-enctype><code>enctype</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>. The <dfn id=dom-fs-encoding title=dom-fs-encoding><code>encoding</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code> content attribute, <a href=#limited-to-only-known-values>limited to only known values</a>. The <dfn id=dom-fs-novalidate title=dom-fs-noValidate><code>noValidate</code></dfn> IDL attribute must reflect the <code title=attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code> content attribute. The <dfn id=dom-fs-formaction title=dom-fs-formAction><code>formAction</code></dfn> IDL attribute must reflect the <code title=attr-fs-formaction><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, <a href="#the-document's-address">the document's address</a> must be returned instead. The <dfn id=dom-fs-formenctype title=dom-fs-formEnctype><code>formEnctype</code></dfn> IDL attribute must reflect the <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code> content attribute, <a href=#limited-to-only-known-values>limited to only known values</a>. The <dfn id=dom-fs-formmethod title=dom-fs-formMethod><code>formMethod</code></dfn> IDL attribute must reflect the <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code> content attribute, <a href=#limited-to-only-known-values>limited to only known values</a>. The <dfn id=dom-fs-formnovalidate title=dom-fs-formNoValidate><code>formNoValidate</code></dfn> IDL attribute must reflect the <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code> content attribute. The <dfn id=dom-fs-formtarget title=dom-fs-formTarget><code>formTarget</code></dfn> IDL attribute must reflect the <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> content attribute. </div> <h5 id=submitting-element-directionality><span class=secno>4.10.19.7 </span>Submitting element directionality</h5> <p>A <dfn id=form-control-dirname-attribute>form control <code title="">dirname</code> attribute</dfn> on a form control element enables the submission of <a href=#the-directionality>the directionality</a> of the element, and gives the name of the field that contains this value during <a href=#form-submission>form submission</a>. If such an attribute is specified, its value must not be the empty string.</p> <h4 id=textFieldSelection><span class=secno>4.10.20 </span>APIs for the text field selections</h4> <!-- v2 idea: DOM Range APIs to expose the textarea/input edited value (ack martijnw) --> <p>The <code><a href=#the-input-element>input</a></code> and <code><a href=#the-textarea-element>textarea</a></code> elements define the following members in their DOM interfaces for handling their selection:</p> <pre class="idl extract"> void <a href=#dom-textarea/input-select title=dom-textarea/input-select>select</a>(); attribute unsigned long <a href=#dom-textarea/input-selectionstart title=dom-textarea/input-selectionStart>selectionStart</a>; attribute unsigned long <a href=#dom-textarea/input-selectionend title=dom-textarea/input-selectionEnd>selectionEnd</a>; attribute DOMString <a href=#dom-textarea/input-selectiondirection title=dom-textarea/input-selectionDirection>selectionDirection</a>; void <a href=#dom-textarea/input-setselectionrange title=dom-textarea/input-setSelectionRange>setSelectionRange</a>(unsigned long start, unsigned long end, optional DOMString direction);</pre> <!-- v2: also add textLength? it seems to be widely used --> <p>These methods and attributes expose and control the selection of <code><a href=#the-input-element>input</a></code> and <code><a href=#the-textarea-element>textarea</a></code> text fields.</p> <dl class=domintro><dt><var title="">element</var> . <code title=dom-textarea/input-select><a href=#dom-textarea/input-select>select</a></code>()</dt> <dd> <p>Selects everything in the text field.</p> </dd> <dt><var title="">element</var> . <code title=dom-textarea/input-selecionStart>selectionStart</code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the offset to the start of the selection.</p> <p>Can be set, to change the start of the selection.</p> </dd> <dt><var title="">element</var> . <code title=dom-textarea/input-selecionEnd>selectionEnd</code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the offset to the end of the selection.</p> <p>Can be set, to change the end of the selection.</p> </dd> <dt><var title="">element</var> . <code title=dom-textarea/input-selecionDirection>selectionDirection</code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current direction of the selection.</p> <p>Can be set, to change the direction of the selection.</p> <p>The possible values are "<code title="">forward</code>", "<code title="">backward</code>", and "<code title="">none</code>".</p> </dd> <dt><var title="">element</var> . <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange</a></code>(<var title="">start</var>, <var title="">end</var> [, <var title="">direction</var>] )</dt> <dd> <p>Changes the selection to cover the given substring in the given direction. If the direction is omitted, it will be reset to be the platform default (none or forward).</p> </dd> </dl><div class=impl> <p>When these methods and attributes are used with <code><a href=#the-input-element>input</a></code> elements while they don't apply, they must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. Otherwise, they must act as described below.</p> <p>For <code><a href=#the-input-element>input</a></code> elements, these methods and attributes must operate on the element's <a href=#concept-fe-value title=concept-fe-value>value</a>. For <code><a href=#the-textarea-element>textarea</a></code> elements, these methods and attributes must operate on the element's <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a>.</p> <p>Where possible, user interface features for changing the text selection in <code><a href=#the-input-element>input</a></code> and <code><a href=#the-textarea-element>textarea</a></code> elements must be implemented in terms of the DOM API described in this section, so that, e.g., all the same events fire.</p> <p>The selections of <code><a href=#the-input-element>input</a></code> and <code><a href=#the-textarea-element>textarea</a></code> elements have a <i>direction</i>, which is either <i>forward</i>, <i>backward</i>, or <i>none</i>. This direction is set when the user manipulates the selection. The exact meaning of the selection direction depends on the platform.</p> <p class=note>On Windows, the direction indicates the position of the caret relative to the selection: a <i>forward</i> selection has the caret at the end of the selection and a <i>backward</i> selection has the caret at the start of the selection. Windows has no <i>none</i> direction. 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 forward direction means the end of the selection is modified, and the backwards direction means the start of the selection is modified. The none 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> <p>The <dfn id=dom-textarea/input-select title=dom-textarea/input-select><code>select()</code></dfn> method must cause the contents of the text field to be fully selected, with the selection direction being none, if the platform support selections with the direction <i>none</i>, or otherwise <i>forward</i>. The user agent must then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-select>select</code> at the element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task source.</p> <p>The <dfn id=dom-textarea/input-selectionstart title=dom-textarea/input-selectionStart><code>selectionStart</code></dfn> attribute must, on getting, return the offset (in logical order) to the character that immediately follows the start of the selection. If there is no selection, then it must return the offset (in logical order) to the character that immediately follows the text entry cursor.</p> <p>On setting, it must act as if the <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> method had been called, with the new value as the first argument; the current value of the <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code> attribute as the second argument, unless the current value of the <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code> is less than the new value, in which case the second argument must also be the new value; and the current value of the <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> as the third argument.</p> <p>The <dfn id=dom-textarea/input-selectionend title=dom-textarea/input-selectionEnd><code>selectionEnd</code></dfn> attribute must, on getting, return the offset (in logical order) to the character that immediately follows the end of the selection. If there is no selection, then it must return the offset (in logical order) to the character that immediately follows the text entry cursor.</p> <p>On setting, it must act as if the <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> method had been called, with the current value of the <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code> attribute as the first argument, the new value as the second argument, and the current value of the <code title=dom-textarea/input-selectionDirection><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> as the third argument.</p> <p>The <dfn id=dom-textarea/input-selectiondirection title=dom-textarea/input-selectionDirection><code>selectionDirection</code></dfn> attribute must, on getting, return the string corresponding to the current selection direction: if the direction is <i>forward</i>, "<code title="">forward</code>"; if the direction is <i>backward</i>, "<code title="">backward</code>"; and otherwise, "<code title="">none</code>".</p> <p>On setting, it must act as if the <code title=dom-textarea/input-setSelectionRange><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code> method had been called, with the current value of the <code title=dom-textarea/input-selectionStart><a href=#dom-textarea/input-selectionstart>selectionStart</a></code> attribute as the first argument, the current value of the <code title=dom-textarea/input-selectionEnd><a href=#dom-textarea/input-selectionend>selectionEnd</a></code> attribute as the second argument, and the new value as the third argument.</p> <p>The <dfn id=dom-textarea/input-setselectionrange title=dom-textarea/input-setSelectionRange><code>setSelectionRange(<var title="">start</var>, <var title="">end</var>, <var title="">direction</var>)</code></dfn> method must set the selection of the text field to the sequence of characters starting with the character at the <var title="">start</var>th position (in logical order) and ending with the character at the <span title="">(<var title="">end</var>-1)</span>th position. Arguments greater than the length of the value in the text field must be treated as pointing at the end of the text field. If <var title="">end</var> is less than or equal to <var title="">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 title="">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 title="">end</var>. The direction of the selection must be set to <i>backward</i> if <var title="">direction</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">backward</code>", <i>forward</i> if <var title="">direction</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">forward</code>" or if the platform does not support selections with the direction <i>none</i>, and <i>none</i> otherwise (including if the argument is omitted). The user agent must then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-select>select</code> at the element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task source.</p> <p>All elements to which this API applies have either a selection or a text entry cursor position at all times (even for elements that are not <a href=#being-rendered>being rendered</a>). User agents should follow platform conventions to determine their initial state.</p> </div> <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> <div class=example> <p>To obtain the currently selected text, the following JavaScript suffices:</p> <pre>var selectionText = control.value.substring(control.selectionStart, control.selectionEnd);</pre> <p>...where <var title="">control</var> is the <code><a href=#the-input-element>input</a></code> or <code><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>var oldStart = control.selectionStart; var oldEnd = control.selectionEnd; var oldDirection = control.selectionDirection; var prefix = "http://"; control.value = prefix + control.value; control.setSelectionRange(oldStart + prefix.length, oldEnd + prefix.length, oldDirection);</pre> <p>...where <var title="">control</var> is the <code><a href=#the-input-element>input</a></code> or <code><a href=#the-textarea-element>textarea</a></code> element.</p> </div> <h4 id=constraints><span class=secno>4.10.21 </span>Constraints</h4> <h5 id=definitions><span class=secno>4.10.21.1 </span>Definitions</h5> <div class=impl> <p>A <a href=#category-listed title=category-listed>listed form-associated 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 title="barred from constraint validation">barred the element from constraint validation</dfn>. (For example, an element is <a href=#barred-from-constraint-validation>barred from constraint validation</a> if it is an <code><a href=#the-output-element>output</a></code> or <code><a href=#the-fieldset-element>fieldset</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>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>suffering from a custom error</a>. It can be set using the <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> method. The user agent should use the <a href=#custom-validity-error-message>custom validity error message</a> when alerting the user to the problem with the control.</p> <p>An element can be constrained in various ways. The following is the list of <dfn id=validity-states>validity states</dfn> that a form control can be in, making the control invalid for the purposes of constraint validation. (The definitions below are non-normative; other parts of this specification define more precisely when each state applies or does not.)</p> <dl><dt> <dfn id=suffering-from-being-missing>Suffering from being missing</dfn> </dt> <dd> <p>When a control has no <a href=#concept-fe-value title=concept-fe-value>value</a> but has a <code title="">required</code> attribute (<code><a href=#the-input-element>input</a></code> <code title=attr-input-required><a href=#attr-input-required>required</a></code>, <code><a href=#the-select-element>select</a></code> <code title=attr-select-required><a href=#attr-select-required>required</a></code>, <code><a href=#the-textarea-element>textarea</a></code> <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code>), or, in the case of an element in a <i><a href=#radio-button-group>radio button group</a></i>, any of the other elements in the group has a <code title=attr-input-required><a href=#attr-input-required>required</a></code> attribute. </dd> <dt> <dfn id=suffering-from-a-type-mismatch>Suffering from a type mismatch</dfn> </dt> <dd> <p>When a control that allows arbitrary user input has a <a href=#concept-fe-value title=concept-fe-value>value</a> that is not in the correct syntax (<a href=#e-mail-state title=attr-input-type-email>E-mail</a>, <a href=#url-state title=attr-input-type-url>URL</a>). </dd> <dt> <dfn id=suffering-from-a-pattern-mismatch>Suffering from a pattern mismatch</dfn> </dt> <dd> <p>When a control has a <a href=#concept-fe-value title=concept-fe-value>value</a> that doesn't satisfy the <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code> attribute.</dd> <dt> <dfn id=suffering-from-being-too-long>Suffering from being too long</dfn> </dt> <dd> <p>When a control has a <a href=#concept-fe-value title=concept-fe-value>value</a> that is too long for the <a href=#attr-fe-maxlength title=attr-fe-maxlength>form control <code title="">maxlength</code> attribute</a> (<code><a href=#the-input-element>input</a></code> <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>, <code><a href=#the-textarea-element>textarea</a></code> <code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code>). </dd> <dt> <dfn id=suffering-from-an-underflow>Suffering from an underflow</dfn> </dt> <dd> <p>When a control has a <a href=#concept-fe-value title=concept-fe-value>value</a> that is too low for the <code title=attr-input-min><a href=#attr-input-min>min</a></code> attribute.</dd> <dt> <dfn id=suffering-from-an-overflow>Suffering from an overflow</dfn> </dt> <dd> <p>When a control has a <a href=#concept-fe-value title=concept-fe-value>value</a> that is too high for the <code title=attr-input-max><a href=#attr-input-max>max</a></code> attribute.</dd> <dt> <dfn id=suffering-from-a-step-mismatch>Suffering from a step mismatch</dfn> </dt> <dd> <p>When a control has a <a href=#concept-fe-value title=concept-fe-value>value</a> that doesn't fit the rules given by the <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute.</dd> <dt> <dfn id=suffering-from-a-custom-error>Suffering from a custom error</dfn> </dt> <dd> <p>When a control's <a href=#custom-validity-error-message>custom validity error message</a> (as set by the element's <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> method) is not the empty string.</p> </dd> </dl><p class=note>An element can still suffer from these states even when the element is <a href=#concept-fe-disabled title=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 title=concept-fv-valid>satisfies its constraints</dfn> if it is not suffering from any of the above <a href=#validity-states>validity states</a>.</p> </div> <div class=impl> <h5 id=constraint-validation><span class=secno>4.10.21.2 </span>Constraint validation</h5> <p>When the user agent is required to <dfn id=statically-validate-the-constraints>statically validate the constraints</dfn> of <code><a href=#the-form-element>form</a></code> element <var title="">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 title="">controls</var> be a list of all the <a href=#category-submit title=category-submit>submittable elements</a> whose <a href=#form-owner>form owner</a> is <var title="">form</var>, in <a href=#tree-order>tree order</a>.</li> <li><p>Let <var title="">invalid controls</var> be an initially empty list of elements.</li> <li> <p>For each element <var title="">field</var> in <var title="">controls</var>, in <a href=#tree-order>tree order</a>, run the following substeps:</p> <ol><li><p>If <var title="">field</var> is not a <a href=#candidate-for-constraint-validation>candidate for constraint validation</a>, then move on to the next element.</li> <li><p>Otherwise, if <var title="">field</var> <a href=#concept-fv-valid title=concept-fv-valid>satisfies its constraints</a>, then move on to the next element.</li> <li><p>Otherwise, add <var title="">field</var> to <var title="">invalid controls</var>.</li> </ol></li> <li><p>If <var title="">invalid controls</var> is empty, then return a <i>positive</i> result and abort these steps.</li> <li><p>Let <var title="">unhandled invalid controls</var> be an initially empty list of elements.</li> <li> <p>For each element <var title="">field</var> in <var title="">invalid controls</var>, if any, in <a href=#tree-order>tree order</a>, run the following substeps:</p> <ol><li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-invalid>invalid</code> that is cancelable at <var title="">field</var>.</li> <li><p>If the event was not canceled, then add <var title="">field</var> to <var title="">unhandled invalid controls</var>.</li> </ol></li> <li><p>Return a <i>negative</i> result with the list of elements in the <var title="">unhandled invalid controls</var> list.</li> </ol><p>If a user agent is to <dfn id=interactively-validate-the-constraints>interactively validate the constraints</dfn> of <code><a href=#the-form-element>form</a></code> element <var title="">form</var>, then the user agent must run the following steps:</p> <ol><li><p><a href=#statically-validate-the-constraints>Statically validate the constraints</a> of <var title="">form</var>, and let <var title="">unhandled invalid controls</var> be the list of elements returned if the result was <i>negative</i>.</li> <li><p>If the result was <i>positive</i>, then return that result and abort these steps.</li> <li><p>Report the problems with the constraints of at least one of the elements given in <var title="">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>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 title="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>being rendered</a> (e.g. it has the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute set) then user agents may report a script error.</li> <li><p>Return a <i>negative</i> result.</li> </ol></div> <h5 id=the-constraint-validation-api><span class=secno>4.10.21.3 </span>The <dfn>constraint validation API</dfn></h5> <dl class=domintro><dt><var title="">element</var> . <code title=dom-cva-willValidate><a href=#dom-cva-willvalidate>willValidate</a></code></dt> <dd> <p>Returns true if the element will be validated when the form is submitted; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity</a></code>(<var title="">message</var>)</dt> <dd> <p>Sets a custom error, so that the element would fail to validate. The given message is the message to be shown to the user when reporting the problem to the user.</p> <p>If the argument is the empty string, clears the custom error.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-valueMissing><a href=#dom-validitystate-valuemissing>valueMissing</a></code></dt> <dd> <p>Returns true if the element has no value but is a required field; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-typeMismatch><a href=#dom-validitystate-typemismatch>typeMismatch</a></code></dt> <dd> <p>Returns true if the element's value is not in the correct syntax; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-patternMismatch><a href=#dom-validitystate-patternmismatch>patternMismatch</a></code></dt> <dd> <p>Returns true if the element's value doesn't match the provided pattern; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-tooLong><a href=#dom-validitystate-toolong>tooLong</a></code></dt> <dd> <p>Returns true if the element's value is longer than the provided maximum length; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-rangeUnderflow><a href=#dom-validitystate-rangeunderflow>rangeUnderflow</a></code></dt> <dd> <p>Returns true if the element's value is lower than the provided minimum; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-rangeOverflow><a href=#dom-validitystate-rangeoverflow>rangeOverflow</a></code></dt> <dd> <p>Returns true if the element's value is higher than the provided maximum; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-stepMismatch><a href=#dom-validitystate-stepmismatch>stepMismatch</a></code></dt> <dd> <p>Returns true if the element's value doesn't fit the rules given by the <code title=attr-input-step><a href=#attr-input-step>step</a></code> attribute; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-customError><a href=#dom-validitystate-customerror>customError</a></code></dt> <dd> <p>Returns true if the element has a custom error; false otherwise.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code title=dom-validitystate-valid><a href=#dom-validitystate-valid>valid</a></code></dt> <dd> <p>Returns true if the element's value has no validity problems; false otherwise.</p> </dd> <dt><var title="">valid</var> = <var title="">element</var> . <code title=dom-cva-checkValidatity><a href=#dom-cva-checkvalidatity>checkValidity</a></code>()</dt> <dd> <p>Returns true if the element's value has no validity problems; false otherwise. Fires an <code title=event-invalid>invalid</code> event at the element in the latter case.</p> </dd> <dt><var title="">element</var> . <code title=dom-cva-validationMessage><a href=#dom-cva-validationmessage>validationMessage</a></code></dt> <dd> <p>Returns the error message that would be shown to the user if the element was to be checked for validity.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-cva-willvalidate title=dom-cva-willValidate><code>willValidate</code></dfn> attribute must return true if an element is a <a href=#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 title="barred from constraint validation">barring it from constraint validation</a>).</p> <p>The <dfn id=dom-cva-setcustomvalidity title=dom-cva-setCustomValidity><code>setCustomValidity(<var title="">message</var>)</code></dfn>, when invoked, must set the <a href=#custom-validity-error-message>custom validity error message</a> to the value of the given <var title="">message</var> argument.</p> </div> <div class=example> <p>In the following example, a script checks the value of a form control each time it is edited, and whenever it is not a valid value, uses the <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> method to set an appropriate message.</p> <pre><label>Feeling: <input name=f type="text" oninput="check(this)"></label> <script> function check(input) { if (input.value == "good" || input.value == "fine" || input.value == "tired") { input.setCustomValidity('"' + input.value + '" is not a feeling.'); <!-- } else if (input.value == "...") { input.setCustomValidity('...'); --> } else { // input is fine -- reset the error message input.setCustomValidity(''); } } </script></pre> </div> <div class=impl> <p>The <dfn id=dom-cva-validity title=dom-cva-validity><code>validity</code></dfn> attribute must return a <code><a href=#validitystate>ValidityState</a></code> object that represents the <a href=#validity-states>validity states</a> of the element. This object is <a href=#live>live</a>, and the same object must be returned each time the element's <code title=dom-cva-validity><a href=#dom-cva-validity>validity</a></code> attribute is retrieved.</p> <pre class=idl>interface <dfn id=validitystate>ValidityState</dfn> { readonly attribute boolean <a href=#dom-validitystate-valuemissing title=dom-ValidityState-valueMissing>valueMissing</a>; readonly attribute boolean <a href=#dom-validitystate-typemismatch title=dom-ValidityState-typeMismatch>typeMismatch</a>; readonly attribute boolean <a href=#dom-validitystate-patternmismatch title=dom-ValidityState-patternMismatch>patternMismatch</a>; readonly attribute boolean <a href=#dom-validitystate-toolong title=dom-ValidityState-tooLong>tooLong</a>; readonly attribute boolean <a href=#dom-validitystate-rangeunderflow title=dom-ValidityState-rangeUnderflow>rangeUnderflow</a>; readonly attribute boolean <a href=#dom-validitystate-rangeoverflow title=dom-ValidityState-rangeOverflow>rangeOverflow</a>; readonly attribute boolean <a href=#dom-validitystate-stepmismatch title=dom-ValidityState-stepMismatch>stepMismatch</a>; readonly attribute boolean <a href=#dom-validitystate-customerror title=dom-ValidityState-customError>customError</a>; readonly attribute boolean <a href=#dom-validitystate-valid title=dom-ValidityState-valid>valid</a>; };</pre> <p>A <code><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 title=dom-ValidityState-valueMissing><code>valueMissing</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-being-missing>suffering from being missing</a>.</p> </dd> <dt><dfn id=dom-validitystate-typemismatch title=dom-ValidityState-typeMismatch><code>typeMismatch</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-a-type-mismatch>suffering from a type mismatch</a>.</p> </dd> <dt><dfn id=dom-validitystate-patternmismatch title=dom-ValidityState-patternMismatch><code>patternMismatch</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-a-pattern-mismatch>suffering from a pattern mismatch</a>.</p> </dd> <dt><dfn id=dom-validitystate-toolong title=dom-ValidityState-tooLong><code>tooLong</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-being-too-long>suffering from being too long</a>.</p> </dd> <dt><dfn id=dom-validitystate-rangeunderflow title=dom-ValidityState-rangeUnderflow><code>rangeUnderflow</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-an-underflow>suffering from an underflow</a>.</p> </dd> <dt><dfn id=dom-validitystate-rangeoverflow title=dom-ValidityState-rangeOverflow><code>rangeOverflow</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-an-overflow>suffering from an overflow</a>.</p> </dd> <dt><dfn id=dom-validitystate-stepmismatch title=dom-ValidityState-stepMismatch><code>stepMismatch</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-a-step-mismatch>suffering from a step mismatch</a>.</p> </dd> <dt><dfn id=dom-validitystate-customerror title=dom-ValidityState-customError><code>customError</code></dfn></dt> <dd> <p>The control is <a href=#suffering-from-a-custom-error>suffering from a custom error</a>.</p> </dd> <dt><dfn id=dom-validitystate-valid title=dom-ValidityState-valid><code>valid</code></dfn></dt> <dd> <p>None of the other conditions are true.</p> </dd> </dl><p>When the <dfn id=dom-cva-checkvalidatity title=dom-cva-checkValidatity><code>checkValidity()</code></dfn> method is invoked, if the element is a <a href=#candidate-for-constraint-validation>candidate for constraint validation</a> and does not <a href=#concept-fv-valid title=concept-fv-valid>satisfy its constraints</a>, the user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-invalid>invalid</code> that is cancelable (but in this case has no default action) at the element and return false. Otherwise, it must only return true without doing anything else.</p> <p>The <dfn id=dom-cva-validationmessage title=dom-cva-validationMessage><code>validationMessage</code></dfn> attribute must return the empty string if the element is not a <a href=#candidate-for-constraint-validation>candidate for constraint validation</a> or if it is one but it <a href=#concept-fv-valid title=concept-fv-valid>satisfies its constraints</a>; otherwise, it must 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 the attribute must 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>candidate for constraint validation</a> and is <a href=#suffering-from-a-custom-error>suffering from a custom error</a>, then the <a href=#custom-validity-error-message>custom validity error message</a> should be present in the return value.</p> </div> <h5 id=security-forms><span class=secno>4.10.21.4 </span>Security</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><span class=secno>4.10.22 </span><dfn>Form submission</dfn></h4> <div class=impl> <h5 id=introduction-3><span class=secno>4.10.22.1 </span>Introduction</h5> </div> <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 title=concept-fs-enctype>enctype</a>, and then sent to the destination specified by the <a href=#concept-fs-action title=concept-fs-action>action</a> using the given <a href=#concept-fs-method title=concept-fs-method>method</a>.</p> <p>For example, take the following form:</p> <pre><form action="/find.cgi" method=get> <input type=text name=t> <input type=search name=q> <input type=submit> </form></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 title="">/find.cgi?t=cats&q=fur</code>.</p> <p>On the other hand, consider this form:</p> <pre><form action="/find.cgi" method=post enctype="multipart/form-data"> <input type=text name=t> <input type=search name=q> <input type=submit> </form></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> <div class=impl> <h5 id=implicit-submission><span class=secno>4.10.22.2 </span>Implicit submission</h5> <p>User agents may establish a <a href=#concept-button title=concept-button>button</a> in each form as being the form's <dfn id=default-button>default button</dfn>. This should be the first <a href=#concept-submit-button title=concept-submit-button>submit button</a> in <a href=#tree-order>tree order</a> whose <a href=#form-owner>form owner</a> is that <code><a href=#the-form-element>form</a></code> element, but user agents may pick another button if another would be more appropriate for the platform. If the platform supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so must cause the form's <a href=#default-button>default button</a>'s <a href=#activation-behavior>activation behavior</a>, if any, to be run.</p> <p class=note>Consequently, if the <a href=#default-button>default button</a> is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, the form is not submitted when such an implicit submission mechanism is used. (A button has no <a href=#activation-behavior>activation behavior</a> when disabled.)</p> <p>If the form has no <a href=#concept-submit-button title=concept-submit-button>submit button</a>, then the implicit submission mechanism must just <a href=#concept-form-submit title=concept-form-submit>submit</a> the <code><a href=#the-form-element>form</a></code> element from the <code><a href=#the-form-element>form</a></code> element itself.</p> </div> <div class=impl> <h5 id=form-submission-algorithm><span class=secno>4.10.22.3 </span>Form submission algorithm</h5> <p>When a <code><a href=#the-form-element>form</a></code> element <var title="">form</var> is <dfn id=concept-form-submit title=concept-form-submit>submitted</dfn> from an element <var title="">submitter</var> (typically a button), optionally with a <var title="">submitted from <code title=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>Let <var title="">form document</var> be the <var title="">form</var>'s <code><a href=#document>Document</a></code>.</li> <li id=sandboxSubmitBlocked><p>If <var title="">form document</var> has no associated <a href=#browsing-context>browsing context</a> or its <a href=#browsing-context>browsing context</a> had its <a href=#sandboxed-forms-browsing-context-flag>sandboxed forms browsing context flag</a> set when the <code><a href=#document>Document</a></code> was created, then abort these steps without doing anything.</li> <li><p>Let <var title="">form browsing context</var> be the <a href=#browsing-context>browsing context</a> of <var title="">form document</var>.</li> <li><p>If <var title="">form</var> is already being submitted (i.e. the form was <a href=#concept-form-submit title=concept-form-submit>submitted</a> again while processing the events fired from the next two steps, probably from a script redundantly calling the <code title=dom-form-submit><a href=#dom-form-submit>submit()</a></code> method on <var title="">form</var>), then abort these steps. This doesn't affect the earlier instance of this algorithm.</li> <!-- lock (implicit in previous step) --> <li><p>If the <var title="">submitted from <code title=dom-form-submit><a href=#dom-form-submit>submit()</a></code> method</var> flag is not set, and the <var title="">submitter</var> element's <a href=#concept-fs-novalidate title=concept-fs-novalidate>no-validate state</a> is false, then <a href=#interactively-validate-the-constraints>interactively validate the constraints</a> of <var title="">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 abort these steps.</li> <li><p>If the <var title="">submitted from <code title=dom-form-submit><a href=#dom-form-submit>submit()</a></code> method</var> flag is not set, then <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-submit>submit</code>, at <var title="">form</var>. If the event's default action is prevented (i.e. if the event is canceled) then abort these steps. Otherwise, continue (effectively the default action is to perform the submission).</li> <!-- if you add any steps between the "lock" and "unlock" lines, make sure to update the step immediately before the "lock" line --> <!-- unlock --> <li><p>Let <var title="">form data set</var> be the result of <a href=#constructing-the-form-data-set>constructing the form data set</a> for <var title="">form</var> in the context of <var title="">submitter</var>.</li> <li><p>Let <var title="">action</var> be the <var title="">submitter</var> element's <a href=#concept-fs-action title=concept-fs-action>action</a>.</li> <li> <p>If <var title="">action</var> is the empty string, let <var title="">action</var> be <a href="#the-document's-address">the document's address</a> of the <var title="">form document</var>.</p> <p class=note>This step is a <a href=#willful-violation>willful violation</a> of RFC 3986, which would require base URL processing here. This violation is motivated by a desire for compatibility with legacy content. <a href=#refsRFC3986>[RFC3986]</a></p> <!-- Don't ask me why. But that's what IE does. It even treats action="" differently from action=" " or action="#" (the latter two resolve to the base URL, the first one resolves to the doc URL). And other browsers concur. It is even required, see e.g. http://bugs.webkit.org/show_bug.cgi?id=7763 https://bugzilla.mozilla.org/show_bug.cgi?id=297761 --> </li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <a href=#url>URL</a> <var title="">action</var>, relative to the <var title="">submitter</var> element. If this fails, abort these steps. Otherwise, let <var title="">action</var> be the resulting <a href=#absolute-url>absolute URL</a>.</li> <li><p>Let <var title="">scheme</var> be the <a href=#url-scheme title=url-scheme><scheme></a> of the resulting <a href=#absolute-url>absolute URL</a>.</li> <li><p>Let <var title="">enctype</var> be the <var title="">submitter</var> element's <a href=#concept-fs-enctype title=concept-fs-enctype>enctype</a>.</li> <li><p>Let <var title="">method</var> be the <var title="">submitter</var> element's <a href=#concept-fs-method title=concept-fs-method>method</a>.</li> <li><p>Let <var title="">target</var> be the <var title="">submitter</var> element's <a href=#concept-fs-target title=concept-fs-target>target</a>.</li> <li><p>If the user indicated a specific <a href=#browsing-context>browsing context</a> to use when submitting the form, then let <var title="">target browsing context</var> be that <a href=#browsing-context>browsing context</a>. Otherwise, apply <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a> using <var title="">target</var> as the name and <var title="">form browsing context</var> as the context in which the algorithm is executed, and let <var title="">target browsing context</var> be the resulting <a href=#browsing-context>browsing context</a>.</li> <li><p>If <var title="">target browsing context</var> was created in the previous step, or if the <var title="">form document</var> has not yet <a href=#completely-loaded>completely loaded</a>, then let <var title="">replace</var> be true. Otherwise, let it be false.</li> <li> <p>Select the appropriate row in the table below based on the value of <var title="">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 title="">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 title=attr-fs-method-GET>GET</a> <th> <a href=#attr-fs-method-post title=attr-fs-method-POST>POST</a> <tbody><tr><th> <code title="">http</code> <td> <a href=#submit-mutate-action title=submit-mutate-action>Mutate action URL</a> <td> <a href=#submit-body title=submit-body>Submit as entity body</a> <tr><th> <code title="">https</code> <td> <a href=#submit-mutate-action title=submit-mutate-action>Mutate action URL</a> <td> <a href=#submit-body title=submit-body>Submit as entity body</a> <tr><th> <code title="">ftp</code> <td> <a href=#submit-get-action title=submit-get-action>Get action URL</a> <td> <a href=#submit-get-action title=submit-get-action>Get action URL</a> <tr><th> <code title="">javascript</code> <td> <a href=#submit-get-action title=submit-get-action>Get action URL</a> <td> <a href=#submit-get-action title=submit-get-action>Get action URL</a> <tr><th> <code title="">data</code> <td> <a href=#submit-get-action title=submit-get-action>Get action URL</a> <td> <a href=#submit-data-post title=submit-data-post>Post to data:</a> <tr><th> <code title="">mailto</code> <td> <a href=#submit-mailto-headers title=submit-mailto-headers>Mail with headers</a> <td> <a href=#submit-mailto-body title=submit-mailto-body>Mail as body</a> </table><p>If <var title="">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>The behaviors are as follows:</p> <dl><dt><dfn id=submit-mutate-action title=submit-mutate-action>Mutate action URL</dfn> <dd> <p>Let <var title="">query</var> be the result of encoding the <var title="">form data set</var> using the <a href=#application/x-www-form-urlencoded-encoding-algorithm><code title="">application/x-www-form-urlencoded</code> encoding algorithm</a>, interpreted as a US-ASCII string.</p> <!-- by this point we've already tried to resolve the URL, so we know we can parse it --> <p>Let <var title="">destination</var> be a new <a href=#url>URL</a> that is equal to the <var title="">action</var> except that its <a href=#url-query title=url-query><query></a> component is replaced by <var title="">query</var> (adding a U+003F QUESTION MARK character (?) if appropriate).</p> <p><a href=#navigate>Navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">destination</var>. If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> <dt><dfn id=submit-body title=submit-body>Submit as entity body</dfn> <dd> <p>Let <var title="">entity body</var> be the result of encoding the <var title="">form data set</var> using the <a href=#appropriate-form-encoding-algorithm>appropriate form encoding algorithm</a>.</p> <p>Let <var title="">MIME type</var> be determined as follows:</p> <dl><dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code></dt> <dd>Let <var title="">MIME type</var> be "<code title="">application/x-www-form-urlencoded</code>".</dd> <dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-formdata><a href=#attr-fs-enctype-formdata>multipart/form-data</a></code></dt> <dd>Let <var title="">MIME type</var> be the concatenation of the string "<code title="">multipart/form-data;</code>", a U+0020 SPACE character, the string "<code title="">boundary=</code>", and the <a href=#multipart/form-data-boundary-string><code title="">multipart/form-data</code> boundary string</a> generated by the <a href=#multipart/form-data-encoding-algorithm><code title="">multipart/form-data</code> encoding algorithm</a>.</dd> <dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-text><a href=#attr-fs-enctype-text>text/plain</a></code></dt> <dd>Let <var title="">MIME type</var> be "<code title="">text/plain</code>".</dd> </dl><!--<p>If <var title="">method</var> is anything but (GET or) POST, and the <span>origin</span> of <var title="">action</var> is not the <span>same origin</span> as that of <var title="">form document</var>, then abort these steps.</p> [or do CORS] (this is commented out since only POST can trigger this now, and that's historically unrestricted)--><p>Otherwise, <a href=#navigate>navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var> using the HTTP method given by <var title="">method</var> and with <var title="">entity body</var> as the entity body, of type <var title="">MIME type</var>. If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> <dt><dfn id=submit-get-action title=submit-get-action>Get action URL</dfn> <dd> <p><a href=#navigate>Navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">action</var>. If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> <dt><dfn id=submit-data-post title=submit-data-post>Post to data:</dfn> <dd> <p>Let <var title="">data</var> be the result of encoding the <var title="">form data set</var> using the <a href=#appropriate-form-encoding-algorithm>appropriate form encoding algorithm</a>.</p> <p>If <var title="">action</var> contains the string "<code title="">%%%%</code>" (four U+0025 PERCENT SIGN characters), then %-escape all bytes in <var title="">data</var> that, if interpreted as US-ASCII, do not match the <code title="">unreserved</code> production in the URI Generic Syntax, and then, treating the result as a US-ASCII string, further %-escape all the U+0025 PERCENT SIGN characters in the resulting string and replace the first occurrence of "<code title="">%%%%</code>" in <var title="">action</var> with the resulting double-escaped string. <a href=#refsRFC3986>[RFC3986]</a></p> <p>Otherwise, if <var title="">action</var> contains the string "<code title="">%%</code>" (two U+0025 PERCENT SIGN characters in a row, but not four), then %-escape all characters in <var title="">data</var> that, if interpreted as US-ASCII, do not match the <code title="">unreserved</code> production in the URI Generic Syntax, and then, treating the result as a US-ASCII string, replace the first occurrence of "<code title="">%%</code>" in <var title="">action</var> with the resulting escaped string. <a href=#refsRFC3986>[RFC3986]</a></p> <p><a href=#navigate>Navigate</a><!--DONAV form--> <var title="">target browsing context</var> to the potentially modified <var title="">action</var> (which will be a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a>). If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> <dt><dfn id=submit-mailto-headers title=submit-mailto-headers>Mail with headers</dfn> <dd> <p>Let <var title="">headers</var> be the resulting encoding the <var title="">form data set</var> using the <a href=#application/x-www-form-urlencoded-encoding-algorithm><code title="">application/x-www-form-urlencoded</code> encoding algorithm</a>, interpreted as a US-ASCII string.</p> <p>Replace occurrences of U+002B PLUS SIGN characters (+) in <var title="">headers</var> with the string "<code title="">%20</code>".</p> <p>Let <var title="">destination</var> consist of all the characters from the first character in <var title="">action</var> to the character immediately before the first U+003F QUESTION MARK character (?), if any, or the end of the string if there are none.</p> <p>Append a single U+003F QUESTION MARK character (?) to <var title="">destination</var>.</p> <p>Append <var title="">headers</var> to <var title="">destination</var>.</p> <p><a href=#navigate>Navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">destination</var>. If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> <dt><dfn id=submit-mailto-body title=submit-mailto-body>Mail as body</dfn> <dd> <p>Let <var title="">body</var> be the resulting encoding the <var title="">form data set</var> using the <a href=#appropriate-form-encoding-algorithm>appropriate form encoding algorithm</a> and then %-escaping all the bytes in the resulting byte string that, when interpreted as US-ASCII, do not match the <code title="">unreserved</code> production in the URI Generic Syntax. <a href=#refsRFC3986>[RFC3986]</a></p> <p>Let <var title="">destination</var> have the same value as <var title="">action</var>.</p> <p>If <var title="">destination</var> does not contain a U+003F QUESTION MARK character (?), append a single U+003F QUESTION MARK character (?) to <var title="">destination</var>. Otherwise, append a single U+0026 AMPERSAND character (&).</p> <p>Append the string "<code title="">body=</code>" to <var title="">destination</var>.</p> <p>Append <var title="">body</var>, interpreted as a US-ASCII string, to <var title="">destination</var>.</p> <p><a href=#navigate>Navigate</a><!--DONAV form--> <var title="">target browsing context</var> to <var title="">destination</var>. If <var title="">replace</var> is true, then <var title="">target browsing context</var> must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> </dd> </dl><p>The <dfn id=appropriate-form-encoding-algorithm>appropriate form encoding algorithm</dfn> is determined as follows:</p> <dl><dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code></dt> <dd>Use the <a href=#application/x-www-form-urlencoded-encoding-algorithm><code title="">application/x-www-form-urlencoded</code> encoding algorithm</a>.</dd> <dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-formdata><a href=#attr-fs-enctype-formdata>multipart/form-data</a></code></dt> <dd>Use the <a href=#multipart/form-data-encoding-algorithm><code title="">multipart/form-data</code> encoding algorithm</a>.</dd> <dt>If <var title="">enctype</var> is <code title=attr-fs-enctype-text><a href=#attr-fs-enctype-text>text/plain</a></code></dt> <dd>Use the <a href=#text/plain-encoding-algorithm><code title="">text/plain</code> encoding algorithm</a>.</dd> </dl></li> </ol><h5 id=constructing-form-data-set><span class=secno>4.10.22.4 </span>Constructing the form data set</h5> <p>The algorithm to <dfn id=constructing-the-form-data-set title="constructing the form data set">construct the form data set</dfn> for a form <var title="">form</var> optionally in the context of a submitter <var title="">submitter</var> is as follows. If not specified otherwise, <var title="">submitter</var> is null.</p> <ol><li><p>Let <var title="">controls</var> be a list of all the <a href=#category-submit title=category-submit>submittable elements</a> whose <a href=#form-owner>form owner</a> is <var title="">form</var>, in <a href=#tree-order>tree order</a>.</li> <li><p>Let the <var title="">form data set</var> be a list of name-value-type tuples, initially empty.</li> <li> <p><i>Loop</i>: For each element <var title="">field</var> in <var title="">controls</var>, in <a href=#tree-order>tree order</a>, run the following substeps:</p> <ol><li> <p>If any of the following conditions are met, then skip these substeps for this element:</p> <ul><li>The <var title="">field</var> element has a <code><a href=#the-datalist-element>datalist</a></code> element ancestor.</li> <li>The <var title="">field</var> element is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>.</li> <li>The <var title="">field</var> element is a <a href=#concept-button title=concept-button>button</a> but it is not <var title="">submitter</var>.</li> <li>The <var title="">field</var> element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state and whose <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is false.</li> <li>The <var title="">field</var> element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state and whose <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> is false.</li> <li>The <var title="">field</var> element is not an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, and either the <var title="">field</var> element does not have a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute specified, or its <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute's value is the empty string.</li> <li>The <var title="">field</var> element is an <code><a href=#the-object-element>object</a></code> element that is not using a <a href=#plugin>plugin</a>.</li> </ul><p>Otherwise, process <var title="">field</var> as follows:</p> </li> <li><p>Let <var title="">type</var> be the value of the <code title="">type</code> IDL attribute of <var title="">field</var>.</li> <!-- if the field is an <object> element, this will get ignored. --> <li> <p>If the <var title="">field</var> element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, then run these further nested substeps:</p> <ol><li><p>If the <var title="">field</var> element has a <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute specified and its value is not the empty string, let <var title="">name</var> be that value followed by a single U+002E FULL STOP character (.). Otherwise, let <var title="">name</var> be the empty string.</li> <li><p>Let <var title="">name<sub title="">x</sub></var> be the string consisting of the concatenation of <var title="">name</var> and a single U+0078 LATIN SMALL LETTER X character (x).</li> <li><p>Let <var title="">name<sub title="">y</sub></var> be the string consisting of the concatenation of <var title="">name</var> and a single U+0079 LATIN SMALL LETTER Y character (y).</li> <li><p>The <var title="">field</var> element is <var title="">submitter</var>, and before this algorithm was invoked the user <a href=#concept-input-type-image-coordinate title=concept-input-type-image-coordinate>indicated a coordinate</a>. Let <var title="">x</var> be the <var title="">x</var>-component of the coordinate selected by the user, and let <var title="">y</var> be the <var title="">y</var>-component of the coordinate selected by the user.</li> <li><p>Append an entry to the <var title="">form data set</var> with the name <var title="">name<sub title="">x</sub></var>, the value <var title="">x</var>, and the type <var title="">type</var>.</li> <li><p>Append an entry to the <var title="">form data set</var> with the name <var title="">name<sub title="">y</sub></var> and the value <var title="">y</var>, and the type <var title="">type</var>.</li> <li><p>Skip the remaining substeps for this element: if there are any more elements in <var title="">controls</var>, return to the top of the <i>loop</i> step, otherwise, jump to the <i>end</i> step below.</li> </ol></li> <li><p>Let <var title="">name</var> be the value of the <var title="">field</var> element's <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute.</li> <li><p>If the <var title="">field</var> element is a <code><a href=#the-select-element>select</a></code> element, then for each <code><a href=#the-option-element>option</a></code> element in the <code><a href=#the-select-element>select</a></code> element whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, append an entry to the <var title="">form data set</var> with the <var title="">name</var> as the name, the <a href=#concept-option-value title=concept-option-value>value</a> of the <code><a href=#the-option-element>option</a></code> element as the value, and <var title="">type</var> as the type.</li> <li> <p>Otherwise, if the <var title="">field</var> element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state or the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state, then run these further nested substeps:</p> <ol><li><p>If the <var title="">field</var> element has a <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute specified, then let <var title="">value</var> be the value of that attribute; otherwise, let <var title="">value</var> be the string "<code title="">on</code>".</li> <li><p>Append an entry to the <var title="">form data set</var> with <var title="">name</var> as the name, <var title="">value</var> as the value, and <var title="">type</var> as the type.</li> </ol></li> <li><p>Otherwise, if the <var title="">field</var> element is an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#file-upload-state title=attr-input-type-file>File Upload</a> state, then for each file <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected</a> in the <code><a href=#the-input-element>input</a></code> element, append an entry to the <var title="">form data set</var> with the <var title="">name</var> as the name, the file (consisting of the name, the type, and the body) as the value, and <var title="">type</var> as the type. If there are no <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a>, then append an entry to the <var title="">form data set</var> with the <var title="">name</var> as the name, the empty string as the value, and <code>application/octet-stream</code> as the type.</li> <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=529859 --> <li><p>Otherwise, if the <var title="">field</var> element is an <code><a href=#the-object-element>object</a></code> element: try to obtain a form submission value from the <a href=#plugin>plugin</a><!-- using NPAPI's NPP_GetValue() entry point with the NPPVformValue variable -->, and if that is successful, append an entry to the <var title="">form data set</var> with <var title="">name</var> as the name, the returned form submission value as the value, and the string "<code title="">object</code>" as the type.</li> <li><p>Otherwise, append an entry to the <var title="">form data set</var> with <var title="">name</var> as the name, the <a href=#concept-fe-value title=concept-fe-value>value</a> of the <var title="">field</var> element as the value, and <var title="">type</var> as the type.</li> <li> <p>If the element has a <a href=#form-control-dirname-attribute>form control <code title="">dirname</code> attribute</a>, and that attribute's value is not the empty string, then run these substeps:</p> <ol><li><p>Let <var title="">dirname</var> be the value of the element's <code title="">dirname</code> attribute.</li> <li><p>Let <var title="">dir</var> be the string "<code title="">ltr</code>" if <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-ltr title=concept-ltr>ltr</a>', and "<code title="">rtl</code>" otherwise (i.e. when <a href=#the-directionality>the directionality</a> of the element is '<a href=#concept-rtl title=concept-rtl>rtl</a>').</li> <li><p>Append an entry to the <var title="">form data set</var> with <var title="">dirname</var> as the name, <var title="">dir</var> as the value, and the string "<code title="">direction</code>" as the type.</li> </ol><p class=note>An element can only have a <a href=#form-control-dirname-attribute>form control <code title="">dirname</code> attribute</a> if it is a <code><a href=#the-textarea-element>textarea</a></code> element or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in either the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state or the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state.</p> </li> </ol></li> <li> <p><i>End</i>: For the name and value of each entry in the <var title="">form data set</var> whose type is not "<code title="">file</code>", 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.</p> <p class=note>In the case of the <a href=#concept-fe-value title=concept-fe-value>value</a> of <code><a href=#the-textarea-element>textarea</a></code> elements, this newline normalization is redundant, as it is already normalized from its <a href=#concept-textarea-raw-value title=concept-textarea-raw-value>raw value</a> for the purposes of the DOM API.</p> </li> <li><p>Return the <var title="">form data set</var>.</li> </ol></div> <h5 id=url-encoded-form-data><span class=secno>4.10.22.5 </span>URL-encoded form data</h5> <p class=note>This form data set encoding is in many ways an aberrant monstrosity, the result of many years of implementation accidents and compromises leading to a set of requirements necessary for interoperability, but in no way representing good design practices. In particular, readers are cautioned to pay close attention to the twisted details involving repeated (and in some cases nested) conversions between character encodings and byte sequences.</p> <div class=impl> <p>The <dfn id=application/x-www-form-urlencoded-encoding-algorithm><code title="">application/x-www-form-urlencoded</code> encoding algorithm</dfn> is as follows:</p> <ol><!-- the first few steps of this are the same as in the next section --><li><p>Let <var title="">result</var> be the empty string.</li> <li> <p>If the <code><a href=#the-form-element>form</a></code> element has an <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute, then, taking into account the characters found in the <var title="">form data set</var>'s names and values, and the character encodings supported by the user agent, select a character encoding from the list given in the <code><a href=#the-form-element>form</a></code>'s <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute that is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>. If none of the encodings are supported, or if none are listed, then let the selected character encoding be UTF-8.</p> <p>Otherwise, if the <a href="#document's-character-encoding">document's character encoding</a> is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>, then that is the selected character encoding.</p> <p>Otherwise, let the selected character encoding be UTF-8.</p> </li> <li><p>Let <var title="">charset</var> be the <a href=#preferred-mime-name>preferred MIME name</a> of the selected character encoding.</li> <li> <p>For each entry in the <var title="">form data set</var>, perform these substeps:</p> <ol><li><p>If the entry's name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and its type is "<code title="">hidden</code>", replace its value with <var title="">charset</var>.</li> <li><p>If the entry's type is "<code title="">file</code>", replace its value with the file's filename only.</li> <!-- this is not present in the next section --> <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 (&), a U+0023 NUMBER SIGN character (#), one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) representing the Unicode code point of the character in base ten, and finally a U+003B SEMICOLON character (;).</li><!-- we should say it should be the shortest possible string, no leading zeros. this whole step is asinine, though, so... --> <!-- this is where the similarities with the next section end --> <li> <p>Encode the entry's name and value using the selected character encoding. The entry's name and value are now byte strings.</p> </li> <li> <p>For each byte in the entry's name and value, apply the appropriate subsubsteps from the following list:</p> <dl class=switch><dt>The byte is 0x20 (U+0020 SPACE if interpreted as ASCII)</dt> <dd>Replace the byte with a single 0x2B byte (U+002B PLUS SIGN character (+) if interpreted as ASCII).</dd> <!-- * - . 0-9 a-z _ A-Z --> <dt>If the byte is in the range 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A</dt> <dd><p>Leave the byte as is.</dd> <dt>Otherwise</dt> <dd> <ol><li><p>Let <var title="">s</var> be a string consisting of a U+0025 PERCENT SIGN character (%) followed by two characters in the ranges U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) and U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F representing the hexadecimal value of the byte in question (zero-padded if necessary).</li> <li><p>Encode the string <var title="">s</var> as US-ASCII, so that it is now a byte string.</p> <li><p>Replace the byte in question in the name or value being processed by the bytes in <var title="">s</var>, preserving their relative order.</li> </ol></dd> </dl></li> <li> <p>Interpret the entry's name and value as Unicode strings encoded in US-ASCII. (All of the bytes in the string will be in the range 0x00 to 0x7F; the high bit will be zero throughout.) The entry's name and value are now Unicode strings again.</p> </li> <li><p>If the entry's name is "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>", its type is "<code title="">text</code>", and this is the first entry in the <var title="">form data set</var>, then append the value to <var title="">result</var> and skip the rest of the substeps for this entry, moving on to the next entry, if any, or the next step in the overall algorithm otherwise.</li> <li><p>If this is not the first entry, append a single U+0026 AMPERSAND character (&) to <var title="">result</var>.</li> <li><p>Append the entry's name to <var title="">result</var>.</li> <li><p>Append a single U+003D EQUALS SIGN character (=) to <var title="">result</var>.</li> <li><p>Append the entry's value to <var title="">result</var>.</li> </ol></li> <li><p>Encode <var title="">result</var> as US-ASCII and return the resulting byte stream.</li> </ol></div> <p>To <dfn id=application/x-www-form-urlencoded-decoding-algorithm title="application/x-www-form-urlencoded decoding algorithm">decode <code>application/x-www-form-urlencoded</code> payloads</dfn>, the following algorithm should be used. This algorithm uses as inputs the payload itself, <var title="">payload</var>, consisting of a Unicode string using only characters in the range U+0000 to U+007F; a default character encoding <var title="">encoding</var>; and optionally an <var title="">isindex</var> flag indicating that the payload is to be processed as if it had been generated for a form containing an <code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code> control. The output of this algorithm is a sorted list of name-value pairs. If the <var title="">isindex</var> flag is set and the first control really was an <code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code> control, then the first name-value pair will have as its name the empty string.</p> <ol><li><p>Let <var title="">strings</var> be the result of <a href=#strictly-split-a-string title="strictly split a string">strictly splitting the string</a> <var title="">payload</var> on U+0026 AMPERSAND characters (&).</li> <li><p>If the <var title="">isindex</var> flag is set and the first string in <var title="">strings</var> does not contain a U+003D EQUALS SIGN character (=), insert a U+003D EQUALS SIGN character (=) at the start of the first string in <var title="">strings</var>.</li> <li><p>Let <var title="">pairs</var> be an empty list of name-value pairs.</li> <li> <p>For each string <var title="">string</var> in <var title="">strings</var>, run these substeps:</p> <ol><li> <p>If <var title="">string</var> contains a U+003D EQUALS SIGN character (=), then let <var title="">name</var> be the substring of <var title="">string</var> from the start of <var title="">string</var> up to but excluding its first U+003D EQUALS SIGN character (=), and let <var title="">value</var> be the substring from the first character, if any, after the first U+003D EQUALS SIGN character (=) up to the end of <var title="">string</var>. If the first U+003D EQUALS SIGN character (=) is the first character, then <var title="">name</var> will be the empty string. If it is the last character, then <var title="">value</var> will be the empty string.</p> <p>Otherwise, <var title="">string</var> contains no U+003D EQUALS SIGN characters (=). Let <var title="">name</var> have the value of <var title="">string</var> and let <var title="">value</var> be the empty string.</p> </li> <li> <p>Replace any U+002B PLUS SIGN characters (+) in <var title="">name</var> and <var title="">value</var> with U+0020 SPACE characters.</p> </li> <li> <p>Replace any escape in <var title="">name</var> and <var title="">value</var> with the character represented by the escape. This replacement most not be recursive.</p> <p>An escape is a U+0025 PERCENT SIGN character (%) followed by two characters in the ranges U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F.</p> <p>The character represented by an escape is the Unicode character whose code point is equal to the value of the two characters after the U+0025 PERCENT SIGN character (%), interpreted as a hexadecimal number (in the range 0..255).</p> <p class=example>So for instance the string "<code title="">A%2BC</code>" would become "<code title="">A+C</code>". Similarly, the string "<code title="">100%25AA%21</code>" becomes the string "<code title="">100%AA!</code>".</p> </li> <li><p>Convert the <var title="">name</var> and <var title="">value</var> strings to their byte representation in ISO-8859-1 (i.e. convert the Unicode string to a byte string, mapping code points to byte values directly).</li> <li><p>Add a pair consisting of <var title="">name</var> and <var title="">value</var> to <var title="">pairs</var>.</li> </ol></li> <li><p>If any of the name-value pairs in <var title="">pairs</var> have a name component consisting of the string "<code title="">_charset_</code>" encoded in US-ASCII, and the value component of the first such pair, when decoded as US-ASCII, is the name of a supported character encoding, then let <var title="">encoding</var> be that character encoding (replacing the default passed to the algorithm).</li> <li><p>Convert the name and value components of each name-value pair in <var title="">pairs</var> to Unicode by interpreting the bytes according to the encoding <var title="">encoding</var>.</li> <li><p>Return <var title="">pairs</var>.</li> </ol><p class=note>Parameters on the <code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code> MIME type are ignored. In particular, this MIME type does not support the <code title="">charset</code> parameter.</p> <div class=impl> <h5 id=multipart-form-data><span class=secno>4.10.22.6 </span>Multipart form data</h5> <!-- http://hixie.ch/tests/adhoc/html/forms/submission/multipart_form-data/ --> <!-- NOTE: This algorithm is also used by the XHR spec --> <p>The <dfn id=multipart/form-data-encoding-algorithm><code title="">multipart/form-data</code> encoding algorithm</dfn> is as follows:</p> <ol><!-- the first few steps of this are the same as in the previous section --><li><p>Let <var title="">result</var> be the empty string.</li> <li> <p>If the algorithm was invoked with an explicit character encoding, let the selected character encoding be that encoding. (This algorithm is used by other specifications, which provide an explicit character encoding to avoid the dependency on the <code><a href=#the-form-element>form</a></code> element described in the next paragraph.)</p> <p>Otherwise, if the <code><a href=#the-form-element>form</a></code> element has an <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute, then, taking into account the characters found in the <var title="">form data set</var>'s names and values, and the character encodings supported by the user agent, select a character encoding from the list given in the <code><a href=#the-form-element>form</a></code>'s <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute that is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>. If none of the encodings are supported, or if none are listed, then let the selected character encoding be UTF-8.</p> <p>Otherwise, if the <a href="#document's-character-encoding">document's character encoding</a> is an <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>, then that is the selected character encoding.</p> <p>Otherwise, let the selected character encoding be UTF-8.</p> </li> <li><p>Let <var title="">charset</var> be the <a href=#preferred-mime-name>preferred MIME name</a> of the selected character encoding.</li> <li> <p>For each entry in the <var title="">form data set</var>, perform these substeps:</p> <ol><li><p>If the entry's name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and its type is "<code title="">hidden</code>", replace its value with <var title="">charset</var>.</li> <!-- the step that replaces a file with its name is missing in this version of the algorithm --> <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 (&), a U+0023 NUMBER SIGN character (#), one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) representing the Unicode code point of the character in base ten, and finally a U+003B SEMICOLON character (;).</li><!-- we should say it should be the shortest possible string, no leading zeros. this whole step is asinine, though, so... --> <!-- this is where the similarities with the previous section end --> </ol></li> <li> <p>Encode the (now mutated) <var title="">form data set</var> using the rules described by RFC 2388, <cite>Returning Values from Forms: <code title="">multipart/form-data</code></cite>, and return the resulting byte stream. <a href=#refsRFC2388>[RFC2388]</a></p> <p>Each entry in the <var title="">form data set</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 the <var title="">form data set</var>. Multiple entries with the same name must be treated as distinct fields.</p> <p class=note>In particular, this means that multiple files submitted as part of a single <code title=""><input type=file multiple></code> element will result in each file having its own field; the "sets of files" feature ("<code title="">multipart/mixed</code>") of RFC 2388 is not used.</p> <p>The parts of the generated <code title="">multipart/form-data</code> resource that correspond to non-file fields must not have a <code><a href=#content-type>Content-Type</a></code> header specified. Their names and values must be encoded using the character encoding selected above (field names in particular do not get converted to a 7-bit safe encoding as suggested in RFC 2388).</p> <p>File names included in the generated <code title="">multipart/form-data</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). User agents must not use the RFC 2231 encoding suggested by RFC 2388.</p> <!-- this isn't a willful violation since 2388 doesn't make it a requirement, it just vaguely suggests it --> <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><code title="">multipart/form-data</code> boundary string</dfn>. (This value is used to generate the MIME type of the form submission payload generated by this algorithm.)</p> </li> </ol></div> <p>For details on how to interpret <code>multipart/form-data</code> payloads, see RFC 2388. <a href=#refsRFC2388>[RFC2388]</a></p> <h5 id=plain-text-form-data><span class=secno>4.10.22.7 </span>Plain text form data</h5> <div class=impl> <p>The <dfn id=text/plain-encoding-algorithm><code title="">text/plain</code> encoding algorithm</dfn> is as follows:</p> <ol><li><p>Let <var title="">result</var> be the empty string.</li> <li> <!-- this is different from application/x-www-form-urlencoded in that it isn't limited to ASCII-compatible encodings --> <p>If the <code><a href=#the-form-element>form</a></code> element has an <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute, then, taking into account the characters found in the <var title="">form data set</var>'s names and values, and the character encodings supported by the user agent, select a character encoding from the list given in the <code><a href=#the-form-element>form</a></code>'s <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code> attribute. If none of the encodings are supported, or if none are listed, then let the selected character encoding be UTF-8.</p> <p>Otherwise, the selected character encoding is the <a href="#document's-character-encoding">document's character encoding</a>.</p> </li> <li><p>Let <var title="">charset</var> be the <a href=#preferred-mime-name>preferred MIME name</a> of the selected character encoding.</li> <li><p>If the entry's name is "<code title=attr-fe-name-charset><a href=#attr-fe-name-charset>_charset_</a></code>" and its type is "<code title="">hidden</code>", replace its value with <var title="">charset</var>.</li> <li><p>If the entry's type is "<code title="">file</code>", replace its value with the file's filename only.</li> <li> <p>For each entry in the <var title="">form data set</var>, perform these substeps:</p> <ol><li><p>Append the entry's name to <var title="">result</var>.</li> <li><p>Append a single U+003D EQUALS SIGN character (=) to <var title="">result</var>.</li> <li><p>Append the entry's value to <var title="">result</var>.</li> <li><p>Append a U+000D CARRIAGE RETURN (CR) U+000A LINE FEED (LF) character pair to <var title="">result</var>.</li> </ol></li> <li><p>Encode <var title="">result</var> using the selected character encoding and return the resulting byte stream.</li> </ol></div> <p>Payloads using the <code>text/plain</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> <div class=impl> <h4 id=resetting-a-form><span class=secno>4.10.23 </span>Resetting a form</h4> <p>When a <code><a href=#the-form-element>form</a></code> element <var title="">form</var> is <dfn id=concept-form-reset title=concept-form-reset>reset</dfn>, the user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-reset>reset</code>, that is cancelable, at <var title="">form</var>, and then, if that event is not canceled, must invoke the <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> of each <a href=#category-reset title=category-reset>resettable element</a> whose <a href=#form-owner>form owner</a> is <var title="">form</var>.</p> <p>Each <a href=#category-reset title=category-reset>resettable element</a> defines its own <dfn id=concept-form-reset-control title=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 title=event-input>input</code> events to fire).</p> </div> <h3 id=interactive-elements><span class=secno>4.11 </span>Interactive elements</h3> <h4 id=the-details-element><span class=secno>4.11.1 </span>The <dfn><code>details</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#sectioning-root>Sectioning root</a>.</dd> <dd><a href=#interactive-content>Interactive content</a>.</dd> <dd><a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>One <code><a href=#the-summary-element>summary</a></code> element followed by <a href=#flow-content>flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-details-open><a href=#attr-details-open>open</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmldetailselement>HTMLDetailsElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-details-open title=dom-details-open>open</a>; };</pre> </dd> </dl><p>The <code><a href=#the-details-element>details</a></code> element <a href=#represents>represents</a> a disclosure widget from which the user can obtain additional information or controls.</p> <p class=note>The <code><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 <span class=impl>first</span> <code><a href=#the-summary-element>summary</a></code> element child of the element, if any, <a href=#represents>represents</a> the summary or legend of the details. <span class=impl>If there is no child <code><a href=#the-summary-element>summary</a></code> element, the user agent should provide its own legend (e.g. "Details").</span></p> <p>The rest of the element's contents <a href=#represents>represents</a> the additional information or controls.</p> <p>The <dfn id=attr-details-open title=attr-details-open><code>open</code></dfn> content attribute is a <a href=#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> <div class=impl> <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 set the <code title=attr-details-open><a href=#attr-details-open>open</a></code> attribute on the element to the value <code title="">open</code>. To honor a request for the information to be hidden, the user agent must remove the <code title=attr-details-open><a href=#attr-details-open>open</a></code> attribute from the element.</p> <p>The <dfn id=dom-details-open title=dom-details-open><code>open</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-details-open><a href=#attr-details-open>open</a></code> content attribute.</p> </div> <div class=example> <p>The following example shows the <code><a href=#the-details-element>details</a></code> element being used to hide technical details in a progress report.</p> <pre><section class="progress window"> <h1>Copying "Really Achieving Your Childhood Dreams"</h1> <details> <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary> <dl> <dt>Transfer rate:</dt> <dd>452KB/s</dd> <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd> <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd> <dt>Duration:</dt> <dd>01:16:27</dd> <dt>Color profile:</dt> <dd>SD (6-1-6)</dd> <dt>Dimensions:</dt> <dd>320×240</dd> </dl> </details> </section></pre> </div> <div class=example> <p>The following shows how a <code><a href=#the-details-element>details</a></code> element can be used to hide some controls by default:</p> <pre><details> <summary><label for=fn>Name & Extension:</label></summary> <p><input type=text id=fn name=fn value="Pillar Magazine.pdf"> <p><label><input type=checkbox name=ext checked> Hide extension</label> </details></pre> <p>One could use this in conjunction with other <code><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 alt="" height=611 src=http://images.whatwg.org/sample-details-1.png width=345><img alt="" height=666 src=http://images.whatwg.org/sample-details-2.png width=345></p> <p>In these examples, the summary really just summarises what the controls can change, and not the actual values, which is less than ideal.</p> </div> <div class=example> <p>Because the <code title=attr-details-open><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 stylesheet is used to animate the color of the summary when the element is opened or closed:</p> <pre><style> details > summary { transition: color 1s; color: black; } details[open] > summary { color: red; } </style> <details> <summary>Automated Status: Operational</summary> <p>Velocity: 12m/s</p> <p>Direction: North</p> </details></pre> </div> <h4 id=the-summary-element><span class=secno>4.11.2 </span>The <dfn><code>summary</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd>None.</dd> <dt>Contexts in which this element can be used:</dt> <dd>As the first child of a <code><a href=#the-details-element>details</a></code> element.</dd> <dt>Content model:</dt> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dt>DOM interface:</dt> <dd>Uses <code><a href=#htmlelement>HTMLElement</a></code>.</dd> </dl><p>The <code><a href=#the-summary-element>summary</a></code> element <a href=#represents>represents</a> a summary, caption, or legend for the rest of the contents of the <code><a href=#the-summary-element>summary</a></code> element's parent <code><a href=#the-details-element>details</a></code> element<span class=impl>, if any</span>.</p> <h4 id=the-command-element><span class=secno>4.11.3 </span>The <dfn id=the-command><code>command</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#metadata-content>Metadata content</a>.</dd> <dd><a href=#flow-content>Flow content</a>.</dd> <dd><a href=#phrasing-content>Phrasing content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd> <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd> <dt>Content model:</dt> <dd>Empty.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-command-type><a href=#attr-command-type>type</a></code></dd> <dd><code title=attr-command-label><a href=#attr-command-label>label</a></code></dd> <dd><code title=attr-command-icon><a href=#attr-command-icon>icon</a></code></dd> <dd><code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code></dd> <dd><code title=attr-command-checked><a href=#attr-command-checked>checked</a></code></dd> <dd><code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code></dd> <!--<dd><code title="attr-command-default">default</code></dd>--> <dd>Also, the <code title=attr-command-title><a href=#attr-command-title>title</a></code> attribute has special semantics on this element.</dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlcommandelement>HTMLCommandElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-command-type title=dom-command-type>type</a>; attribute DOMString <a href=#dom-command-label title=dom-command-label>label</a>; attribute DOMString <a href=#dom-command-icon title=dom-command-icon>icon</a>; attribute boolean <a href=#dom-command-disabled title=dom-command-disabled>disabled</a>; attribute boolean <a href=#dom-command-checked title=dom-command-checked>checked</a>; attribute DOMString <a href=#dom-command-radiogroup title=dom-command-radiogroup>radiogroup</a>;<!-- attribute boolean <span title="dom-command-default">default</span>;--> };</pre> </dd> </dl><p>The <code><a href=#the-command-element>command</a></code> element represents a command that the user can invoke.</p> <p>A command can be part of a context menu or toolbar, using the <code><a href=#the-menu-element>menu</a></code> element, or can be put anywhere else in the page, to define a keyboard shortcut.</p> <!-- in the future we'll also add a command="" attribute to refer to a command, which can then be defined anywhere --> <p>The <dfn id=attr-command-type title=attr-command-type><code>type</code></dfn> attribute indicates the kind of command: either a normal command with an associated action, or a state or option that can be toggled, or a selection of one item from a list of items.</p> <p>The attribute is an <a href=#enumerated-attribute>enumerated attribute</a> with three keywords and states. The "<dfn id=attr-command-type-keyword-command title=attr-command-type-keyword-command><code>command</code></dfn>" keyword maps to the <a href=#attr-command-type-state-command title=attr-command-type-state-command>Command</a> state, the "<dfn id=attr-command-type-keyword-checkbox title=attr-command-type-keyword-checkbox><code>checkbox</code></dfn>" keyword maps to the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state, and the "<dfn id=attr-command-type-keyword-radio title=attr-command-type-keyword-radio><code>radio</code></dfn>" keyword maps to the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state. The <i>missing value default</i> is the <a href=#attr-command-type-state-command title=attr-command-type-state-command>Command</a> state.</p> <dl><dt>The <dfn id=attr-command-type-state-command title=attr-command-type-state-command>Command</dfn> state</dt> <dd><p>The element <a href=#represents>represents</a> a normal command with an associated action.</dd> <dt>The <dfn id=attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</dfn> state</dt> <dd><p>The element <a href=#represents>represents</a> a state or option that can be toggled.</dd> <dt>The <dfn id=attr-command-type-state-radio title=attr-command-type-state-radio>Radio</dfn> state</dt> <dd><p>The element <a href=#represents>represents</a> a selection of one item from a list of items.</dd> </dl><p>The <dfn id=attr-command-label title=attr-command-label><code>label</code></dfn> attribute gives the name of the command, as shown to the user. The <code title=attr-command-label><a href=#attr-command-label>label</a></code> attribute must be specified and must have a value that is not the empty string.</p> <p>The <dfn id=attr-command-title title=attr-command-title><code>title</code></dfn> attribute gives a hint describing the command, which might be shown to the user to help him.</p> <p>The <dfn id=attr-command-icon title=attr-command-icon><code>icon</code></dfn> attribute gives a picture that represents the command. If the attribute is specified, the attribute's value must contain a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by spaces</a>. <span class=impl>To obtain the <a href=#absolute-url>absolute URL</a> of the icon when the attribute's value is not the empty string, the attribute's value must be <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element. When the attribute is absent, or its value is the empty string, or <a href=#resolve-a-url title="resolve a url">resolving</a> its value fails, there is no icon.</span></p> <!-- this is affected by the base URL being changed, so users of this should cache the image once they've fetched it once, at least until the relative url changes again --> <p>The <dfn id=attr-command-disabled title=attr-command-disabled><code>disabled</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> that, if present, indicates that the command is not available in the current state.</p> <p class=note>The distinction between <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> and <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> is subtle. A command would be disabled if, in the same context, it could be enabled if only certain aspects of the situation were changed. A command would be marked as hidden if, in that situation, the command will never be enabled. For example, in the context menu for a water faucet, the command "open" might be disabled if the faucet is already open, but the command "eat" would be marked hidden since the faucet could never be eaten.</p> <p>The <dfn id=attr-command-checked title=attr-command-checked><code>checked</code></dfn> attribute is a <a href=#boolean-attribute>boolean attribute</a> that, if present, indicates that the command is selected. The attribute must be omitted unless the <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in either the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state or the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state.</p> <p>The <dfn id=attr-command-radiogroup title=attr-command-radiogroup><code>radiogroup</code></dfn> attribute gives the name of the group of commands that will be toggled when the command itself is toggled, for commands whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute has the value "<code title="">radio</code>". The scope of the name is the child list of the parent element. The attribute must be omitted unless the <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state.</p> <!-- <p>If the <code>command</code> element is used when <span title="menu generation">generating</span> a <span>context menu</span>, then the <dfn title="attr-command-default"><code>default</code></dfn> attribute indicates, if present, that the command is the one that would have been invoked if the user had directly activated the menu's subject instead of using its context menu. The <code title="attr-command-default">default</code> attribute is a <span>boolean attribute</span>. The attribute must be omitted unless the <code title="attr-command-type">type</code> attribute is in the <span title="attr-command-type-state-command">Command</span> state.</p> <div class="example"> ...an example that shows an element that, if double-clicked, invokes an action, but that also has a context menu, showing the various <code>command</code> attributes off, and that has a default command... </div> --> <div class=impl> <p>The <dfn id=dom-command-type title=dom-command-type><code>type</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values>limited to only known values</a>.</p> <p>The <dfn id=dom-command-label title=dom-command-label><code>label</code></dfn>, <dfn id=dom-command-icon title=dom-command-icon><code>icon</code></dfn>, <dfn id=dom-command-disabled title=dom-command-disabled><code>disabled</code></dfn>, <dfn id=dom-command-checked title=dom-command-checked><code>checked</code></dfn>, and <dfn id=dom-command-radiogroup title=dom-command-radiogroup><code>radiogroup</code></dfn><!--, and <dfn title="dom-command-default"><code>default</code></dfn>--> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The element's <a href=#activation-behavior>activation behavior</a> depends on the value of the <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute of the element, as follows:</p> <dl class=switch><dt>If the <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state</dt> <dd><p>If the element has a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, the UA must remove that attribute. Otherwise, the UA must add a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, with the literal value <code title="">checked</code>.</dd> <dt>If the <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state</dt> <dd><p>If the element has a parent, then the UA must walk the list of child nodes of that parent element, and for each node that is a <code><a href=#the-command-element>command</a></code> element, if that element has a <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attribute whose value exactly matches the current element's (treating missing <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code> attributes as if they were the empty string), and has a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, must remove that attribute.</p> <p>Then, the element's <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute attribute must be set to the literal value <code title="">checked</code>.</dd> <dt>Otherwise</dt> <dd><p>The element has no <a href=#activation-behavior>activation behavior</a>.</dd> </dl><p class=note>Firing a synthetic <code title=event-click><a href=#event-click>click</a></code> event at the element does not cause any of the actions described above to happen.</p> <!-- v2COMMAND: the command="" attribute to make a <command> element reflect the state of another command, so that the script can update one place in the page and have context menus, toolbars, shortcuts, etc, automatically update. Once we add this, expose the Triggers facet again. --> </div> <p class=note><code><a href=#the-command-element>command</a></code> elements are not rendered unless they <a href=#the-menu-element title=menu>form part of a menu</a>.</p> <div class=example> <p>Here is an example of a toolbar with three buttons that let the user toggle between left, center, and right alignment. One could imagine such a toolbar as part of a text editor. The toolbar also has a separator followed by another button labeled "Publish", though that button is disabled.</p> <pre><menu type="toolbar"> <command type="radio" radiogroup="alignment" checked="checked" label="Left" icon="icons/alL.png" onclick="setAlign('left')"> <command type="radio" radiogroup="alignment" label="Center" icon="icons/alC.png" onclick="setAlign('center')"> <command type="radio" radiogroup="alignment" label="Right" icon="icons/alR.png" onclick="setAlign('right')"> <hr> <command type="command" disabled label="Publish" icon="icons/pub.png" onclick="publish()"> </menu></pre> </div> <h4 id=the-menu-element><span class=secno>4.11.4 </span>The <dfn id=menus><code>menu</code></dfn> element</h4> <dl class=element><dt>Categories</dt> <dd><a href=#flow-content>Flow content</a>.</dd> <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state: <a href=#interactive-content>Interactive content</a>.</dd> <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state or the <a href=#list-state title="list state">list</a> state: <a href=#palpable-content>Palpable content</a>.</dd> <dt>Contexts in which this element can be used:</dt> <dd>Where <a href=#flow-content>flow content</a> is expected.</dd> <dt>Content model:</dt> <dd>Either: Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd> <dd>Or: <a href=#flow-content>Flow content</a>.</dd> <dt>Content attributes:</dt> <dd><a href=#global-attributes>Global attributes</a></dd> <dd><code title=attr-menu-type><a href=#attr-menu-type>type</a></code></dd> <dd><code title=attr-menu-label><a href=#attr-menu-label>label</a></code></dd> <dt>DOM interface:</dt> <dd> <pre class=idl>interface <dfn id=htmlmenuelement>HTMLMenuElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-menu-type title=dom-menu-type>type</a>; attribute DOMString <a href=#dom-menu-label title=dom-menu-label>label</a>; };</pre> </dl><p>The <code><a href=#the-menu-element>menu</a></code> element represents a list of commands.</p> <!-- v2 idea: <menu> should get an icon, like <command> --> <p>The <dfn id=attr-menu-type title=attr-menu-type><code>type</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a> indicating the kind of menu being declared. The attribute has three states. The <code title=attr-menu-type-context>context</code> keyword maps to the <dfn id=context-menu-state title="context menu state">context menu</dfn> state, in which the element is declaring a context menu. The <code title=attr-menu-type-toolbar>toolbar</code> keyword maps to the <dfn id=toolbar-state title="toolbar state">toolbar</dfn> state, in which the element is declaring a toolbar. The attribute may also be omitted. The <i>missing value default</i> is the <dfn id=list-state title="list state">list</dfn> state, which indicates that the element is merely a list of commands that is neither declaring a context menu nor defining a toolbar.</p> <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#context-menu-state title="context menu state">context menu</a> state, then the element <a href=#represents>represents</a> the commands of a context menu, and the user can only interact with the commands if that context menu is activated.</p> <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the element <a href=#represents>represents</a> a list of active commands that the user can immediately interact with.</p> <p>If a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#list-state title="list state">list</a> state, then the element either <a href=#represents>represents</a> an unordered list of items (each represented by an <code><a href=#the-li-element>li</a></code> element), each of which represents a command that the user can perform or activate, or, if the element has no <code><a href=#the-li-element>li</a></code> element children, <a href=#flow-content>flow content</a> describing available commands.</p> <p>The <dfn id=attr-menu-label title=attr-menu-label><code>label</code></dfn> attribute gives the label of the menu. It is used by user agents to display nested menus in the UI. For example, a context menu containing another menu would use the nested menu's <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute for the submenu's menu label.</p> <div class=impl> <p>The <dfn id=dom-menu-type title=dom-menu-type><code>type</code></dfn> and <dfn id=dom-menu-label title=dom-menu-label><code>label</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> </div> <h5 id=menus-intro><span class=secno>4.11.4.1 </span>Introduction</h5> <p><i>This section is non-normative.</i></p> <p>The <code><a href=#the-menu-element>menu</a></code> element is used to define context menus and toolbars.</p> <p>For example, the following represents a toolbar with three menu buttons on it, each of which has a dropdown menu with a series of options:</p> <pre><menu type="toolbar"> <li> <menu label="File"> <button type="button" onclick="fnew()">New...</button> <button type="button" onclick="fopen()">Open...</button> <button type="button" onclick="fsave()">Save</button> <button type="button" onclick="fsaveas()">Save as...</button> </menu> </li> <li> <menu label="Edit"> <button type="button" onclick="ecopy()">Copy</button> <button type="button" onclick="ecut()">Cut</button> <button type="button" onclick="epaste()">Paste</button> </menu> </li> <li> <menu label="Help"> <li><a href="help.html">Help</a></li> <li><a href="about.html">About</a></li> </menu> </li> </menu></pre> <p>In a supporting user agent, this might look like this:</p> <p><img alt="A toolbar with three buttons, labeled 'File', 'Edit', and 'Help'; where if you select the 'Edit' button you get a drop-down menu with three more options, 'Copy', 'Cut', and 'Paste'." height=101 src=http://images.whatwg.org/sample-toolbar-1.png width=303></p> <p>In a legacy user agent, the above would look like a bulleted list with three items, the first of which has four buttons, the second of which has three, and the third of which has two nested bullet points with two items consisting of links.</p> <hr><p>The following implements a similar toolbar, with a single button whose values, when selected, redirect the user to Web sites.</p> <pre><form action="redirect.cgi"> <menu type="toolbar"> <label for="goto">Go to...</label> <menu label="Go"> <select id="goto"<!-- onchange="if (this.options[this.selectedIndex].value) window.location = this.options[this.selectedIndex].value"-->> <option value="" selected="selected"> Select site: </option> <option value="http://www.apple.com/"> Apple </option> <option value="http://www.mozilla.org/"> Mozilla </option> <option value="http://www.opera.com/"> Opera </option> </select> <span><input type="submit" value="Go"></span> </menu> </menu> </form></pre> <p>The behavior in supporting user agents is similar to the example above, but here the legacy behavior consists of a single <code><a href=#the-select-element>select</a></code> element with a submit button. The submit button doesn't appear in the toolbar, because it is not a child of the <code><a href=#the-menu-element>menu</a></code> element or of its <code><a href=#the-li-element>li</a></code> children.</p> <div class=impl> <h5 id=building-menus-and-toolbars><span class=secno>4.11.4.2 </span><dfn>Building menus and toolbars</dfn></h5> <p>A menu (or toolbar) consists of a list of zero or more of the following components:</p> <ul class=brief><li><a href=#concept-command title=concept-command>Commands</a>, which can be marked as default commands</li> <li>Separators</li> <li>Other menus (which allows the list to be nested)</li> </ul><p>The list corresponding to a particular <code><a href=#the-menu-element>menu</a></code> element is built by iterating over its child nodes. For each child node in <a href=#tree-order>tree order</a>, the required behavior depends on what the node is, as follows:</p> <dl class=switch><dt>An element that <a href=#concept-command title=concept-command>defines a command</a></dt> <dd>Append the command to the menu, respecting its <a href=#concept-facet title=concept-facet>facets</a><!-- we might need to be explicit about what this means for each facet, if testing shows this isn't well-implemented. e.g.: If there's an Icon facet for the command, it should be <span title="fetch">fetched</span> (this would be http-origin privacy-sensitive), and then that image should be associated with the command, such that each command only has its image fetched once, to prevent changes to the base URL from having effects after the image has been fetched once. (no need to resolve the Icon facet, it's an absolute URL) -->. <!--If the element is a <code>command</code> element with a <code title="attr-command-default">default</code> attribute, mark the command as being a default command.--></dd> <dt>An <code><a href=#the-hr-element>hr</a></code> element</dt> <dt>An <code><a href=#the-option-element>option</a></code> element that has a <code title=attr-option-value><a href=#attr-option-value>value</a></code> attribute set to the empty string, and has a <code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code> attribute, and whose <code><a href=#textcontent>textContent</a></code> consists of a string of one or more hyphens (U+002D HYPHEN-MINUS)</dt> <dd>Append a separator to the menu.</dd> <dt>An <code><a href=#the-li-element>li</a></code> element</dt> <dt>A <code><a href=#the-label-element>label</a></code> element</dt> <dd>Iterate over the children of the element.</dd> <dt>A <code><a href=#the-menu-element>menu</a></code> element with no <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt> <dt>A <code><a href=#the-select-element>select</a></code> element</dt> <dd>Append a separator to the menu, then iterate over the children of the <code><a href=#the-menu-element>menu</a></code> or <code><a href=#the-select-element>select</a></code> element, then append another separator.</dd> <!-- v2: we might want to support <select> in <label> as giving a named submenu --> <dt>A <code><a href=#the-menu-element>menu</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt> <dt>An <code><a href=#the-optgroup-element>optgroup</a></code> element with a <code title=attr-menu-label><a href=#attr-menu-label>label</a></code> attribute</dt> <dd>Append a submenu to the menu, using the value of the element's <code title="">label</code> attribute as the label of the menu. The submenu must be constructed by taking the element and creating a new menu for it using the complete process described in this section.</dd> <dt>Any other node</dt> <dd><a href=#ignore>Ignore</a> the node.</dd> </dl><p>Once all the nodes have been processed as described above, the user agent must the post-process the menu as follows:</p> <ol><li>Except for separators, any menu item with no label, or whose label is the empty string, must be removed.</li> <li>Any sequence of two or more separators in a row must be collapsed to a single separator.</li> <li>Any separator at the start or end of the menu must be removed.</li> </ol></div> <h5 id=context-menus><span class=secno>4.11.4.3 </span><dfn>Context menus</dfn></h5> <p>The <dfn id=attr-contextmenu title=attr-contextmenu><code>contextmenu</code></dfn> attribute gives the element's <a href=#context-menus title="context menus">context menu</a>. The value must be the <a href=#concept-id title=concept-id>ID</a> of a <code><a href=#the-menu-element>menu</a></code> element in the DOM. <span class=impl>If the node that would be obtained by invoking the <code title=dom-Document-getElementById><a href=#dom-document-getelementbyid>getElementById()</a></code> method using the attribute's value as the only argument is null or not a <code><a href=#the-menu-element>menu</a></code> element, then the element has no assigned context menu. Otherwise, the element's assigned context menu is the element so identified.</span></p> <div class=impl> <p>When an element's context menu is requested (e.g. by the user right-clicking the element, or pressing a context menu key), the user agent must apply the appropriate rules from the following list:</p> <dl class=switch><dt>If the user requested a context menu using a pointing device</dt> <dd><p>The user agent must fire an event with the name <code title=event-contextmenu>contextmenu</code>, that bubbles and is cancelable, and that uses the <code><a href=#mouseevent>MouseEvent</a></code> interface, at the element for which the menu was requested. The context information of the event must be initialized to the same values as the last <code><a href=#mouseevent>MouseEvent</a></code> user interaction event that was fired as part of the gesture that that was interpreted as a request for the context menu.</dd> <dt>Otherwise</dt> <dd><p>The user agent must <a href=#fire-a-synthetic-mouse-event title="fire a synthetic mouse event">fire a synthetic mouse event named <code title=event-contextmenu>contextmenu</code></a> that bubbles and is cancelable at the element for which the menu was requested.</dd> </dl><p class=note>Typically, therefore, the firing of the <code title=event-contextmenu>contextmenu</code> event will be the default action of a <code title=mouseup>mouseup</code> or <code title=event-keyup>keyup</code> event. The exact sequence of events is UA-dependent, as it will vary based on platform conventions.</p> <p>The default action of the <code title=event-contextmenu>contextmenu</code> event depends on whether the element or one of its ancestors has a context menu assigned (using the <code title=attr-contextmenu><a href=#attr-contextmenu>contextmenu</a></code> attribute) or not. If there is no context menu assigned, the default action must be for the user agent to show its default context menu, if it has one.</p> <p>If the element or one of its ancestors <em>does</em> have a context menu assigned, then the user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-show>show</code> at the <code><a href=#the-menu-element>menu</a></code> element of the context menu of the nearest ancestor (including the element itself) with one assigned.</p> <!-- v2: include modifier key information --> <p>The default action of <em>this</em> event is that the user agent must show a context menu <a href=#building-menus-and-toolbars title="building menus and toolbars">built</a> from the <code><a href=#the-menu-element>menu</a></code> element.</p> <p>The user agent may also provide access to its default context menu, if any, with the context menu shown. For example, it could merge the menu items from the two menus together, or provide the page's context menu as a submenu of the default menu.</p> <p>If the user dismisses the menu without making a selection, nothing in particular happens.</p> <p>If the user selects a menu item that represents a <a href=#concept-command title=concept-command>command</a>, then the UA must invoke that command's <a href=#command-facet-action title=command-facet-Action>Action</a>.</p> <p>Context menus must not, while being shown, reflect changes in the DOM; they are constructed as the default action of the <code title=event-show>show</code> event and must remain as constructed until dismissed.</p> <p>User agents may provide means for bypassing the context menu processing model, ensuring that the user can always access the UA's default context menus. For example, the user agent could handle right-clicks that have the Shift key depressed in such a way that it does not fire the <code title=event-contextmenu>contextmenu</code> event and instead always shows the default context menu.</p> <p>The <dfn id=dom-contextmenu title=dom-contextMenu><code>contextMenu</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-contextmenu><a href=#attr-contextmenu>contextmenu</a></code> content attribute.</p> </div> <div class=example> <p>Here is an example of a context menu for an input control:</p> <pre><form name="npc"> <label>Character name: <input name=char type=text contextmenu=namemenu required></label> <menu type=context id=namemenu> <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()"> <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)"> </menu> </form></pre> <p>This adds two items to the control's context menu, one called "Pick random name", and one called "Prefill other fields based on name". They invoke scripts that are not shown in the example above.</p> </div> <div class=impl> <h5 id=toolbars><span class=secno>4.11.4.4 </span><dfn>Toolbars</dfn></h5> <p>When a <code><a href=#the-menu-element>menu</a></code> element has a <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, then the user agent must <a href=#building-menus-and-toolbars title="building menus and toolbars">build</a> the menu for that <code><a href=#the-menu-element>menu</a></code> element, and use the result in the rendering.</p> <p>The user agent must reflect changes made to the <code><a href=#the-menu-element>menu</a></code>'s DOM, by immediately <a href=#building-menus-and-toolbars title="building menus and toolbars">rebuilding</a> the menu.</p> </div> <h4 id=commands><span class=secno>4.11.5 </span>Commands</h4> <p>A <dfn id=concept-command title=concept-command>command</dfn> is the abstraction behind menu items, buttons, and links.<!--v2COMMAND: 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 aspects such as the disabled state.--></p> <p id=facets>Commands are defined to have the following <dfn id=concept-facet title=concept-facet>facets</dfn>:</p> <dl><dt><dfn id=command-facet-type title=command-facet-Type>Type</dfn></dt> <dd>The kind of command: "command", meaning it is a normal command; "radio", meaning that triggering the command will, amongst other things, set the <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> to true (and probably uncheck some other commands); or "checkbox", meaning that triggering the command will, amongst other things, toggle the value of the <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a>.</dd> <dt><dfn id=command-facet-id title=command-facet-ID>ID</dfn></dt> <dd>The name of the command, for referring to the command from the markup or from script. If a command has no ID, it is an <dfn id=anonymous-command>anonymous command</dfn>.</dd> <dt><dfn id=command-facet-label title=command-facet-Label>Label</dfn></dt> <dd>The name of the command as seen by the user.</dd> <dt><dfn id=command-facet-hint title=command-facet-Hint>Hint</dfn></dt> <dd>A helpful or descriptive string that can be shown to the user.</dd> <dt><dfn id=command-facet-icon title=command-facet-Icon>Icon</dfn></dt> <dd>An <a href=#absolute-url>absolute URL</a> identifying a graphical image that represents the action. A command might not have an Icon.</dd> <!-- changing base URLs might change the icon --> <dt><dfn id=command-facet-accesskey title=command-facet-AccessKey>Access Key</dfn></dt> <dd>A key combination selected by the user agent that triggers the command. A command might not have an Access Key.</dd> <dt><dfn id=command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</dfn></dt> <dd>Whether the command is hidden or not (basically, whether it should be shown in menus).</dd> <dt><dfn id=command-facet-disabledstate title=command-facet-DisabledState>Disabled State</dfn></dt> <dd>Whether the command is relevant and can be triggered or not.</dd> <dt><dfn id=command-facet-checkedstate title=command-facet-CheckedState>Checked State</dfn></dt> <dd>Whether the command is checked or not.</dd> <dt><dfn id=command-facet-action title=command-facet-Action>Action</dfn></dt> <dd>The actual effect that triggering the command will have. This could be a scripted event handler, a <a href=#url>URL</a> to which to <a href=#navigate>navigate</a>, or a form submission.</dd> <!-- v2COMMAND <dt><dfn title="command-facet-Triggers">Triggers</dfn></dt> <dd>The list of elements that can trigger the command. The element defining a command is always in the list of elements that can trigger the command. For anonymous commands, only the element defining the command is on the list, since other elements have no way to refer to it.</dd> --> </dl><p>These facets are exposed on elements using the <dfn id=command-api>command API</dfn>:</p> <dl class=domintro><dt><var title="">element</var> . <code title=dom-command-ro-commandType><a href=#dom-command-ro-commandtype>commandType</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-type title=command-facet-Type>Type</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-Element-id><a href=#dom-element-id>id</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-id title=command-facet-ID>ID</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-command-ro-commandLabel><a href=#dom-command-ro-commandlabel>commandLabel</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-label title=command-facet-Label>Label</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-title><a href=#dom-title>title</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-hint title=command-facet-Hint>Hint</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-command-ro-commandIcon><a href=#dom-command-ro-commandicon>commandIcon</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-icon title=command-facet-Icon>Icon</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-accessKeyLabel><a href=#dom-accesskeylabel>accessKeyLabel</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-accesskey title=command-facet-AccessKey>Access Key</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-command-ro-commandHidden><a href=#dom-command-ro-commandhidden>commandHidden</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-command-ro-commandDisabled><a href=#dom-command-ro-commanddisabled>commandDisabled</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-command-ro-commandChecked><a href=#dom-command-ro-commandchecked>commandChecked</a></code></dt> <dd> <p>Exposes the <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> facet of the command.</p> </dd> <dt><var title="">element</var> . <code title=dom-click><a href=#dom-click>click</a></code>()</dt> <dd> <p>Triggers the <a href=#command-facet-action title=command-facet-Action>Action</a> of the command.</p> </dd> <!--v2COMMAND <dt><var title="">element</var> . <code title="dom-command-ro-commandTriggers">commandTriggers</code></dt> <dd> <p>Exposes the <span title="command-facet-Triggers">Triggers</span> facet of the command.</p> </dd> --> </dl><div class=impl> <p>The <dfn id=dom-command-ro-commandtype title=dom-command-ro-commandType><code>commandType</code></dfn> attribute must return a string whose value is either "<code title="">command</code>", "<code title="">radio</code>", or "<code title="">checkbox</code>", depending on whether the <a href=#command-facet-type title=command-facet-Type>Type</a> of the command defined by the element is "command", "radio", or "checkbox" respectively. If the element does not define a command, it must return null.</p> <p>The <dfn id=dom-command-ro-commandlabel title=dom-command-ro-commandLabel><code>commandLabel</code></dfn> attribute must return the command's <a href=#command-facet-label title=command-facet-Label>Label</a>, or null if the element does not define a command or does not specify a <a href=#command-facet-label title=command-facet-Label>Label</a>.</p> <p>The <dfn id=dom-command-ro-commandicon title=dom-command-ro-commandIcon><code>commandIcon</code></dfn> attribute must return the <a href=#absolute-url>absolute URL</a> of the command's <a href=#command-facet-icon title=command-facet-Icon>Icon</a>. If the element does not specify an icon, or if the element does not define a command, then the attribute must return null.</p> <p>The <dfn id=dom-command-ro-commandhidden title=dom-command-ro-commandHidden><code>commandHidden</code></dfn> attribute must return true if the command's <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> is that the command is hidden, and false if the command is not hidden. If the element does not define a command, the attribute must return null.</p> <p>The <dfn id=dom-command-ro-commanddisabled title=dom-command-ro-commandDisabled><code>commandDisabled</code></dfn> attribute must return true if the command's <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> is that the command is disabled, and false if the command is not disabled. This attribute is not affected by the command's <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a>. If the element does not define a command, the attribute must return null.</p> <p>The <dfn id=dom-command-ro-commandchecked title=dom-command-ro-commandChecked><code>commandChecked</code></dfn> attribute must return true if the command's <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> is that the command is checked, and false if it is that the command is not checked. If the element does not define a command, the attribute must return null.</p> <!--v2COMMAND <p>The <dfn title="dom-command-ro-commandTriggers"><code>commandTriggers</code></dfn> attribute must return a list containing the elements that can trigger the command (the command's <span title="command-facet-Triggers">Triggers</span>). The list must be <span>live</span>. The same object must be returned each time. While the element does not define a command, the list must be empty.</p> --> <p class=note>The <a href=#command-facet-id title=command-facet-ID>ID</a> facet is exposed by the <code title=dom-Element-id><a href=#dom-element-id>id</a></code> IDL attribute, the <a href=#command-facet-hint title=command-facet-Hint>Hint</a> facet is exposed by the <code title=dom-title><a href=#dom-title>title</a></code> IDL attribute, and the <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> facet is exposed by the <code title=dom-accessKeyLabel><a href=#dom-accesskeylabel>accessKeyLabel</a></code> IDL attribute.</p> </div> <hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-commands><a href=#dom-document-commands>commands</a></code></dt> <dd> <p>Returns an <code><a href=#htmlcollection>HTMLCollection</a></code> of the elements in the <code><a href=#document>Document</a></code> that define commands and have IDs.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-commands title=dom-document-commands><code>commands</code></dfn> attribute of the document's <code><a href=#document>Document</a></code> interface must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only elements that <a href=#concept-command title=concept-command>define commands</a> and have <a href=#command-facet-id title=command-facet-ID>IDs</a>.</p> </div> <hr><p>User agents may expose the <a href=#concept-command title=concept-command>commands</a> whose <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> facet is false (visible) and whose elements are <a href=#in-a-document>in a <code>Document</code></a>. For example, such commands could be listed in the user agent's menu bar. User agents are encouraged to do this especially for commands that have <a href=#command-facet-accesskey title=command-facet-AccessKey>Access Keys</a>, as a way to advertise those keys to the user.</p> <div class=impl> <h5 id=using-the-a-element-to-define-a-command><span class=secno>4.11.5.1 </span><dfn title=a-command>Using the <code>a</code> element to define a command</dfn></h5> <p>An <code><a href=#the-a-element>a</a></code> element with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "command".</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command is the string given by the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the value of the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the element. If the attribute is not present, the <a href=#command-facet-hint title=command-facet-Hint>Hint</a> is the empty string.</p> <p>The <a href=#command-facet-icon title=command-facet-Icon>Icon</a> of the command is the <a href=#absolute-url>absolute URL</a> obtained from <a href=#resolve-a-url title="resolve a url">resolving</a> the value of the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of the first <code><a href=#the-img-element>img</a></code> element descendant of the element in <a href=#tree-order>tree order</a>, relative to that element, if there is such an element and resolving its attribute is successful. Otherwise, there is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>, if any.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> of the command is true (hidden) if the element has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> facet of the command is always false. (The command is always enabled.)</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is always false. (The command is never checked.)</p> <p>The <a href=#command-facet-action title=command-facet-Action>Action</a> of the command is to <a href=#fire-a-click-event title="fire a click event">fire a <code title=event-click>click</code> event</a> at the element.</p> <h5 id=using-the-button-element-to-define-a-command><span class=secno>4.11.5.2 </span><dfn title=button-command>Using the <code>button</code> element to define a command</dfn></h5> <p>A <code><a href=#the-button-element>button</a></code> element always <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a>, <a href=#command-facet-id title=command-facet-ID>ID</a>, <a href=#command-facet-label title=command-facet-Label>Label</a>, <a href=#command-facet-hint title=command-facet-Hint>Hint</a>, <a href=#command-facet-icon title=command-facet-Icon>Icon</a>, <a href=#command-facet-accesskey title=command-facet-AccessKey>Access Key</a>, <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a>, <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a>, and <a href=#command-facet-action title=command-facet-Action>Action</a> facets of the command are determined <a href=#using-the-a-element-to-define-a-command title=a-command>as for <code>a</code> elements</a> (see the previous section).</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> of the command mirrors the <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a> state of the button.</p> <h5 id=using-the-input-element-to-define-a-command><span class=secno>4.11.5.3 </span><dfn title=input-command>Using the <code>input</code> element to define a command</dfn></h5> <p>An <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in one of the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a>, <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>, <a href=#image-button-state title=attr-input-type-image>Image Button</a>, <a href=#button-state title=attr-input-type-button>Button</a>, <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a>, or <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> states <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "radio" if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <code title=attr-input-type-radio><a href=#radio-button-state>Radio Button</a></code> state, "checkbox" if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <code title=attr-input-type-checkbox><a href=#checkbox-state>Checkbox</a></code> state, and "command" otherwise.</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command depends on the Type of the command:</p> <p>If the <a href=#command-facet-type title=command-facet-Type>Type</a> is "command", then it is the string given by the <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if any, and a UA-dependent, locale-dependent value that the UA uses to label the button itself if the attribute is absent.</p> <p>Otherwise, the <a href=#command-facet-type title=command-facet-Type>Type</a> is "radio" or "checkbox". If the element is a <a href=#labeled-control>labeled control</a>, the <code><a href=#textcontent>textContent</a></code> of the first <code><a href=#the-label-element>label</a></code> element in <a href=#tree-order>tree order</a> whose <a href=#labeled-control>labeled control</a> is the element in question is the <a href=#command-facet-label title=command-facet-Label>Label</a> (in DOM terms, this is the string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise, the value of the <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if present, is the <a href=#command-facet-label title=command-facet-Label>Label</a>. Otherwise, the <a href=#command-facet-label title=command-facet-Label>Label</a> is the empty string.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the value of the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the <code><a href=#the-input-element>input</a></code> element. If the attribute is not present, the <a href=#command-facet-hint title=command-facet-Hint>Hint</a> is the empty string.</p> <p>If the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, and the element has a <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute, and that attribute's value can be successfully <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element, then the <a href=#command-facet-icon title=command-facet-Icon>Icon</a> of the command is the <a href=#absolute-url>absolute URL</a> obtained from resolving that attribute that way. Otherwise, there is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>, if any.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> of the command is true (hidden) if the element has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> of the command mirrors the <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a> state of the control.</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is true if the command is of <a href=#command-facet-type title=command-facet-Type>Type</a> "radio" or "checkbox" and the element is <a href=#concept-fe-checked title=concept-fe-checked>checked</a> attribute, and false otherwise.</p> <p>The <a href=#command-facet-action title=command-facet-Action>Action</a> of the command, if the element has a defined <a href=#activation-behavior>activation behavior</a>, is to <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the element. Otherwise, it is just to <a href=#fire-a-click-event>fire a <code title=event-click>click</code> event</a> at the element.</p> <h5 id=using-the-option-element-to-define-a-command><span class=secno>4.11.5.4 </span><dfn title=option-command>Using the <code>option</code> element to define a command</dfn></h5> <p>An <code><a href=#the-option-element>option</a></code> element with an ancestor <code><a href=#the-select-element>select</a></code> element and either no <code title=attr-option-value><a href=#attr-option-value>value</a></code> attribute or a <code title=attr-option-value><a href=#attr-option-value>value</a></code> attribute that is not the empty string <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "radio" if the <code><a href=#the-option-element>option</a></code>'s nearest ancestor <code><a href=#the-select-element>select</a></code> element has no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute, and "checkbox" if it does.</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command is the value of the <code><a href=#the-option-element>option</a></code> element's <code title=attr-option-label><a href=#attr-option-label>label</a></code> attribute, if there is one, or else the value of <code><a href=#the-option-element>option</a></code> element's <code><a href=#textcontent>textContent</a></code> IDL attribute, with <a href=#strip-leading-and-trailing-whitespace title="strip leading and trailing whitespace">leading and trailing whitespace stripped</a>, and with any sequences of two or more <a href=#space-character title="space character">space characters</a> replaced by a single U+0020 SPACE character.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the string given by the element's <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute, if any, and the empty string if the attribute is absent.</p> <p>There is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>, if any.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> of the command is true (hidden) if the element has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> of the command is true (disabled) if the element is <a href=#concept-option-disabled title=concept-option-disabled>disabled</a> or if its nearest ancestor <code><a href=#the-select-element>select</a></code> element is <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, and false otherwise.</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is true (checked) if the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, and false otherwise.</p> <p>The <a href=#command-facet-action title=command-facet-Action>Action</a> of the command depends on its <a href=#command-facet-type title=command-facet-Type>Type</a>. If the command is of <a href=#command-facet-type title=command-facet-Type>Type</a> "radio" then it must <a href=#concept-select-pick title=concept-select-pick>pick</a> the <code><a href=#the-option-element>option</a></code> element. Otherwise, it must <a href=#concept-select-toggle title=concept-select-toggle>toggle</a> the <code><a href=#the-option-element>option</a></code> element.</p> <h5 id=using-the-command-element-to-define-a-command><span class=secno>4.11.5.5 </span>Using the <dfn title=command-element><code>command</code></dfn> element to define a command</h5> <p>A <code><a href=#the-command-element>command</a></code> element <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "radio" if the <code><a href=#the-command-element>command</a></code>'s <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is "<code>radio</code>", "checkbox" if the attribute's value is "<code>checkbox</code>", and "command" otherwise.</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command is the value of the element's <code title=attr-command-label><a href=#attr-command-label>label</a></code> attribute, if there is one, or the empty string if it doesn't.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the string given by the element's <code title=attr-command-title><a href=#attr-command-title>title</a></code> attribute, if any, and the empty string if the attribute is absent.</p> <p>The <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command is the <a href=#absolute-url>absolute URL</a> obtained from <a href=#resolve-a-url title="resolve a url">resolving</a> the value of the element's <code title=attr-command-icon><a href=#attr-command-icon>icon</a></code> attribute, relative to the element, if it has such an attribute and resolving it is successful. Otherwise, there is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>, if any.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> of the command is true (hidden) if the element has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> of the command is true (disabled) if the element has a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is true (checked) if the element has a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-action title=command-facet-Action>Action</a> of the command, if the element has a defined <a href=#activation-behavior>activation behavior</a>, is to <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the element. Otherwise, it is just to <a href=#fire-a-click-event>fire a <code title=event-click>click</code> event</a> at the element.</p> <h5 id=using-the-accesskey-attribute-on-a-label-element-to-define-a-command><span class=secno>4.11.5.6 </span><dfn title=label-command>Using the <code title=attr-accesskey>accesskey</code> attribute on a <code>label</code> element to define a command</dfn></h5> <p>A <code><a href=#the-label-element>label</a></code> element that has an <a href=#assigned-access-key>assigned access key</a> and a <a href=#labeled-control>labeled control</a> and whose <a href=#labeled-control>labeled control</a> <a href=#concept-command title=concept-command>defines a command</a>, itself <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "command".</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command is the string given by the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the value of the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the element.</p> <p>There is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a>, <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a>, and <a href=#command-facet-action title=command-facet-Action>Action</a> facets of the command are the same as the respective facets of the element's <a href=#labeled-control>labeled control</a>.</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is always false. (The command is never checked.)</p> <h5 id=using-the-accesskey-attribute-on-a-legend-element-to-define-a-command><span class=secno>4.11.5.7 </span><dfn title=legend-command>Using the <code title=attr-accesskey>accesskey</code> attribute on a <code>legend</code> element to define a command</dfn></h5> <p>A <code><a href=#the-legend-element>legend</a></code> element that has an <a href=#assigned-access-key>assigned access key</a> and is a child of a <code><a href=#the-fieldset-element>fieldset</a></code> element that has a descendant that is not a descendant of the <code><a href=#the-legend-element>legend</a></code> element and is neither a <code><a href=#the-label-element>label</a></code> element nor a <code><a href=#the-legend-element>legend</a></code> element but that <a href=#concept-command title=concept-command>defines a command</a>, itself <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>The <a href=#command-facet-type title=command-facet-Type>Type</a> of the command is "command".</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command is the string given by the element's <code><a href=#textcontent>textContent</a></code> IDL attribute.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the value of the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the element.</p> <p>There is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a>, <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a>, and <a href=#command-facet-action title=command-facet-Action>Action</a> facets of the command are the same as the respective facets of the first element in <a href=#tree-order>tree order</a> that is a descendant of the parent of the <code><a href=#the-legend-element>legend</a></code> element that <a href=#concept-command title=concept-command>defines a command</a> but is not a descendant of the <code><a href=#the-legend-element>legend</a></code> element and is neither a <code><a href=#the-label-element>label</a></code> nor a <code><a href=#the-legend-element>legend</a></code> element.</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is always false. (The command is never checked.)</p> <h5 id=using-the-accesskey-attribute-to-define-a-command-on-other-elements><span class=secno>4.11.5.8 </span><dfn title=accesskey-command>Using the <code title=attr-accesskey>accesskey</code> attribute to define a command on other elements</dfn></h5> <p>An element that has an <a href=#assigned-access-key>assigned access key</a> <a href=#concept-command title=concept-command>defines a command</a>.</p> <p>If one of the other sections that define elements that <a href=#concept-command title=concept-command>define commands</a> define that this element <a href=#concept-command title=concept-command>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-type title=command-facet-Type>Type</a> of the command is "command".</p> <p>The <a href=#command-facet-id title=command-facet-ID>ID</a> of the command is the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute of the element, if the attribute is present and not empty. Otherwise the command is an <a href=#anonymous-command>anonymous command</a>.</p> <p>The <a href=#command-facet-label title=command-facet-Label>Label</a> of the command depends on the element. If the element is a <a href=#labeled-control>labeled control</a>, the <code><a href=#textcontent>textContent</a></code> of the first <code><a href=#the-label-element>label</a></code> element in <a href=#tree-order>tree order</a> whose <a href=#labeled-control>labeled control</a> is the element in question is the <a href=#command-facet-label title=command-facet-Label>Label</a> (in DOM terms, this is the string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise, the <a href=#command-facet-label title=command-facet-Label>Label</a> is the <code><a href=#textcontent>textContent</a></code> of the element itself.</p> <p>The <a href=#command-facet-hint title=command-facet-Hint>Hint</a> of the command is the value of the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute of the element. If the attribute is not present, the <a href=#command-facet-hint title=command-facet-Hint>Hint</a> is the empty string.</p> <p>There is no <a href=#command-facet-icon title=command-facet-Icon>Icon</a> for the command.</p> <p>The <a href=#command-facet-accesskey title=command-facet-AccessKey>AccessKey</a> of the command is the element's <a href=#assigned-access-key>assigned access key</a>.</p> <p>The <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> of the command is true (hidden) if the element has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p> <p>The <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> facet of the command is always false. (The command is always enabled.)</p> <p>The <a href=#command-facet-checkedstate title=command-facet-CheckedState>Checked State</a> of the command is always false. (The command is never checked.)</p> <p>The <a href=#command-facet-action title=command-facet-Action>Action</a> of the command is to run the following steps:</p> <ol><li>If the element is <a href=#focusable>focusable</a>, run the <a href=#focusing-steps>focusing steps</a> for the element.</li> <li>If the element has a defined <a href=#activation-behavior>activation behavior</a>, <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the element.</li> <li>Otherwise, if the element does not have a defined <a href=#activation-behavior>activation behavior</a>, <a href=#fire-a-click-event>fire a <code title=event-click>click</code> event</a> at the element.</li> </ol></div> <h3 id=links><span class=secno>4.12 </span>Links</h3> <h4 id=introduction-4><span class=secno>4.12.1 </span>Introduction</h4> <p>Links are a conceptual construct, created by <code><a href=#the-a-element>a</a></code>, <code><a href=#the-area-element>area</a></code>, and <code><a href=#the-link-element>link</a></code> elements, that <a href=#represents title=represents>represent</a> a connection between two resources, one of which is the current <code><a href=#document>Document</a></code>. There are two kinds of links in HTML:</p> <dl><dt><dfn id=external-resource-link title="external resource link">Links to external resources</dfn></dt> <dd><p>These are links to resources that are to be used to augment the current document, generally automatically processed by the user agent.</dd> <dt><dfn id=hyperlink title=hyperlink>Hyperlinks</dfn></dt> <dd><p>These are links to other resources that are generally exposed to the user by the user agent so that the user can cause the user agent to <a href=#navigate>navigate</a> to those resources, e.g. to visit them in a browser or download them.</dd> </dl><p>For <code><a href=#the-link-element>link</a></code> elements with an <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute and a <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute, links must be created for the keywords of the <code title=attr-link-rel><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><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute and a <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute, links must be created for the keywords of the <code title=attr-hyperlink-rel><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><a href=#the-link-element>link</a></code> elements, however, <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> element with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute that either do not have a <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute, or whose <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute has no keywords that are defined as specifying <a href=#hyperlink title=hyperlink>hyperlinks</a>, must also create a <a href=#hyperlink>hyperlink</a>. This implied hyperlink has no special meaning (it has no <a href=#linkTypes>link type</a>) beyond linking the element's document to the resource given by the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute.</p> <p>A <a href=#hyperlink>hyperlink</a> can have one or more <dfn id=hyperlink-annotation title="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.12.2 </span>Links created by <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements</h4> <p>The <dfn id=attr-hyperlink-href title=attr-hyperlink-href><code>href</code></dfn> attribute on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements must have a value that is a <a href=#valid-url-potentially-surrounded-by-spaces>valid URL potentially surrounded by spaces</a>.</p> <p class=note>The <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements is not required; when those elements do not have <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attributes they do not create hyperlinks.</p> <p>The <dfn id=attr-hyperlink-target title=attr-hyperlink-target><code>target</code></dfn> attribute, if present, must be a <a href=#valid-browsing-context-name-or-keyword>valid browsing context name or keyword</a>. It gives the name of the <a href=#browsing-context>browsing context</a> that will be used. <span class=impl>User agents use this name when <a href=#following-hyperlinks>following hyperlinks</a>.</span></p> <!--DOWNLOAD--> <p>When an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element's <a href=#activation-behavior>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 title=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 title=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 title=navigate>navigation</a> then the user agent must <a href=#following-hyperlinks title="following hyperlinks">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 title="downloading hyperlinks">download the hyperlink</a>. These terms are defined in subsequent sections below.</p> <p>The <dfn id=attr-hyperlink-download title=attr-hyperlink-download><code>download</code></dfn> attribute, if present, indicates that the author intends the hyperlink to be used for downloading a resource. The attribute may have a value; the value, if any, specifies the default filename that the author recommends for use in labeling the resource in a local file system. There are no restrictions on allowed values, but authors are cautioned that most file systems have limitations with regard to what punctuation is supported in file names, and user agents are likely to adjust file names accordingly.</p> <!--DOWNLOAD--> <!--PING--> <p>The <dfn id=ping title=attr-hyperlink-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>set of space-separated tokens</a>, each of which must be a <a href=#valid-non-empty-url>valid non-empty URL</a>. <span class=impl>The value is used by the user agent for <a href=#hyperlink-auditing>hyperlink auditing</a>.</span></p> <!--PING--> <p>The <dfn id=attr-hyperlink-rel title=attr-hyperlink-rel><code>rel</code></dfn> attribute on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements controls what kinds of links the elements create. The attribue's value must be a <a href=#set-of-space-separated-tokens>set of space-separated tokens</a>. The <a href=#linkTypes>allowed keywords and their meanings</a> are defined below.</p> <p>The <code title=attr-hyperlink-rel><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-media title=attr-hyperlink-media><code>media</code></dfn> attribute describes for which media the target document was designed. It is purely advisory. The value must be a <a href=#valid-media-query>valid media query</a>. The default, if the <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code> attribute is omitted, is "<code title="">all</code>".</p> <p>The <dfn id=attr-hyperlink-hreflang title=attr-hyperlink-hreflang><code>hreflang</code></dfn> attribute on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements that create <a href=#hyperlink title=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> <span class=impl>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.</span></p> <p>The <dfn id=attr-hyperlink-type title=attr-hyperlink-type><code>type</code></dfn> attribute, if present, gives the <a href=#mime-type>MIME type</a> of the linked resource. It is purely advisory. The value must be a <a href=#valid-mime-type>valid MIME type</a>. <span class=impl>User agents must not consider the <code title=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.</span></p> <div class=impl> <h4 id=following-hyperlinks-0><span class=secno>4.12.3 </span>Following hyperlinks</h4> <!-- This whole section should be rewritten to use algorithmic style --> <p>When a user <dfn id=following-hyperlinks title="following hyperlinks">follows a hyperlink</dfn> created by an element, the user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the <a href=#url>URL</a> given by the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute of that element, relative to that element, and if that is successful, must <a href=#navigate>navigate</a><!--DONAV hyperlink--> a <a href=#browsing-context>browsing context</a> to the resulting <a href=#absolute-url>absolute URL</a>. In the case of server-side image maps, that <a href=#absolute-url>absolute URL</a> must have its <var><a href=#hyperlink-suffix>hyperlink suffix</a></var> appended to it before the navigation is started.</p> <p>If <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> fails, the user agent may report the error to the user in a user-agent-specific manner, may <a href=#navigate>navigate</a><!--DONAV hyperlink--> to an error page to report the error, or may ignore the error and do nothing.</p> <p>If the user indicated a specific <a href=#browsing-context>browsing context</a> when following the hyperlink, or if the user agent is configured to follow hyperlinks by navigating a particular browsing context, then that must be the <a href=#browsing-context>browsing context</a> that is navigated.</p> <p>Otherwise, if the element is an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element that has a <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute, then the <a href=#browsing-context>browsing context</a> that is navigated must be chosen by applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a>, using the value of the <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute as the browsing context name. If these rules result in the creation of a new <a href=#browsing-context>browsing context</a>, it must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> <!-- if http://www.w3.org/Bugs/Public/show_bug.cgi?id=11183 is ever reverted, then change the dfn below back into a span --> <!-- in the meantime, the definition of rel=sidebar in the wiki says that it's a "sidebar hyperlink" --> <!--!--> <p>Otherwise, if the hyperlink is a <dfn id=rel-sidebar-hyperlink title=rel-sidebar-hyperlink>sidebar hyperlink</dfn> and the user agent implements a feature that can be considered a <a href=#secondary-browsing-context>secondary browsing context</a>, such a <a href=#secondary-browsing-context>secondary browsing context</a> may be selected as the browsing context to be navigated.</p> <p>Otherwise, if the element is an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element with no <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> attribute, but the <code><a href=#document>Document</a></code> contains a <code><a href=#the-base-element>base</a></code> element with a <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute, then the browsing context that is navigated must be chosen by applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a>, using the value of the <code title=attr-base-target><a href=#attr-base-target>target</a></code> attribute of the first such <code><a href=#the-base-element>base</a></code> element as the browsing context name. If these rules result in the creation of a new <a href=#browsing-context>browsing context</a>, it must be navigated with <a href=#replacement-enabled>replacement enabled</a>.</p> <!-- c.f. concept-fs-target --> <p>Otherwise, the browsing context that must be navigated is the same browsing context as the one which the element itself is in.</p> <p>The navigation must be done with the <a href=#browsing-context>browsing context</a> that contains the <code><a href=#document>Document</a></code> object with which the element in question is associated as the <a href=#source-browsing-context>source browsing context</a>.</p> </div> <!--DOWNLOAD--> <h4 id=downloading-resources><span class=secno>4.12.4 </span>Downloading resources</h4> <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 title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute can be specified on the <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element that creates the <a href=#hyperlink>hyperlink</a> to that resource.</p> <p>The attribute can furthermore be given a value, to specify the filename that user agents are to use when storing the resource in a file system. This value can be overridden by the <code title=http-content-disposition>Content-Disposition</code> HTTP header's filename parameters. <a href=#refsRFC6266>[RFC6266]</a></p> <p>In cross-origin situations, the <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute has to be combined with the <code title=http-content-disposition>Content-Disposition</code> HTTP header, specifically with the <code title="">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> <div class=impl> <hr><p>When a user <dfn id=downloading-hyperlinks title="downloading hyperlinks">downloads a hyperlink</dfn> created by an element, the user agent must run the following steps:</p> <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <a href=#url>URL</a> given by the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute of that element, relative to that element.</li> <li><p>If <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> fails, the user agent may report the error to the user in a user-agent-specific manner, may <a href=#navigate>navigate</a><!--DONAV download error--> to an error page to report the error, or may ignore the error and do nothing. In either case, the user agent must abort these steps.</p> <li><p>Otherwise, let <var title="">URL</var> be the resulting <a href=#absolute-url>absolute URL</a>.</li> <li><p>In the case of server-side image maps, append the <var><a href=#hyperlink-suffix>hyperlink suffix</a></var> to <var title="">URL</var>.</li> <li><p>Return to whatever algorithm invoked these steps and continue these steps asynchronously.</li> <li><p><a href=#fetch>Fetch</a> <var title="">URL</var> and handle the resulting resource <a href=#as-a-download>as a download</a>.</li> <!-- http-origin privacy sensitive --> </ol><p>When a user agent is to handle a resource obtained from a <a href=#fetch>fetch</a> algorithm <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>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 recommended to follow it.</p> <!-- but it's optional, since it's not really an interoperability issue --> <ol><li><p>Let <var title="">filename</var> be the void value.</li> <li><p>If the resource has a <code title=http-content-disposition>Content-Disposition</code> header, <!-- Content-Disposition: attachment; filename="" is always honoured, even cross-origin --> that header specifies the <code title="">attachment</code> disposition type, and the header includes a filename parameter, then let <var title="">filename</var> have the value specified by the header, and jump to the step labeled "sanitize" below. <a href=#refsRFC6266>[RFC6266]</a></li> <li><p>Let <var title="">resource origin</var> be the <a href=#origin>origin</a> of the resource being downloaded.</li> <li><p>Let <var title="">interface origin</var> be the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> in which the <a href=#downloading-hyperlinks title="downloading hyperlinks">download</a> or <a href=#navigate>navigate</a> action resulting in the download was initiated, if any.</li> <li><p>If there is no <var title="">interface origin</var>, then let <var title="">trusted operation</var> be true. Otherwise, let <var title="">trusted operation</var> be true if <var title="">resource origin</var> is the <a href=#same-origin>same origin</a> as <var title="">interface origin</var>, and false otherwise.</li> <li><p>If <var title="">trusted operation</var> is true and the <!-- Content-Disposition: *; filename="" overrides download="" for same-origin --> resource has a <code title=http-content-disposition>Content-Disposition</code> header and that header includes a filename parameter, then let <var title="">filename</var> have the value specified by the header, and jump to the step labeled "sanitize" below. <a href=#refsRFC6266>[RFC6266]</a></li> <li><p>If the download was not initiated from a <a href=#hyperlink>hyperlink</a> created by an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element, or if the element of the <a href=#hyperlink>hyperlink</a> from which it was initiated did not have a <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute when the download was initiated, or if there was such an attribute but its value when the download was initiated was the empty string, then jump to the step labeled <i>no proposed filename</i>.</li> <li><p>Let <var title="">proposed filename</var> have the value of the <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute of the element of the <a href=#hyperlink>hyperlink</a> that initiated the download at the time the download was initiated.</li> <li><p>If <var title="">trusted operation</var> is true, let <var title="">filename</var> have the value of <var title="">proposed filename</var>, and jump to the step labeled "sanitize" <!-- download="" works for all links when same-origin --> below.</li> <!-- it is not used cross-origin, though, even for explicit user gestures --> <!-- except: --> <li><p>If the resource has a <code title=http-content-disposition>Content-Disposition</code> header <!-- Content-Disposition: attachment with no filename="" allows download="" cross-origin --> and that header specifies the <code title="">attachment</code> disposition type, let <var title="">filename</var> have the value of <var title="">proposed filename</var>, and jump to the step labeled "sanitize" below. <a href=#refsRFC6266>[RFC6266]</a></li> <li><p><i>No proposed filename</i>: If <var title="">trusted <!-- fallback for same-origin resources or explicit downloads: use the resource's file name --> operation</var> is true, or if the user indicated a preference for having the resource in question downloaded, let <var title="">filename</var> have a value derived from the <a href=#url>URL</a> of the resource in a user-agent-defined manner, and jump to the step labeled "sanitize" below.</li> <li> <p>Act in a user-agent-defined manner to safeguard the user from a <!-- no C-D: a header on cross-origin raises red flags --> potentially hostile cross-origin download. If the download is not to be aborted, then let <var title="">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 "sanitize" 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 title=attr-hyperlink-download><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 filename from the potentially hostile <var title="">interface origin</var> should be ignored.</p> </div> </li> <li><p><i>Sanitize</i>: Optionally, allow the user to influence <var title="">filename</var>. For example, a user agent could prompt the user for a file name, potentially providing the value of <var title="">filename</var> as determined above as a default value.</li> <li> <p>Adjust <var title="">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> <li><p>If the platform conventions do not in any way use <a href=#concept-extension title=concept-extension>extensions</a> to determine the types of file on the file system, then return <var title="">filename</var> as the file name and abort these steps.</li> <li><p>Let <var title="">claimed type</var> be the type given by the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>, if any is known. Let <var title="">named type</var> be the type given by <var title="">filename</var>'s <a href=#concept-extension title=concept-extension>extension</a>, if any is known. For the purposes of this step, a <i>type</i> is a mapping of a <a href=#mime-type>MIME type</a> to an <a href=#concept-extension title=concept-extension>extension</a>.</li> <li><p>If <var title="">named type</var> is consistent with the user's preferences (e.g. because the value of <var title="">filename</var> was determined by prompting the user), then return <var title="">filename</var> as the file name and abort these steps.</li> <li><p>If <var title="">claimed type</var> and <var title="">named type</var> are the same type (i.e. the type given by the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a> is consistent with the type given by <var title="">filename</var>'s <a href=#concept-extension title=concept-extension>extension</a>), then return <var title="">filename</var> as the file name and abort these steps.</li> <li> <p>If the <var title="">claimed type</var> is known, then alter <var title="">filename</var> to add an <a href=#concept-extension title=concept-extension>extension</a> corresponding to <var title="">claimed type</var>.</p> <p>Otherwise, if <var title="">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 title="">filename</var> to add a known-safe <a href=#concept-extension title=concept-extension>extension</a> (e.g. "<code title="">.txt</code>").</p> <p class=note>This last step would make it impossible to download executables, which might not be desireable. As always, implementors are forced to balance security and usability in this matter.</p> </li> <li><p>Return <var title="">filename</var> as the file name.</li> </ol><p>For the purposes of this algorithm, a file <dfn id=concept-extension title=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 title="">.</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 href=#url>URL</a>, and any <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code> attribute, in deciding where to store the resulting file in the user's file system.</p> </div> <!--DOWNLOAD--> <!--PING--> <div class=impl> <h5 id=hyperlink-auditing><span class=secno>4.12.4.1 </span><dfn>Hyperlink auditing</dfn></h5> <p>If a <a href=#hyperlink>hyperlink</a> created by an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element has a <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute, and the user follows the hyperlink, and the value of the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute can be <a href=#resolve-a-url title="resolve a url">resolved</a>, relative to the element, without failure, then the user agent must take the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute's value, <a href=#split-a-string-on-spaces title="split a string on spaces">split that string on spaces</a>, <a href=#resolve-a-url title="resolve a url">resolve</a> each resulting token relative to the element, and then should send a request (as described below) to each of the resulting <a href=#absolute-url title="absolute URL">absolute URLs</a>. (Tokens that fail to resolve are ignored.) This may be done in parallel with the primary request, and is independent of the result of that request.</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 title=http-referer>Referer</code> (sic) headers. Based on the user's preferences, UAs may either <a href=#ignore>ignore</a> the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute altogether, or selectively ignore URLs in the list (e.g. ignoring any third-party URLs).</p> <p>For URLs that are HTTP URLs, the requests must be performed by <a href=#fetch title=fetch>fetching</a> the specified URLs using the POST method, with an entity body with the <a href=#mime-type>MIME type</a> <code><a href=#text/ping>text/ping</a></code> consisting of the four-character string "<code title="">PING</code>", from the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> containing the <a href=#hyperlink>hyperlink</a>. <!-- not http-origin privacy sensitive --> All relevant cookie and HTTP authentication headers must be included in the request. Which other headers are required depends on the URLs involved.</p> <dl class=switch><dt>If both the <a href="#the-document's-address" title="the document's address">address</a> of the <code><a href=#document>Document</a></code> object containing the hyperlink being audited and the ping URL have the <a href=#same-origin>same origin</a></dt> <dd>The request must include a <code title=http-ping-from><a href=#ping-from>Ping-From</a></code> HTTP header with, as its value, the <a href="#the-document's-address" title="the document's address">address</a> of the document containing the hyperlink, and a <code title=http-ping-to><a href=#ping-to>Ping-To</a></code> HTTP header with, as its value, the address of the <a href=#absolute-url>absolute URL</a> of the target of the hyperlink. The request must not include a <code title=http-referer>Referer</code> (sic) HTTP header. <!-- because otherwise it would look like a trustable same-origin POST --></dd> <dt>Otherwise, if the origins are different, but the document containing the hyperlink being audited was not retrieved over an encrypted connection</dt> <dd>The request must include a <code title=http-referer>Referer</code> (sic) HTTP header with, as its value, the <a href="#the-document's-current-address" title="the document's current address">current address</a> of the document containing the hyperlink, a <code title=http-ping-from><a href=#ping-from>Ping-From</a></code> HTTP header with the same value, and a <code title=http-ping-to><a href=#ping-to>Ping-To</a></code> HTTP header with, as its value, the address of the target of the hyperlink.</dd> <dt>Otherwise, the origins are different and the document containing the hyperlink being audited was retrieved over an encrypted connection</dt> <dd>The request must include a <code title=http-ping-to><a href=#ping-to>Ping-To</a></code> HTTP header with, as its value, the address of the target of the hyperlink. The request must neither include a <code title=http-referer>Referer</code> (sic) HTTP header nor include a <code title=http-ping-from><a href=#ping-from>Ping-From</a></code> HTTP header.</dd> </dl><p class=note>To save bandwidth, implementors might also wish to consider omitting optional headers such as <code>Accept</code> from these requests.</p> <p>User agents must, unless otherwise specified by the user, honor the HTTP headers (including, in particular, redirects and HTTP cookie headers), but must ignore any entity bodies returned in the responses. User agents may close the connection prematurely once they start receiving an entity body. <a href=#refsCOOKIES>[COOKIES]</a></p> <p>For URLs that are not HTTP URLs, the requests must be performed by <a href=#fetch title=fetch>fetching</a> the specified URL normally, and discarding the results.</p> <p>When the <code title=attr-hyperlink-ping><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> <div class=note> <p>The <code title=attr-hyperlink-ping><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 title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute provides these advantages to the user over those alternatives:</p> <ul><li>It allows the user to see the final target URL unobscured.</li> <li>It allows the UA to inform the user about the out-of-band notifications.</li> <li>It allows the user to disable the notifications without losing the underlying link functionality.</li> <li>It allows the UA to optimize the use of available network bandwidth so that the target page loads faster.</li> </ul><p>Thus, while it is possible to track users without this feature, authors are encouraged to use the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute so that the user agent can make the user experience more transparent.</p> </div> <!-- resolving ping urls happens at audit time, so base URL changes affect the values of ping attributes --> <!--PING--> <h4 id=linkTypes><span class=secno>4.12.5 </span>Link types</h4> <p>The following table summarizes the link types that are defined by this specification. 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> <div class=impl> <p>To determine which link types apply to a <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, or <code><a href=#the-area-element>area</a></code> element, the element's <code title="">rel</code> attribute must be <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</a>. The resulting tokens are the link types that apply to that element.</p> </div> <p>Except where otherwise specified, a keyword must not be specified more than once per <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute.</p> <p>Link types are always <a href=#ascii-case-insensitive>ASCII case-insensitive</a><span class=impl>, and must be compared as such</span>.</p> <p class=example>Thus, <code title="">rel="next"</code> is the same as <code title="">rel="NEXT"</code>.</p> <table><thead><tr><th rowspan=2>Link type</th> <th colspan=2>Effect on...</th> <th rowspan=2>Brief description</th> <tr><th><code><a href=#the-link-element>link</a></code></th> <th><code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code></th> <tbody><tr><td><code title=rel-alternate><a href=#rel-alternate>alternate</a></code></td> <!-- second most used <link rel> value --> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Gives alternate representations of the current document.</td> <tr><td><code title=rel-author><a href=#link-type-author>author</a></code></td> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Gives a link to the current document's author.</td> <tr><td><code title=rel-bookmark><a href=#link-type-bookmark>bookmark</a></code></td> <!-- fourth most used <a rel> value --> <td><em>not allowed</em></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Gives the permalink for the nearest ancestor section.</td> </tr><!-- (commented out on the assumption that rel=contact is really XFN) <tr> <td><code title="rel-contact">contact</code></td> <!- 8th most used <a rel> value -> <td><span>Hyperlink</span></td> <td><span>Hyperlink</span></td> <td>Gives a link to contact information for the current document.</td> </tr> --><!-- fifth and sixth most used <a rel> value (sixth is "external nofollow"), but moved to the wiki because of http://www.w3.org/Bugs/Public/show_bug.cgi?id=11181 --><!--!--><!-- <tr> <td><code title="rel-external">external</code></td> <td><em>not allowed</em></td> <td><span>Hyperlink</span></td> <td>Indicates that the referenced document is not part of the same site as the current document.</td> </tr> --><tr><td><code title=rel-help><a href=#link-type-help>help</a></code></td> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Provides a link to context-sensitive help.</td> <tr><td><code title=rel-icon><a href=#rel-icon>icon</a></code></td> <!-- link rel="shortcut icon" and its ilk are the fourth, sixth, and ninth most used values --> <td><a href=#external-resource-link title="external resource link">External Resource</a></td> <td><em>not allowed</em></td> <td>Imports an icon to represent the current document.</td> <tr><td><code title=rel-license><a href=#link-type-license>license</a></code></td> <!-- seventh most used <a rel> value --> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Indicates that the main content of the current document is covered by the copyright license described by the referenced document.</td> <tr><td><code title=rel-next><a href=#link-type-next>next</a></code></td> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Indicates that the current document is a part of a series, and that the next document in the series is the referenced document.</td> <tr><td><code title=rel-nofollow><a href=#link-type-nofollow>nofollow</a></code></td> <!-- most used <a rel> value (and sixth most used is "external nofollow") --> <td><em>not allowed</em></td> <td><a href=#hyperlink-annotation title="hyperlink annotation">Annotation</a></td> <td>Indicates that the current document's original author or publisher does not endorse the referenced document.</td> <tr><td><code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code></td> <td><em>not allowed</em></td> <td><a href=#hyperlink-annotation title="hyperlink annotation">Annotation</a></td> <td>Requires that the user agent not send an HTTP <code title=http-referer>Referer</code> (sic) header if the user follows the hyperlink.</td> </tr><!-- used quite a bit; removed for http://www.w3.org/Bugs/Public/show_bug.cgi?id=12224 --><!-- now registered in http://microformats.org/wiki/existing-rel-values#formats --><!-- <tr> <td><code title="rel-pingback">pingback</code></td> <td><span title="external resource link">External Resource</span></td> <td><em>not allowed</em></td> <td>Gives the address of the pingback server that handles pingbacks to the current document.</td> </tr> --><tr><td><code title=rel-prefetch><a href=#link-type-prefetch>prefetch</a></code></td> <td><a href=#external-resource-link title="external resource link">External Resource</a></td> <td><a href=#external-resource-link title="external resource link">External Resource</a></td> <td>Specifies that the target resource should be preemptively cached.</td> <tr><td><code title=rel-prev><a href=#link-type-prev>prev</a></code></td> <!-- prev is used more than previous --> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document.</td> <tr><td><code title=rel-search><a href=#link-type-search>search</a></code></td> <!-- used quite a bit --> <td><a href=#hyperlink>Hyperlink</a></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Gives a link to a resource that can be used to search through the current document and its related pages.</td> </tr><!-- used quite a bit, but dropped due to wg decision in http://www.w3.org/Bugs/Public/show_bug.cgi?id=11183 --><!--!--><!-- <tr> <td><code title="rel-sidebar">sidebar</code></td> <td><span>Hyperlink</span></td> <td><span>Hyperlink</span></td> <td>Specifies that the referenced document, if retrieved, is intended to be shown in the browser's sidebar (if it has one).</td> </tr> --><tr><td><code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code></td> <!-- most commonly used <link rel> value, variants came in 7th, 8th, 12th, 17th... --> <td><a href=#external-resource-link title="external resource link">External Resource</a></td> <td><em>not allowed</em></td> <td>Imports a stylesheet.</td> <tr><td><code title=rel-tag><a href=#link-type-tag>tag</a></code></td> <!-- second and third most used <a rel> value (third is technically "category tag"). --> <td><em>not allowed</em></td> <td><a href=#hyperlink>Hyperlink</a></td> <td>Gives a tag (identified by the given address) that applies to the current document.</td> </table><div class=impl> <p>Some of the types described below list synonyms for these values. These <!--<span class="impl">-->are to be handled as specified by user agents, but<!--</span>--> must not be used in documents.</p> </div> <!-- v2 ideas: * rel="related" // see also * http://microformats.org/wiki/rel-enclosure --> <h5 id=rel-alternate><span class=secno>4.12.5.1 </span>Link type "<dfn title=rel-alternate><code>alternate</code></dfn>"</h5> <p>The <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><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><a href=#the-link-element>link</a></code> element and the <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute also contains the keyword <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code></dt> <dd> <p>The <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword modifies the meaning of the <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> keyword in the way described for that keyword. The <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword does not create a link of its own.</p> </dd> <dt>The <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword is used with the <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attribute set to the value <code title="">application/rss+xml</code> or the value <code title="">application/atom+xml</code></dt> <dd> <p>The keyword creates a <a href=#hyperlink>hyperlink</a> referencing a syndication feed (though not necessarily syndicating exactly the same content as the current page).</p> <div class=impl> <p>The first <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, or <code><a href=#the-area-element>area</a></code> element in the document (in tree order) with the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword used with the <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attribute set to the value <code title="">application/rss+xml</code> or the value <code title="">application/atom+xml</code> must be treated as the default syndication feed for the purposes of feed autodiscovery.</p> <div class=example> <p>The following <code><a href=#the-link-element>link</a></code> element gives the syndication feed for the current page:</p> <pre><link rel="alternate" type="application/atom+xml" href="data.xml"></pre> <p>The following extract offers various different syndication feeds:</p> <pre><p>You can access the planets database using Atom feeds:</p> <ul> <li><a href="recently-visited-planets.xml" rel="alternate" type="application/atom+xml">Recently Visited Planets</a></li> <li><a href="known-bad-planets.xml" rel="alternate" type="application/atom+xml">Known Bad Planets</a></li> <li><a href="unexplored-planets.xml" rel="alternate" type="application/atom+xml">Unexplored Planets</a></li> </ul></pre> </div> </div> </dd> <dt>Otherwise</dt> <dd> <p>The keyword creates a <a href=#hyperlink>hyperlink</a> referencing an alternate representation of the current document.</p> <p>The nature of the referenced document is given by the <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attributes.</p> <p>If the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword is used with the <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code> attribute, it indicates that the referenced document is intended for use with the media specified.</p> <p>If the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword is used with the <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code> attribute, and that attribute's value differs from the <a href=#root-element>root element</a>'s <a href=#language>language</a>, it indicates that the referenced document is a translation.</p> <p>If the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword is used with the <code title=attr-hyperlink-type><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 title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>, <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>, and <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code> attributes can be combined when specified with the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword.</p> <div class=example> <p>For example, the following link is a French translation that uses the PDF format:</p> <pre><link rel=alternate type=application/pdf hreflang=fr href=manual-fr></pre> </div> <p>This relationship is transitive — that is, if a document links to two other documents with the link type "<code title=rel-alternate><a href=#rel-alternate>alternate</a></code>", then, in addition to implying that those documents are alternative representations of the first document, it is also implying that those two documents are alternative representations of each other.</p> </dd> </dl><h5 id=link-type-author><span class=secno>4.12.5.2 </span>Link type "<dfn title=rel-author><code>author</code></dfn>"</h5> <p>The <code title=rel-author><a href=#link-type-author>author</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>For <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements, the <code title=rel-author><a href=#link-type-author>author</a></code> keyword indicates that the referenced document provides further information about the author of the nearest <code><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><a href=#the-link-element>link</a></code> elements, the <code title=rel-author><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 title="">mailto:</code> URL giving the e-mail address of the author. <a href=#refsMAILTO>[MAILTO]</a></p> <div class=impl> <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements that have a <code title="">rev</code> attribute with the value "<code>made</code>" as having the <code title=rel-author><a href=#link-type-author>author</a></code> keyword specified as a link relationship.</p> </div> <h5 id=link-type-bookmark><span class=secno>4.12.5.3 </span>Link type "<dfn title=rel-bookmark><code>bookmark</code></dfn>"</h5> <p>The <code title=rel-bookmark><a href=#link-type-bookmark>bookmark</a></code> keyword may be used with <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-bookmark><a href=#link-type-bookmark>bookmark</a></code> keyword gives a permalink for the nearest ancestor <code><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><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> ... <body> <h1>Example of permalinks</h1> <div id="a"> <h2>First example</h2> <p><a href="a.html" rel="bookmark">This</a> permalink applies to only the content from the first H2 to the second H2. The DIV isn't exactly that section, but it roughly corresponds to it.</p> </div> <h2>Second example</h2> <article id="b"> <p><a href="b.html" rel="bookmark">This</a> permalink applies to the outer ARTICLE element (which could be, e.g., a blog post).</p> <article id="c"> <p><a href="c.html" rel="bookmark">This</a> permalink applies to the inner ARTICLE element (which could be, e.g., a blog comment).</p> </article> </article> </body> ...</pre> </div> <!-- (commented out on the assumption that rel=contact is really XFN) <h5>Link type "<dfn title="rel-contact"><code>contact</code></dfn>"</h5> <p>The <code title="rel-contact">contact</code> keyword may be used with <code>link</code>, <code>a</code>, and <code>area</code> elements. This keyword creates a <span>hyperlink</span>.</p> <p>For <code>a</code> and <code>area</code> elements, the <code title="rel-contact">contact</code> keyword indicates that the referenced document provides further contact information for the author of the nearest <code>article</code> element ancestor of the element defining the hyperlink, if there is one, or of the page as a whole, otherwise.</p> <div class="impl"> <p>User agents must treat any hyperlink in an <code>address</code> element as having the <code title="rel-contact">contact</code> link type specified.</p> </div> <p>For <code>link</code> elements, the <code title="rel-contact">contact</code> keyword indicates that the referenced document provides further contact information for the page as a whole.</p> --> <!-- fifth and sixth most used <a rel> value (sixth is "external nofollow"), but moved to the wiki because of http://www.w3.org/Bugs/Public/show_bug.cgi?id=11181 --> <!--!--> <!-- <h5>Link type "<dfn title="rel-external"><code>external</code></dfn>"</h5> <p>The <code title="rel-external">external</code> keyword may be used with <code>a</code> and <code>area</code> elements. This keyword creates a <span>hyperlink</span>.</p> <p>The <code title="rel-external">external</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.12.5.4 </span>Link type "<dfn title=rel-help><code>help</code></dfn>"</h5> <p>The <code title=rel-help><a href=#link-type-help>help</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>For <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements, the <code title=rel-help><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> <p><label> Topic: <input name=topic> <a href="help/topic.html" rel="help">(Help)</a></label></p></pre> </div> <p>For <code><a href=#the-link-element>link</a></code> elements, the <code title=rel-help><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><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements, on some browsers, the <code title=rel-help><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.12.5.5 </span>Link type "<dfn title=rel-icon><code>icon</code></dfn>"</h5> <p>The <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code> elements. This keyword creates an <a href=#external-resource-link title="external resource link">external resource link</a>.</p> <div class=impl> <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> </div> <p>Icons could be auditory icons, visual icons, or other kinds of icons. <span class=impl>If multiple icons are provided, the user agent must select the most appropriate icon according to the <code title=attr-link-type><a href=#attr-link-type>type</a></code>, <code title=attr-link-media><a href=#attr-link-media>media</a></code>, and <code title=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 href=#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.</span></p> <div class=impl> <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 title=rel-icon><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> </div> <p>The <dfn id=attr-link-sizes title=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.</p> <p>If specified, the attribute must have a value that is an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of unique space-separated tokens</a> which are <a href=#ascii-case-insensitive>ASCII case-insensitive</a>. Each value must be either an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=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 title="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.</p> <p>The keywords represent icon sizes.</p> <div class=impl> <p>To parse and process the attribute's value, the user agent must first <a href=#split-a-string-on-spaces title="split a string on spaces">split the attribute's value on spaces</a>, and must then parse each resulting keyword to determine what it represents.</p> </div> <p>The <dfn id=attr-link-sizes-any title=attr-link-sizes-any><code>any</code></dfn> keyword represents that the resource contains a scalable icon, e.g. as provided by an SVG image.</p> <div class=impl> <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. Abort these steps for that keyword.</li> <li><p>Let <var title="">width string</var> be the string before the "<code title="">x</code>" or "<code title="">X</code>".</li> <li><p>Let <var title="">height string</var> be the string after the "<code title="">x</code>" or "<code title="">X</code>".</li> <li><p>If either <var title="">width string</var> or <var title="">height string</var> start with a U+0030 DIGIT ZERO (0) character or contain any characters other than characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then this keyword doesn't represent anything. Abort these steps for that keyword.</li> <li><p>Apply the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> to <var title="">width string</var> to obtain <var title="">width</var>.</li> <li><p>Apply the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> to <var title="">height string</var> to obtain <var title="">height</var>.</li> <li><p>The keyword represents that the resource contains a bitmap icon with a width of <var title="">width</var> device pixels and a height of <var title="">height</var> device pixels.</li> </ul></div> <p>The keywords specified on the <code title=attr-link-sizes><a href=#attr-link-sizes>sizes</a></code> attribute must not represent icon sizes that are not actually available in the linked resource.</p> <div class=impl> <p>In the absence of a <code><a href=#the-link-element>link</a></code> with the <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword, for <code><a href=#document>Document</a></code>s obtained over HTTP or HTTPS, user agents may instead attempt to <a href=#fetch>fetch</a> and use an icon with the <a href=#absolute-url>absolute URL</a> obtained by resolving the <a href=#url>URL</a> "<code title="">/favicon.ico</code>" against <a href="#the-document's-address">the document's address</a>, as if the page had declared that icon using the <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword.</p> </div> <div class=example> <p>The following snippet shows the top part of an application with several icons.</p> <pre><!DOCTYPE HTML> <html> <head> <title>lsForums — Inbox</title> <link rel=icon href=favicon.png sizes="16x16" type="image/png"> <link rel=icon href=windows.ico sizes="32x32 48x48" type="image/vnd.microsoft.icon"> <link rel=icon href=mac.icns sizes="128x128 512x512 8192x8192 32768x32768"> <link rel=icon href=iphone.png sizes="57x57" type="image/png"> <link rel=icon href=gnome.svg sizes="any" type="image/svg+xml"> <link rel=stylesheet href=lsforums.css> <script src=lsforums.js></script> <meta name=application-name content="lsForums"> </head> <body> ...</pre> </div> <p>For historical reasons, the <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword may be preceded by the keyword "<code title="">shortcut</code>". If the "<code title="">shortcut</code>" keyword is present, it must be come immediately before the <code title=rel-icon><a href=#rel-icon>icon</a></code> keyword and the two keywords must be separated by only a single U+0020 SPACE character.</p> <h5 id=link-type-license><span class=secno>4.12.5.6 </span>Link type "<dfn title=rel-license><code>license</code></dfn>"</h5> <p>The <code title=rel-license><a href=#link-type-license>license</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-license><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><!DOCTYPE HTML> <html> <head> <title>Exampl Pictures: Kissat</title> <link rel="stylesheet" href="/style/default"> </head> <body> <h1>Kissat</h1> <nav> <a href="../">Return to photo index</a> </nav> <figure> <img src="/pix/39627052_fd8dcd98b5.jpg"> <figcaption>Kissat</figcaption> </figure> <p>One of them has six toes!</p> <p><small><a rel="license" href="http://www.opensource.org/licenses/mit-license.php">MIT Licensed</a></small></p> <footer> <a href="/">Home</a> | <a href="../">Photo index</a> <p><small>© copyright 2009 Exampl Pictures. All Rights Reserved.</small></p> </footer> </body> </html></pre> <p>In this case the <code title=rel-license><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> <div class=impl> <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat the keyword "<code title="">copyright</code>" like the <code title=rel-license><a href=#link-type-license>license</a></code> keyword.</p> </div> <h5 id=link-type-nofollow><span class=secno>4.12.5.7 </span>Link type "<dfn title=rel-nofollow><code>nofollow</code></dfn>"</h5> <p>The <code title=rel-nofollow><a href=#link-type-nofollow>nofollow</a></code> keyword may be used with <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements. This keyword does not create a <a href=#hyperlink>hyperlink</a>, but <a href=#hyperlink-annotation title="hyperlink annotation">annotates</a> any other hyperlinks created by the element (the implied hyperlink, if no other keywords create one).</p> <p>The <code title=rel-nofollow><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-noreferrer><span class=secno>4.12.5.8 </span>Link type "<dfn title=rel-noreferrer><code>noreferrer</code></dfn>"</h5> <p>The <code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> keyword may be used with <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements. This keyword does not create a <a href=#hyperlink>hyperlink</a>, but <a href=#hyperlink-annotation title="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> <div class=impl> <p>If a user agent follows a link defined by an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element that has the <code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> keyword, the user agent must not include a <code title=http-referer>Referer</code> (sic) HTTP header (<a href=#concept-http-equivalent-headers title=concept-http-equivalent-headers>or equivalent</a> for other protocols) in the request.</p> <p>This keyword also <a href=#noopener>causes the <code title=dom-opener>opener</code> attribute to remain null</a> if the hyperlink creates a new <a href=#browsing-context>browsing context</a>.</p> </div> <!-- v2: Would be nice to apply this to other elements too, e.g. letting <img> or CSS or <video> hide the referrer --> <!-- used quite a bit; removed for http://www.w3.org/Bugs/Public/show_bug.cgi?id=12224 --> <!-- now registered in http://microformats.org/wiki/existing-rel-values#formats --> <!-- <h5>Link type "<dfn title="rel-pingback"><code>pingback</code></dfn>"</h5> <p>The <code title="rel-pingback">pingback</code> keyword may be used with <code>link</code> elements. This keyword creates an <span title="external resource link">external resource link</span>.</p> <p>For the semantics of the <code title="rel-pingback">pingback</code> keyword, see the Pingback 1.0 specification. <a href="#refsPINGBACK">[PINGBACK]</a></p> --> <h5 id=link-type-prefetch><span class=secno>4.12.5.9 </span>Link type "<dfn title=rel-prefetch><code>prefetch</code></dfn>"</h5> <p>The <code title=rel-prefetch><a href=#link-type-prefetch>prefetch</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates an <a href=#external-resource-link title="external resource link">external resource link</a>.</p> <p>The <code title=rel-prefetch><a href=#link-type-prefetch>prefetch</a></code> keyword indicates that preemptively fetching and caching the specified resource is likely to be beneficial, as it is highly likely that the user will require this resource.</p> <p>There is no default type for resources given by the <code title=rel-prefetch><a href=#link-type-prefetch>prefetch</a></code> keyword.</p> <h5 id=link-type-search><span class=secno>4.12.5.10 </span>Link type "<dfn title=rel-search><code>search</code></dfn>"</h5> <p>The <code title=rel-search><a href=#link-type-search>search</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-search><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><a href=#the-link-element>link</a></code> elements and the <code title=rel-search><a href=#link-type-search>search</a></code> link type to enable user agents to autodiscover search interfaces. <a href=#refsOPENSEARCH>[OPENSEARCH]</a></p> <!-- dropped due to wg decision in http://www.w3.org/Bugs/Public/show_bug.cgi?id=11183 --> <!--!--> <!-- <h5>Link type "<dfn title="rel-sidebar"><code>sidebar</code></dfn>"</h5> <p>The <code title="rel-sidebar">sidebar</code> keyword may be used with <code>link</code>, <code>a</code>, and <code>area</code> elements. This keyword creates a <span>hyperlink</span>.</p> <p>The <code title="rel-sidebar">sidebar</code> keyword indicates that the referenced document, if retrieved, is intended to be shown in a <span>secondary browsing context</span> (if possible), instead of in the current <span>browsing context</span>.</p> <p>A <span>hyperlink</span> with the <code title="rel-sidebar">sidebar</code> keyword specified is a <dfn title="rel-sidebar-hyperlink">sidebar hyperlink</dfn>.</p> --> <h5 id=link-type-stylesheet><span class=secno>4.12.5.11 </span>Link type "<dfn title=rel-stylesheet><code>stylesheet</code></dfn>"</h5> <p>The <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code> elements. This keyword creates an <a href=#external-resource-link title="external resource link">external resource link</a> that contributes to the <a href=#styling>styling processing model</a>.</p> <p>The specified resource is a resource that describes how to present the document. Exactly how the resource is to be processed depends on the actual type of the resource.</p> <p>If the <code title=rel-alternate><a href=#rel-alternate>alternate</a></code> keyword is also specified on the <code><a href=#the-link-element>link</a></code> element, then <dfn id=the-link-is-an-alternative-stylesheet>the link is an alternative stylesheet</dfn>; in this case, the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute must be specified on the <code><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 title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code> keyword is <code title="">text/css</code>.</p> <div class=impl> <p>The appropriate time to <a href=#concept-link-obtain title=concept-link-obtain>obtain</a> the resource is when the <a href=#external-resource-link title="external resource link">external resource link</a> is created or when its element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a document</a>, whichever happens last. If the resource is <a href=#the-link-is-an-alternative-stylesheet title="the link is an alternative stylesheet">an alternative stylesheet</a> then the user agent may defer obtaining the resource until it is part of the <a href=#preferred-style-sheet-set>preferred style sheet set</a>. <a href=#refsCSSOM>[CSSOM]</a></p> <!-- what about DOM access of alt style sheets? --> <p><strong>Quirk</strong>: If the document has been set to <a href=#quirks-mode>quirks mode</a>, has the <a href=#same-origin>same origin</a> as the <a href=#url>URL</a> of the external resource<!-- CVE-2010-0654 -->, and the <a href=#content-type title=Content-Type>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 title="">text/css</code>.</p> </div> <h5 id=link-type-tag><span class=secno>4.12.5.12 </span>Link type "<dfn title=rel-tag><code>tag</code></dfn>"</h5> <p>The <code title=rel-tag><a href=#link-type-tag>tag</a></code> keyword may be used with <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-tag><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> <h5 id=sequential-link-types><span class=secno>4.12.5.13 </span>Sequential link types</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.12.5.13.1 </span>Link type "<dfn title=rel-next><code>next</code></dfn>"</h6> <p>The <code title=rel-next><a href=#link-type-next>next</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-next><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> <h6 id=link-type-prev><span class=secno>4.12.5.13.2 </span>Link type "<dfn title=rel-prev><code>prev</code></dfn>"</h6> <p>The <code title=rel-prev><a href=#link-type-prev>prev</a></code> keyword may be used with <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements. This keyword creates a <a href=#hyperlink>hyperlink</a>.</p> <p>The <code title=rel-prev><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> <div class=impl> <p><strong>Synonyms</strong>: For historical reasons, user agents must also treat the keyword "<code title="">previous</code>" like the <code title=rel-prev><a href=#link-type-prev>prev</a></code> keyword.</p> </div> <h5 id=other-link-types><span class=secno>4.12.5.14 </span>Other link types</h5> <!-- XXX should update this section to more closely match the wiki --> <!-- possibly also applying the principles described here: http://lists.w3.org/Archives/Public/public-html/2011Mar/0497.html --> <p><dfn id=concept-rel-extensions title=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 title="">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</dt> <dd> <p>The actual value being defined. The value should not be confusingly similar to any other defined value (e.g. differing only in case).</p> <p>If the value contains a U+003A COLON character (:), it must also be an <a href=#absolute-url>absolute URL</a>.</p> </dd> <dt>Effect on... <code><a href=#the-link-element>link</a></code></dt> <dd> <p>One of the following:</p> <dl><dt>Not allowed</dt> <dd>The keyword must not be specified on <code><a href=#the-link-element>link</a></code> elements.</dd> <dt>Hyperlink</dt> <dd>The keyword may be specified on a <code><a href=#the-link-element>link</a></code> element; it creates a <a href=#hyperlink>hyperlink</a>.</dd> <dt>External Resource</dt> <dd>The keyword may be specified on a <code><a href=#the-link-element>link</a></code> element; it creates an <a href=#external-resource-link>external resource link</a>.</dd> </dl></dd> <dt>Effect on... <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code></dt> <dd> <p>One of the following:</p> <dl><dt>Not allowed</dt> <dd>The keyword must not be specified on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements.</dd> <dt>Hyperlink</dt> <dd>The keyword may be specified on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements; it creates a <a href=#hyperlink>hyperlink</a>.</dd> <dt>External Resource</dt> <dd>The keyword may be specified on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements; it creates an <a href=#external-resource-link>external resource link</a>.</dd> <dt>Hyperlink Annotation</dt> <dd>The keyword may be specified on <code><a href=#the-a-element>a</a></code> and <code><a href=#the-area-element>area</a></code> elements; it <a href=#hyperlink-annotation title="hyperlink annotation">annotates</a> other <a href=#hyperlink title=hyperlink>hyperlinks</a> created by the element.</dd> </dl></dd> <dt>Brief description</dt> <dd><p>A short non-normative description of what the keyword's meaning is.</dd> <dt>Specification</dt> <dd><p>A link to a more detailed description of the keyword's semantics and requirements. It could be another page on the Wiki, or a link to an external page.</dd> <dt>Synonyms</dt> <dd><p>A list of other keyword values that have exactly the same processing requirements. Authors should not use the values defined to be synonyms, they are only intended to allow user agents to support legacy content. Anyone may remove synonyms that are not used in practice; only names that need to be processed as synonyms for compatibility with legacy content are to be registered in this way.</dd> <dt>Status</dt> <dd> <p>One of the following:</p> <dl><dt>Proposed</dt> <dd>The keyword has not received wide peer review and approval. Someone has proposed it and is, or soon will be, using it.</dd> <dt>Ratified</dt> <dd>The keyword has received wide peer review and approval. It has a specification that unambiguously defines how to handle pages that use the keyword, including when they use it in incorrect ways.</dd> <dt>Discontinued</dt> <dd>The keyword has received wide peer review and it has been found wanting. Existing pages are using this keyword, but new pages should avoid it. The "brief description" and "specification" entries will give details of what authors should use instead, if anything.</dd> </dl><p>If a keyword is found to be redundant with existing values, it should be removed and listed as a synonym for the existing value.</p> <p>If a keyword is registered in the "proposed" state for a period of a month or more without being used or specified, then it may be removed from the registry.</p> <p>If a keyword is added with the "proposed" status and found to be redundant with existing values, it should be removed and listed as a synonym for the existing value. If a keyword is added with the "proposed" status and found to be harmful, then it should be changed to "discontinued" status.</p> <p>Anyone can change the status at any time, but should only do so in accordance with the definitions above.</p> </dd> </dl><div class=impl> <p>Conformance checkers must use the information given on the <span title="">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> </div> <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 title="">rel</code> attribute on <code><a href=#the-link-element>link</a></code>, <code><a href=#the-a-element>a</a></code>, and <code><a href=#the-area-element>area</a></code> elements in accordance to the "Effect on..." field. <a href=#refsMFREL>[MFREL]</a></p> <h3 id=common-idioms><span class=secno>4.13 </span>Common idioms without dedicated elements</h3> <h4 id=the-main-part-of-the-content><span class=secno>4.13.1 </span>The main part of the content</h4> <p>The main content of a page — not including headers and footers, navigation links, sidebars, advertisements, and so forth — can be marked up in a variety of ways, depending on the needs of the author.</p> <p>The simplest solution is to not mark up the main content at all, and just leave it as implicit. Another way to think of this is that the <code><a href=#the-body-element>body</a></code> elements marks up the main content of the page, and the bits that aren't main content are excluded through the use of more appropriate elements like <code><a href=#the-aside-element>aside</a></code> and <code><a href=#the-nav-element>nav</a></code>.</p> <div class=example> <p>Here is a short Web page marked up along this minimalistic school of thought. The main content is highlighted. Notice how all the <em>other</em> content in the <code><a href=#the-body-element>body</a></code> is marked up with elements to indicate that it's not part of the main content, in this case <code><a href=#the-header-element>header</a></code>, <code><a href=#the-nav-element>nav</a></code>, and <code><a href=#the-footer-element>footer</a></code>.</p> <pre><!DOCTYPE HTML> <html> <head> <title> My Toys </title> </head> <body> <header> <h1>My toys</h1> </header> <nav> <p><a href="/">Home</a></p> <p><a href="/contact">Contact</a></p> </nav> <strong> <p>I really like my chained book and my telephone. I'm not such a fan of my big ball.</p> <p>Another toy I like is my mirror.</p></strong> <footer> <p>© copyright 2010 by the boy</p> </footer> </body> </html></pre> </div> <p>If the main content is an independent unit of content that one could imagine syndicating independently, then the <code><a href=#the-article-element>article</a></code> element would be appropriate to mark up the main content of the document.</p> <div class=example> <p>The document in the previous example is here recast as a blog post:</p> <pre><!DOCTYPE HTML> <html> <head> <title> The Boy Blog: My Toys </title> </head> <body> <header> <h1>The Boy Blog</h1> </header> <nav> <p><a href="/">Home</a></p> <p><a href="/contact">Contact</a></p> </nav> <strong> <article> <header> <h1>My toys</h1> <p>Published August 4th</p> </header> <p>I really like my chained book and my telephone. I'm not such a fan of my big ball.</p> <p>Another toy I like is my mirror.</p> </article></strong> <footer> <p>© copyright 2010 by the boy</p> </footer> </body> </html></pre> </div> <p>If the main content is not an independent unit of content so much as a section of a larger work, for instance a chapter, then the <code><a href=#the-section-element>section</a></code> element would be appropriate to mark up the main content of the document.</p> <div class=example> <p>Here is the same document, case as a chapter in an online book:</p> <pre><!DOCTYPE HTML> <html> <head> <title> Chapter 2: My Toys — The Book of the Boy </title> </head> <body> <header> <h1>Chapter 2: My Toys</h1> </header> <nav> <p><a href="/">Front Page</a></p> <p><a href="/toc">Table of Contents</a></p> <p><a href="/c1">Chapter 1</a> — <a href="/c3">Chapter 3</a></p> </nav> <strong> <section> <p>I really like my chained book and my telephone. I'm not such a fan of my big ball.</p> <p>Another toy I like is my mirror.</p> </section></strong> <footer> <p>© copyright 2010 by the boy</p> </footer> </body> </html></pre> </div> <p>If neither <code><a href=#the-article-element>article</a></code> nor <code><a href=#the-section-element>section</a></code> would be appropriate, but the main content still needs an explicit element, for example for styling purposes, then the <code><a href=#the-div-element>div</a></code> element can be used.</p> <div class=example> <p>This is the same as the original example, but using <code><a href=#the-div-element>div</a></code> for the main content instead of leaving it implied:</p> <pre><!DOCTYPE HTML> <html> <head> <title> My Toys </title> <style> body > div { background: navy; color: yellow; } </style> </head> <body> <header> <h1>My toys</h1> </header> <nav> <p><a href="/">Home</a></p> <p><a href="/contact">Contact</a></p> </nav> <strong> <div> <p>I really like my chained book and my telephone. I'm not such a fan of my big ball.</p> <p>Another toy I like is my mirror.</p> </div></strong> <footer> <p>© copyright 2010 by the boy</p> </footer> </body> </html></pre> </div> <h4 id=rel-up><span class=secno>4.13.2 </span>Bread crumb navigation</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><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><nav> <p> <a href="/">Main</a> > <a href="/products/">Products</a> > <a href="/products/dishwashers/">Dishwashers</a> > <a>Second hand</a> </p> <p> <a href="/">Main</a> > <a href="/second-hand/">Second hand</a> > <a>Dishwashers</a> </p> </nav></pre> </div> <h4 id=tag-clouds><span class=secno>4.13.3 </span>Tag clouds</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><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><style> @media screen, print, handheld, tv { /* should be ignored by non-visual browsers */ .tag-cloud > li > span { display: none; } .tag-cloud > li { display: inline; } .tag-cloud-1 { font-size: 0.7em; } .tag-cloud-2 { font-size: 0.9em; } .tag-cloud-3 { font-size: 1.1em; } .tag-cloud-4 { font-size: 1.3em; } .tag-cloud-5 { font-size: 1.5em; } } </style> ... <ul class="tag-cloud"> <li class="tag-cloud-4"><a title="28 instances" href="/t/apple">apple</a> <span>(popular)</span> <li class="tag-cloud-2"><a title="6 instances" href="/t/kiwi">kiwi</a> <span>(rare)</span> <li class="tag-cloud-5"><a title="41 instances" href="/t/pear">pear</a> <span>(very popular)</span> </ul></pre> <p>The actual frequency of each tag is given using the <code title=attr-title><a href=#the-title-attribute>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><a href=#the-ul-element>ul</a></code> element is used (rather than <code><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 title=rel-tag><a href=#link-type-tag>tag</a></code> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>-keyword is <em>not</em> used on these <code><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.13.4 </span>Conversations</h4> <!-- http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/022576.html --> <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><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><a href=#the-span-element>span</a></code> or <code><a href=#the-b-element>b</a></code>. Paragraphs with their text wrapped in the <code><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><p> Costello: Look, you gotta first baseman? <p> Abbott: Certainly. <p> Costello: Who's playing first? <p> Abbott: That's right. <p> Costello becomes exasperated. <p> Costello: When you pay off the first baseman every month, who gets the money? <p> Abbott: Every dollar of it.</pre> </div> <div class=example> <p>The following extract shows how an IM conversation log could be marked up, using the <code><a href=#the-data-element>data</a></code> element to provide Unix timestamps for each line.</p> <pre><p> <data value="1319898155">14:22</data> <b>egof</b> I'm not that nerdy, I've only seen 30% of the star trek episodes <p> <data value="1319898192">14:23</data> <b>kaj</b> if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy <p> <data value="1319898200">14:23</data> <b>egof</b> it's unarguably <p> <data value="1319898228">14:23</data> <i>* kaj blinks</i> <p> <data value="1319898260">14:24</data> <b>kaj</b> you are not helping your case</pre> <!-- with thanks to http://bash.org/?854262 --> </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><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><p> Next, you meet a fisherman. You can say one of several greetings: <dl> <dt> "Hello there!" <dd> <p> He responds with "Hello, how may I help you?"; you can respond with: <dl> <dt> "I would like to buy a fish." <dd> <p> He sells you a fish and the conversation finishes. <dt> "Can I borrow your boat?" <dd> <p> He is surprised and asks "What are you offering in return?". <dl> <dt> "Five gold." (if you have enough) <dt> "Ten gold." (if you have enough) <dt> "Fifteen gold." (if you have enough) <dd> <p> He lends you his boat. The conversation ends. <dt> "A fish." (if you have one) <dt> "A newspaper." (if you have one) <dt> "A pebble." (if you have one) <dd> <p> "No thanks", he replies. Your conversation options at this point are the same as they were after asking to borrow his boat, minus any options you've suggested before. </dl> </dd> </dl> </dd> <dt> "Vote for me in the next election!" <dd> <p> He turns away. The conversation finishes. <dt> "Sir, are you aware that your fish are running away?" <dd> <p> He looks at you skeptically and says "Fish cannot run, sir". <dl> <dt> "You got me!" <dd> <p> The fisherman sighs and the conversation ends. <dt> "Only kidding." <dd> <p> "Good one!" he retorts. Your conversation options at this point are the same as those following "Hello there!" above. <dt> "Oh, then what are they doing?" <dd> <p> He looks at his fish, giving you an opportunity to steal his boat, which you do. The conversation ends. </dl> </dd> </ul></pre> </div> <h4 id=footnotes><span class=secno>4.13.5 </span>Footnotes</h4> <p>HTML does not have a dedicated mechanism for marking up footnotes. Here are the recommended alternatives.</p> <hr><p>For short inline annotations, the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute should be used.</p> <div class=example> <p>In this example, two parts of a dialogue are annotated with footnote-like content using the <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute.</p> <pre><p> <b>Customer</b>: Hello! I wish to register a complaint. Hello. Miss? <p> <b>Shopkeeper</b>: <strong><span title="Colloquial pronunciation of 'What do you'"</strong> >Watcha</span> mean, miss? <p> <b>Customer</b>: Uh, I'm sorry, I have a cold. I wish to make a complaint. <p> <b>Shopkeeper</b>: Sorry, <span <strong>title="This is, of course, a lie."</strong>>we're closing for lunch</span>.</pre> </div> <hr><p>For longer annotations, the <code><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><p> Announcer: Number 16: The <i>hand</i>. <p> 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 <em>do</em> you contradict people? <p> Norman: I don't. <sup><a href="#fn1" id="r1">[1]</a></sup> <p> Interviewer: You told me you did! <em>...</em> <section> <p id="fn1"><a href="#r1">[1]</a> 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.</p> </section></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><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><p> <span class="speaker">Customer</span>: I will not buy this record, it is scratched. <p> <span class="speaker">Shopkeeper</span>: I'm sorry? <p> <span class="speaker">Customer</span>: I will not buy this record, it is scratched. <p> <span class="speaker">Shopkeeper</span>: No no no, this's'a tobacconist's. <aside> <p>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. </aside></pre> </div> <hr><p>For figures or tables, footnotes can be included in the relevant <code><a href=#the-figcaption-element>figcaption</a></code> or <code><a href=#the-caption-element>caption</a></code> element, or in surrounding prose.</p> <div class=example> <p>In this example, a <!-- round --> table has cells with footnotes that are given in prose. A <code><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><figure> <figcaption>Table 1. Alternative activities for knights.</figcaption> <table> <tr> <th> Activity <th> Location <th> Cost <tr> <td> Dance <td> Wherever possible <td> £0<sup><a href="#fn1">1</a></sup> <tr> <td> Routines, chorus scenes<sup><a href="#fn2">2</a></sup> <td> Undisclosed <td> Undisclosed <tr> <td> Dining<sup><a href="#fn3">3</a></sup> <td> Camelot <td> Cost of ham, jam, and spam<sup><a href="#fn4">4</a></sup> </table> <p id="fn1">1. Assumed.</p> <p id="fn2">2. Footwork impeccable.</p> <p id="fn3">3. Quality described as "well".</p> <p id="fn4">4. A lot.</p> </figure></pre> </div> <div class=impl> <h3 id=selectors><span class=secno>4.14 </span>Matching HTML elements using selectors</h3> <h4 id=case-sensitivity><span class=secno>4.14.1 </span>Case-sensitivity</h4> <p>The Selectors specification leaves the case-sensitivity of IDs, classes, element names, attribute names, and attribute values to be defined by the host language. <a href=#refsSELECTORS>[SELECTORS]</a></p> <p>The <a href=#concept-id title=concept-id>unique identifier</a> of <a href=#html-elements>HTML elements</a> in documents that are in <a href=#quirks-mode>quirks mode</a> must be treated as <a href=#ascii-case-insensitive>ASCII case-insensitive</a> for the purposes of selector matching.</p> <p>Classes from the <code title=attr-class><a href=#classes>class</a></code> attribute of <a href=#html-elements>HTML elements</a> in documents that are in <a href=#quirks-mode>quirks mode</a> must be treated as <a href=#ascii-case-insensitive>ASCII case-insensitive</a> for the purposes of selector matching.</p> <p>Attribute and element <em>names</em> of <a href=#html-elements>HTML elements</a> in <a href=#html-documents>HTML documents</a> must be treated as <a href=#ascii-case-insensitive>ASCII case-insensitive</a> for the purposes of selector matching.</p> <p>Everything else (attribute values on <a href=#html-elements>HTML elements</a>, IDs and classes in <a href=#no-quirks-mode>no-quirks mode</a> and <a href=#limited-quirks-mode>limited-quirks mode</a>, and element names, attribute names, and attribute values in <a href=#xml-documents>XML documents</a>) must be treated as <a href=#case-sensitive>case-sensitive</a> for the purposes of selector matching.</p> <h4 id=pseudo-classes><span class=secno>4.14.2 </span>Pseudo-classes</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-link title=selector-link><code>:link</code></dfn></dt> <dt><dfn id=selector-visited title=selector-visited><code>:visited</code></dfn></dt> <dd> <p>All <code><a href=#the-a-element>a</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, all <code><a href=#the-area-element>area</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, and all <code><a href=#the-link-element>link</a></code> elements that have an <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute, must match one of <code title=selector-link><a href=#selector-link>:link</a></code> and <code title=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 pseudo-elements, to mitigate some privacy concerns that apply with straightforward implementations of this requirement.</p> </dd> <dt><dfn id=selector-active title=selector-active><code>:active</code></dfn></dt> <dd> <p>The <code title=selector-active><a href=#selector-active>:active</a></code> pseudo-class is defined to match an element <q cite=http://dev.w3.org/csswg/selectors3/#the-user-action-pseudo-classes-hover-act>while an element is <i>being activated</i> by the user</q>. For the purposes of defining the <code title=selector-active><a href=#selector-active>:active</a></code> pseudo-class only, an HTML user agent must consider an element as <i>being activated</i> if it is:</p> <ul><li> <p>An element falling into one of the following categories between the time the user begins to indicate an intent to trigger the element's <a href=#activation-behavior>activation behavior</a> and either the time the user stops indicating an intent to trigger the element's <a href=#activation-behavior>activation behavior</a>, or the time the element's <a href=#activation-behavior>activation behavior</a> has finished running, which ever comes first:</p> <ul><li><code><a href=#the-a-element>a</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</li> <li><code><a href=#the-area-element>area</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</li> <li><code><a href=#the-link-element>link</a></code> elements that have an <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute</li> <li><code><a href=#the-button-element>button</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a>, <a href=#image-button-state title=attr-input-type-image>Image Button</a>, <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>, or <a href=#button-state title=attr-input-type-button>Button</a> state</li> <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li> <li>elements that are <a href=#specially-focusable>specially focusable</a></li> </ul><p class=example>For example, if the user is using a keyboard to push a <code><a href=#the-button-element>button</a></code> element by pressing the space bar, the element would match this pseudo-class in between the time that the element received the <code title=event-keydown>keydown</code> event and the time the element received the <code title=event-keyup>keyup</code> event.</p> </li> <li> <p>An element that the user indicates 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).</p> </li> <li> <p>An element that has a descendant that is currently matching the <code title=selector-active><a href=#selector-active>:active</a></code> pseudo-class.</p> </li> </ul></dd> <dt><dfn id=selector-enabled title=selector-enabled><code>:enabled</code></dfn></dt> <dd> <p>The <code title=selector-enabled><a href=#selector-enabled>:enabled</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-a-element>a</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</li> <li><code><a href=#the-area-element>area</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</li> <li><code><a href=#the-link-element>link</a></code> elements that have an <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute</li> <li><code><a href=#the-button-element>button</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute are not in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-select-element>select</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-optgroup-element>optgroup</a></code> elements that do not have a <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code> attribute</li> <li><code><a href=#the-option-element>option</a></code> elements that are not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li> <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li> <li><code><a href=#the-li-element>li</a></code> elements that are children of <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that defines a <a href=#concept-command title=concept-command>command</a>, if the first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet is false (not disabled)</li> <li><code><a href=#the-fieldset-element>fieldset</a></code> elements that do not have a <code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>disabled</a></code> attribute</li> </ul></dd> <dt><dfn id=selector-disabled title=selector-disabled><code>:disabled</code></dfn></dt> <dd> <p>The <code title=selector-disabled><a href=#selector-disabled>:disabled</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-button-element>button</a></code> elements that are <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute are not in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state and that are <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-select-element>select</a></code> elements that are <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that are <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-optgroup-element>optgroup</a></code> elements that have a <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code> attribute</li> <li><code><a href=#the-option-element>option</a></code> elements that are <a href=#concept-option-disabled title=concept-option-disabled>disabled</a></li> <li><code><a href=#the-command-element>command</a></code> elements that have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li> <li><code><a href=#the-li-element>li</a></code> elements that are children of <code><a href=#the-menu-element>menu</a></code> elements, and that have a child element that defines a <a href=#concept-command title=concept-command>command</a>, if the first such element's <a href=#command-facet-disabledstate title=command-facet-disabledstate>Disabled State</a> facet is true (disabled)</li> <li><code><a href=#the-fieldset-element>fieldset</a></code> elements that have a <code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>disabled</a></code> attribute</li> </ul></dd> <dt><dfn id=selector-checked title=selector-checked><code>:checked</code></dfn></dt> <dd> <p>The <code title=selector-checked><a href=#selector-checked>:checked</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state and whose <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state is true</li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state and whose <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> state is true</li> <li><code><a href=#the-option-element>option</a></code> elements whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true</li> <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-checkbox title=attr-command-type-state-checkbox>Checkbox</a> state and that have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute</li> <li><code><a href=#the-command-element>command</a></code> elements whose <code title=attr-command-type><a href=#attr-command-type>type</a></code> attribute is in the <a href=#attr-command-type-state-radio title=attr-command-type-state-radio>Radio</a> state and that have a <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code> attribute</li> </ul></dd> <dt><dfn id=selector-indeterminate title=selector-indeterminate><code>:indeterminate</code></dfn></dt> <dd> <!-- does this pseudo-class even exist? --> <p>The <code title=selector-indeterminate><a href=#selector-indeterminate>:indeterminate</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state and whose <code title=dom-input-indeterminate><a href=#dom-input-indeterminate>indeterminate</a></code> IDL attribute is set to true</li> <li><code><a href=#the-progress-element>progress</a></code> elements with no <code title=attr-progress-value><a href=#attr-progress-value>value</a></code> content attribute</li> </ul></dd> <dt><dfn id=selector-default title=selector-default><code>:default</code></dfn></dt> <dd> <p>The <code title=selector-default><a href=#selector-default>:default</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-button-element>button</a></code> elements that are their form's <a href=#default-button>default button</a></li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a> or <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, and that are their form's <a href=#default-button>default button</a></li> <li><code><a href=#the-input-element>input</a></code> elements to which the <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> attribute applies and that have a <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code> attribute</li> <li><code><a href=#the-option-element>option</a></code> elements that have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute</li> <!-- <li><code>command</code> elements that have a <code title="attr-command-default">default</code> attribute</li> --> </ul></dd> <dt><dfn id=selector-valid title=selector-valid><code>:valid</code></dfn></dt> <dd> <p>The <code title=selector-valid><a href=#selector-valid>:valid</a></code> pseudo-class must match all elements that are <a href=#candidate-for-constraint-validation title="candidate for constraint validation">candidates for constraint validation</a> and that <a href=#concept-fv-valid title=concept-fv-valid>satisfy their constraints</a>.</p> </dd> <dt><dfn id=selector-invalid title=selector-invalid><code>:invalid</code></dfn></dt> <dd> <p>The <code title=selector-invalid><a href=#selector-invalid>:invalid</a></code> pseudo-class must match all elements that are <a href=#candidate-for-constraint-validation title="candidate for constraint validation">candidates for constraint validation</a> but that do not <a href=#concept-fv-valid title=concept-fv-valid>satisfy their constraints</a>.</p> </dd> <dt><dfn id=selector-in-range title=selector-in-range><code>:in-range</code></dfn></dt> <dd> <p>The <code title=selector-in-range><a href=#selector-in-range>:in-range</a></code> pseudo-class must match all elements that are <a href=#candidate-for-constraint-validation title="candidate for constraint validation">candidates for constraint validation</a>, <a href=#have-range-limitations>have range limitations</a>, and that are neither <a href=#suffering-from-an-underflow>suffering from an underflow</a> nor <a href=#suffering-from-an-overflow>suffering from an overflow</a>.</p> </dd> <dt><dfn id=selector-out-of-range title=selector-out-of-range><code>:out-of-range</code></dfn></dt> <dd> <p>The <code title=selector-out-of-range><a href=#selector-out-of-range>:out-of-range</a></code> pseudo-class must match all elements that are <a href=#candidate-for-constraint-validation title="candidate for constraint validation">candidates for constraint validation</a>, <a href=#have-range-limitations>have range limitations</a>, and that are either <a href=#suffering-from-an-underflow>suffering from an underflow</a> or <a href=#suffering-from-an-overflow>suffering from an overflow</a>.</p> </dd> <dt><dfn id=selector-required title=selector-required><code>:required</code></dfn></dt> <dd> <p>The <code title=selector-required><a href=#selector-required>:required</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-input-element>input</a></code> elements that are <i title=concept-input-required><a href=#concept-input-required>required</a></i></li> <li><code><a href=#the-select-element>select</a></code> elements that have a <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute</li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that have a <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute</li> </ul></dd> <dt><dfn id=selector-optional title=selector-optional><code>:optional</code></dfn></dt> <dd> <p>The <code title=selector-optional><a href=#selector-optional>:optional</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-input-element>input</a></code> elements to which the <code title=attr-input-required><a href=#attr-input-required>required</a></code> attribute applies that are not <i title=concept-input-required><a href=#concept-input-required>required</a></i></li> <li><code><a href=#the-select-element>select</a></code> elements that do not have a <code title=attr-select-required><a href=#attr-select-required>required</a></code> attribute</li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that do not have a <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code> attribute</li> </ul></dd> <dt><dfn id=selector-read-only title=selector-read-only><code>:read-only</code></dfn></dt> <dt><dfn id=selector-read-write title=selector-read-write><code>:read-write</code></dfn></dt> <dd> <p>The <code title=selector-read-write><a href=#selector-read-write>:read-write</a></code> pseudo-class must match any element falling into one of the following categories:</p> <ul><li><code><a href=#the-input-element>input</a></code> elements to which the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute applies, but that are not <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i> (i.e. that do not have the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute specified and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>)</li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that do not have a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute, and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li>elements that are <a href=#editing-host title="editing host">editing hosts</a> or <a href=#editable>editable</a> and are neither <code><a href=#the-input-element>input</a></code> elements nor <code><a href=#the-textarea-element>textarea</a></code> elements</li> </ul><p>The <code title=selector-read-only><a href=#selector-read-only>:read-only</a></code> pseudo-class must match all other <a href=#html-elements>HTML elements</a>.</p> </dd> <dt><dfn id=selector-ltr title=selector-ltr><code>:dir(ltr)</code></dfn></dt> <dd> <p>The <code title=selector-ltr><a href=#selector-ltr>:dir(ltr)</a></code> pseudo-class must match all elements whose <a href=#the-directionality title="the directionality">directionality</a> is '<a href=#concept-ltr title=concept-ltr>ltr</a>'.</p> </dd> <dt><dfn id=selector-rtl title=selector-rtl><code>:dir(rtl)</code></dfn></dt> <dd> <p>The <code title=selector-rtl><a href=#selector-rtl>:dir(rtl)</a></code> pseudo-class must match all elements whose <a href=#the-directionality title="the directionality">directionality</a> is '<a href=#concept-rtl title=concept-rtl>rtl</a>'.</p> </dd> </dl><p class=note>Another section of this specification defines the <i><a href=#target-element>target element</a></i> used with the <code title=selector-target>:target</code> pseudo-class.</p> <p class=note>This specification does not define when an element matches the <code title=selector-hover>:hover</code>, <code title=selector-focus>:focus</code>, or <code title=selector-lang()>:lang()</code> dynamic pseudo-classes, as those are all defined in sufficient detail in a language-agnostic fashion in the Selectors specification. <a href=#refsSELECTORS>[SELECTORS]</a></p> </div> <!--MD--> <div data-component="HTML Microdata (editor: Ian Hickson)"> <h2 id=microdata><span class=secno>5 </span><dfn>Microdata</dfn></h2> <!-- USE CASES Getting data out of poorly written Web pages http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019595.html Allowing authors to keep track of where content originates http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019620.html Helping people seaching for content filtered by license http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019668.html Allowing authors to annotate their documents to explain things for readers http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019672.html Annotating structured data that HTML has no semantics for http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019681.html Exposing known data types in a reusable way http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019833.html Providing enhanced search results http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019834.html Dragging or copying data between sites http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019835.html Writing authoring tools and validators for custom microdata vocabularies http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019839.html Removing the need for separate feeds http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019884.html Use cases for which I haven't been able to find solutions http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019886.html --> <!-- v2 * <itemref itemprop="foo" src="url#id"> to import the item with id="id" from url into the current microdata block as the value of property foo? * splitting the 'content' part of a property into multiple sub-bits, as in: <span itemprop="tel" item-content-in-bits> Telephone: <span content-bit>+44</span> (0) <span content-bit>1223 123 123</span> </span> maybe vocabs that need this can use a sub vocabulary specifically for this: <span itemprop="tel" itemscope itemtype="http://bits.example/"> Telephone: <span itemprop=bit>+44</span> (0) <span itemprop=bit>1223 123 123</span> </span> --> <h3 id=introduction-5><span class=secno>5.1 </span>Introduction</h3> <h4 id=overview><span class=secno>5.1.1 </span>Overview</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 customised 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</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 title=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 title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute is used.</p> <p>To add a property to an item, the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is used on one of the <a href=#concept-item title=concept-item>item's</a> descendants.</p> <div class=example> <p>Here there are two items, each of which has the property "name":</p> <pre><div itemscope> <p>My name is <span itemprop="name">Elizabeth</span>.</p> </div> <div itemscope> <p>My name is <span itemprop="name">Daniel</span>.</p> </div></pre> </div> <p>Properties generally have values that are strings.</p> <div class=example> <p>Here the item has three properties:</p> <pre><div itemscope> <p>My name is <span itemprop="name">Neil</span>.</p> <p>My band is called <span itemprop="band">Four Parts Water</span>.</p> <p>I am <span itemprop="nationality">British</span>.</p> </div></pre> </div> <p>When a string value is a <a href=#url title=URL>URLs</a>, it is expressed using the <code><a href=#the-a-element>a</a></code> element and its <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, the <code><a href=#the-img-element>img</a></code> element and its <code title=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><div itemscope> <img itemprop="image" src="google-logo.png" alt="Google"> </div></pre> </div> <p>When a string value is in some machine-readable format unsuitable for human consumption, it is expressed using the <code title=attr-data-value><a href=#attr-data-value>value</a></code> attribute of the <code><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>In this example, the item has one property, "birthday", whose value is a date:</p> <pre><div itemscope> I was born on <data itemprop="birthday" value="2009-05-10">May 10th 2009</data>. </div></pre> </div> <p>Properties can also themselves be groups of name-value pairs, by putting the <code title=attr-itemscope><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>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><div itemscope> <p>Name: <span itemprop="name">Amanda</span></p> <p>Band: <span itemprop="band" itemscope> <span itemprop="name">Jazz Band</span> (<span itemprop="size">12</span> players)</span></p> </div></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 title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute can be associated with the <a href=#concept-item title=concept-item>item</a> using the <code title=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 title=attr-itemscope><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 title=concept-item>items</a>:</p> <pre><div itemscope id="amanda" itemref="a b"></div> <p id="a">Name: <span itemprop="name">Amanda</span></p> <div id="b" itemprop="band" itemscope itemref="c"></div> <div id="c"> <p>Band: <span itemprop="name">Jazz Band</span></p> <p>Size: <span itemprop="size">12</span> players</p> </div></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 title=concept-item>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><div itemscope> <p>Flavors in my favorite ice cream:</p> <ul> <li itemprop="flavor">Lemon sorbet</li> <li itemprop="flavor">Apricot sorbet</li> </ul> </div></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><div itemscope> <span itemprop="favorite-color favorite-fruit">orange</span> </div></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><figure> <img src="castle.jpeg"> <figcaption><span itemscope><span itemprop="name">The Castle</span></span> (1986)</figcaption> </figure></pre> <pre><span itemscope><meta itemprop="name" content="The Castle"></span> <figure> <img src="castle.jpeg"> <figcaption>The Castle (1986)</figcaption> </figure></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</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 title=concept-item>item</a> a type, such as "http://example.com/person", or "http://example.org/cat", or "http://band.example.net/". Types are identified as <a href=#url title=URL>URLs</a>.</p> <p>The type for an <a href=#concept-item title=concept-item>item</a> is given as the value of an <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute on the same element as the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute.</p> <div class=example> <p>Here, the item's type is "http://example.org/animals#cat":</p> <pre><section itemscope itemtype="http://example.org/animals#cat"> <h1 itemprop="name">Hedral</h1> <p itemprop="desc">Hedral is a male american domestic shorthair, with a fluffy black fur with white paws and belly.</p> <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months"> </section></pre> <p>In this example the "http://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 defining a vocabulary: a property named "class" given for an item with the type "http://census.example/person" might refer to the economic class of an individual, while a property named "class" given for an item with the type "http://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 title="">http://example.org/people/teacher</code>" and "<code title="">http://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 title="">http://example.org/people/engineer</code>" type might not typically be used with the "<code title="">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</h4> <p><i>This section is non-normative.</i></p> <p>Sometimes, an <a href=#concept-item title=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 title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute) can be designed such that <a href=#concept-item title=concept-item>items</a> get associated with their global identifier in an unambiguous way by expressing the global identifiers as <a href=#url title=URL>URLs</a> given in an <code title=attr-itemid><a href=#attr-itemid>itemid</a></code> attribute.</p> <p>The exact meaning of the <a href=#url title=URL>URLs</a> given in <code title=attr-itemid><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><dl itemscope itemtype="http://vocab.example.net/book" <strong>itemid="urn:isbn:0-330-34032-8"</strong>> <dt>Title <dd itemprop="title">The Reality Dysfunction <dt>Author <dd itemprop="author">Peter F. Hamilton <dt>Publication date <dd><data itemprop="pubdate" value="1996-01-26">26 January 1996</data> </dl></pre> <p>The "<code title="">http://vocab.example.net/book</code>" vocabulary in this example would define that the <code title=attr-itemid><a href=#attr-itemid>itemid</a></code> attribute takes a <code title="">urn:</code> <a href=#url>URL</a> pointing to the ISBN of the book.</p> </div> <!-- (commented out since itemtype="" defines the meaning of the identifier for now) <p>Although it is common practice, authors are encouraged not to use the same URL to identify multiple topics; in particular, an HTTP URL usually identifies a specific resource (such as an image or document), and authors are encouraged to not use them to identify people, non-Web resources like companies, movies, and products, or other abstract concepts. Using an HTTP URL as a global identifier for something other than the resource actually designated by the URL leads to a situation where it is ambiguous whether the identifier, and thus the set of properties specified in the microdata, references the page or something else.</p> --> <h4 id=selecting-names-when-defining-vocabularies><span class=secno>5.1.5 </span>Selecting names when defining vocabularies</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=#url title=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 title="">example.com</code>, at <code title="">http://example.com/~jon/...</code> and <code title="">http://example.com/~adam/...</code> respectively, then they could select identifiers of the form "http://example.com/~jon/name" and "http://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 "http://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><section itemscope itemtype="http://example.org/animals#cat"> <h1 itemprop="name http://example.com/fn">Hedral</h1> <p itemprop="desc">Hedral is a male american domestic shorthair, with a fluffy <span itemprop="http://example.com/color">black</span> fur with <span itemprop="http://example.com/color">white</span> paws and belly.</p> <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months"> </section></pre> <p>This example has one item with the type "http://example.org/animals#cat" and the following properties:</p> <table><thead><tr><td>Property <td>Value <tbody><tr><td>name <td>Hedral <tr><td>http://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>http://example.com/color <td>black <tr><td>http://example.com/color <td>white <tr><td>img <td>.../hedral.jpeg </table></div> <h4 id=using-the-microdata-dom-api><span class=secno>5.1.6 </span>Using the microdata DOM API</h4> <p><i>This section is non-normative.</i></p> <p>The microdata becomes even more useful when scripts can use it to expose information to the user, for example offering it in a form that can be used by other applications.</p> <p>The <code title=dom-document-getItems><a href=#dom-document-getitems>document.getItems(<var title="">typeNames</var>)</a></code> method provides access to the <a href=#top-level-microdata-items>top-level microdata items</a>. It returns a <code><a href=#nodelist>NodeList</a></code> containing the items with the specified types, or all types if no argument is specified.</p> <p>Each <a href=#concept-item title=concept-item>item</a> is represented in the DOM by the element on which the relevant <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute is found. These elements have their <code title=dom-itemScope><a href=#dom-itemscope>element.itemScope</a></code> IDL attribute set to true.</p> <p>The type(s) of <a href=#concept-item title=concept-item>items</a> can be obtained using the <code title=dom-itemType><a href=#dom-itemtype>element.itemType</a></code> IDL attribute on the element with the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute.</p> <div class=example> <p>This sample shows how the <code title=dom-document-getItems><a href=#dom-document-getitems>getItems()</a></code> method can be used to obtain a list of all the top-level microdata items of a particular type given in the document:</p> <pre>var cats = document.getItems("http://example.com/feline");</pre> </div> <p>Once an element representing an <a href=#concept-item title=concept-item>item</a> has been obtained, its properties can be extracted using the <code title=dom-properties><a href=#dom-properties>properties</a></code> IDL attribute. This attribute returns an <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code>, which can be enumerated to go through each element that adds one or more properties to the item. It can also be indexed by name, which will return an object with a list of the elements that add properties with that name.</p> <p>Each element that adds a property also has a <code title=dom-itemValue><a href=#dom-itemvalue>itemValue</a></code> IDL attribute that returns its value.</p> <div class=example> <p>This sample gets the first item of type "http://example.net/user" and then pops up an alert using the "name" property from that item.</p> <pre>var user = document.getItems('http://example.net/user')[0]; alert('Hello ' + user.properties['name'][0].itemValue + '!');</pre> </div> <p>The <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> object, when indexed by name in this way, actually returns a <code><a href=#propertynodelist>PropertyNodeList</a></code> object with all the matching properties. The <code><a href=#propertynodelist>PropertyNodeList</a></code> object can be used to obtain all the values at once using <em>its</em> <code title=dom-PropertyNodeList-getValues><a href=#dom-propertynodelist-getvalues>getValues</a></code> method, which returns an array of all the values.</p> <div class=example> <p>In an earlier example, a "http://example.org/animals#cat" item had two "http://example.com/color" values. This script looks up the first such item and then lists all its values.</p> <pre>var cat = document.getItems('http://example.org/animals#cat')[0]; var colors = cat.properties['http://example.com/color'].getValues(); var result; if (colors.length == 0) { result = 'Color unknown.'; } else if (colors.length == 1) { result = 'Color: ' + colors[0]; } else { result = 'Colors:'; for (var i = 0; i < colors.length; i += 1) result += ' ' + colors[i]; }</pre> </div> <p>It's also possible to get a list of all the <a href=#property-names>property names</a> using the object's <code title=dom-HTMLPropertiesCollection-names><a href=#dom-htmlpropertiescollection-names>names</a></code> IDL attribute.</p> <div class=example> <p>This example creates a big list with a nested list for each item on the page, each with of all the property names used in that item.</p> <pre>var outer = document.createElement('ul'); var items = document.getItems(); for (var item = 0; item < items.length; item += 1) { var itemLi = document.createElement('li'); var inner = document.createElement('ul'); for (var name = 0; name < items[item].properties.names.length; name += 1) { var propLi = document.createElement('li'); propLi.appendChild(document.createTextNode(items[item].properties.names[name])); inner.appendChild(propLi); } itemLi.appendChild(inner); outer.appendChild(itemLi); } document.body.appendChild(outer);</pre> <p>If faced with the following from an earlier example:</p> <pre><section itemscope itemtype="http://example.org/animals#cat"> <h1 itemprop="name http://example.com/fn">Hedral</h1> <p itemprop="desc">Hedral is a male american domestic shorthair, with a fluffy <span itemprop="http://example.com/color">black</span> fur with <span itemprop="http://example.com/color">white</span> paws and belly.</p> <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months"> </section></pre> <p>...it would result in the following output:</p> <ul><li> <ul><li>name</li> <li>http://example.com/fn</li> <li>desc</li> <li>http://example.com/color</li> <li>img</li> </ul></li> </ul><p>(The duplicate occurrence of "http://example.com/color" is not included in the list.)</p> </div> <h3 id=encoding-microdata><span class=secno>5.2 </span>Encoding microdata</h3> <h4 id=the-microdata-model><span class=secno>5.2.1 </span>The microdata model</h4> <p>The microdata model consists of groups of name-value pairs known as <a href=#concept-item title=concept-item>items</a>.</p> <p>Each group is known as an <a href=#concept-item title=concept-item>item</a>. Each <a href=#concept-item title=concept-item>item</a> can have <a href=#item-types>item types</a>, a <a href=#global-identifier>global identifier</a> (if the vocabulary specified by the <a href=#item-types>item types</a> <a href=#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 title="the properties of an item">property</a>, and each <a href=#the-properties-of-an-item title="the properties of an item">property</a> has one or more <a href=#concept-property-value title=concept-property-value>values</a>. Each <a href=#concept-property-value title=concept-property-value>value</a> is either a string or itself a group of name-value pairs (an <a href=#concept-item title=concept-item>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> <p>An <a href=#concept-item title=concept-item>item</a> is said to be a <dfn id=typed-item>typed item</dfn> when either it has an <a href=#item-types title="item types">item type</a>, or it is the <a href=#concept-property-value title=concept-property-value>value</a> of a <a href=#the-properties-of-an-item title="the properties of an item">property</a> of a <a href=#typed-item>typed item</a>. The <dfn id=relevant-types>relevant types</dfn> for a <a href=#typed-item>typed item</a> is the <a href=#concept-item title=concept-item>item</a>'s <a href=#item-types>item types</a>, if it has one, or else is the <a href=#relevant-types>relevant types</a> of the <a href=#concept-item title=concept-item>item</a> for which it is a <a href=#the-properties-of-an-item title="the properties of an item">property</a>'s <a href=#concept-property-value title=concept-property-value>value</a>.</p> <h4 id=items><span class=secno>5.2.2 </span>Items</h4> <p>Every <a href=#html-elements title="HTML elements">HTML element</a> may have an <dfn id=attr-itemscope title=attr-itemscope><code>itemscope</code></dfn> attribute specified. The <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute is a <a href=#boolean-attribute>boolean attribute</a>.</p> <p>An element with the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified creates a new <dfn id=concept-item title=concept-item>item</dfn>, a group of name-value pairs.</p> <hr><p>Elements with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute may have an <dfn id=attr-itemtype title=attr-itemtype><code>itemtype</code></dfn> attribute specified, to give the <a href=#item-types>item types</a> of the <a href=#concept-item title=concept-item>item</a>.</p> <p>The <code title=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>unordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, each of which is a <a href=#valid-url>valid URL</a> that is an <a href=#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 title=concept-item>item</a> are the tokens obtained by <a href=#split-a-string-on-spaces title="split a string on spaces">splitting the element's <code title=attr-itemtype>itemtype</code> attribute's value on spaces</a>. If the <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute is missing or parsing it in this way finds no tokens, the <a href=#concept-item title=concept-item>item</a> is said to have no <a href=#item-types>item types</a>.</p> <p>The <a href=#item-types>item types</a> must all be types defined in <a href=#other-applicable-specifications title="other applicable specifications">applicable specifications</a> and must all be defined to use the same vocabulary.</p> <div class=impl> <p>Except if otherwise specified by that specification, the <a href=#url title=URL>URLs</a> given as the <a href=#item-types>item types</a> should not be automatically dereferenced.</p> <p class=note>A specification could define that its <a href=#item-types title="item types">item type</a> can be derefenced to provide the user with help information, for example. In fact, vocabulary authors are encouraged to provide useful information at the given <a href=#url>URL</a>.</p> <p><a href=#item-types>Item types</a> are opaque identifiers, and user agents must not dereference unknown <a href=#item-types>item types</a>, or otherwise deconstruct them, in order to determine how to process <a href=#concept-item title=concept-item>items</a> that use them.</p> </div> <p>The <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute must not be specified on elements that do not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified.</p> <hr><p>Elements with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute and an <code title=attr-itemtype><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 title=attr-itemid><code>itemid</code></dfn> attribute specified, to give a global identifier for the <a href=#concept-item title=concept-item>item</a>, so that it can be related to other <a href=#concept-item title=concept-item>items</a> on pages elsewhere on the Web.</p> <p>The <code title=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>valid URL potentially surrounded by spaces</a>.</p> <p>The <dfn id=global-identifier>global identifier</dfn> of an <a href=#concept-item title=concept-item>item</a> is the value of its element's <code title=attr-itemid><a href=#attr-itemid>itemid</a></code> attribute, if it has one, <a href=#resolve-a-url title="resolve a url">resolved</a> relative to the element on which the attribute is specified. If the <code title=attr-itemid><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>global identifier</a>.</p> <p>The <code title=attr-itemid><a href=#attr-itemid>itemid</a></code> attribute must not be specified on elements that do not have both an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute and an <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute specified, and must not be specified on elements with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute whose <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute specifies a vocabulary that does not <a href=#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>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 title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute may have an <dfn id=attr-itemref title=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 title=concept-item>item</a>.</p> <p>The <code title=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>unordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, consisting of <a href=#concept-id title=concept-ID>IDs</a> of elements in the same <a href=#home-subtree>home subtree</a>.</p> <p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute must not be specified on elements that do not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified.</p> <p class=note>The <code title=attr-itemref><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 title=concept-item>item</a>, while keeping the properties in the cells.</p> <div class=example> <p>This example shows a simple vocabulary used to describe the products of a model railway manufacturer. The vocabulary has just five property names:</p> <dl><dt>product-code</dt> <dd>An integer that names the product in the manufacturer's catalog.</dd> <dt>name</dt> <dd>A brief description of the product.</dd> <dt>scale</dt> <dd>One of "HO", "1", or "Z" (potentially with leading or trailing whitespace), indicating the scale of the product.</dd> <dt>digital</dt> <dd>If present, one of "Digital", "Delta", or "Systems" (potentially with leading or trailing whitespace) indicating that the product has a digital decoder of the given type.</dd> <dt>track-type</dt> <dd>For track-specific products, one of "K", "M", "C" (potentially with leading or trailing whitespace) indicating the type of track for which the product is intended.</dd> </dl><p>This vocabulary has four defined <a href=#item-types>item types</a>:</p> <dl><dt>http://md.example.com/loco</dt> <dd>Rolling stock with an engine</dd> <dt>http://md.example.com/passengers</dt> <dd>Passenger rolling stock</dd> <dt>http://md.example.com/track</dt> <dd>Track pieces</dd> <dt>http://md.example.com/lighting</dt> <dd>Equipment with lighting</dd> </dl><p>Each <a href=#concept-item title=concept-item>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><dl itemscope itemtype="http://md.example.com/loco http://md.example.com/lighting"> <dt>Name: <dd itemprop="name">Tank Locomotive (DB 80) <dt>Product code: <dd itemprop="product-code">33041 <dt>Scale: <dd itemprop="scale">HO <dt>Digital: <dd itemprop="digital">Delta </dl></pre> <p>A turnout lantern retrofit kit might be marked up as:</p> <pre><dl itemscope itemtype="http://md.example.com/track http://md.example.com/lighting"> <dt>Name: <dd itemprop="name">Turnout Lantern Kit <dt>Product code: <dd itemprop="product-code">74470 <dt>Purpose: <dd>For retrofitting 2 <span itemprop="track-type">C</span> Track turnouts. <meta itemprop="scale" content="HO"> </dl></pre> <p>A passenger car with no lighting might be marked up as:</p> <pre><dl itemscope itemtype="http://md.example.com/passengers"> <dt>Name: <dd itemprop="name">Express Train Passenger Car (DB Am 203) <dt>Product code: <dd itemprop="product-code">8710 <dt>Scale: <dd itemprop="scale">Z </dl></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 title=attr-itemprop><code>itemprop</code></dfn> attribute</h4> <p>Every <a href=#html-elements title="HTML elements">HTML element</a> may have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute specified, if doing so <a href=#the-properties-of-an-item title="the properties of an item">adds one or more properties</a> to one or more <a href=#concept-item title=concept-item>items</a> (as defined below).</p> <p>The <code title=attr-itemprop><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>unordered set of unique space-separated tokens</a> that are <a href=#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>A <a href=#valid-url>valid URL</a> that is an <a href=#absolute-url>absolute URL</a>, or</li> <li>If the item is a <a href=#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>relevant types</a> for the item, or</li> <li>If the item is not a <a href=#typed-item>typed item</a>: a string that contains no U+002E FULL STOP characters (.) and no U+003A COLON characters (:).</li> </ul><p>Specifications that introduce <a href=#defined-property-name title="defined property name">defined property names</a> that are not <a href=#absolute-url title="absolute URL">absolute URLs</a> must ensure all such property names contain no U+002E FULL STOP characters (.), no U+003A COLON characters (:), and no <a href=#space-character title="space character">space characters</a>.</p> <p>When an element with an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute <a href=#the-properties-of-an-item title="the properties of an item">adds a property</a> to multiple <a href=#concept-item title=concept-item>items</a>, the requirement above regarding the tokens applies for each <a href=#concept-item title=concept-item>item</a> individually.</p> <!-- e.g.: <div itemscope itemtype="http://example.com/a"> <ref refid="x"> </div> <div itemscope itemtype="http://example.com/b"> <ref refid="x"> </div> <meta id="x" itemprop="z" content=""> "z" had better be valid for both http://example.com/a and http://example.com/b --> <p>The <dfn id=property-names>property names</dfn> of an element are the tokens that the element's <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is found to contain when its value is <a href=#split-a-string-on-spaces title="split a string on spaces">split on spaces</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 title=concept-item>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>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><div itemscope> <p itemprop="a">1</p> <p itemprop="a">2</p> <p itemprop="b">test</p> </div></pre> <p>Thus, the following is equivalent:</p> <pre><div itemscope> <p itemprop="b">test</p> <p itemprop="a">1</p> <p itemprop="a">2</p> </div></pre> <p>As is the following:</p> <pre><div itemscope> <p itemprop="a">1</p> <p itemprop="b">test</p> <p itemprop="a">2</p> </div></pre> <p>And the following:</p> <pre><div id="x"> <p itemprop="a">1</p> </div> <div itemscope itemref="x"> <p itemprop="b">test</p> <p itemprop="a">2</p> </div> </pre> </div> <h4 id=values><span class=secno>5.2.4 </span>Values</h4> <p>The <dfn id=concept-property-value title=concept-property-value>property value</dfn> of a name-value pair added by an element with an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute depends on the element, as follows:</p> <dl><dt>If the element also has an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute</dt> <dd><p>The value is the <a href=#concept-item title=concept-item>item</a> created by the element.</dd> <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt> <dd><p>The value is the value of the element's <code title=attr-content>content</code> attribute, if any, or the empty string if there is no such attribute.</dd> <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt> <dd><p>The value is the <a href=#absolute-url>absolute URL</a> that results from <a href=#resolve-a-url title="resolve a url">resolving</a> the value of the element's <code title="">src</code> attribute relative to the element at the time the attribute is set, or the empty string if there is no such attribute or if <a href=#resolve-a-url title="resolve a url">resolving</a> it results in an error.</dd> <dt>If the element is an <code><a href=#the-a-element>a</a></code>, <code><a href=#the-area-element>area</a></code>, or <code><a href=#the-link-element>link</a></code> element</dt> <dd><p>The value is the <a href=#absolute-url>absolute URL</a> that results from <a href=#resolve-a-url title="resolve a url">resolving</a> the value of the element's <code title="">href</code> attribute relative to the element at the time the attribute is set, or the empty string if there is no such attribute or if <a href=#resolve-a-url title="resolve a url">resolving</a> it results in an error.</dd> <dt>If the element is an <code><a href=#the-object-element>object</a></code> element</dt> <dd><p>The value is the <a href=#absolute-url>absolute URL</a> that results from <a href=#resolve-a-url title="resolve a url">resolving</a> the value of the element's <code title="">data</code> attribute relative to the element at the time the attribute is set, or the empty string if there is no such attribute or if <a href=#resolve-a-url title="resolve a url">resolving</a> it results in an error.</dd> <dt>If the element is a <code><a href=#the-data-element>data</a></code> element</dt> <dd><p>The value is the value of the element's <code title=attr-data-value><a href=#attr-data-value>value</a></code> attribute, if it has one, or the empty string otherwise.</dd> <dt>Otherwise</dt> <dd><p>The value is the element's <code><a href=#textcontent>textContent</a></code>.</dd> </dl><p>The <dfn id=url-property-elements>URL property elements</dfn> are the <code><a href=#the-a-element>a</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, and <code><a href=#the-video-element>video</a></code> elements.</p> <p>If a property's <a href=#concept-property-value title=concept-property-value>value</a>, as defined by the property's definition, is an <a href=#absolute-url>absolute URL</a>, the property must be specified using a <a href=#url-property-elements title="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 <!-- 1969-07-20 --> 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><a href=#the-a-element>a</a></code> element, even though it looks like a <a href=#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><a href=#the-a-element>a</a></code> element (or one of the other <a href=#url-property-elements>URL property elements</a>), because of the requirement above.</p> <div class=impl> <!-- this is unfortunate, as it is hiding authoring conformance criteria (so we leave it in for the w3c copy) --> <h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</h4> <p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn> defined by the element <var title="">root</var>, the user agent must run the following steps. These steps are also used to flag <a href=#microdata-error title="microdata error">microdata errors</a>.</p> <ol><li><p>Let <var title="">results</var>, <var title="">memory</var>, and <var title="">pending</var> be empty lists of elements.</li> <li><p>Add the element <var title="">root</var> to <var title="">memory</var>.</li> <li><p>Add the child elements of <var title="">root</var>, if any, to <var title="">pending</var>.</li> <li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For each resulting token <var title="">ID</var>, if there is an element in the <a href=#home-subtree>home subtree</a> of <var title="">root</var> with the <a href=#concept-id title=concept-ID>ID</a> <var title="">ID</var>, then add the first such element to <var title="">pending</var>.</li> <li><p><i>Loop</i>: If <var title="">pending</var> is empty, jump to the step labeled <i>end of loop</i>.</li> <li><p>Remove an element from <var title="">pending</var> and let <var title="">current</var> be that element.</li> <li><p>If <var title="">current</var> is already in <var title="">memory</var>, there is a <a href=#microdata-error>microdata error</a>; return to the step labeled <i>loop</i>.</li> <li><p>Add <var title="">current</var> to <var title="">memory</var>.</li> <li><p>If <var title="">current</var> does not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, then: add all the child elements of <var title="">current</var> to <var title="">pending</var>.</li> <li><p>If <var title="">current</var> has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute specified, add it to <var title="">results</var>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> <li><p><i>End of loop</i>: Sort <var title="">results</var> in <a href=#tree-order>tree order</a>.</li> <li><p>Return <var title="">results</var>.</li> </ol><p>A document must not contain any <a href=#concept-item title=concept-item>items</a> for which the algorithm to find <a href=#the-properties-of-an-item>the properties of an item</a> finds any <dfn id=microdata-error title="microdata error">microdata errors</dfn>.</p> <p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p> <!--(this is currently redundant with "requirement itemprop" below) <p>An <span title="concept-item">item</span> is a <dfn title="used microdata items">used microdata item</dfn> if it is a <span title="top-level microdata items">top-level microdata item</span>, or if it has an <code title="attr-itemprop">itemprop</code> attribute and would be <span title="the properties of an item">found to be the property</span> of an <span title="concept-item">item</span> that is itself a <span title="used microdata items">used microdata item</span>.</p> <p>All <span title="concept-item">items</span> in a document must be <span>used microdata items</span>.</p> --> <p>All <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attributes in a <code><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 title=concept-item>item</a> in the <code><a href=#document>Document</a></code> as a node in the graph and each <a href=#the-properties-of-an-item title="the properties of an item">property</a> of an item whose <a href=#concept-property-value title=concept-property-value>value</a> is another item as an edge in the graph connecting those two items.</p> <!-- "requirement itemprop" (see above) --> <p>A document must not contain any elements that have an <code title=attr-itemprop><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 title=concept-item>items</a> in that document were their <a href=#the-properties-of-an-item title="the properties of an item">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 title=attr-itemref><a href=#attr-itemref>itemref</a></code> from the items representing the works:</p> <pre><!DOCTYPE HTML> <html> <head> <title>Photo gallery</title> </head> <body> <h1>My photos</h1> <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses"> <img itemprop="work" src="images/house.jpeg" alt="A white house, boarded up, sits in a forest."> <figcaption itemprop="title">The house I found.</figcaption> </figure> <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses"> <img itemprop="work" src="images/mailbox.jpeg" alt="Outside the house is a mailbox. It has a leaflet inside."> <figcaption itemprop="title">The mailbox.</figcaption> </figure> <footer> <p id="licenses">All images licensed under the <a itemprop="license" href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</p> </footer> </body> </html></pre> <p>The above results in two items with the type "<code title="">http://n.whatwg.org/work</code>", one with:</p> <dl class=brief><dt>work <dd><code title="">images/house.jpeg</code> <dt>title <dd>The house I found. <dt>license <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code> </dl><p>...and one with:</p> <dl class=brief><dt>work <dd><code title="">images/mailbox.jpeg</code> <dt>title <dd>The mailbox. <dt>license <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code> </dl></div> </div> <!-- see comment above --> <h4 id=microdata-and-other-namespaces><span class=secno>5.2.6 </span>Microdata and other namespaces</h4> <p>Currently, the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code>, <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code>, and other microdata attributes are only defined for <a href=#html-elements>HTML elements</a>. This means that attributes with the literal names "<code title="">itemscope</code>", "<code title="">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><p itemscope></p> <!-- this is an item (with no properties and no type) --> <svg itemscope></svg> <!-- this is not, it's just an <code><a href=#svg>svg</a></code> element with an invalid unknown attribute --></pre> </div> <h3 id=microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</h3> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-getItems><a href=#dom-document-getitems>getItems</a></code>( [ <var title="">types</var> ] )</dt> <dd> <p>Returns a <code><a href=#nodelist>NodeList</a></code> of the elements in the <code><a href=#document>Document</a></code> that create <a href=#concept-item title=concept-item>items</a>, that are not part of other <a href=#concept-item title=concept-item>items</a>, and that are of the types given in the argument, if any are listed.</p> <p>The <var title="">types</var> argument is interpreted as a space-separated list of types.</p> </dd> <dt><var title="">element</var> . <code title=dom-properties><a href=#dom-properties>properties</a></code></dt> <dd> <p>If the element has an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, returns an <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> object with all the element's properties. Otherwise, an empty <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> object.</p> </dd> <dt><var title="">element</var> . <code title=dom-itemValue><a href=#dom-itemvalue>itemValue</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the element's <a href=#concept-property-value title=concept-property-value>value</a>.</p> <p>Can be set, to change the element's <a href=#concept-property-value title=concept-property-value>value</a>. Setting the <a href=#concept-property-value title=concept-property-value>value</a> when the element has no <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute or when the element's value is an <a href=#concept-item title=concept-item>item</a> throws an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-getitems title=dom-document-getItems><code>document.getItems(<var title="">typeNames</var>)</code></dfn> method takes an optional string that contains an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, representing types. When called, the method must return a <a href=#live>live</a> <code><a href=#nodelist>NodeList</a></code> object containing all the elements in the document, in <a href=#tree-order>tree order</a>, that are each <a href=#top-level-microdata-items>top-level microdata items</a> whose <a href=#item-types title="item types">types</a> include all the types specified in the method's argument, having obtained the types by <a href=#split-a-string-on-spaces title="split a string on spaces">splitting the string on spaces</a>. If there are no tokens specified in the argument, or if the argument is missing, then the method must return a <code><a href=#nodelist>NodeList</a></code> containing all the <a href=#top-level-microdata-items>top-level microdata items</a> in the document. When the method is invoked on a <code><a href=#document>Document</a></code> object again with the same argument, the user agent may return the same object as the object returned by the earlier call. In other cases, a new <code><a href=#nodelist>NodeList</a></code> object must be returned.</p> <p>The <dfn id=dom-itemscope title=dom-itemScope><code>itemScope</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must <a href=#reflect>reflect</a> the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> content attribute. The <dfn id=dom-itemtype title=dom-itemType><code>itemType</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must <a href=#reflect>reflect</a> the <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> content attribute. The <dfn id=dom-itemid title=dom-itemId><code>itemId</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must <a href=#reflect>reflect</a> the <code title=attr-itemid><a href=#attr-itemid>itemid</a></code> content attribute. The <dfn id=dom-itemprop title=dom-itemProp><code>itemProp</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must <a href=#reflect>reflect</a> the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> content attribute. The <dfn id=dom-itemref title=dom-itemRef><code>itemRef</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must <a href=#reflect>reflect</a> the <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> content attribute.</p> <p>The <dfn id=dom-properties title=dom-properties><code>properties</code></dfn> IDL attribute on <a href=#html-elements>HTML elements</a> must return an <code><a href=#htmlpropertiescollection>HTMLPropertiesCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only elements that have <a href=#property-names>property names</a> and are <a href=#the-properties-of-an-item title="the properties of an item">the properties of the item</a> created by the element on which the attribute was invoked, while that element is an <a href=#concept-item title=concept-item>item</a>, and matches nothing the rest of the time.</p> <p>The <dfn id=dom-itemvalue title=dom-itemValue><code>itemValue</code></dfn> IDL attribute's behavior depends on the element, as follows:</p> <dl><dt>If the element has no <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute</dt> <dd><p>The attribute must return null on getting and must throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception on setting.</p> <dt>If the element has an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute</dt> <dd><p>The attribute must return the element itself on getting and must throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception on setting.</p> <dt>If the element is a <code><a href=#the-meta-element>meta</a></code> element</dt> <dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> content attribute.</dd> <dt>If the element is an <code><a href=#the-audio-element>audio</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, or <code><a href=#the-video-element>video</a></code> element</dt> <dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title="">src</code> content attribute.</dd> <dt>If the element is an <code><a href=#the-a-element>a</a></code>, <code><a href=#the-area-element>area</a></code>, or <code><a href=#the-link-element>link</a></code> element</dt> <dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title="">href</code> content attribute.</dd> <dt>If the element is an <code><a href=#the-object-element>object</a></code> element</dt> <dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title="">data</code> content attribute.</dd> <dt>If the element is a <code><a href=#the-data-element>data</a></code> element</dt> <dd><p>The attribute must act as it would if it was <a href=#reflect title=reflect>reflecting</a> the element's <code title=attr-data-value><a href=#attr-data-value>value</a></code> content attribute.</dd> <dt>Otherwise</dt> <dd><p>The attribute must act the same as the element's <code><a href=#textcontent>textContent</a></code> attribute.</dd> </dl><p>When the <code title=dom-itemValue><a href=#dom-itemvalue>itemValue</a></code> IDL attribute is <a href=#reflect title=reflect>reflecting</a> a content attribute or acting like the element's <code><a href=#textcontent>textContent</a></code> attribute, the user agent must, on setting, convert the new value to the IDL <code title="">DOMString</code> value before using it according to the mappings described above.</p> </div> <div class=exmaple> <p>In this example, a script checks to see if a particular element <var title="">element</var> is declaring a particular property, and if it is, it increments a counter:</p> <pre>if (element.itemProp.contains('color')) count += 1;</pre> </div> <div class=exmaple> <p>This script iterates over each of the values of an element's <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, calling a function for each referenced element:</p> <pre>for (var index = 0; index < element.itemRef.length; index += 1) process(document.getElementById(element.itemRef[index]));</pre> </div> <h3 id=mdvocabs><span class=secno>5.4 </span>Microdata vocabularies</h3> <h4 id=vcard><span class=secno>5.4.1 </span>vCard</h4> <p>An item with the <a href=#item-types title="item types">item type</a> <dfn id=md-vcard title=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>support global identifiers for items</a>.</p> <p>The following are the type's <a href=#defined-property-name title="defined property name">defined property names</a>. They are based on the vocabulary defined in the vCard 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 title=md-vcard-kind><code>kind</code></dfn></dt> <dd> <p>Describes what kind of contact the item represents.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that, when compared in a <a href=#case-sensitive>case-sensitive</a> manner, is equal to one of the <a href=#kind-strings>kind strings</a>.</p> <p>A single property with the name <code title=md-vcard-kind><a href=#md-vcard-kind>kind</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <!-- XML not included since there's no good way to do it here --> <!-- Note: vCard->microdata->vCard doesn't count as "propagating vCards" according to Tantek, so we're not non-conforming when we drop it, despite vCard's requirement --> <dt><dfn id=md-vcard-fn title=md-vcard-fn><code>fn</code></dfn></dt> <dd> <p>Gives the formatted text corresponding to the name of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Exactly one property with the name <code title=md-vcard-fn><a href=#md-vcard-fn>fn</a></code> must be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n title=md-vcard-n><code>n</code></dfn></dt> <dd> <p>Gives the structured name of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#concept-item title=concept-item>item</a> with zero or more of each of the <code title=md-vcard-n-family-name><a href=#md-vcard-n-family-name>family-name</a></code>, <code title=md-vcard-n-given-name><a href=#md-vcard-n-given-name>given-name</a></code>, <code title=md-vcard-n-additional-name><a href=#md-vcard-n-additional-name>additional-name</a></code>, <code title=md-vcard-n-honorific-prefix><a href=#md-vcard-n-honorific-prefix>honorific-prefix</a></code>, and <code title=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 title=md-vcard-n><a href=#md-vcard-n>n</a></code> must be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n-family-name title=md-vcard-n-family-name><code>family-name</code></dfn> (inside <code title=md-vcard-n><a href=#md-vcard-n>n</a></code>)</dt> <dd> <p>Gives the family name of the person, or the full name of the organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-n-family-name><a href=#md-vcard-n-family-name>family-name</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n-given-name title=md-vcard-n-given-name><code>given-name</code></dfn> (inside <code title=md-vcard-n><a href=#md-vcard-n>n</a></code>)</dt> <dd> <p>Gives the given-name of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-n-given-name><a href=#md-vcard-n-given-name>given-name</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n-additional-name title=md-vcard-n-additional-name><code>additional-name</code></dfn> (inside <code title=md-vcard-n><a href=#md-vcard-n>n</a></code>)</dt> <dd> <p>Gives the any additional names of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-n-additional-name><a href=#md-vcard-n-additional-name>additional-name</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n-honorific-prefix title=md-vcard-n-honorific-prefix><code>honorific-prefix</code></dfn> (inside <code title=md-vcard-n><a href=#md-vcard-n>n</a></code>)</dt> <dd> <p>Gives the honorific prefix of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-n-honorific-prefix><a href=#md-vcard-n-honorific-prefix>honorific-prefix</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-n-honorific-suffix title=md-vcard-n-honorific-suffix><code>honorific-suffix</code></dfn> (inside <code title=md-vcard-n><a href=#md-vcard-n>n</a></code>)</dt> <dd> <p>Gives the honorific suffix of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-n-honorific-suffix><a href=#md-vcard-n-honorific-suffix>honorific-suffix</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-nickname title=md-vcard-nickname><code>nickname</code></dfn></dt> <dd> <p>Gives the nickname of the person or organization.</p> <!-- copied from vCard --> <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 title=md-vcard-fn><a href=#md-vcard-fn>fn</a></code> or <code title=md-vcard-n><a href=#md-vcard-n>n</a></code> properties.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-nickname><a href=#md-vcard-nickname>nickname</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-photo title=md-vcard-photo><code>photo</code></dfn></dt> <dd> <p>Gives a photograph of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-photo><a href=#md-vcard-photo>photo</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-bday title=md-vcard-bday><code>bday</code></dfn></dt> <dd> <p>Gives the birth date of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be a <a href=#valid-date-string>valid date string</a>.</p> <p>A single property with the name <code title=md-vcard-bday><a href=#md-vcard-bday>bday</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-anniversary title=md-vcard-anniversary><code>anniversary</code></dfn></dt> <dd> <p>Gives the birth date of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be a <a href=#valid-date-string>valid date string</a>.</p> <p>A single property with the name <code title=md-vcard-anniversary><a href=#md-vcard-anniversary>anniversary</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-sex title=md-vcard-sex><code>sex</code></dfn></dt> <dd> <p>Gives the biological sex of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be one of <code title="">F</code>, meaning "female", <code title="">M</code>, meaning "male", <code title="">N</code>, meaning "none or not applicable", <code title="">O</code>, meaning "other", or <code title="">U</code>, meaning "unknown".</p> <p>A single property with the name <code title=md-vcard-sex><a href=#md-vcard-sex>sex</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-gender-identity title=md-vcard-gender-identity><code>gender-identity</code></dfn></dt> <dd> <p>Gives the gender identity of the person.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-gender-identity><a href=#md-vcard-gender-identity>gender-identity</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr title=md-vcard-adr><code>adr</code></dfn></dt> <dd> <p>Gives the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#concept-item title=concept-item>item</a> with zero or more <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code>, <code title=md-vcard-adr-post-office-box><a href=#md-vcard-adr-post-office-box>post-office-box</a></code>, <code title=md-vcard-adr-extended-address><a href=#md-vcard-adr-extended-address>extended-address</a></code>, and <code title=md-vcard-adr-street-address><a href=#md-vcard-adr-street-address>street-address</a></code> properties, and optionally a <code title=md-vcard-adr-locality><a href=#md-vcard-adr-locality>locality</a></code> property, optionally a <code title=md-vcard-adr-region><a href=#md-vcard-adr-region>region</a></code> property, optionally a <code title=md-vcard-adr-postal-code><a href=#md-vcard-adr-postal-code>postal-code</a></code> property, and optionally a <code title=md-vcard-adr-country-name><a href=#md-vcard-adr-country-name>country-name</a></code> property.</p> <p>If no <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code> properties are present within an <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, then the <a href=#address-type-strings>address type strings</a> <code title=mv-vcard-type-adr-intl>intl</code>, <code title=mv-vcard-type-adr-postal>postal</code>, <code title=mv-vcard-type-adr-parcel>parcel</code>, and <code title=mv-vcard-type-adr-work>work</code> are implied.</p> <p>Any number of properties with the name <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-type title=md-vcard-adr-type><code>type</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the type of delivery address.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that, when compared in a <a href=#case-sensitive>case-sensitive</a> manner, is equal to one of the <a href=#address-type-strings>address type strings</a>.</p> <p>Within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, there must be no more than one <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property <a href=#concept-item title=concept-item>item</a> with a <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code> property whose value is <code title=md-vcard-type-adr-pref>pref</code>.</p> <p>Any number of properties with the name <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, but within each such <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property <a href=#concept-item title=concept-item>item</a> there must only be one <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code> property per distinct value.</p> </dd> <dt><dfn id=md-vcard-adr-post-office-box title=md-vcard-adr-post-office-box><code>post-office-box</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the post office box component of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-adr-post-office-box><a href=#md-vcard-adr-post-office-box>post-office-box</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-extended-address title=md-vcard-adr-extended-address><code>extended-address</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives an additional component of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-adr-extended-address><a href=#md-vcard-adr-extended-address>extended-address</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-street-address title=md-vcard-adr-street-address><code>street-address</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the street address component of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-adr-street-address><a href=#md-vcard-adr-street-address>street-address</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-locality title=md-vcard-adr-locality><code>locality</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the locality component (e.g. city) of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-adr-locality><a href=#md-vcard-adr-locality>locality</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-region title=md-vcard-adr-region><code>region</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the region component (e.g. state or province) of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-adr-region><a href=#md-vcard-adr-region>region</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-postal-code title=md-vcard-adr-postal-code><code>postal-code</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the postal code component of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-adr-postal-code><a href=#md-vcard-adr-postal-code>postal-code</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-adr-country-name title=md-vcard-adr-country-name><code>country-name</code></dfn> (inside <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code>)</dt> <dd> <p>Gives the country name component of the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-adr-country-name><a href=#md-vcard-adr-country-name>country-name</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-label title=md-vcard-label><code>label</code></dfn></dt> <dd> <p>Gives the formatted text corresponding to the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be either text or an <a href=#concept-item title=concept-item>item</a> with zero or more <code title=md-vcard-label-type><a href=#md-vcard-label-type>type</a></code> properties and exactly one <code title=md-vcard-label-value><a href=#md-vcard-label-value>value</a></code> property.</p> <p>If no <code title=md-vcard-label-type><a href=#md-vcard-label-type>type</a></code> properties are present within an <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, or if the <a href=#concept-property-value title=concept-property-value>value</a> of such a <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property is text, then the <a href=#address-type-strings>address type strings</a> <code title=mv-vcard-type-adr-intl>intl</code>, <code title=mv-vcard-type-adr-postal>postal</code>, <code title=mv-vcard-type-adr-parcel>parcel</code>, and <code title=mv-vcard-type-adr-work>work</code> are implied.</p> <p>Any number of properties with the name <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-label-type title=md-vcard-label-type><code>type</code></dfn> (inside <code title=md-vcard-label><a href=#md-vcard-label>label</a></code>)</dt> <dd> <p>Gives the type of delivery address.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that, when compared in a <a href=#case-sensitive>case-sensitive</a> manner, is equal to one of the <a href=#address-type-strings>address type strings</a>.</p> <p>Within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, there must be no more than one <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property <a href=#concept-item title=concept-item>item</a> with a <code title=md-vcard-label-type><a href=#md-vcard-label-type>type</a></code> property whose value is <code title=md-vcard-type-adr-pref>pref</code>.</p> <p>Any number of properties with the name <code title=md-vcard-label-type><a href=#md-vcard-label-type>type</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, but within each such <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property <a href=#concept-item title=concept-item>item</a> there must only be one <code title=md-vcard-label-type><a href=#md-vcard-label-type>type</a></code> property per distinct value.</p> </dd> <dt><dfn id=md-vcard-label-value title=md-vcard-label-value><code>value</code></dfn> (inside <code title=md-vcard-label><a href=#md-vcard-label>label</a></code>)</dt> <dd> <p>Gives the actual formatted text corresponding to the delivery address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Exactly one property with the name <code title=md-vcard-label-value><a href=#md-vcard-label-value>value</a></code> must be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-label><a href=#md-vcard-label>label</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-tel title=md-vcard-tel><code>tel</code></dfn></dt> <dd> <p>Gives the telephone number of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>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 title=concept-item>item</a> with zero or more <code title=md-vcard-tel-type><a href=#md-vcard-tel-type>type</a></code> properties and exactly one <code title=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 title=md-vcard-tel-type><a href=#md-vcard-tel-type>type</a></code> properties are present within an <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, or if the <a href=#concept-property-value title=concept-property-value>value</a> of such a <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property is text, then the <a href=#telephone-type-strings title="telephone type strings">telephone type string</a> <code title=mv-vcard-type-tel-voice>voice</code> is implied.</p> <p>Any number of properties with the name <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-tel-type title=md-vcard-tel-type><code>type</code></dfn> (inside <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code>)</dt> <dd> <p>Gives the type of telephone number.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that, when compared in a <a href=#case-sensitive>case-sensitive</a> manner, is equal to one of the <a href=#telephone-type-strings>telephone type strings</a>.</p> <p>Within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, there must be no more than one <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property <a href=#concept-item title=concept-item>item</a> with a <code title=md-vcard-tel-type><a href=#md-vcard-tel-type>type</a></code> property whose value is <code title=md-vcard-type-tel-pref>pref</code>.</p> <p>Any number of properties with the name <code title=md-vcard-tel-type><a href=#md-vcard-tel-type>type</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, but within each such <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property <a href=#concept-item title=concept-item>item</a> there must only be one <code title=md-vcard-tel-type><a href=#md-vcard-tel-type>type</a></code> property per distinct value.</p> </dd> <dt><dfn id=md-vcard-tel-value title=md-vcard-tel-value><code>value</code></dfn> (inside <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code>)</dt> <dd> <p>Gives the actual telephone number of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>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 title=md-vcard-tel-value><a href=#md-vcard-tel-value>value</a></code> must be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of a <code title=md-vcard-tel><a href=#md-vcard-tel>tel</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-email title=md-vcard-email><code>email</code></dfn></dt> <dd> <p>Gives the e-mail address of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-email><a href=#md-vcard-email>email</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-impp title=md-vcard-impp><code>impp</code></dfn></dt> <dd> <p>Gives a <a href=#url>URL</a> for instant messaging and presence protocol communications with the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-impp><a href=#md-vcard-impp>impp</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-lang title=md-vcard-lang><code>lang</code></dfn></dt> <dd> <p>Gives a language understood by the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>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 title=md-vcard-lang><a href=#md-vcard-lang>lang</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-tz title=md-vcard-tz><code>tz</code></dfn></dt> <dd> <p>Gives the time zone of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text and must match the following syntax:</p> <ol><li>Either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li> <li>A <a href=#valid-non-negative-integer>valid non-negative integer</a> that is exactly two digits long and that represents a number in the range 00..23.</li> <li>A U+003A COLON character (:).</li> <li>A <a href=#valid-non-negative-integer>valid non-negative integer</a> that is exactly two digits long and that represents a number in the range 00..59.</li> </ol><p>Any number of properties with the name <code title=md-vcard-tz><a href=#md-vcard-tz>tz</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-geo title=md-vcard-geo><code>geo</code></dfn></dt> <dd> <p>Gives the geographical position of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text and must match the following syntax:</p> <ol><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li> <li>One or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>Optionally*, a U+002E FULL STOP character (.) followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>A U+003B SEMICOLON character (;).</li> <li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li> <li>One or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>Optionally*, a U+002E FULL STOP character (.) followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol><p>The optional components marked with an asterisk (*) should be included, and should have six digits each.</p> <!-- copied from vCard --> <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 title=md-vcard-geo><a href=#md-vcard-geo>geo</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-title title=md-vcard-title><code>title</code></dfn></dt> <dd> <p>Gives the job title, functional position or function of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-title><a href=#md-vcard-title>title</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-role title=md-vcard-role><code>role</code></dfn></dt> <dd> <p>Gives the role, occupation, or business category of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-role><a href=#md-vcard-role>role</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-logo title=md-vcard-logo><code>logo</code></dfn></dt> <dd> <p>Gives the logo of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-logo><a href=#md-vcard-logo>logo</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-agent title=md-vcard-agent><code>agent</code></dfn></dt> <dd> <p>Gives the contact information of another person who will act on behalf of the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be either an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, or an <a href=#absolute-url>absolute URL</a>, or text.</p> <p>Any number of properties with the name <code title=md-vcard-agent><a href=#md-vcard-agent>agent</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-org title=md-vcard-org><code>org</code></dfn></dt> <dd> <p>Gives the name and units of the organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be either text or an <a href=#concept-item title=concept-item>item</a> with one <code title=md-vcard-org-organization-name><a href=#md-vcard-org-organization-name>organization-name</a></code> property and zero or more <code title=md-vcard-n-organization-unit>organization-unit</code> properties.</p> <p>Any number of properties with the name <code title=md-vcard-org><a href=#md-vcard-org>org</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-org-organization-name title=md-vcard-org-organization-name><code>organization-name</code></dfn> (inside <code title=md-vcard-org><a href=#md-vcard-org>org</a></code>)</dt> <dd> <p>Gives the name of the organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Exactly one property with the name <code title=md-vcard-org-organization-name><a href=#md-vcard-org-organization-name>organization-name</a></code> must be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-org><a href=#md-vcard-org>org</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-org-organization-unit title=md-vcard-org-organization-unit><code>organization-unit</code></dfn> (inside <code title=md-vcard-org><a href=#md-vcard-org>org</a></code>)</dt> <dd> <p>Gives the name of the organization unit.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-org-organization-unit><a href=#md-vcard-org-organization-unit>organization-unit</a></code> may be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of the <code title=md-vcard-org><a href=#md-vcard-org>org</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-member title=md-vcard-member><code>member</code></dfn></dt> <dd> <p>Gives a <a href=#url>URL</a> that represents a member of the group.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-member><a href=#md-vcard-member>member</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code> if the <a href=#concept-item title=concept-item>item</a> also has a property with the name <code title=md-vcard-kind><a href=#md-vcard-kind>kind</a></code> whose value is "<code title=md-vcard-kind-group><a href=#md-vcard-kind-group>group</a></code>".</p> </dd> <dt><dfn id=md-vcard-related title=md-vcard-related><code>related</code></dfn></dt> <dd> <p>Gives a relationship to another entity.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must an <a href=#concept-item title=concept-item>item</a> with one <code title=md-vcard-org-related-url><a href=#md-vcard-org-related-url>url</a></code> property and one <code title=md-vcard-org-related-rel><a href=#md-vcard-org-related-rel>rel</a></code> properties.</p> <p>Any number of properties with the name <code title=md-vcard-related><a href=#md-vcard-related>orrelated</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-org-related-url title=md-vcard-org-related-url><code>url</code></dfn> (inside <code title=md-vcard-related><a href=#md-vcard-related>related</a></code>)</dt> <dd> <p>Gives the <a href=#url>URL</a> for the related entity.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Exactly one property with the name <code title=md-vcard-org-url>url</code> must be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-related><a href=#md-vcard-related>related</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-org-related-rel title=md-vcard-org-related-rel><code>rel</code></dfn> (inside <code title=md-vcard-related><a href=#md-vcard-related>related</a></code>)</dt> <dd> <p>Gives the relationship between the entity and the related entity.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that, when compared in a <a href=#case-sensitive>case-sensitive</a> manner, is equal to one of the <a href=#relationship-strings>relationship strings</a>.</p> <p>Exactly one property with the name <code title=md-vcard-org-rel>rel</code> must be present within the <a href=#concept-item title=concept-item>item</a> that forms the <a href=#concept-property-value title=concept-property-value>value</a> of an <code title=md-vcard-related><a href=#md-vcard-related>related</a></code> property of an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-categories title=md-vcard-categories><code>categories</code></dfn></dt> <dd> <p>Gives the name of a category or tag that the person or organization could be classified as.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-categories><a href=#md-vcard-categories>categories</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-note title=md-vcard-note><code>note</code></dfn></dt> <dd> <p>Gives supplemental information or a comment about the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vcard-note><a href=#md-vcard-note>note</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <!-- PRODID not included --> <dt><dfn id=md-vcard-rev title=md-vcard-rev><code>rev</code></dfn></dt> <dd> <p>Gives the revision date and time of the contact information.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <!-- copied from vCard --> <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 title=md-vcard-rev><a href=#md-vcard-rev>rev</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-sound title=md-vcard-sound><code>sound</code></dfn></dt> <dd> <p>Gives a sound file relating to the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-sound><a href=#md-vcard-sound>sound</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <dt><dfn id=md-vcard-uid title=md-vcard-uid><code>uid</code></dfn></dt> <dd> <p>Gives a globally unique identifier corresponding to the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vcard-uid><a href=#md-vcard-uid>uid</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <!-- CLIENTPIDMAP not included since the global parameters are not included --> <dt><dfn id=md-vcard-url title=md-vcard-url><code>url</code></dfn></dt> <dd> <p>Gives a <a href=#url>URL</a> relating to the person or organization.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vcard-url><a href=#md-vcard-url>url</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</p> </dd> <!-- VERSION not included - always 4.0 --> <!-- KEY not included - no way to include binary data at this time --> <!-- FBURL, CALADRURI, CALURI not included - unclear how calendars would be exposed on the web --> </dl><p>The <dfn id=kind-strings>kind strings</dfn> are:</p> <dl><dt><dfn id=md-vcard-kind-individual title=md-vcard-kind-individual><code>individual</code></dfn></dt> <dd> <p>Indicates a single entity (e.g. a person).</p> </dd> <dt><dfn id=md-vcard-kind-group title=md-vcard-kind-group><code>group</code></dfn></dt> <dd> <p>Indicates multiple entities (e.g. a mailing list).</p> </dd> <dt><dfn id=md-vcard-kind-org title=md-vcard-kind-org><code>org</code></dfn></dt> <dd> <p>Indicates a single entity that is not a person (e.g. a company).</p> </dd> <dt><dfn id=md-vcard-kind-location title=md-vcard-kind-location><code>location</code></dfn></dt> <dd> <p>Indicates a geographical place (e.g. an office building).</p> </dd> <!-- update this when http://www.iana.org/assignments/vcard-elements/vcard-elements.xml#property-values is updated --> </dl><p>The <dfn id=address-type-strings>address type strings</dfn> are:</p> <dl><dt><dfn id=md-vcard-type-adr-home title=md-vcard-type-adr-home><code>home</code></dfn></dt> <dd> <p>Indicates a residential delivery address.</p> </dd> <dt><dfn id=md-vcard-type-adr-work title=md-vcard-type-adr-work><code>work</code></dfn></dt> <dd> <p>Indicates a delivery address for a place of work.</p> </dd> </dl><p>The <dfn id=telephone-type-strings>telephone type strings</dfn> are:</p> <dl><dt><dfn id=md-vcard-type-tel-home title=md-vcard-type-tel-home><code>home</code></dfn></dt> <dd> <p>Indicates a residential number.</p> </dd> <dt><dfn id=md-vcard-type-tel-work title=md-vcard-type-tel-work><code>work</code></dfn></dt> <dd> <p>Indicates a telephone number for a place of work.</p> </dd> <dt><dfn id=md-vcard-type-tel-text title=md-vcard-type-tel-text><code>text</code></dfn></dt> <dd> <p>Indicates that the telephone number supports text messages (SMS).</p> </dd> <dt><dfn id=md-vcard-type-tel-voice title=md-vcard-type-tel-voice><code>voice</code></dfn></dt> <dd> <p>Indicates a voice telephone number.</p> </dd> <dt><dfn id=md-vcard-type-tel-fax title=md-vcard-type-tel-fax><code>fax</code></dfn></dt> <dd> <p>Indicates a facsimile telephone number.</p> </dd> <dt><dfn id=md-vcard-type-tel-cell title=md-vcard-type-tel-cell><code>cell</code></dfn></dt> <dd> <p>Indicates a cellular telephone number.</p> </dd> <dt><dfn id=md-vcard-type-tel-video title=md-vcard-type-tel-video><code>video</code></dfn></dt> <dd> <p>Indicates a video conferencing telephone number.</p> </dd> <dt><dfn id=md-vcard-type-tel-pager title=md-vcard-type-tel-pager><code>pager</code></dfn></dt> <dd> <p>Indicates a paging device telephone number.</p> </dd> <dt><dfn id=md-vcard-type-tel-textphone title=md-vcard-type-tel-textphone><code>textphone</code></dfn></dt> <dd> <p>Indicates a telecommunication device for people with hearing or speech difficulties.</p> </dd> </dl><p>The <dfn id=relationship-strings>relationship strings</dfn> are:</p> <dl><dt><dfn id=md-vcard-rel-emergency title=md-vcard-rel-emergency><code>emergency</code></dfn></dt> <dd> <p>An emergency contact.</p> </dd> <dt><dfn id=md-vcard-rel-agent title=md-vcard-rel-agent><code>agent</code></dfn></dt> <dd> <p>Another entity that acts on behalf of this entity.</p> </dd> <dt><dfn id=md-vcard-rel-contact title=md-vcard-rel-contact>contact</dfn></dt> <dt><dfn id=md-vcard-rel-acquaintance title=md-vcard-rel-acquaintance>acquaintance</dfn></dt> <dt><dfn id=md-vcard-rel-friend title=md-vcard-rel-friend>friend</dfn></dt> <dt><dfn id=md-vcard-rel-met title=md-vcard-rel-met>met</dfn></dt> <dt><dfn id=md-vcard-rel-co-worker title=md-vcard-rel-co-worker>worker</dfn></dt> <dt><dfn id=md-vcard-rel-colleague title=md-vcard-rel-colleague>colleague</dfn></dt> <dt><dfn id=md-vcard-rel-co-resident title=md-vcard-rel-co-resident>resident</dfn></dt> <dt><dfn id=md-vcard-rel-neighbor title=md-vcard-rel-neighbor>neighbor</dfn></dt> <dt><dfn id=md-vcard-rel-child title=md-vcard-rel-child>child</dfn></dt> <dt><dfn id=md-vcard-rel-parent title=md-vcard-rel-parent>parent</dfn></dt> <dt><dfn id=md-vcard-rel-sibling title=md-vcard-rel-sibling>sibling</dfn></dt> <dt><dfn id=md-vcard-rel-spouse title=md-vcard-rel-spouse>spouse</dfn></dt> <dt><dfn id=md-vcard-rel-kin title=md-vcard-rel-kin>kin</dfn></dt> <dt><dfn id=md-vcard-rel-muse title=md-vcard-rel-muse>muse</dfn></dt> <dt><dfn id=md-vcard-rel-crush title=md-vcard-rel-crush>crush</dfn></dt> <dt><dfn id=md-vcard-rel-date title=md-vcard-rel-date>date</dfn></dt> <dt><dfn id=md-vcard-rel-sweetheart title=md-vcard-rel-sweetheart>sweetheart</dfn></dt> <dt><dfn id=md-vcard-rel-me title=md-vcard-rel-me>me</dfn></dt> <dd> <p>Has the meaning defined in XFN. <a href=#refsXFN>[XFN]</a></p> </dd> <!-- update this when http://www.iana.org/assignments/vcard-elements/vcard-elements.xml#parameter-values is updated --> </dl><h5 id=conversion-to-vcard><span class=secno>5.4.1.1 </span>Conversion to vCard</h5> <p>Given a list of nodes <var title="">nodes</var> in a <code><a href=#document>Document</a></code>, a user agent must run the following algorithm to <dfn id=extracting-a-vcard title="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 title="">nodes</var> are <a href=#concept-item title=concept-item>items</a> with the <a href=#item-types title="item types">item type</a> <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>, then there is no vCard. Abort the algorithm, returning nothing.</li> <li><p>Let <var title="">node</var> be the first node in <var title="">nodes</var> that is an <a href=#concept-item title=concept-item>item</a> with the <a href=#item-types title="item types">item type</a> <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code>.</li> <li><p>Let <var title="">output</var> be an empty string.</li> <li><p><a href=#add-a-vcard-line>Add a vCard line</a> with the type "<code title="">BEGIN</code>" and the value "<code title="">VCARD</code>" to <var title="">output</var>.</li> <li><p><a href=#add-a-vcard-line>Add a vCard line</a> with the type "<code title="">PROFILE</code>" and the value "<code title="">VCARD</code>" to <var title="">output</var>.</li> <li><p><a href=#add-a-vcard-line>Add a vCard line</a> with the type "<code title="">VERSION</code>" and the value "<code title="">4.0</code>" to <var title="">output</var>.</li> <li><p><a href=#add-a-vcard-line>Add a vCard line</a> with the type "<code title="">SOURCE</code>" and the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> that is <a href="#the-document's-current-address">the document's current address</a> as the value to <var title="">output</var>.</li> <li><p>If <a href=#the-title-element-0>the <code>title</code> element</a> is not null, <a href=#add-a-vcard-line>add a vCard line</a> with the type "<code title="">NAME</code>" and with the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> obtained from the <code><a href=#textcontent>textContent</a></code> of <a href=#the-title-element-0>the <code>title</code> element</a> as the value to <var title="">output</var>.</li> <li><p>Let <var title="">sex</var> be the empty string.</li> <li><p>Let <var title="">gender-identity</var> be the empty string.</li> <li> <p>For each element <var title="">element</var> that is <a href=#the-properties-of-an-item title="the properties of an item">a property of the item</a> <var title="">node</var>: for each name <var title="">name</var> in <var title="">element</var>'s <a href=#property-names>property names</a>, run the following substeps:</p> <ol><li><p>Let <var title="">parameters</var> be an empty set of name-value pairs.</li> <li> <p>Run the appropriate set of substeps from the following list. The steps will set a variable <var title="">value</var>, which is used in the next step.</p> <dl><dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a> <var title="">subitem</var> and <var title="">name</var> is <code title=md-vcard-n><a href=#md-vcard-n>n</a></code></dt> <dd> <ol><li><p>Let <var title="">value</var> be the empty string.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-n-family-name><a href=#md-vcard-n-family-name>family-name</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-n-given-name><a href=#md-vcard-n-given-name>given-name</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-n-additional-name><a href=#md-vcard-n-additional-name>additional-name</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-n-honorific-prefix><a href=#md-vcard-n-honorific-prefix>honorific-prefix</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-n-honorific-suffix><a href=#md-vcard-n-honorific-suffix>honorific-suffix</a></code> in <var title="">subitem</var>.</p> </ol></dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a> <var title="">subitem</var> and <var title="">name</var> is <code title=md-vcard-adr><a href=#md-vcard-adr>adr</a></code></dt> <dd> <ol><li><p>Let <var title="">value</var> be the empty string.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-vcard-subproperties>collecting vCard subproperties</a> named <code title=md-vcard-adr-post-office-box><a href=#md-vcard-adr-post-office-box>post-office-box</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-vcard-subproperties>collecting vCard subproperties</a> named <code title=md-vcard-adr-extended-address><a href=#md-vcard-adr-extended-address>extended-address</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-vcard-subproperties>collecting vCard subproperties</a> named <code title=md-vcard-adr-street-address><a href=#md-vcard-adr-street-address>street-address</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-adr-locality><a href=#md-vcard-adr-locality>locality</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-adr-region><a href=#md-vcard-adr-region>region</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-adr-postal-code><a href=#md-vcard-adr-postal-code>postal-code</a></code> in <var title="">subitem</var>.</p> <li>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-adr-country-name><a href=#md-vcard-adr-country-name>country-name</a></code> in <var title="">subitem</var>.</p> <li><p>If there is a property named <code title=md-vcard-adr-type><a href=#md-vcard-adr-type>type</a></code> in <var title="">subitem</var>, and the first such property has a <a href=#concept-property-value title=concept-property-value>value</a> that is not an <a href=#concept-item title=concept-item>item</a> and whose value consists only of <a href=#alphanumeric-ascii-characters>alphanumeric ASCII characters</a>, then add a parameter named "<code title="">TYPE</code>" whose value is the <a href=#concept-property-value title=concept-property-value>value</a> of that property to <var title="">parameters</var>.</li> </ol></dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a> <var title="">subitem</var> and <var title="">name</var> is <code title=md-vcard-org><a href=#md-vcard-org>org</a></code></dt> <dd> <ol><li><p>Let <var title="">value</var> be the empty string.</li> <li><p>Append to <var title="">value</var> the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title=md-vcard-org-organization-name><a href=#md-vcard-org-organization-name>organization-name</a></code> in <var title="">subitem</var>.</p> <li> <p>For each property named <code title=md-vcard-org-organization-unit><a href=#md-vcard-org-organization-unit>organization-unit</a></code> in <var title="">subitem</var>, run the following steps:</p> <ol><li><p>If the <a href=#concept-property-value title=concept-property-value>value</a> of the property is an <a href=#concept-item title=concept-item>item</a>, then skip this property.</li> <li><p>Append a U+003B SEMICOLON character (;) to <var title="">value</var>.</li> <li><p>Append the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> given by the <a href=#concept-property-value title=concept-property-value>value</a> of the property to <var title="">value</var>.</li> </ol></li> </ol></dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a> <var title="">subitem</var> with the <a href=#item-types title="item types">item type</a> <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code> and <var title="">name</var> is <code title=md-vcard-related><a href=#md-vcard-related>related</a></code></dt> <dd> <ol><li><p>Let <var title="">value</var> be the empty string.</li> <li><p>If there is a property named <code title=md-vcard-related-url>url</code> in <var title="">subitem</var>, and its element is a <a href=#url-property-elements title="URL property elements">URL property element</a>, then append the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> given by the <a href=#concept-property-value title=concept-property-value>value</a> of the first such property to <var title="">value</var>, and add a parameter with the name "<code title="">VALUE</code>" and the value "<code title="">URI</code>" to <var title="">parameters</var>.</li> <li><p>If there is a property named <code title=md-vcard-related-rel>rel</code> in <var title="">subitem</var>, and the first such property has a <a href=#concept-property-value title=concept-property-value>value</a> that is not an <a href=#concept-item title=concept-item>item</a> and whose value consists only of <a href=#alphanumeric-ascii-characters>alphanumeric ASCII characters</a>, then add a parameter named "<code title="">RELATION</code>" whose value is the <a href=#concept-property-value title=concept-property-value>value</a> of that property to <var title="">parameters</var>.</li> </ol></dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a> and <var title="">name</var> is none of the above</dt> <!-- tel, adr --> <dd> <ol><li><p>Let <var title="">value</var> be the result of <a href=#collecting-the-first-vcard-subproperty>collecting the first vCard subproperty</a> named <code title="">value</code> in <var title="">subitem</var>.</p> <li><p>If there is a property named <code title="">type</code> in <var title="">subitem</var>, and the first such property has a <a href=#concept-property-value title=concept-property-value>value</a> that is not an <a href=#concept-item title=concept-item>item</a> and whose value consists only of <a href=#alphanumeric-ascii-characters>alphanumeric ASCII characters</a>, then add a parameter named "<code title="">TYPE</code>" whose value is the <a href=#concept-property-value title=concept-property-value>value</a> of that property to <var title="">parameters</var>.</li> </ol></dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is not an <a href=#concept-item title=concept-item>item</a> and its <var title="">name</var> is <code title=md-vcard-sex><a href=#md-vcard-sex>sex</a></code></dt> <dd> <p>If this is the first such property to be found, set <var title="">sex</var> to the property's <a href=#concept-property-value title=concept-property-value>value</a>.</p> </dd> <dt>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is not an <a href=#concept-item title=concept-item>item</a> and its <var title="">name</var> is <code title=md-vcard-gender-identity><a href=#md-vcard-gender-identity>gender-identity</a></code></dt> <dd> <p>If this is the first such property to be found, set <var title="">gender-identity</var> to the property's <a href=#concept-property-value title=concept-property-value>value</a>.</p> </dd> <dt>Otherwise (the property's <a href=#concept-property-value title=concept-property-value>value</a> is not an <a href=#concept-item title=concept-item>item</a>)</dt> <dd> <ol><li><p>Let <var title="">value</var> be the property's <a href=#concept-property-value title=concept-property-value>value</a>.</li> <li><p>If <var title="">element</var> is one of the <a href=#url-property-elements>URL property elements</a>, add a parameter with the name "<code title="">VALUE</code>" and the value "<code title="">URI</code>" to <var title="">parameters</var>.</li> <li><p>Otherwise, if <var title="">name</var> is <code title=md-vcard-bday><a href=#md-vcard-bday>bday</a></code> or <code title=md-vcard-anniversary><a href=#md-vcard-anniversary>anniversary</a></code> and the <var title="">value</var> is a <a href=#valid-date-string>valid date string</a>, add a parameter with the name "<code title="">VALUE</code>" and the value "<code title="">DATE</code>" to <var title="">parameters</var>.</li> <li><p>Otherwise, if <var title="">name</var> is <code title=md-vcard-rev><a href=#md-vcard-rev>rev</a></code> and the <var title="">value</var> is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>, add a parameter with the name "<code title="">VALUE</code>" and the value "<code title="">DATE-TIME</code>" to <var title="">parameters</var>.</li> <li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var title="">value</var> with another U+005C REVERSE SOLIDUS character (\).</li> <li><p>Prefix every U+002C COMMA character (,) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Unless <var title="">name</var> is <code title=md-vcard-geo><a href=#md-vcard-geo>geo</a></code>, prefix every U+003B SEMICOLON character (;) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> </ol></dd> </dl></li> <li> <p><a href=#add-a-vcard-line>Add a vCard line</a> with the type <var title="">name</var>, the parameters <var title="">parameters</var>, and the value <var title="">value</var> to <var title="">output</var>.</p> </li> </ol></li> <li><p>If either of <var title="">sex</var> or <var title="">gender-identity</var> have a value that is not the empty string, <a href=#add-a-vcard-line>add a vCard line</a> with the type "<code title="">GENDER</code>" and the value consisting of the concatenation of <var title="">sex</var>, a U+003B SEMICOLON character (;), and <var title="">gender-identity</var> to <var title="">output</var>.</li> <li><p><a href=#add-a-vcard-line>Add a vCard line</a> with the type "<code title="">END</code>" and the value "<code title="">VCARD</code>" to <var title="">output</var>.</li> </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 title="">type</var>, optionally some parameters, and a value <var title="">value</var> to a string <var title="">output</var>, it must run the following steps:</p> <ol><li><p>Let <var title="">line</var> be an empty string. <li><p>Append <var title="">type</var>, <a href=#converted-to-ascii-uppercase>converted to ASCII uppercase</a>, to <var title="">line</var>.</li> <li> <p>If there are any parameters, then for each parameter, in the order that they were added, run these substeps:</p> <ol><li><p>Append a U+003B SEMICOLON character (;) to <var title="">line</var>.</li> <li><p>Append the parameter's name to <var title="">line</var>.</li> <li><p>Append a U+003D EQUALS SIGN character (=) to <var title="">line</var>.</li> <li><p>Append the parameter's value to <var title="">line</var>.</li> </ol></li> <li><p>Append a U+003A COLON character (:) to <var title="">line</var>.</li> <li><p>Append <var title="">value</var> to <var title="">line</var>.</li> <li><p>Let <var title="">maximum length</var> be 75.</li> <li> <p>If and while <var title="">line</var> is longer than <var title="">maximum length</var> Unicode code points long, run the following substeps:</p> <ol><li><p>Append the first <var title="">maximum length</var> Unicode code points of <var title="">line</var> to <var title="">output</var>.</li> <li><p>Remove the first <var title="">maximum length</var> Unicode code points from <var title="">line</var>.</li> <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var title="">output</var>.</li> <li><p>Append a U+000A LINE FEED character (LF) to <var title="">output</var>.</li> <li><p>Append a U+0020 SPACE character to <var title="">output</var>.</li> <li><p>Let <var title="">maximum length</var> be 74.</li> </ol></li> <li><p>Append (what remains of) <var title="">line</var> to <var title="">output</var>.</li> <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var title="">output</var>.</li> <li><p>Append a U+000A LINE FEED character (LF) to <var title="">output</var>.</li> </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 title="">subname</var> in <var title="">subitem</var>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">value</var> be the empty string.</li> <li> <p>For each property named <var title="">subname</var> in the item <var title="">subitem</var>, run the following substeps:</p> <ol><li><p>If the <a href=#concept-property-value title=concept-property-value>value</a> of the property is itself an <a href=#concept-item title=concept-item>item</a>, then skip this property.</li> <li><p>If this is not the first property named <var title="">subname</var> in <var title="">subitem</var> (ignoring any that were skipped by the previous step), then append a U+002C COMMA character (,) to <var title="">value</var>.</li> <li><p>Append the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> given by the <a href=#concept-property-value title=concept-property-value>value</a> of the property to <var title="">value</var>.</li> </ol></li> <li><p>Return <var title="">value</var>.</li> </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 title="">subname</var> in <var title="">subitem</var>, the user agent must run the following steps:</p> <ol><li><p>If there are no properties named <var title="">subname</var> in <var title="">subitem</var>, then abort these substeps, returning the empty string.</li> <li><p>If the <a href=#concept-property-value title=concept-property-value>value</a> of the first property named <var title="">subname</var> in <var title="">subitem</var> is an <a href=#concept-item title=concept-item>item</a>, then abort these substeps, returning the empty string.</li> <li><p>Return the result of <a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> given by the <a href=#concept-property-value title=concept-property-value>value</a> of the first property named <var title="">subname</var> in <var title="">subitem</var>.</li> </ol><p>When the above algorithms say the user agent is to <dfn id=escaping-the-vcard-text-string title="escaping the vCard text string">escape the vCard text string</dfn> <var title="">value</var>, the user agent must use the following steps:</p> <ol><li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var title="">value</var> with another U+005C REVERSE SOLIDUS character (\).</li> <li><p>Prefix every U+002C COMMA character (,) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Prefix every U+003B SEMICOLON character (;) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> <li><p>Return the mutated <var title="">value</var>.</li> </ol><p class=note>This algorithm can generate invalid vCard output, if the input does not conform to the rules described for the <code title=md-vcard><a href=#md-vcard>http://microformats.org/profile/hcard</a></code> <a href=#item-types title="item types">item type</a> and <a href=#defined-property-name title="defined property name">defined property names</a>.</p> <!-- of course since vcard doesn't define error handling, this is somewhat problematic. --> <h5 id=examples-1><span class=secno>5.4.1.2 </span>Examples</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><section id="jack" itemscope itemtype="http://microformats.org/profile/hcard"> <h1 itemprop="fn"> <span itemprop="n" itemscope> <span itemprop="given-name">Jack</span> <span itemprop="family-name">Bauer</span> </span> </h1> <img itemprop="photo" alt="" src="jack-bauer.jpg"> <p itemprop="org" itemscope> <span itemprop="organization-name">Counter-Terrorist Unit</span> (<span itemprop="organization-unit">Los Angeles Division</span>) </p> <p> <span itemprop="adr" itemscope> <span itemprop="street-address">10201 W. Pico Blvd.</span><br> <span itemprop="locality">Los Angeles</span>, <span itemprop="region">CA</span> <span itemprop="postal-code">90064</span><br> <span itemprop="country-name">United States</span><br> </span> <span itemprop="geo">34.052339;-118.410623</span> </p> <h2>Assorted Contact Methods</h2> <ul> <li itemprop="tel" itemscope> <span itemprop="value">+1 (310) 597 3781</span> <span itemprop="type">work</span> <meta itemprop="type" content="voice"> </li> <li><a itemprop="url" href="http://en.wikipedia.org/wiki/Jack_Bauer">I'm on Wikipedia</a> so you can leave a message on my user talk page.</li> <li><a itemprop="url" href="http://www.jackbauerfacts.com/">Jack Bauer Facts</a></li> <li itemprop="email"><a href="mailto:j.bauer@la.ctu.gov.invalid">j.bauer@la.ctu.gov.invalid</a></li> <li itemprop="tel" itemscope> <span itemprop="value">+1 (310) 555 3781</span> <span> <meta itemprop="type" content="cell">mobile phone</span> </li> </ul> <ins datetime="2008-07-20T21:00:00+01:00"> <meta itemprop="rev" content="2008-07-20T21:00:00+01:00"> <p itemprop="tel" itemscope><strong>Update!</strong> My new <span itemprop="type">home</span> phone number is <span itemprop="value">01632 960 123</span>.</p> </ins> </section></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><a href=#the-address-element>address</a></code> element) containing an address with two street components:</p> <pre><address itemscope itemtype="http://microformats.org/profile/hcard"> <strong itemprop="fn"><span itemprop="n" itemscope><span itemprop="given-name">Alfred</span> <span itemprop="family-name">Person</span></span></strong> <br> <span itemprop="adr" itemscope> <span itemprop="street-address">1600 Amphitheatre Parkway</span> <br> <span itemprop="street-address">Building 43, Second Floor</span> <br> <span itemprop="locality">Mountain View</span>, <span itemprop="region">CA</span> <span itemprop="postal-code">94043</span> </span> </address></pre> </div> <div class=example> <p>The vCard vocabulary can be used to just mark up people's names:</p> <pre><span itemscope itemtype="http://microformats.org/profile/hcard" ><span itemprop=fn><span itemprop="n" itemscope><span itemprop="given-name" >George</span> <span itemprop="family-name">Washington</span></span ></span></span></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 title="">document's address</var> FN:George Washington N:Washington;George;;; END:VCARD</pre> </div> <h4 id=vevent><span class=secno>5.4.2 </span>vEvent</h4> <p>An item with the <a href=#item-types title="item types">item type</a> <dfn id=md-vevent title=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>support global identifiers for items</a>.</p> <p>The following are the type's <a href=#defined-property-name title="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=#refsRFC2445>[RFC2445]</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 title=md-vevent-attach><code>attach</code></dfn></dt> <dd> <p>Gives the address of an associated document for the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-vevent-attach><a href=#md-vevent-attach>attach</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-categories title=md-vevent-categories><code>categories</code></dfn></dt> <dd> <p>Gives the name of a category or tag that the event could be classified as.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vevent-categories><a href=#md-vevent-categories>categories</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-class title=md-vevent-class><code>class</code></dfn></dt> <dd> <p>Gives the access classification of the information regarding the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text with one of the following values:</p> <ul class=brief><li><code title="">public</code></li> <li><code title="">private</code></li> <li><code title="">confidential</code></li> </ul><p class=warning>This is merely advisory and cannot be considered a confidentiality measure.</p> <p>A single property with the name <code title=md-vevent-class><a href=#md-vevent-class>class</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-comment title=md-vevent-comment><code>comment</code></dfn></dt> <dd> <p>Gives a comment regarding the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>Any number of properties with the name <code title=md-vevent-comment><a href=#md-vevent-comment>comment</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-description title=md-vevent-description><code>description</code></dfn></dt> <dd> <p>Gives a detailed description of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vevent-description><a href=#md-vevent-description>description</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-geo title=md-vevent-geo><code>geo</code></dfn></dt> <dd> <p>Gives the geographical position of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text and must match the following syntax:</p> <ol><li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li> <li>One or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>Optionally*, a U+002E FULL STOP character (.) followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>A U+003B SEMICOLON character (;).</li> <li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character (-).</li> <li>One or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> <li>Optionally*, a U+002E FULL STOP character (.) followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li> </ol><p>The optional components marked with an asterisk (*) should be included, and should have six digits each.</p> <!-- iCalendar actually limits the range to -91.0 < lat < 91.0; -181.0 < long < 181.0, which seems weird. It also gives special meanings to +90/-90 lat, and +180 long. --> <!-- copied from vcard (not icalendar!) --> <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 title=md-vevent-geo><a href=#md-vevent-geo>geo</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-location title=md-vevent-location><code>location</code></dfn></dt> <dd> <p>Gives the location of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <!-- v2: support vcard here --> <p>A single property with the name <code title=md-vevent-location><a href=#md-vevent-location>location</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <!-- PRIORITY not included - always 0 - doesn't make sense for single events --> <dt><dfn id=md-vevent-resources title=md-vevent-resources><code>resources</code></dfn></dt> <dd> <p>Gives a resource that will be needed for the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <!-- v2: support vcard here --> <p>Any number of properties with the name <code title=md-vevent-resources><a href=#md-vevent-resources>resources</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-status title=md-vevent-status><code>status</code></dfn></dt> <dd> <p>Gives the confirmation status of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text with one of the following values:</p> <ul class=brief><li><code title="">tentative</code></li> <li><code title="">confirmed</code></li> <li><code title="">cancelled</code></li> <!-- two Ls as per iCalendar spec --> </ul><p>A single property with the name <code title=md-vevent-status><a href=#md-vevent-status>status</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-summary title=md-vevent-summary><code>summary</code></dfn></dt> <dd> <p>Gives a short summary of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>User agents should replace U+000A LINE FEED (LF) characters in the <a href=#concept-property-value title=concept-property-value>value</a> by U+0020 SPACE characters when using the value.</p> <p>A single property with the name <code title=md-vevent-summary><a href=#md-vevent-summary>summary</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-dtend title=md-vevent-dtend><code>dtend</code></dfn></dt> <dd> <p>Gives the date and time by which the event ends.</p> <p>If the property with the name <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code> is present within an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code> that has a property with the name <code title=md-vevent-dtstart><a href=#md-vevent-dtstart>dtstart</a></code> whose value is a <a href=#valid-date-string>valid date string</a>, then the <a href=#concept-property-value title=concept-property-value>value</a> of the property with the name <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code> must be text that is a <a href=#valid-date-string>valid date string</a> also. Otherwise, the <a href=#concept-property-value title=concept-property-value>value</a> of the property must be text that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>In either case, the <a href=#concept-property-value title=concept-property-value>value</a> be later in time than the value of the <code title=md-event-dtstart>dtstart</code> property of the same <a href=#concept-item title=concept-item>item</a>.</p> <p class=note>The time given by the <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code> property is not inclusive. For day-long events, therefore, the <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code> property's <a href=#concept-property-value title=concept-property-value>value</a> will be the day <em>after</em> the end of the event.</p> <p>A single property with the name <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>, so long as that <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code> does not have a property with the name <code title=md-vevent-duration><a href=#md-vevent-duration>duration</a></code>.</p> </dd> <dt><dfn id=md-vevent-dtstart title=md-vevent-dtstart><code>dtstart</code></dfn></dt> <dd> <p>Gives the date and time at which the event starts.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is either a <a href=#valid-date-string>valid date string</a> or a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>Exactly one property with the name <code title=md-vevent-dtstart><a href=#md-vevent-dtstart>dtstart</a></code> must be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-duration title=md-vevent-duration><code>duration</code></dfn></dt> <dd> <p>Gives the duration of the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is a <a href=#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 title=md-vevent-duration><a href=#md-vevent-duration>duration</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>, so long as that <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code> does not have a property with the name <code title=md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code>.</p> </dd> <dt><dfn id=md-vevent-transp title=md-vevent-transp><code>transp</code></dfn></dt> <dd> <p>Gives whether the event is to be considered as consuming time on a calendar, for the purpose of free-busy time searches.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text with one of the following values:</p> <ul class=brief><li><code title="">opaque</code></li> <li><code title="">transparent</code></li> </ul><p>A single property with the name <code title=md-vevent-transp><a href=#md-vevent-transp>transp</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <!-- ATTENDEE not included; iCalendar says MUST NOT be included in published events --> <dt><dfn id=md-vevent-contact title=md-vevent-contact><code>contact</code></dfn></dt> <dd> <p>Gives the contact information for the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <!-- v2: support vcard here --> <p>Any number of properties with the name <code title=md-vevent-contact><a href=#md-vevent-contact>contact</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <!-- ORGANIZER not included, as it is calendar-system-specific (gives a CAL-ADDRESS value); use CONTACT instead --> <!-- RECURRENCE-ID not included... unclear how to make it usefully work here --> <!-- RELATED-TO not included, as it only makes sense for complete calendars --> <dt><dfn id=md-vevent-url title=md-vevent-url><code>url</code></dfn></dt> <dd> <p>Gives a <a href=#url>URL</a> for the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>A single property with the name <code title=md-vevent-url><a href=#md-vevent-url>url</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-uid title=md-vevent-uid><code>uid</code></dfn></dt> <dd> <p>Gives a globally unique identifier corresponding to the event.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text.</p> <p>A single property with the name <code title=md-vevent-uid><a href=#md-vevent-uid>uid</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-exdate title=md-vevent-exdate><code>exdate</code></dfn></dt> <dd> <p>Gives a date and time at which the event does not occur despite the recurrence rules.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is either a <a href=#valid-date-string>valid date string</a> or a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>Any number of properties with the name <code title=md-vevent-exdate><a href=#md-vevent-exdate>exdate</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-exrule title=md-vevent-exrule><code>exrule</code></dfn></dt> <dd> <p>Gives a rule for finding dates and times at which the event does not occur despite the recurrence rules.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that matches the RECUR value type defined in the iCalendar specification. <a href=#refsRFC2445>[RFC2445]</a></p> <p>Any number of properties with the name <code title=md-vevent-exrule><a href=#md-vevent-exrule>exrule</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-rdate title=md-vevent-rdate><code>rdate</code></dfn></dt> <dd> <p>Gives a date and time at which the event recurs.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is one of the following: <ul><li>A <a href=#valid-date-string>valid date string</a>.</li> <li>A <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</li> <li>A <a href=#valid-global-date-and-time-string>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>valid global date and time string</a> representing a later time.</li> <li>A <a href=#valid-global-date-and-time-string>valid global date and time string</a> followed by a U+002F SOLIDUS character (/) followed by a <a href=#valid-vevent-duration-string>valid vevent duration string</a>.</li> </ul><p>Any number of properties with the name <code title=md-vevent-rdate><a href=#md-vevent-rdate>rdate</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-rrule title=md-vevent-rrule><code>rrule</code></dfn></dt> <dd> <p>Gives a rule for finding dates and times at which the event occurs.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that matches the RECUR value type defined in the iCalendar specification. <a href=#refsRFC2445>[RFC2445]</a></p> <p>Any number of properties with the name <code title=md-vevent-rrule><a href=#md-vevent-rrule>rrule</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-created title=md-vevent-created><code>created</code></dfn></dt> <dd> <p>Gives the date and time at which the event information was first created in a calendaring system.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>A single property with the name <code title=md-vevent-created><a href=#md-vevent-created>created</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <!-- DTSTAMP not included, it gets added when serialising --> <dt><dfn id=md-vevent-last-modified title=md-vevent-last-modified><code>last-modified</code></dfn></dt> <dd> <p>Gives the date and time at which the event information was last modified in a calendaring system.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is a <a href=#valid-global-date-and-time-string>valid global date and time string</a>.</p> <p>A single property with the name <code title=md-vevent-last-modified><a href=#md-vevent-last-modified>last-modified</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <dt><dfn id=md-vevent-sequence title=md-vevent-sequence><code>sequence</code></dfn></dt> <dd> <p>Gives a revision number for the event information.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be text that is a <a href=#valid-non-negative-integer>valid non-negative integer</a>.</p> <p>A single property with the name <code title=md-vevent-sequence><a href=#md-vevent-sequence>sequence</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code>.</p> </dd> <!-- REQUEST-STATUS not included, calendaring system interop feature --> </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> <li>One of the following: <ul><li> A <a href=#valid-non-negative-integer>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> <li> At least one, and possible both in this order, of the following: <ol><li> A <a href=#valid-non-negative-integer>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> <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>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> <li> A <a href=#valid-non-negative-integer>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> <li> A <a href=#valid-non-negative-integer>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. </li> </ol></ol></li> </ul></li> </ol><h5 id=conversion-to-icalendar><span class=secno>5.4.2.1 </span>Conversion to iCalendar</h5> <p>Given a list of nodes <var title="">nodes</var> in a <code><a href=#document>Document</a></code>, a user agent must run the following algorithm to <dfn id=extracting-vevent-data title="extracting vEvent data">extract any vEvent data represented by those nodes</dfn>:</p> <ol><li><p>If none of the nodes in <var title="">nodes</var> are <a href=#concept-item title=concept-item>items</a> with the type <code title=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> <li><p>Let <var title="">output</var> be an empty string.</li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">BEGIN</code>" and the value "<code title="">VCALENDAR</code>" to <var title="">output</var>.</li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">PRODID</code>" and the value equal to a user-agent-specific string representing the user agent to <var title="">output</var>.</li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">VERSION</code>" and the value "<code title="">2.0</code>" to <var title="">output</var>.</li> <li> <p>For each node <var title="">node</var> in <var title="">nodes</var> that is an <a href=#concept-item title=concept-item>item</a> with the type <code title=md-vevent><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>Add an iCalendar line</a> with the type "<code title="">BEGIN</code>" and the value "<code title="">VEVENT</code>" to <var title="">output</var>.</li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">DTSTAMP</code>" and a value consisting of an iCalendar DATE-TIME string representing the current date and time, with the annotation "<code title="">VALUE=DATE-TIME</code>", to <var title="">output</var>. <a href=#refsRFC2445>[RFC2445]</a></li> <li> <p>For each element <var title="">element</var> that is <a href=#the-properties-of-an-item title="the properties of an item">a property of the item</a> <var title="">node</var>: for each name <var title="">name</var> in <var title="">element</var>'s <a href=#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 title=concept-property-value>value</a> is an <a href=#concept-item title=concept-item>item</a></dt> <dd> <p>Skip the property.</p> </dd> <dt>If the property is <code title=md-event-dtend>dtend</code></dt> <dt>If the property is <code title=md-event-dtstart>dtstart</code></dt> <dt>If the property is <code title=md-event-exdate>exdate</code></dt> <dt>If the property is <code title=md-event-rdate>rdate</code></dt> <dt>If the property is <code title=md-event-created>created</code></dt> <dt>If the property is <code title=md-event-last-modified>last-modified</code></dt> <dd> <p>Let <var title="">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 title=concept-property-value>value</a>.</p> <p>If the property's <a href=#concept-property-value title=concept-property-value>value</a> is a <a href=#valid-date-string>valid date string</a> then <a href=#add-an-icalendar-line>add an iCalendar line</a> with the type <var title="">name</var> and the value <var title="">value</var> to <var title="">output</var>, with the annotation "<code title="">VALUE=DATE</code>".</p> <p>Otherwise, if the property's <a href=#concept-property-value title=concept-property-value>value</a> is a <a href=#valid-global-date-and-time-string>valid global date and time string</a> then <a href=#add-an-icalendar-line>add an iCalendar line</a> with the type <var title="">name</var> and the value <var title="">value</var> to <var title="">output</var>, with the annotation "<code title="">VALUE=DATE-TIME</code>".</p> <p>Otherwise skip the property.</p> </dd> <dt>Otherwise</dt> <dd> <p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type <var title="">name</var> and the property's <a href=#concept-property-value title=concept-property-value>value</a> to <var title="">output</var>.</p> </dd> </dl></li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">END</code>" and the value "<code title="">VEVENT</code>" to <var title="">output</var>.</li> </ol></li> <li><p><a href=#add-an-icalendar-line>Add an iCalendar line</a> with the type "<code title="">END</code>" and the value "<code title="">VCALENDAR</code>" to <var title="">output</var>.</li> </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 title="">type</var>, a value <var title="">value</var>, and optionally an annotation, to a string <var title="">output</var>, it must run the following steps:</p> <ol><li><p>Let <var title="">line</var> be an empty string.</li> <li><p>Append <var title="">type</var>, <a href=#converted-to-ascii-uppercase>converted to ASCII uppercase</a>, to <var title="">line</var>.</li> <li> <p>If there is an annotation:</p> <ol><li><p>Append a U+003B SEMICOLON character (;) to <var title="">line</var>.</li> <li><p>Append the annotation to <var title="">line</var>.</li> </ol></li> <li><p>Append a U+003A COLON character (:) to <var title="">line</var>.</li> <li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var title="">value</var> with another U+005C REVERSE SOLIDUS character (\).</li> <li><p>Prefix every U+002C COMMA character (,) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Prefix every U+003B SEMICOLON character (;) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\).</li> <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF) in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or U+000A LINE FEED (LF) character in <var title="">value</var> with a U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL LETTER N character (n).</li> <li><p>Append <var title="">value</var> to <var title="">line</var>.</li> <li><p>Let <var title="">maximum length</var> be 75.</li> <li> <p>If and while <var title="">line</var> is longer than <var title="">maximum length</var> Unicode code points long, run the following substeps:</p> <ol><li><p>Append the first <var title="">maximum length</var> Unicode code points of <var title="">line</var> to <var title="">output</var>.</li> <li><p>Remove the first <var title="">maximum length</var> Unicode code points from <var title="">line</var>.</li> <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var title="">output</var>.</li> <li><p>Append a U+000A LINE FEED character (LF) to <var title="">output</var>.</li> <li><p>Append a U+0020 SPACE character to <var title="">output</var>.</li> <li><p>Let <var title="">maximum length</var> be 74.</li> </ol></li> <li><p>Append (what remains of) <var title="">line</var> to <var title="">output</var>.</li> <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var title="">output</var>.</li> <li><p>Append a U+000A LINE FEED character (LF) to <var title="">output</var>.</li> </ol><p class=note>This algorithm can generate invalid iCalendar output, if the input does not conform to the rules described for the <code title=md-vevent><a href=#md-vevent>http://microformats.org/profile/hcalendar#vevent</a></code> <a href=#item-types title="item types">item type</a> and <a href=#defined-property-name title="defined property name">defined property names</a>.</p> <!-- of course since iCalendar doesn't define error handling, this is somewhat problematic. --> <h5 id=examples-2><span class=secno>5.4.2.2 </span>Examples</h5> <p><i>This section is non-normative.</i></p> <!-- get more from http://tools.ietf.org/html/rfc2445 --> <div class=example> <p>Here is an example of a page that uses the vEvent vocabulary to mark up an event:</p> <pre><body itemscope itemtype="http://microformats.org/profile/hcalendar#vevent"> ... <h1 itemprop="summary">Bluesday Tuesday: Money Road</h1> ... <data itemprop="dtstart" value="2009-05-05T19:00:00Z">May 5th @ 7pm</data> (until <data itemprop="dtend" value="2009-05-05T21:00:00Z">9pm</data>) ... <a href="http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road" rel="bookmark" itemprop="url">Link to this page</a> ... <p>Location: <span itemprop="location">The RoadHouse</span></p> ... <p><input type=button value="Add to Calendar" onclick="location = getCalendar(this)"></p> ... <meta itemprop="description" content="via livebrum.co.uk"> </body></pre> <p>The "<code title="">getCalendar()</code>" method could look like this:</p> <pre>function getCalendar(node) { // This function assumes the content is valid. // It is not a compliant implementation of the algorithm for <a href=#extracting-vevent-data>extracting vEvent data</a>. while (node && (!node.itemScope || !node.itemType.contains('http://microformats.org/profile/hcalendar#vevent'))) node = node.parentNode; if (!node) { alert('No event data found.'); return; } var stamp = new Date(); var stampString = '' + stamp.getUTCFullYear() + (stamp.getUTCMonth() + 1) + stamp.getUTCDate() + 'T' + stamp.getUTCHours() + stamp.getUTCMinutes() + stamp.getUTCSeconds() + 'Z'; var calendar = 'BEGIN:VCALENDAR\r\nPRODID:HTML\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nDTSTAMP:' + stampString + '\r\n'; for (var propIndex = 0; propIndex < node.properties.length; propIndex += 1) { var prop = node.properties[propIndex]; var value = prop.itemValue; var parameters = ''; if (prop.localName == 'time') { value = value.replace(/[:-]/g, ''); if (value.match(/T/)) parameters = ';VALUE=DATE'; else parameters = ';VALUE=DATE-TIME'; } else { value = value.replace(/\\/g, '\\n'); value = value.replace(/;/g, '\\;'); value = value.replace(/,/g, '\\,'); value = value.replace(/\n/g, '\\n'); } for (var nameIndex = 0; nameIndex < prop.itemProp.length; nameIndex += 1) { var name = prop.itemProp[nameIndex]; if (!name.match(/:/) && !name.match(/\./)) calendar += name.toUpperCase() + parameters + ':' + value + '\r\n'; } } calendar += 'END:VEVENT\r\nEND:VCALENDAR\r\n'; return 'data:text/calendar;component=vevent,' + encodeURI(calendar); }</pre> <p>The same page could offer some markup, such as the following, for copy-and-pasting into blogs:</p> <pre><div itemscope itemtype="http://microformats.org/profile/hcalendar#vevent"> <p>I'm going to <strong itemprop="summary">Bluesday Tuesday: Money Road</strong>, <data itemprop="dtstart" value="2009-05-05T19:00:00Z">May 5th at 7pm</data> to <data itemprop="dtend" value="2009-05-05T21:00:00Z">9pm</data>, at <span itemprop="location">The RoadHouse</span>!</p> <p><a href="http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road" itemprop="url">See this event on livebrum.co.uk</a>.</p> <meta itemprop="description" content="via livebrum.co.uk"> </div></pre> </div> <h4 id=licensing-works><span class=secno>5.4.3 </span>Licensing works</h4> <p>An item with the <a href=#item-types title="item types">item type</a> <dfn id=md-work title=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 title="defined property name">defined property names</a>.</p> <dl><dt><dfn id=md-work-work title=md-work-work><code>work</code></dfn></dt> <dd> <p>Identifies the work being described.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Exactly one property with the name <code title=md-work-work><a href=#md-work-work>work</a></code> must be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-work><a href=#md-work>http://n.whatwg.org/work</a></code>.</p> </dd> <dt><dfn id=md-work-title title=md-work-title><code>title</code></dfn></dt> <dd> <p>Gives the name of the work.</p> <p>A single property with the name <code title=md-work-title><a href=#md-work-title>title</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-work><a href=#md-work>http://n.whatwg.org/work</a></code>.</p> </dd> <dt><dfn id=md-work-author title=md-work-author><code>author</code></dfn></dt> <dd> <p>Gives the name or contact information of one of the authors or creators of the work.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be either an <a href=#concept-item title=concept-item>item</a> with the type <code title=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 title=md-work-author><a href=#md-work-author>author</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-work><a href=#md-work>http://n.whatwg.org/work</a></code>.</p> </dd> <dt><dfn id=md-work-license title=md-work-license><code>license</code></dfn></dt> <dd> <p>Identifies one of the licenses under which the work is available.</p> <p>The <a href=#concept-property-value title=concept-property-value>value</a> must be an <a href=#absolute-url>absolute URL</a>.</p> <p>Any number of properties with the name <code title=md-work-license><a href=#md-work-license>license</a></code> may be present within each <a href=#concept-item title=concept-item>item</a> with the type <code title=md-work><a href=#md-work>http://n.whatwg.org/work</a></code>.</p> </dd> </dl><h5 id=examples-3><span class=secno>5.4.3.1 </span>Examples</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 3.0 United States License and the MIT license simultaneously.</p> <pre><figure <strong>itemscope itemtype="http://n.whatwg.org/work"</strong>> <img <strong>itemprop="work"</strong> src="mypond.jpeg"> <figcaption> <p><cite <strong>itemprop="title"</strong>>My Pond</cite></p> <p><small>Licensed under the <a <strong>itemprop="license"</strong> href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution-Share Alike 3.0 United States License</a> and the <a <strong>itemprop="license"</strong> href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</small> </figcaption> </figure></pre> </div> <div class=impl> <h3 id=converting-html-to-other-formats><span class=secno>5.5 </span>Converting HTML to other formats</h3> <h4 id=json><span class=secno>5.5.1 </span>JSON</h4> <p>Given a list of nodes <var title="">nodes</var> in a <code><a href=#document>Document</a></code>, a user agent must run the following algorithm to <dfn id=extracting-json title="extracting JSON">extract the microdata from those nodes into a JSON form</dfn>:</p> <ol><li><p>Let <var title="">result</var> be an empty object.</li> <li><p>Let <var title="">items</var> be an empty array.</li> <li><p>For each <var title="">node</var> in <var title="">nodes</var>, check if the element is a <a href=#top-level-microdata-items title="top-level microdata items">top-level microdata item</a>, and if it is then <a href=#get-the-object>get the object</a> for that element and add it to <var title="">items</var>.</li> <li><p>Add an entry to <var title="">result</var> called "<code title="">items</code>" whose value is the array <var title="">items</var>.</li> <li><p>Return the result of serializing <var title="">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 title="">e</code>" used, when appropriate, in the representation of any numbers. <a href=#refsJSON>[JSON]</a></li> </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 title="">item</var>, optionally with a list of elements <var title="">memory</var>, it must run the following substeps:</p> <ol><li><p>Let <var title="">result</var> be an empty object.</li> <li><p>Add <var title="">item</var> to <var title="">memory</var>.</li> <li><p>If the <var title="">item</var> has any <a href=#item-types>item types</a>, add an entry to <var title="">result</var> called "<code title="">type</code>" whose value is an array listing the <a href=#item-types>item types</a> of <var title="">item</var>, in the order they were specified on the <code title=attr-itemtype><a href=#attr-itemtype>itemtype</a></code> attribute.</p> <li><p>If the <var title="">item</var> has a <a href=#global-identifier>global identifier</a>, add an entry to <var title="">result</var> called "<code title="">id</code>" whose value is the <a href=#global-identifier>global identifier</a> of <var title="">item</var>.</li> <li><p>Let <var title="">properties</var> be an empty object.</li> <li> <p>For each element <var title="">element</var> that has one or more <a href=#property-names>property names</a> and is one of <a href=#the-properties-of-an-item title="the properties of an item">the properties of the item</a> <var title="">item</var>, in the order those elements are given by the algorithm that returns <a href=#the-properties-of-an-item>the properties of an item</a>, run the following substeps:</p> <ol><li><p>Let <var title="">value</var> be the <a href=#concept-property-value title=concept-property-value>property value</a> of <var title="">element</var>.</li> <li><p>If <var title="">value</var> is an <a href=#concept-item title=concept-item>item</a>, then: If <var title="">value</var> is in <var title="">memory</var>, then let <var title="">value</var> be the string "<code title="">ERROR</code>". Otherwise, <a href=#get-the-object>get the object</a> for <var title="">value</var>, passing a copy of <var title="">memory</var>, and then replace <var title="">value</var> with the object returned from those steps.</li> <li> <p>For each name <var title="">name</var> in <var title="">element</var>'s <a href=#property-names>property names</a>, run the following substeps:</p> <ol><li><p>If there is no entry named <var title="">name</var> in <var title="">properties</var>, then add an entry named <var title="">name</var> to <var title="">properties</var> whose value is an empty array.</li> <li><p>Append <var title="">value</var> to the entry named <var title="">name</var> in <var title="">properties</var>.</li> </ol></li> </ol></li> <li><p>Add an entry to <var title="">result</var> called "<code title="">properties</code>" whose value is the object <var title="">properties</var>.</li> <li><p>Return <var title="">result</var>.</li> </ol></div> </div><!--data-component--> <!--MD--> <h2 id=browsers><span class=secno>6 </span>Loading Web pages</h2> <div class=impl> <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> </div> <h3 id=windows><span class=secno>6.1 </span>Browsing contexts</h3> <p>A <dfn id=browsing-context>browsing context</dfn> is an environment in which <code><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>browsing context</a>, as does an <code><a href=#the-iframe-element>iframe</a></code><span class=impl> or <code><a href=#frame>frame</a></code>s in a <code><a href=#frameset>frameset</a></code></span>.</p> <p>Each <a href=#browsing-context>browsing context</a> has a corresponding <code><a href=#windowproxy>WindowProxy</a></code> object.</p> <p>A <a href=#browsing-context>browsing context</a> has a <a href=#session-history>session history</a>, which lists the <code><a href=#document>Document</a></code> objects that that <a href=#browsing-context>browsing context</a> has presented, is presenting, or will present. At any time, one <code><a href=#document>Document</a></code> in each <a href=#browsing-context>browsing context</a> is designated the <dfn id=active-document>active document</dfn>.</p> <p>Each <code><a href=#document>Document</a></code> is associated with a <code><a href=#window>Window</a></code> object. A <a href=#browsing-context>browsing context</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object forwards everything to the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>'s <code><a href=#window>Window</a></code> object.</p> <p class=note>In general, there is a 1-to-1 mapping from the <code><a href=#window>Window</a></code> object to the <code><a href=#document>Document</a></code> object. There are two exceptions. First, a <code><a href=#window>Window</a></code> can be reused for the presentation of a second <code><a href=#document>Document</a></code> in the same <a href=#browsing-context>browsing context</a>, such that the mapping is then 2-to-1. This occurs when a <a href=#browsing-context>browsing context</a> is <a href=#navigate title=navigate>navigated</a> from the initial <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> to another, with <a href=#replacement-enabled>replacement enabled</a>. Second, a <code><a href=#document>Document</a></code> can end up being reused for several <code><a href=#window>Window</a></code> objects when the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method is used, such that the mapping is then 1-to-many.</p> <p class=note>A <code><a href=#document>Document</a></code> does not necessarily have a <a href=#browsing-context>browsing context</a> associated with it. In particular, data mining tools are likely to never instantiate browsing contexts.</p> <hr><p>A <a href=#browsing-context>browsing context</a> can have a <dfn id=creator-browsing-context>creator browsing context</dfn>, the <a href=#browsing-context>browsing context</a> that was responsible for its creation. If a <a href=#browsing-context>browsing context</a> has a <a href=#parent-browsing-context>parent browsing context</a>, then that is its <a href=#creator-browsing-context>creator browsing context</a>. Otherwise, if the <a href=#browsing-context>browsing context</a> has an <a href=#opener-browsing-context>opener browsing context</a>, then <em>that</em> is its <a href=#creator-browsing-context>creator browsing context</a>. Otherwise, the <a href=#browsing-context>browsing context</a> has no <a href=#creator-browsing-context>creator browsing context</a>.</p> <p>If a <a href=#browsing-context>browsing context</a> <var title="">A</var> has a <a href=#creator-browsing-context>creator browsing context</a>, then the <code><a href=#document>Document</a></code> that was the <a href=#active-document>active document</a> of that <a href=#creator-browsing-context>creator browsing context</a> at the time <var title="">A</var> was created is the <dfn id=creator-document>creator <code>Document</code></dfn>.</p> <div class=impl> <p>When a <a href=#browsing-context>browsing context</a> is first created, it must be created with a single <code><a href=#document>Document</a></code> in its session history, whose <a href="#the-document's-address" title="the document's address">address</a> is <code><a href=#about:blank>about:blank</a></code>, which is marked as being an <a href=#html-documents title="HTML documents">HTML document</a>, and whose <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> is UTF-8. The <code><a href=#document>Document</a></code> must have a single child <code><a href=#the-html-element>html</a></code> node, which itself has a single child <code><a href=#the-body-element>body</a></code> node.</p> <p class=note>If the <a href=#browsing-context>browsing context</a> is created specifically to be immediately navigated, then that initial navigation will have <a href=#replacement-enabled>replacement enabled</a>.</p> <p id=about-blank-origin>The <a href=#origin>origin</a> of the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> is set when the <code><a href=#document>Document</a></code> is created. If the new <a href=#browsing-context>browsing context</a> has a <a href=#creator-browsing-context>creator browsing context</a>, then the <a href=#origin>origin</a> of the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> is the <a href=#origin>origin</a> of the <a href=#creator-document>creator <code>Document</code></a>. Otherwise, the <a href=#origin>origin</a> of the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> is a globally unique identifier assigned when the new <a href=#browsing-context>browsing context</a> is created.</p> </div> <h4 id=nested-browsing-contexts><span class=secno>6.1.1 </span>Nested browsing contexts</h4> <p>Certain elements (for example, <code><a href=#the-iframe-element>iframe</a></code> elements) can instantiate further <a href=#browsing-context title="browsing context">browsing contexts</a>. These are called <dfn id=nested-browsing-context title="nested browsing context">nested browsing contexts</dfn>. If a browsing context <var title="">P</var> has a <code><a href=#document>Document</a></code> <var title="">D</var> with an element <var title="">E</var> that nests another browsing context <var title="">C</var> inside it, then <var title="">C</var> is said to be <dfn id=browsing-context-nested-through title="browsing context nested through">nested through</dfn> <var title="">D</var>, and <var title="">E</var> is said to be the <dfn id=browsing-context-container>browsing context container</dfn> of <var title="">C</var>. If the <a href=#browsing-context-container>browsing context container</a> element <var title="">E</var> is <a href=#in-a-document title="in a Document">in</a> the <code><a href=#document>Document</a></code> <var title="">D</var>, then <var title="">P</var> is said to be the <dfn id=parent-browsing-context>parent browsing context</dfn> of <var title="">C</var> and <var title="">C</var> is said to be a <dfn id=child-browsing-context>child browsing context</dfn> of <var title="">P</var>. Otherwise, the <a href=#nested-browsing-context>nested browsing context</a> <var title="">C</var> has no <a href=#parent-browsing-context>parent browsing context</a>.</p> <p>A browsing context <var title="">A</var> is said to be an <dfn id=ancestor-browsing-context title="ancestor browsing context">ancestor</dfn> of a browsing context <var title="">B</var> if there exists a browsing context <var title="">A'</var> that is a <a href=#child-browsing-context>child browsing context</a> of <var title="">A</var> and that is itself an <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor</a> of <var title="">B</var>, or if there is a browsing context <var title="">P</var> that is a <a href=#child-browsing-context>child browsing context</a> of <var title="">A</var> and that is the <a href=#parent-browsing-context>parent browsing context</a> of <var title="">B</var>.</p> <p>A browsing context that is not a <a href=#nested-browsing-context>nested browsing context</a> has no <a href=#parent-browsing-context>parent browsing context</a>, and is the <dfn id=top-level-browsing-context>top-level browsing context</dfn> of all the browsing contexts for which it is an <a href=#ancestor-browsing-context>ancestor browsing context</a>.</p> <p>The transitive closure of <a href=#parent-browsing-context title="parent browsing context">parent browsing contexts</a> for a <a href=#nested-browsing-context>nested browsing context</a> gives the list of <a href=#ancestor-browsing-context title="ancestor browsing context">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><a href=#document>Document</a></code> <var title="">d</var> is the (ordered) list returned by the following algorithm:</p> <ol><li><p>Let <var title="">list</var> be an empty list.</li> <li> <p>For each <a href=#child-browsing-context>child browsing context</a> of <var title="">d</var> that is <a href=#browsing-context-nested-through title="browsing context nested through">nested through</a> an element that is <a href=#in-a-document title="in a document">in the <code>Document</code></a> <var title="">d</var>, in the <a href=#tree-order>tree order</a> of the elements nesting those <a href=#browsing-context title="browsing context">browsing contexts</a>, run these substeps:</p> <ol><li><p>Append that <a href=#child-browsing-context>child browsing context</a> to the list <var title="">list</var>.</p> <li><p>Append the <a href=#list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the <a href=#active-document>active document</a> of that <a href=#child-browsing-context>child browsing context</a> to the list <var title="">list</var>.</li> </ol></li> <li><p>Return the constructed <var title="">list</var>.</li> </ol><p>A <code><a href=#document>Document</a></code> is said to be <dfn id=fully-active>fully active</dfn> when it is the <a href=#active-document>active document</a> of its <a href=#browsing-context>browsing context</a>, and either its browsing context is a <a href=#top-level-browsing-context>top-level browsing context</a>, or it has a <a href=#parent-browsing-context>parent browsing context</a> and the <code><a href=#document>Document</a></code> <a href=#browsing-context-nested-through title="browsing context nested through">through which</a> it is <a href=#nested-browsing-context title="nested browsing context">nested</a> is itself <a href=#fully-active>fully active</a>.</p> <p>Because they are nested through an element, <a href=#child-browsing-context title="child browsing context">child browsing contexts</a> are always tied to a specific <code><a href=#document>Document</a></code> in their <a href=#parent-browsing-context>parent browsing context</a>. User agents must not allow the user to interact with <a href=#child-browsing-context title="child browsing context">child browsing contexts</a> of elements that are in <code><a href=#document>Document</a></code>s that are not themselves <a href=#fully-active>fully active</a>.</p> <p>A <a href=#nested-browsing-context>nested browsing context</a> can have a <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> set, if it is embedded through an <code><a href=#the-iframe-element>iframe</a></code> element with a <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code> attribute.</p> <p class=note>A <a href=#nested-browsing-context>nested browsing context</a> can in some cases be taken out of its <a href=#parent-browsing-context>parent browsing context</a> (e.g. if an <code><a href=#the-iframe-element>iframe</a></code> element is removed from its <code><a href=#document>Document</a></code>). In such a situation, the <a href=#nested-browsing-context>nested browsing context</a> has no <a href=#parent-browsing-context>parent browsing context</a>, but it still has the same <a href=#browsing-context-container>browsing context container</a> and is still <a href=#browsing-context-nested-through title="browsing context nested through">nested through</a> that element's <code><a href=#document>Document</a></code>. Such a <a href=#nested-browsing-context>nested browsing context</a> is <em>not</em> a <a href=#top-level-browsing-context>top-level browsing context</a>, and cannot contain <code><a href=#document>Document</a></code>s that are <a href=#fully-active>fully active</a>. Furthermore, if a <a href=#browsing-context-container>browsing context container</a> (such as an <code><a href=#the-iframe-element>iframe</a></code>) is moved to another <code><a href=#document>Document</a></code>, then the <a href=#parent-browsing-context>parent browsing context</a> of its <a href=#nested-browsing-context>nested browsing context</a> will change.</p> <h5 id=navigating-nested-browsing-contexts-in-the-dom><span class=secno>6.1.1.1 </span>Navigating nested browsing contexts in the DOM</h5> <dl class=domintro><dt><var title="">window</var> . <code title=dom-top><a href=#dom-top>top</a></code></dt> <dd> <p>Returns the <code><a href=#windowproxy>WindowProxy</a></code> for the <a href=#top-level-browsing-context>top-level browsing context</a>.</p> </dd> <dt><var title="">window</var> . <code title=dom-parent><a href=#dom-parent>parent</a></code></dt> <dd> <p>Returns the <code><a href=#windowproxy>WindowProxy</a></code> for the <a href=#parent-browsing-context>parent browsing context</a>.</p> </dd> <dt><var title="">window</var> . <code title=dom-frameElement><a href=#dom-frameelement>frameElement</a></code></dt> <dd> <p>Returns the <code><a href=#element>Element</a></code> for the <a href=#browsing-context-container>browsing context container</a>.</p> <p>Returns null if there isn't one.</p> <p>Throws a <code><a href=#securityerror>SecurityError</a></code> exception in cross-origin situations.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-top title=dom-top><code>top</code></dfn> IDL attribute on the <code><a href=#window>Window</a></code> object of a <code><a href=#document>Document</a></code> in a <a href=#browsing-context>browsing context</a> <var title="">b</var> must return the <code><a href=#windowproxy>WindowProxy</a></code> object of its <a href=#top-level-browsing-context>top-level browsing context</a> (which would be its own <code><a href=#windowproxy>WindowProxy</a></code> object if it was a <a href=#top-level-browsing-context>top-level browsing context</a> itself), if it has one, or its own <code><a href=#windowproxy>WindowProxy</a></code> object otherwise (e.g. if it was a detached <a href=#nested-browsing-context>nested browsing context</a>).</p> <p>The <dfn id=dom-parent title=dom-parent><code>parent</code></dfn> IDL attribute on the <code><a href=#window>Window</a></code> object of a <code><a href=#document>Document</a></code> in a <a href=#browsing-context>browsing context</a> <var title="">b</var> must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#parent-browsing-context>parent browsing context</a>, if there is one (i.e. if <var title="">b</var> is a <a href=#child-browsing-context>child browsing context</a>), or the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#browsing-context>browsing context</a> <var title="">b</var> itself, otherwise (i.e. if it is a <a href=#top-level-browsing-context>top-level browsing context</a> or a detached <a href=#nested-browsing-context>nested browsing context</a>).</p> <p>The <dfn id=dom-frameelement title=dom-frameElement><code>frameElement</code></dfn> IDL attribute on the <code><a href=#window>Window</a></code> object of a <code><a href=#document>Document</a></code> <var title="">d</var>, on getting, must run the following algorithm:</p> <ol><li><p>If <var title="">d</var> is not a <code><a href=#document>Document</a></code> in a <a href=#nested-browsing-context>nested browsing context</a>, return null and abort these steps.</li> <li><p>If the <a href=#browsing-context-container>browsing context container</a>'s <code><a href=#document>Document</a></code> does not have the <a href=#same-origin title="same origin">same</a> <a href=#effective-script-origin>effective script origin</a> as the <a href=#entry-script>entry script</a>, then throw a <code><a href=#securityerror>SecurityError</a></code> exception.</li> <li><p>Otherwise, return the <a href=#browsing-context-container>browsing context container</a> for <var title="">b</var>.</li> </ol></div> <h4 id=auxiliary-browsing-contexts><span class=secno>6.1.2 </span>Auxiliary browsing contexts</h4> <p>It is possible to create new browsing contexts that are related to a <a href=#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 title="auxiliary browsing context">auxiliary browsing contexts</dfn>. Auxiliary browsing contexts are always <a href=#top-level-browsing-context title="top-level browsing context">top-level browsing contexts</a>.</p> <p>An <a href=#auxiliary-browsing-context>auxiliary browsing context</a> has an <dfn id=opener-browsing-context>opener browsing context</dfn>, which is the <a href=#browsing-context>browsing context</a> from which the <a href=#auxiliary-browsing-context>auxiliary browsing context</a> was created.</p> <h5 id=navigating-auxiliary-browsing-contexts-in-the-dom><span class=secno>6.1.2.1 </span>Navigating auxiliary browsing contexts in the DOM</h5> <p>The <dfn id=dom-opener title=dom-opener><code>opener</code></dfn> IDL attribute on the <code><a href=#window>Window</a></code> object, on getting, must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#browsing-context>browsing context</a> from which the current <a href=#browsing-context>browsing context</a> was created (its <a href=#opener-browsing-context>opener browsing context</a>), if there is one, if it is still available, and if the current <a href=#browsing-context>browsing context</a> has not <i><a href=#disowned-its-opener>disowned its opener</a></i>. On setting, if the new value is null then the current <a href=#browsing-context>browsing context</a> must <dfn id=disowned-its-opener title="disowned its opener">disown its opener</dfn>; if the new value is anything else then the user agent must ignore the new value.</p> <h4 id=secondary-browsing-contexts><span class=secno>6.1.3 </span>Secondary browsing contexts</h4> <!-- This section only exists for the purpose of defining rel=sidebar, which was dropped due to wg decision in http://www.w3.org/Bugs/Public/show_bug.cgi?id=11183 and then moved to the wiki --> <p>User agents may support <dfn id=secondary-browsing-context title="secondary browsing context">secondary browsing contexts</dfn>, which are <a href=#browsing-context title="browsing context">browsing contexts</a> that form part of the user agent's interface, apart from the main content area.</p> <div class=impl> <h4 id=security-nav><span class=secno>6.1.4 </span>Security</h4> <p id=security-1>A <a href=#browsing-context>browsing context</a> <var title="">A</var> is <dfn id=allowed-to-navigate>allowed to navigate</dfn> a second <a href=#browsing-context>browsing context</a> <var title="">B</var> if one of the following conditions is true:</p> <ul><li>Either the <a href=#origin>origin</a> of the <a href=#active-document>active document</a> of <var title="">A</var> is the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <a href=#active-document>active document</a> of <var title="">B</var>, or</li> <li>The browsing context <var title="">A</var> is a <a href=#nested-browsing-context>nested browsing context</a> with a <a href=#top-level-browsing-context>top-level browsing context</a>, and its <a href=#top-level-browsing-context>top-level browsing context</a> is <var title="">B</var>, or</li> <li>The browsing context <var title="">B</var> is an <a href=#auxiliary-browsing-context>auxiliary browsing context</a> and <var title="">A</var> is <a href=#allowed-to-navigate>allowed to navigate</a> <var title="">B</var>'s <a href=#opener-browsing-context>opener browsing context</a>, or</li> <li>The browsing context <var title="">B</var> is not a <a href=#top-level-browsing-context>top-level browsing context</a>, but there exists an <a href=#ancestor-browsing-context>ancestor browsing context</a> of <var title="">B</var> whose <a href=#active-document>active document</a> has the <a href=#same-origin title="same origin">same</a> <a href=#origin>origin</a> as the <a href=#active-document>active document</a> of <var title="">A</var> (possibly in fact being <var title="">A</var> itself).</li> </ul><hr><p>An element has a <dfn id=browsing-context-scope-origin>browsing context scope origin</dfn> if its <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> is a <a href=#top-level-browsing-context>top-level browsing context</a> or if all of its <code><a href=#document>Document</a></code>'s <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor browsing contexts</a> all have <a href=#active-document title="active document">active documents</a> whose <a href=#origin>origin</a> are the <a href=#same-origin>same origin</a> as the element's <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a>. If an element has a <a href=#browsing-context-scope-origin>browsing context scope origin</a>, then its value is the <a href=#origin>origin</a> of the element's <code><a href=#document>Document</a></code>.</p> </div> <div class=impl> <h4 id=groupings-of-browsing-contexts><span class=secno>6.1.5 </span>Groupings of browsing contexts</h4> <p>Each <a href=#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>browsing context</a> itself.</li> <li>All the <a href=#browsing-context>browsing context</a>'s <a href=#child-browsing-context title="child browsing context">child browsing contexts</a>.</li> <li>The <a href=#browsing-context>browsing context</a>'s <a href=#parent-browsing-context>parent browsing context</a>.</li> <li>All the <a href=#browsing-context title="browsing context">browsing contexts</a> that have the <a href=#browsing-context>browsing context</a> as their <a href=#opener-browsing-context>opener browsing context</a>.</li> <li>The <a href=#browsing-context>browsing context</a>'s <a href=#opener-browsing-context>opener browsing context</a>.</li> </ul><p>The transitive closure of all the <a href=#browsing-context title="browsing context">browsing contexts</a> that are <a href=#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>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>active document</a> with an <a href=#effective-script-origin>effective script origin</a> that, through appropriate manipulation of the <code title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute, could be made to be the same as 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>unit of related similar-origin browsing contexts</dfn>.</p> <p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> can have an <dfn id=entry-script>entry script</dfn> which is used to obtain, amongst other things, the <a href="#script's-base-url">script's base URL</a> to <a href=#resolve-a-url title="resolve a url">resolve</a> relative <a href=#url title=URL>URLs</a> used in scripts running in that <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>. Initially, there is no <a href=#entry-script>entry script</a>. It is changed by the <a href=#jump-to-a-code-entry-point>jump to a code entry-point</a> algorithm.</p> <p class=note>There is at most one <a href=#event-loop>event loop</a> per <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>.</p> </div> <h4 id=browsing-context-names><span class=secno>6.1.6 </span>Browsing context names</h4> <p>Browsing contexts can have a <dfn id=browsing-context-name>browsing context name</dfn>. By default, a browsing context has no name (its name is not set).</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>valid browsing context name</a> or that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for one of: <code title="">_blank</code>, <code title="">_self</code>, <code title="">_parent</code>, or <code title="">_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>browsing context</a> that the link or script is in, "parent" means the <a href=#parent-browsing-context>parent browsing context</a> of the one the link or script is in, "master" means the nearest <a href=#ancestor-browsing-context>ancestor browsing context</a> of the one the link or script is in that is not itself in a <a href=#attr-iframe-seamless title=attr-iframe-seamless>seamless iframe</a>, "top" means the <a href=#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>top-level browsing context</a> or <a href=#auxiliary-browsing-context>auxiliary browsing context</a> is to be created, subject to various user preferences and user agent policies, "maybe new" means the same as "new" but the requirements for those cases encourage user agents to treat it more like "none", and "none" means that by default nothing will happen.</p> <table><thead><tr><th rowspan=2>Keyword <th rowspan=2>Ordinary effect <th colspan=5>Effect in an <code><a href=#the-iframe-element>iframe</a></code> with... <tr><!-- nothing --><th><code title="">seamless=""</code> <th><code title="">sandbox=""</code> <th><code title="">sandbox="" seamless=""</code> <th><code title="">sandbox="allow-top-navigation"</code> <th><code title="">sandbox="allow-top-navigation" seamless=""</code> <tbody><tr><td>none specified, for links and form submissions <!-- same as empty string --> <td>current <td>master <td>current <td>master <td>current <td>master <tr><td>none specified, for <code title=dom-open><a href=#dom-open>window.open()</a></code> <!-- same as _blank --> <td>new <td>new <td>maybe new† <td>maybe new† <td>maybe new† <td>maybe new† <tr><td>empty string <td>current <td>master <td>current <td>master <td>current <td>master <tr><td><code title="">_blank</code> <td>new <td>new <td>maybe new <td>maybe new <td>maybe new <td>maybe new <tr><td><code title="">_self</code> <td>current <td>current <td>current <td>current <td>current <td>current <tr><td><code title="">_parent</code> if there isn't a parent <td>current <td>current <td>current <td>current <td>current <td>current <tr><td><code title="">_parent</code> if parent is also top <td>parent/top <td>parent/top <td>none <td>none <td>parent/top <td>parent/top <tr><td><code title="">_parent</code> if there is one and it's not top <td>parent <td>parent <td>none <td>none <td>none <td>none <tr><td><code title="">_top</code> if top is current <td>current <td>current <td>current <td>current <td>current <td>current <tr><td><code title="">_top</code> if top is not current <td>top <td>top <td>none <td>none <td>top <td>top <tr><td>name that doesn't exist <td>new <td>new <td>maybe new <td>maybe 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 <td>specified descendant <td>specified descendant <td>specified descendant <tr><td>name that exists and is current <td>current <td>current <td>current <td>current <td>current <td>current <tr><td>name that exists and is an ancestor that is top <td>specified ancestor <td>specified ancestor <td>none <td>none <td>specified ancestor/top <td>specified ancestor/top <tr><td>name that exists and is an ancestor that is not top <td>specified ancestor <td>specified ancestor <td>none <td>none <td>none <td>none </table><p><small>† This case is only possible if the <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute also allows scripts.</small></p> <div class=impl> <hr><p>An algorithm is <dfn id=allowed-to-show-a-pop-up>allowed to show a pop-up</dfn> if, in the <a href=#concept-task title=concept-task>task</a> in which the algorithm is running, either:</p> <ul class=brief><li>an <a href=#activation-behavior>activation behavior</a> is currently being processed whose <code title=event-click><a href=#event-click>click</a></code> event was <a href=#concept-events-trusted title=concept-events-trusted>trusted</a>, or</li> <li>the event listener for a <a href=#concept-events-trusted title=concept-events-trusted>trusted</a> <code title=event-click><a href=#event-click>click</a></code> event is being handled.</li> </ul><hr><p><dfn id=the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>The rules for choosing a browsing context given a browsing context name</dfn> are as follows. The rules assume that they are being applied in the context of a <a href=#browsing-context>browsing context</a>.</p> <ol><li> <p>If the given browsing context name is the empty string or <code title="">_self</code>, then the chosen browsing context must be the current one.</p> <p>If the given browsing context name is <code title="">_self</code>, then this is an <dfn id=explicit-self-navigation-override>explicit self-navigation override</dfn>, which overrides the behavior of the <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> set by the <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code> attribute on <code><a href=#the-iframe-element>iframe</a></code> elements.</p> </li> <li><p>If the given browsing context name is <code title="">_parent</code>, then the chosen browsing context must be the <a href=#parent-browsing-context><em>parent</em> browsing context</a> of the current one, unless there isn't one, in which case the chosen browsing context must be the current browsing context.</li> <li><p>If the given browsing context name is <code title="">_top</code>, then the chosen browsing context must be the <a href=#top-level-browsing-context>top-level browsing context</a> of the current one, if there is one, or else the current browsing context.</li> <li> <p>If the given browsing context name is not <code title="">_blank</code> and there exists a browsing context whose <a href=#browsing-context-name title="browsing context name">name</a> is the same as the given browsing context name, and the current browsing context is <a href=#allowed-to-navigate>allowed to navigate</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 that browsing context must be the chosen one. If there are multiple matching browsing contexts, the user agent should select one in some arbitrary consistent manner, such as the most recently opened, most recently focused, or more closely related.</p> <p>If the browsing context is chosen by this step to be the current browsing context, then this is also an <a href=#explicit-self-navigation-override>explicit self-navigation override</a>.</p> </li> <li> <p>Otherwise, a new browsing context is being requested, and what happens depends on the user agent's configuration and/or abilities — it is determined by the rules given for the first applicable option from the following list:</p> <dl class=switch><dt id=sandboxWindowOpen>If the current browsing context had the <a href=#sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> set when its <a href=#active-document>active document</a> was created.</dt> <dd><p>The user agent may offer to create a new <a href=#top-level-browsing-context>top-level browsing context</a> or reuse an existing <a href=#top-level-browsing-context>top-level browsing context</a>. If the user picks one of those options, then the designated browsing context must be the chosen one (the browsing context's name isn't set to the given browsing context name). The default behaviour (if the user agent doesn't offer the option to the user, or if the user declines to allow a browsing context to be used) there must not be a chosen browsing context.</dd> <dt id=noopener>If the user agent has been configured such that in this instance it will create a new browsing context, and the browsing context is being requested as part of <a href=#following-hyperlinks title="following hyperlinks">following a hyperlink</a> whose <a href=#linkTypes>link types</a> include the <code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> keyword</dt> <dd><p>A new <a href=#top-level-browsing-context>top-level browsing context</a> must be created. If the given browsing context name is not <code title="">_blank</code>, then the new top-level browsing context's name must be the given browsing context name (otherwise, it has no name). The chosen browsing context must be this new browsing context.</p> <p class=note>If it is immediately <a href=#navigate title=navigate>navigated</a>, then the navigation will be done with <a href=#replacement-enabled>replacement enabled</a>.</dd> <dt>If the user agent has been configured such that in this instance it will create a new browsing context, and the <code title=rel-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code> keyword doesn't apply</dt> <dd><p>A new <a href=#auxiliary-browsing-context>auxiliary browsing context</a> must be created, with the <a href=#opener-browsing-context>opener browsing context</a> being the current one. If the given browsing context name is not <code title="">_blank</code>, then the new auxiliary browsing context's name must be the given browsing context name (otherwise, it has no name). The chosen browsing context must be this new browsing context.</p> <p class=note>If it is immediately <a href=#navigate title=navigate>navigated</a>, then the navigation will be done with <a href=#replacement-enabled>replacement enabled</a>.</dd> <dt>If the user agent has been configured such that in this instance it will reuse the current browsing context</dt> <dd><p>The chosen browsing context is the current browsing context.</dd> <dt>If the user agent has been configured such that in this instance it will not find a browsing context</dt> <dd><p>There must not be a chosen browsing context.</dd> </dl><p>User agent implementors are encouraged to provide a way for users to configure the user agent to always reuse the current browsing context.</p> </li> </ol></div> <h3 id=the-window-object><span class=secno>6.2 </span>The <code><a href=#window>Window</a></code> object</h3> <pre class=idl>[ReplaceableNamedProperties] interface <dfn id=window>Window</dfn> : <a href=#eventtarget>EventTarget</a> { // the current browsing context [Unforgeable] readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-window title=dom-window>window</a>; [Replaceable] readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-self title=dom-self>self</a>; [Unforgeable] readonly attribute <a href=#document>Document</a> <a href=#dom-document title=dom-document>document</a>; attribute DOMString <a href=#dom-name title=dom-name>name</a>; <!-- not [Replaceable] per WebKit and IE8 --> [PutForwards=<a href=#dom-location-href title=dom-location-href>href</a>, Unforgeable] readonly attribute <a href=#location>Location</a> <a href=#dom-location title=dom-location>location</a>; readonly attribute <a href=#history-0>History</a> <a href=#dom-history title=dom-history>history</a>; <!--FIND--> boolean <a href=#dom-find title=dom-find>find</a>(optional DOMString aString, optional boolean aCaseSensitive, optional boolean aBackwards, optional boolean aWrapAround, optional boolean aWholeWord, optional boolean aSearchInFrames, optional boolean aShowDialog); <!--FIND--> [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-locationbar title=dom-window-locationbar>locationbar</a>; [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-menubar title=dom-window-menubar>menubar</a>; [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-personalbar title=dom-window-personalbar>personalbar</a>; [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-scrollbars title=dom-window-scrollbars>scrollbars</a>; [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-statusbar title=dom-window-statusbar>statusbar</a>; [Replaceable] readonly attribute <a href=#barprop>BarProp</a> <a href=#dom-window-toolbar title=dom-window-toolbar>toolbar</a>;<!-- [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-directories">directories</span>; // legacy (Gecko-only) --> attribute DOMString <a href=#dom-window-status title=dom-window-status>status</a>; void <a href=#dom-window-close title=dom-window-close>close</a>(); void <a href=#dom-window-stop title=dom-window-stop>stop</a>(); void <a href=#dom-window-focus title=dom-window-focus>focus</a>(); void <a href=#dom-window-blur title=dom-window-blur>blur</a>(); // other browsing contexts [Replaceable] readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-frames title=dom-frames>frames</a>; [Replaceable] readonly attribute unsigned long <a href=#dom-length title=dom-length>length</a>; [Unforgeable] readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-top title=dom-top>top</a>; attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-opener title=dom-opener>opener</a>; readonly attribute <a href=#windowproxy>WindowProxy</a> <a href=#dom-parent title=dom-parent>parent</a>; readonly attribute <a href=#element>Element</a>? <a href=#dom-frameelement title=dom-frameElement>frameElement</a>; <a href=#windowproxy>WindowProxy</a> <a href=#dom-open title=dom-open>open</a>(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace); <a href=#dom-window-item title=dom-window-item>getter</a> <a href=#windowproxy>WindowProxy</a> (unsigned long index); <a href=#dom-window-nameditem title=dom-window-namedItem>getter</a> object (DOMString name); // the user agent readonly attribute <a href=#navigator>Navigator</a> <a href=#dom-navigator title=dom-navigator>navigator</a>; <!-- IE also has window.clientInformation === window.navigator --> readonly attribute <a href=#external>External</a> <a href=#dom-external title=dom-external>external</a>; readonly attribute <a href=#applicationcache>ApplicationCache</a> <a href=#dom-applicationcache title=dom-applicationCache>applicationCache</a>; // user prompts void <a href=#dom-alert title=dom-alert>alert</a>(DOMString message); boolean <a href=#dom-confirm title=dom-confirm>confirm</a>(DOMString message); DOMString? <a href=#dom-prompt title=dom-prompt>prompt</a>(DOMString message, optional DOMString default); void <a href=#dom-print title=dom-print>print</a>(); any <a href=#dom-showmodaldialog title=dom-showModalDialog>showModalDialog</a>(DOMString url, optional any argument<!--, optional DOMString features-->); <!--POSTMSG--> // <a href=#web-messaging>cross-document messaging</a> void <a href=#dom-window-postmessage title=dom-window-postMessage>postMessage</a>(any message, DOMString targetOrigin, optional sequence<<a href=#transferable>Transferable</a>> transfer); <!--POSTMSG--> // <a href=#event-handler-idl-attributes>event handler IDL attributes</a> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onabort title=handler-onabort>onabort</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onafterprint title=handler-window-onafterprint>onafterprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeprint title=handler-window-onbeforeprint>onbeforeprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onblur title=handler-window-onblur>onblur</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplay title=handler-oncanplay>oncanplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncanplaythrough title=handler-oncanplaythrough>oncanplaythrough</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onchange title=handler-onchange>onchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onclick title=handler-onclick>onclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncontextmenu title=handler-oncontextmenu>oncontextmenu</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oncuechange title=handler-oncuechange>oncuechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondblclick title=handler-ondblclick>ondblclick</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrag title=handler-ondrag>ondrag</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragend title=handler-ondragend>ondragend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragenter title=handler-ondragenter>ondragenter</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragleave title=handler-ondragleave>ondragleave</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragover title=handler-ondragover>ondragover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondragstart title=handler-ondragstart>ondragstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondrop title=handler-ondrop>ondrop</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ondurationchange title=handler-ondurationchange>ondurationchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onemptied title=handler-onemptied>onemptied</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onended title=handler-onended>onended</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onerror title=handler-window-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onfocus title=handler-window-onfocus>onfocus</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onhashchange title=handler-window-onhashchange>onhashchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninput title=handler-oninput>oninput</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-oninvalid title=handler-oninvalid>oninvalid</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeydown title=handler-onkeydown>onkeydown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeypress title=handler-onkeypress>onkeypress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onkeyup title=handler-onkeyup>onkeyup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onload title=handler-window-onload>onload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadeddata title=handler-onloadeddata>onloadeddata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadedmetadata title=handler-onloadedmetadata>onloadedmetadata</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onloadstart title=handler-onloadstart>onloadstart</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onmessage title=handler-window-onmessage>onmessage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousedown title=handler-onmousedown>onmousedown</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousemove title=handler-onmousemove>onmousemove</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseout title=handler-onmouseout>onmouseout</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseover title=handler-onmouseover>onmouseover</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmouseup title=handler-onmouseup>onmouseup</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onmousewheel title=handler-onmousewheel>onmousewheel</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onoffline title=handler-window-onoffline>onoffline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-ononline title=handler-window-ononline>ononline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onpause title=handler-onpause>onpause</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplay title=handler-onplay>onplay</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onplaying title=handler-onplaying>onplaying</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpagehide title=handler-window-onpagehide>onpagehide</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpageshow title=handler-window-onpageshow>onpageshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpopstate title=handler-window-onpopstate>onpopstate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onprogress title=handler-onprogress>onprogress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onratechange title=handler-onratechange>onratechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onreset title=handler-onreset>onreset</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onresize title=handler-window-onresize>onresize</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onscroll title=handler-onscroll>onscroll</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeked title=handler-onseeked>onseeked</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onseeking title=handler-onseeking>onseeking</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onselect title=handler-onselect>onselect</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onshow title=handler-onshow>onshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onstalled title=handler-onstalled>onstalled</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onstorage title=handler-window-onstorage>onstorage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsubmit title=handler-onsubmit>onsubmit</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onsuspend title=handler-onsuspend>onsuspend</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-ontimeupdate title=handler-ontimeupdate>ontimeupdate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onunload title=handler-window-onunload>onunload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onvolumechange title=handler-onvolumechange>onvolumechange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onwaiting title=handler-onwaiting>onwaiting</a>; };</pre> <!-- for more features to add here, look here: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window.asp http://www.mozilla.org/docs/dom/domref/dom_window_ref.html http://lxr.mozilla.org/mozilla/source/dom/public/idl/base/nsIDOMWindow.idl - scrollBy, etc http://lxr.mozilla.org/mozilla/source/dom/public/idl/base/nsIDOMWindowInternal.idl - DOM level 0 --> <dl class=domintro><dt><var title="">window</var> . <code title=dom-window><a href=#dom-window>window</a></code></dt> <dt><var title="">window</var> . <code title=dom-frames><a href=#dom-frames>frames</a></code></dt> <dt><var title="">window</var> . <code title=dom-self><a href=#dom-self>self</a></code></dt> <dd> <p>These attributes all return <var title="">window</var>.</p> </dd> <dt><var title="">window</var> . <code title=dom-document><a href=#dom-document>document</a></code></dt> <dd> <p>Returns the <a href=#active-document>active document</a>.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-defaultView><a href=#dom-document-defaultview>defaultView</a></code></dt> <dd> <p>Returns the <code><a href=#window>Window</a></code> object of the <a href=#active-document>active document</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-window title=dom-window><code>window</code></dfn>, <dfn id=dom-frames title=dom-frames><code>frames</code></dfn>, and <dfn id=dom-self title=dom-self><code>self</code></dfn> IDL attributes must all return the <code><a href=#window>Window</a></code> object's <a href=#browsing-context>browsing context</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object.</p> <p>The <dfn id=dom-document title=dom-document><code>document</code></dfn> IDL attribute must return the <code><a href=#document>Document</a></code> object of the <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>.</p> <p>The <dfn id=dom-document-defaultview title=dom-document-defaultView><code>defaultView</code></dfn> IDL attribute of the <code><a href=#document>Document</a></code> interface must return the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object, if there is one, or null otherwise.</p> <hr><p>For historical reasons, <code><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><a href=#document>Document</a></code> interface object.</p> </div> <div class=impl> <h4 id=security-window><span class=secno>6.2.1 </span>Security</h4> <p id=security-2>User agents must throw a <code><a href=#securityerror>SecurityError</a></code> exception whenever any properties of a <code><a href=#window>Window</a></code> object are accessed by scripts whose <a href=#effective-script-origin>effective script origin</a> is not the same as the <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>'s <a href=#effective-script-origin>effective script origin</a>, with the following exceptions:</p> <ul><li>The <code title=dom-location><a href=#dom-location>location</a></code> attribute <li>The <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage()</a></code> method <li>The <code title=dom-frames><a href=#dom-frames>frames</a></code> attribute <li>The <a href=#dynamic-nested-browsing-context-properties>dynamic nested browsing context properties</a> </ul><p>When a script whose <a href=#effective-script-origin>effective script origin</a> is not the same as the <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>'s <a href=#effective-script-origin>effective script origin</a> attempts to access that <code><a href=#window>Window</a></code> object's methods or attributes, the user agent must act as if any changes to the <code><a href=#window>Window</a></code> object's properties, getters, setters, etc, were not present.</p> <p>For members that return objects (including function objects), each distinct <a href=#effective-script-origin>effective script origin</a> that is not the same as the <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>'s <a href=#effective-script-origin>effective script origin</a> must be provided with a separate set of objects. These objects must have the prototype chain appropriate for the script for which the objects are created (not those that would be appropriate for scripts whose <a href="#script's-global-object">script's global object</a> is the <code><a href=#window>Window</a></code> object in question).</p> <div class=example> <p>For instance, if two frames containing <code><a href=#document>Document</a></code>s from different <a href=#origin title=origin>origins</a> access the same <code><a href=#window>Window</a></code> object's <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage()</a></code> method, they will get distinct objects that are not equal.</p> </div> </div> <h4 id=apis-for-creating-and-navigating-browsing-contexts-by-name><span class=secno>6.2.2 </span>APIs for creating and navigating browsing contexts by name</h4> <dl class=domintro><dt><var title="">window</var> = <var title="">window</var> . <code title=dom-open><a href=#dom-open>open</a></code>( [ <var title="">url</var> [, <var title="">target</var> [, <var title="">features</var> [, <var title="">replace</var> ] ] ] ] )</dt> <dd> <p>Opens a window to show <var title="">url</var> (defaults to <code><a href=#about:blank>about:blank</a></code>), and returns it. The <var title="">target</var> argument gives the name of the new window. If a window exists with that name already, it is reused. The <var title="">replace</var> attribute, if true, means that whatever page is currently open in that window will be removed from the window's session history. The <var title="">features</var> argument is ignored.</p> </dd> <dt><var title="">window</var> . <code title=dom-name><a href=#dom-name>name</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the name of the window.</p> <p>Can be set, to change the name.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-close><a href=#dom-window-close>close</a></code>()</dt> <dd> <p>Closes the window.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-stop><a href=#dom-window-stop>stop</a></code>()</dt> <dd> <p>Cancels the document load.</p> </dd> </dl><div class=impl> <!-- This whole section should be rewritten to use algorithmic style --> <p>The <dfn id=dom-open title=dom-open><code>open()</code></dfn> method on <code><a href=#window>Window</a></code> objects provides a mechanism for <a href=#navigate title=navigate>navigating</a> an existing <a href=#browsing-context>browsing context</a> or opening and navigating an <a href=#auxiliary-browsing-context>auxiliary browsing context</a>.</p> <p>The method has four arguments, though they are all optional.</p> <p>The first argument, <var title="">url</var>, must be a <a href=#valid-non-empty-url>valid non-empty URL</a> for a page to load in the browsing context. If no arguments are provided, or if the first argument is the empty string, then the <var title="">url</var> argument defaults to "<code><a href=#about:blank>about:blank</a></code>". The argument must be <a href=#resolve-a-url title="resolve a url">resolved</a> to an <a href=#absolute-url>absolute URL</a> (or an error), relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>, when the method is invoked.</p> <p>The second argument, <var title="">target</var>, specifies the <a href=#browsing-context-name title="browsing context name">name</a> of the browsing context that is to be navigated. It must be a <a href=#valid-browsing-context-name-or-keyword>valid browsing context name or keyword</a>. If fewer than two arguments are provided, then the <var title="">target</var> argument defaults to the value "<code>_blank</code>".</p> <p>The third argument, <var title="">features</var>, has no defined effect and is mentioned for historical reasons only. User agents may interpret this argument as instructions to set the size and position of the browsing context, but are encouraged to instead ignore the argument entirely.</p> <p>The fourth argument, <var title="">replace</var>, specifies whether or not the new page will <a href=#replacement-enabled title="replacement enabled">replace</a> the page currently loaded in the browsing context, when <var title="">target</var> identifies an existing browsing context (as opposed to leaving the current page in the browsing context's <a href=#session-history>session history</a>). When three or fewer arguments are provided, <var title="">replace</var> defaults to false.</p> <p>When the method is invoked, the user agent must first select a <a href=#browsing-context>browsing context</a> to navigate by applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a> using the <var title="">target</var> argument as the name and the <a href=#browsing-context>browsing context</a> of the script as the context in which the algorithm is executed, unless the user has indicated a preference, in which case the browsing context to navigate may instead be the one indicated by the user.</p> <p class=example>For example, suppose there is a user agent that supports control-clicking a link to open it in a new tab. If a user clicks in that user agent on an element whose <code title=handler-onclick><a href=#handler-onclick>onclick</a></code> handler uses the <code title=dom-open><a href=#dom-open>window.open()</a></code> API to open a page in an iframe, but, while doing so, holds the control key down, the user agent could override the selection of the target browsing context to instead target a new tab.</p> <p>If the method is not <a href=#allowed-to-show-a-pop-up>allowed to show a pop-up</a> and applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a> using the <var title="">target</var> argument, would result in there not being a chosen browsing context, then throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these steps.</p> <p>Otherwise, if <var title="">url</var> is not "<code><a href=#about:blank>about:blank</a></code>", the user agent must <a href=#navigate>navigate</a><!--DONAV window.open()--> the selected <a href=#browsing-context>browsing context</a> to the <a href=#absolute-url>absolute URL</a> (or error) obtained from <a href=#resolve-a-url title="resolve a url">resolving</a> <var title="">url</var> earlier. If the <var title="">replace</var> is true or if the <a href=#browsing-context>browsing context</a> was just created as part of <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context given a browsing context name</a>, then <a href=#replacement-enabled title="replacement enabled">replacement must be enabled</a>. The navigation must be done with the <a href="#script's-browsing-context" title="script's browsing context">browsing context</a> of the <a href=#entry-script>entry script</a> as the <a href=#source-browsing-context>source browsing context</a>.</p> <p>If <var title="">url</var> <em>is</em> "<code><a href=#about:blank>about:blank</a></code>", the user agent must instead <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the selected <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code> object, but with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the selected <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the <code><a href=#window>Window</a></code> object).</p> <p>The method must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#browsing-context>browsing context</a> that was navigated, or null if no browsing context was navigated.</p> <hr><p>The <dfn id=dom-name title=dom-name><code>name</code></dfn> attribute of the <code><a href=#window>Window</a></code> object must, on getting, return the current name of the <a href=#browsing-context>browsing context</a>, and, on setting, set the name of the <a href=#browsing-context>browsing context</a> to the new value.</p> <p class=note>The name <a href=#resetBCName>gets reset</a> when the browsing context is navigated to another domain.</p> <hr><p>The <dfn id=dom-window-close title=dom-window-close><code>close()</code></dfn> method on <code><a href=#window>Window</a></code> objects should, if the corresponding <a href=#browsing-context>browsing context</a> <var title="">A</var> is an <a href=#auxiliary-browsing-context>auxiliary browsing context</a> that was created by a script (as opposed to by an action of the user), and if the <a href="#script's-browsing-context" title="script's browsing context">browsing context</a> of the <a href=#concept-script title=concept-script>script</a> that invokes the method is <a href=#allowed-to-navigate>allowed to navigate</a> the <a href=#browsing-context>browsing context</a> <var title="">A</var>, close the <a href=#browsing-context>browsing context</a> <var title="">A</var> (and may <a href=#a-browsing-context-is-discarded title="a browsing context is discarded">discard</a> it too).</p> <p>The <dfn id=dom-window-stop title=dom-window-stop><code>stop()</code></dfn> method on <code><a href=#window>Window</a></code> objects should, if there is an existing attempt to <a href=#navigate>navigate</a> the <a href=#browsing-context>browsing context</a> and that attempt is not currently running the <a href=#unload-a-document>unload a document</a> algorithm, cancel that <a href=#navigate title=navigate>navigation</a> and any associated instances of the <a href=#fetch title=fetch>fetch algorithm</a>. Otherwise, it must do nothing.</p> </div> <h4 id=accessing-other-browsing-contexts><span class=secno>6.2.3 </span>Accessing other browsing contexts</h4> <dl class=domintro><dt><var title="">window</var> . <code title=dom-length><a href=#dom-length>length</a></code></dt> <dd> <p>Returns the number of <a href=#child-browsing-context title="child browsing context">child browsing contexts</a>.</p> </dd> <dt><var title="">window</var>[<var title="">index</var>]</dt> <dd> <p>Returns the indicated <a href=#child-browsing-context>child browsing context</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-length title=dom-length><code>length</code></dfn> IDL attribute on the <code><a href=#window>Window</a></code> interface must return the number of <a href=#child-browsing-context title="child browsing context">child browsing contexts</a> that are <a href=#browsing-context-nested-through title="browsing context nested through">nested through</a> elements that are <a href=#in-a-document title="in a document">in the <code>Document</code></a> that is the <a href=#active-document>active document</a> of that <code><a href=#window>Window</a></code> object, if that <code><a href=#window>Window</a></code>'s <a href=#browsing-context>browsing context</a> shares the same <a href=#event-loop>event loop</a> as the <a href="#script's-browsing-context">script's browsing context</a> of the <a href=#entry-script>entry script</a> accessing the IDL attribute; otherwise, it must return zero.</p> <!-- in other words, frames are only accessible to same-thread processes --> <p>The <a href=#supported-property-indices>supported property indices</a> on the <code><a href=#window>Window</a></code> object at any instant are the numbers in the range 0 .. <span title=""><var title="">n</var>-1</span>, where <var title="">n</var> is the number returned by the <code title=dom-length><a href=#dom-length>length</a></code> IDL attribute. If <var title="">n</var> is zero then there are no <a href=#supported-property-indices>supported property indices</a>.</p> <p>To <dfn id=dom-window-item title=dom-window-item>determine the value of an indexed property</dfn> <var title="">index</var> of a <code><a href=#window>Window</a></code> object, the user agent must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <var title="">index</var>th <a href=#child-browsing-context>child browsing context</a> of the <code><a href=#document>Document</a></code> that is nested through an element that is <a href=#in-a-document title="in a document">in the <code>Document</code></a>, sorted in the <a href=#tree-order>tree order</a> of the elements nesting those <a href=#browsing-context title="browsing context">browsing contexts</a>.</p> <p>These properties are the <dfn id=dynamic-nested-browsing-context-properties>dynamic nested browsing context properties</dfn>.</p> </div> <h4 id=named-access-on-the-window-object><span class=secno>6.2.4 </span>Named access on the <code><a href=#window>Window</a></code> object</h4> <dl class=domintro><dt><var title="">window</var>[<var title="">name</var>]</dt> <dd> <p>Returns the indicated element or collection of elements.</p> </dd> </dl><div class=impl> <p>The <code><a href=#window>Window</a></code> interface <span title="support named properties">supports named properties</span>. The <a href=#supported-property-names>supported property names</a> at any moment consist of:</p> <ul><li>the value of the <code title="">name</code> content attribute for all <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, and <code><a href=#the-object-element>object</a></code> elements in the <a href=#active-document>active document</a> that have a <code title="">name</code> content attribute, and</li> <li>the value of the <code title=attr-id><a href=#the-id-attribute>id</a></code> content attribute of any <a href=#html-elements title="HTML elements">HTML element</a> in the <a href=#active-document>active document</a> with an <code title=attr-id><a href=#the-id-attribute>id</a></code> content attribute.</li> </ul><p class=critical>It is possible that this will change. Browser vendors are considering limiting this behaviour to <a href=#quirks-mode>quirks mode</a>. <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=11960">Read more...</a></p> <p>To <a href=#determine-the-value-of-a-named-property>determine the value of a named property</a> <var title="">name</var> when <dfn id=dom-window-nameditem title=dom-window-namedItem>the <code>Window</code> object is indexed for property retrieval</dfn>, the user agent must return the value obtained using the following steps:</p> <ol><li> <p>Let <var title="">elements</var> be the list of <a href=#dom-window-nameditem-filter title=dom-window-namedItem-filter>named elements</a> with the name <var title="">name</var> in the <a href=#active-document>active document</a>. <p class=note>There will be at least one such element, by definition.<!-- (If there wasn't, then this algorithm wouldn't have been invoked by Web IDL.) --></p> </li> <li> <p>If <var title="">elements</var> contains an <code><a href=#the-iframe-element>iframe</a></code> element, then return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#nested-browsing-context>nested browsing context</a> represented by the first such <code><a href=#the-iframe-element>iframe</a></code> element in <a href=#tree-order>tree order</a>, and abort these steps.</p> </li> <li> <p>Otherwise, if <var title="">elements</var> has only one element, return that element and abort these steps.</p> </li> <li> <p>Otherwise return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <a href=#dom-window-nameditem-filter title=dom-window-namedItem-filter>named elements</a> with the name <var title="">name</var>.</p> <!-- the same one each time is returned, because of the rule under collections --> </li> </ol><p><dfn id=dom-window-nameditem-filter title=dom-window-nameditem-filter>Named elements</dfn> with the name <var title="">name</var>, for the purposes of the above algorithm, are those that are either:</p> <ul><li><code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <code><a href=#the-object-element>object</a></code> elements that have a <code title=attr-name>name</code> content attribute whose value is <var title="">name</var>, or</li> <li><a href=#html-elements>HTML elements</a> that have an <code title=attr-id><a href=#the-id-attribute>id</a></code> content attribute whose value is <var title="">name</var>.</li> </ul></div> <div class=impl> <h4 id=garbage-collection-and-browsing-contexts><span class=secno>6.2.5 </span>Garbage collection and browsing contexts</h4> <p>A <a href=#browsing-context>browsing context</a> has a strong reference to each of its <code><a href=#document>Document</a></code>s and its <code><a href=#windowproxy>WindowProxy</a></code> object, and the user agent itself has a strong reference to its <a href=#top-level-browsing-context title="top-level browsing context">top-level browsing contexts</a>.</p> <p>A <code><a href=#document>Document</a></code> has a strong reference to its <code><a href=#window>Window</a></code> object.</p> <p class=note>A <code><a href=#window>Window</a></code> object <a href=#implied-strong-reference title="implied strong reference">has a strong reference</a> to its <code><a href=#document>Document</a></code> object through its <code title=dom-document><a href=#dom-document>document</a></code> attribute. Thus, references from other scripts to either of those objects will keep both alive. Similarly, both <code><a href=#document>Document</a></code> and <code><a href=#window>Window</a></code> objects have <a href=#implied-strong-reference title="implied strong reference">implied strong references</a> to the <code><a href=#windowproxy>WindowProxy</a></code> object.</p> <p>Each <a href=#concept-script title=concept-script>script</a> has a strong reference to its <a href="#script's-browsing-context" title="script's browsing context">browsing context</a> and its <a href="#script's-document" title="script's document">document</a>.</p> <!-- discard a document --> <p>When a <a href=#browsing-context>browsing context</a> is to <dfn id=discard-a-document>discard a <code>Document</code></dfn>, the user agent must run the following steps:</p> <ol><li><p>Set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</li> <li><p>Run any <a href=#unloading-document-cleanup-steps>unloading document cleanup steps</a> for the <code><a href=#document>Document</a></code> that are defined by this specification and <a href=#other-applicable-specifications>other applicable specifications</a>.</li> <li><p><a href=#abort-a-document title="abort a document">Abort the <code>Document</code></a>.</li> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> associated with the <code><a href=#document>Document</a></code> in any <a href=#task-source>task source</a>, without running those tasks.</li> <li><p><a href=#a-browsing-context-is-discarded title="a browsing context is discarded">Discard</a> all the <a href=#child-browsing-context title="child browsing context">child browsing contexts</a> of the <code><a href=#document>Document</a></code>.</li> <li><p>Lose the strong reference from the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> to the <code><a href=#document>Document</a></code>.</li> </ol><p class=note>Whenever a <code><a href=#document>Document</a></code> object is <a href=#discard-a-document title="discard a Document">discarded</a>, it is also removed from the list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> of each worker whose list contains that <code><a href=#document>Document</a></code>.</p> <p>When <dfn id=a-browsing-context-is-discarded>a <em><span>browsing context</span></em> is discarded</dfn>, the strong reference from the user agent itself to the <a href=#browsing-context>browsing context</a> must be severed, and all the <code><a href=#document>Document</a></code> objects for all the entries in the <a href=#browsing-context>browsing context</a>'s session history must be <a href=#discard-a-document title="discard a document">discarded</a> as well.</p> <p>User agents may <a href=#a-browsing-context-is-discarded title="a browsing context is discarded">discard</a> <a href=#top-level-browsing-context title="top-level browsing context">top-level browsing contexts</a> at any time (typically, in response to user requests, e.g. when a user closes a window containing one or more <a href=#top-level-browsing-context title="top-level browsing context">top-level browsing contexts</a>). Other <a href=#browsing-context title="browsing context">browsing contexts</a> must be discarded once their <code><a href=#windowproxy>WindowProxy</a></code> object is eligible for garbage collection.</p> </div> <h4 id=browser-interface-elements><span class=secno>6.2.6 </span>Browser interface elements</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><a href=#barprop>BarProp</a></code> object:</p> <pre class=idl>interface <dfn id=barprop>BarProp</dfn> { attribute boolean <a href=#dom-barprop-visible title=dom-BarProp-visible>visible</a>; };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-window-locationbar><a href=#dom-window-locationbar>locationbar</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <dd> <p>Returns true if the location bar is visible; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-menubar><a href=#dom-window-menubar>menubar</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <dd> <p>Returns true if the menu bar is visible; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-personalbar><a href=#dom-window-personalbar>personalbar</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <!--<dt><var title="">window</var> . <code title="dom-window-directories">directories</code> . <code title="dom-BarProp-visible">visible</code></dt>--> <dd> <p>Returns true if the personal bar is visible; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-scrollbars><a href=#dom-window-scrollbars>scrollbars</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <dd> <p>Returns true if the scroll bars are visible; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-statusbar><a href=#dom-window-statusbar>statusbar</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <dd> <p>Returns true if the status bar is visible; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-toolbar><a href=#dom-window-toolbar>toolbar</a></code> . <code title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code></dt> <dd> <p>Returns true if the toolbar is visible; otherwise, returns false.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-barprop-visible title=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. On setting, the new value must be discarded.</p> <p>The following <code><a href=#barprop>BarProp</a></code> objects exist for each <code><a href=#document>Document</a></code> object in a <a href=#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 title=dom-BarProp-visible><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></dt> <dd>Represents the user interface element that contains a control that displays the <a href=#url>URL</a> of the <a href=#active-document>active document</a>, or some similar interface concept.</dd> <dt><dfn id=the-menu-bar-barprop-object>The menu bar <code>BarProp</code> object</dfn></dt> <dd>Represents the user interface element that contains a list of commands in menu form, or some similar interface concept.</dd> <dt><dfn id=the-personal-bar-barprop-object>The personal bar <code>BarProp</code> object</dfn></dt> <dd>Represents the user interface element that contains links to the user's favorite pages, or some similar interface concept.</dd> <dt><dfn id=the-scrollbar-barprop-object>The scrollbar <code>BarProp</code> object</dfn></dt> <dd>Represents the user interface element that contains a scrolling mechanism, or some similar interface concept.</dd> <dt><dfn id=the-status-bar-barprop-object>The status bar <code>BarProp</code> object</dfn></dt> <dd>Represents a user interface element found immediately below or after the document, as appropriate for the user's media. 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 title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code> attribute may return false).</dd> <dt><dfn id=the-toolbar-barprop-object>The toolbar <code>BarProp</code> object</dfn></dt> <dd>Represents the user interface element found immediately above or before the document, as appropriate for the user's media. 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 title=dom-BarProp-visible><a href=#dom-barprop-visible>visible</a></code> attribute may return false).</dd> </dl><p>The <dfn id=dom-window-locationbar title=dom-window-locationbar><code>locationbar</code></dfn> attribute must return <a href=#the-location-bar-barprop-object>the location bar <code>BarProp</code> object</a>.</p> <p>The <dfn id=dom-window-menubar title=dom-window-menubar><code>menubar</code></dfn> attribute must return <a href=#the-menu-bar-barprop-object>the menu bar <code>BarProp</code> object</a>.</p> <p>The <dfn id=dom-window-personalbar title=dom-window-personalbar><code>personalbar</code></dfn> attribute must return <a href=#the-personal-bar-barprop-object>the personal bar <code>BarProp</code> object</a>.</p> <p>The <dfn id=dom-window-scrollbars title=dom-window-scrollbars><code>scrollbars</code></dfn> attribute must return <a href=#the-scrollbar-barprop-object>the scrollbar <code>BarProp</code> object</a>.</p> <p>The <dfn id=dom-window-statusbar title=dom-window-statusbar><code>statusbar</code></dfn> attribute must return <a href=#the-status-bar-barprop-object>the status bar <code>BarProp</code> object</a>.</p> <p>The <dfn id=dom-window-toolbar title=dom-window-toolbar><code>toolbar</code></dfn> attribute must return <a href=#the-toolbar-barprop-object>the toolbar <code>BarProp</code> object</a>.</p> <!-- <p>For legacy reasons, the <dfn title="dom-window-directories"><code>directories</code></dfn> attribute must also return <span>the personal bar <code>BarProp</code> object</span>.</p> --> <hr><p>For historical reasons, the <dfn id=dom-window-status title=dom-window-status><code>status</code></dfn> attribute on the <code><a href=#window>Window</a></code> object must return an empty string on getting, and do nothing on setting.</p> </div> <div class=impl> <h4 id=the-windowproxy-object><span class=secno>6.2.7 </span>The <code><a href=#windowproxy>WindowProxy</a></code> object</h4> <p>As mentioned earlier, each <a href=#browsing-context>browsing context</a> has a <dfn id=windowproxy><code>WindowProxy</code></dfn> object. This object is unusual in that all operations that would be performed on it must be performed on the <code><a href=#window>Window</a></code> object of the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> instead. It is thus indistinguishable from that <code><a href=#window>Window</a></code> object in every way until the <a href=#browsing-context>browsing context</a> is navigated.</p> <p>There is no <code><a href=#windowproxy>WindowProxy</a></code> interface object.</p> <p class=note>The <code><a href=#windowproxy>WindowProxy</a></code> object allows scripts to act as if each <a href=#browsing-context>browsing context</a> had a single <code><a href=#window>Window</a></code> object, while still keeping separate <code><a href=#window>Window</a></code> objects for each <code><a href=#document>Document</a></code>.</p> <div class=example> <p>In the following example, the variable <var title="">x</var> is set to the <code><a href=#windowproxy>WindowProxy</a></code> object returned by the <code title=dom-window><a href=#dom-window>window</a></code> accessor on the global object. All of the expressions following the assignment return true, because in every respect, the <code><a href=#windowproxy>WindowProxy</a></code> object acts like the underlying <code><a href=#window>Window</a></code> object.</p> <pre>var x = window; x instanceof Window; // true x === this; // true</pre> </div> </div> <h3 id=origin-0><span class=secno>6.3 </span>Origin</h3> <!-- Hallowed are the Ori --> <p>The <dfn id=origin>origin</dfn> of a resource and the <dfn id=effective-script-origin>effective script origin</dfn> of a resource are both either opaque identifiers or tuples consisting of a scheme component, a host component, a port component, and optionally extra data.</p> <p class=note>The extra data could include the certificate of the site when using encrypted connections, to ensure that if the site's secure certificate changes, the origin is considered to change as well.</p> <div class=impl> <p>These characteristics are defined as follows:</p> <dl><dt>For URLs</dt> <dd> <p>The <a href=#origin>origin</a> and <a href=#effective-script-origin>effective script origin</a> of the <a href=#url>URL</a> are the origin defined in <cite>The Web Origin Concept</cite>. <a href=#refsORIGIN>[ORIGIN]</a></p> </dd> <dt>For scripts</dt> <dd> <p>The <a href=#origin>origin</a> and <a href=#effective-script-origin>effective script origin</a> of a script are determined from another resource, called the <i>owner</i>:</p> <dl class=switch><dt>If a script is in a <code><a href=#the-script-element>script</a></code> element</dt> <dd>The owner is the <code><a href=#document>Document</a></code> to which the <code><a href=#the-script-element>script</a></code> element belongs.</dd> <dt>If a script is in an <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a></dt> <dd>The owner is the <code><a href=#document>Document</a></code> to which the attribute node belongs.</dd> <dt>If a script is a function or other code reference created by another script</dt> <dd>The owner is the script that created it.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> that was returned as the location of an HTTP redirect (<a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a> in other protocols)</dt> <dd>The owner is the <a href=#url>URL</a> that redirected to the <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> in an attribute</dt> <dd>The owner is the <code><a href=#document>Document</a></code> of the element on which the attribute is found.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> in a style sheet</dt> <dd>The owner is the <a href=#url>URL</a> of the style sheet.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> to which a <a href=#browsing-context>browsing context</a> is being <a href=#navigate title=navigate>navigated</a>, the URL having been provided by the user (e.g. by using a <i>bookmarklet</i>)</dt> <dd>The owner is the <code><a href=#document>Document</a></code> of the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> to which a <a href=#browsing-context>browsing context</a> is being <a href=#navigate title=navigate>navigated</a>, the URL having been declared in markup</dt> <dd>The owner is the <code><a href=#document>Document</a></code> of the element (e.g. an <code><a href=#the-a-element>a</a></code> or <code><a href=#the-area-element>area</a></code> element) that declared the URL.</dd> <dt>If a script is a <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a> to which a <a href=#browsing-context>browsing context</a> is being <a href=#navigate title=navigate>navigated</a>, the URL having been provided by script</dt> <dd>The owner is the script that provided the URL.</dd> </dl><p>The <a href=#origin>origin</a> of the script is then equal to the <a href=#origin>origin</a> of the owner, and the <a href=#effective-script-origin>effective script origin</a> of the script is equal to the <a href=#effective-script-origin>effective script origin</a> of the owner.</p> </dd> <dt>For <code><a href=#document>Document</a></code> objects</dt> <dd> <dl class=switch><dt id=sandboxOrigin>If a <code><a href=#document>Document</a></code> is in a <a href=#browsing-context>browsing context</a> whose <a href=#sandboxed-origin-browsing-context-flag>sandboxed origin browsing context flag</a> was set when the <code><a href=#document>Document</a></code> was created</dt> <dd>The <a href=#origin>origin</a> is a globally unique identifier assigned when the <code><a href=#document>Document</a></code> is created.</dd> <dt>If a <code><a href=#document>Document</a></code> was generated from a <a href=#javascript-protocol title="javascript protocol"><code>javascript:</code> URL</a></dt> <dd>The <a href=#origin>origin</a> is equal to the <a href=#origin>origin</a> of the script of that <a href=#javascript-protocol title="javascript protocol"><code>javascript:</code> URL</a>.</dd> <dt>If a <code><a href=#document>Document</a></code> was served over the network and has an address that uses a URL scheme with a server-based naming authority</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of <a href="#the-document's-address">the <code>Document</code>'s address</a>.</dd> <dt>If a <code><a href=#document>Document</a></code> was generated from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> that was returned as the location of an HTTP redirect (<a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a> in other protocols)</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <a href=#url>URL</a> that redirected to the <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a>.</dd> <dt>If a <code><a href=#document>Document</a></code> was generated from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> found in another <code><a href=#document>Document</a></code> or in a script</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> or script that initiated the <a href=#navigate title=navigate>navigation</a> to that <a href=#url>URL</a>.</dd> <dt>If a <code><a href=#document>Document</a></code> has the <a href="#the-document's-address" title="the document's address">address</a> "<code><a href=#about:blank>about:blank</a></code>"</dt> <dd>The <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> is <a href=#about-blank-origin>the <span>origin</span> it was assigned when its browsing context was created</a>.</dd> <dt>If a <code><a href=#document>Document</a></code> is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a></dt> <dd>The <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> is the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-container>browsing context container</a>'s <code><a href=#document>Document</a></code>.</dd> <dt>If a <code><a href=#document>Document</a></code> was obtained in some other manner (e.g. a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> typed in by the user, a <code><a href=#document>Document</a></code> created using the <code title=dom-DOMImplementation-createDocument><a href=#dom-domimplementation-createdocument>createDocument()</a></code> API, etc)</dt> <dd>The <a href=#origin>origin</a> is a globally unique identifier assigned when the <code><a href=#document>Document</a></code> is created.</dd> </dl><p>When a <code><a href=#document>Document</a></code> is created, its <a href=#effective-script-origin>effective script origin</a> is initialized to the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code>. However, the <code title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute can be used to change it.</p> </dd> <dt>For images</dt> <dd> <dl class=switch><dt>If an image is the image of an <code><a href=#the-img-element>img</a></code> element and its image data is <a href=#cors-cross-origin>CORS-cross-origin</a></dt> <dd>The <a href=#origin>origin</a> is a globally unique identifier assigned when the image is created.</dd> <dt>If an image is the image of an <code><a href=#the-img-element>img</a></code> element and its image data is <a href=#cors-same-origin>CORS-same-origin</a></dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <code><a href=#the-img-element>img</a></code> element's <code><a href=#document>Document</a></code>.</dd> <!-- does anything depend on the origin of an image other than from <img>? If not, we can cut out the remainder of this <dl>: --> <dt>If an image was served over the network and has an address that uses a URL scheme with a server-based naming authority</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the image's <a href=#url>URL</a>.</dd> <dt>If an image was generated from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> that was returned as the location of an HTTP redirect (<a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a> in other protocols)</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <a href=#url>URL</a> that redirected to the <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a>.</dd> <dt>If an image was generated from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> found in another <code><a href=#document>Document</a></code> or in a script</dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> or script that loaded that image.</dd> <dt>If an image was obtained in some other manner (e.g. a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> typed in by the user)</dt> <dd>The <a href=#origin>origin</a> is a globally unique identifier assigned when the image is created.</dd> </dl></dd> <dt>For <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements</dt> <dd> <dl class=switch><dt>If the <a href=#media-data>media data</a> is <a href=#cors-cross-origin>CORS-cross-origin</a></dt> <dd>The <a href=#origin>origin</a> is a globally unique identifier assigned when the image is created.</dd> <dt>If the <a href=#media-data>media data</a> is <a href=#cors-same-origin>CORS-same-origin</a></dt> <dd>The <a href=#origin>origin</a> is the <a href=#origin>origin</a> of the <a href=#media-element>media element</a>'s <code><a href=#document>Document</a></code>.</dd> </dl></dd> <dt>For fonts</dt> <dd> <p>The <a href=#origin>origin</a> of a downloadable Web font is equal to the <a href=#origin>origin</a> of the <a href=#absolute-url>absolute URL</a> used to obtain the font (after any redirects). <a href=#refsCSSFONTS>[CSSFONTS]</a></p> <!-- this means you can get data from a remote site if you can make it redirect to your own site in some fashion controlled by the data you want to read --> <p>The <a href=#origin>origin</a> of a locally installed system font is equal to the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> in which that font is being used.</p> </dd> </dl><p>Other specifications can override the above definitions by themselves specifying the origin of a particular URL, script, <code><a href=#document>Document</a></code>, or image.</p> <!-- e.g.: <p>The <span>origin</span> of a <code>Document</code> object returned by the <code>XMLHttpRequest</code> API is equal to the <span>XMLHttpRequest origin</span> of the <code>XMLHttpRequest</code> object.</p> --> <hr><p>The <dfn id=unicode-serialization-of-an-origin>Unicode serialization of an origin</dfn> is the string obtained by applying the following algorithm to the given <a href=#origin>origin</a>:</p> <ol><li><p>If the <a href=#origin>origin</a> in question is not a scheme/host/port tuple, then return the literal string "<code title="">null</code>" and abort these steps.</li> <li><p>Otherwise, let <var title="">result</var> be the scheme part of the <a href=#origin>origin</a> tuple.</li> <li><p>Append the string "<code title="">://</code>" to <var title="">result</var>.</li> <li><p>Apply the IDNA ToUnicode algorithm to each component of the host part of the <a href=#origin>origin</a> tuple, and append the results — each component, in the same order, separated by U+002E FULL STOP characters (.) — to <var title="">result</var>. <a href=#refsRFC3490>[RFC3490]</a></li> <li><p>If the port part of the <a href=#origin>origin</a> tuple gives a port that is different from the default port for the protocol given by the scheme part of the <a href=#origin>origin</a> tuple, then append a U+003A COLON character (:) and the given port, in base ten, to <var title="">result</var>.</li> <li><p>Return <var title="">result</var>.</li> </ol><p>The <dfn id=ascii-serialization-of-an-origin>ASCII serialization of an origin</dfn> is the string obtained by applying the following algorithm to the given <a href=#origin>origin</a>:</p> <ol><li><p>If the <a href=#origin>origin</a> in question is not a scheme/host/port tuple, then return the literal string "<code title="">null</code>" and abort these steps.</li> <li><p>Otherwise, let <var title="">result</var> be the scheme part of the <a href=#origin>origin</a> tuple.</li> <li><p>Append the string "<code title="">://</code>" to <var title="">result</var>.</li> <li> <p>Apply the IDNA ToASCII algorithm the host part of the <a href=#origin>origin</a> tuple, with both the AllowUnassigned and UseSTD3ASCIIRules flags set, and append the results <var title="">result</var>.</p> <p>If ToASCII fails to convert one of the components of the string, e.g. because it is too long or because it contains invalid characters, then return the empty string and abort these steps. <a href=#refsRFC3490>[RFC3490]</a></p> </li> <li><p>If the port part of the <a href=#origin>origin</a> tuple gives a port that is different from the default port for the protocol given by the scheme part of the <a href=#origin>origin</a> tuple, then append a U+003A COLON character (:) and the given port, in base ten, to <var title="">result</var>.</li> <li><p>Return <var title="">result</var>.</li> </ol><p>Two <a href=#origin title=origin>origins</a> are said to be the <dfn id=same-origin>same origin</dfn> if the following algorithm returns true:</p> <ol><li><p>Let <var title="">A</var> be the first <a href=#origin>origin</a> being compared, and <var title="">B</var> be the second <a href=#origin>origin</a> being compared.</li> <li><p>If <var title="">A</var> and <var title="">B</var> are both opaque identifiers, and their value is equal, then return true.</li> <li><p>Otherwise, if either <var title="">A</var> or <var title="">B</var> or both are opaque identifiers, return false.</li> <li><p>If <var title="">A</var> and <var title="">B</var> have scheme components that are not identical, return false.</li> <li><p>If <var title="">A</var> and <var title="">B</var> have host components that are not identical, return false.</li> <li><p>If <var title="">A</var> and <var title="">B</var> have port components that are not identical, return false.</li> <li><p>If either <var title="">A</var> or <var title="">B</var> have additional data, but that data is not identical for both, return false.</li> <li><p>Return true.</li> </ol></div> <h4 id=relaxing-the-same-origin-restriction><span class=secno>6.3.1 </span>Relaxing the same-origin restriction</h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-domain><a href=#dom-document-domain>domain</a></code> [ = <var title="">domain</var> ]</dt> <dd> <p>Returns the current domain used for security checks.</p> <p>Can be set to a value that removes subdomains, to change the <a href=#effective-script-origin>effective script origin</a> to allow pages on other subdomains of the same domain (if they do the same thing) to access each other.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-domain title=dom-document-domain><code>domain</code></dfn> attribute on <code><a href=#document>Document</a></code> objects must be initialized to <a href="#the-document's-domain">the document's domain</a>, if it has one, and the empty string otherwise. If the value is an IPv6 address, then the square brackets from the host portion of the <a href=#url-host title=url-host><host></a> component must be omitted from the attribute's value.</p> <p>On getting, the attribute must return its current value, unless the <code><a href=#document>Document</a></code> has no <a href=#browsing-context>browsing context</a>, in which case it must return the empty string.</p> <p>On setting, the user agent must run the following algorithm:</p> <ol><li> <p>If the <code><a href=#document>Document</a></code> has no <a href=#browsing-context>browsing context</a>, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</p> </li> <li> <p>If the new value is an IP address, let <var title="">new value</var> be the new value. Otherwise, apply the IDNA ToASCII algorithm to the new value, with both the AllowUnassigned and UseSTD3ASCIIRules flags set, and let <var title="">new value</var> be the result of the ToASCII algorithm.</p> <p>If ToASCII fails to convert one of the components of the string, e.g. because it is too long or because it contains invalid characters, then throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps. <a href=#refsRFC3490>[RFC3490]</a></p> </li> <li> <p>If <var title="">new value</var> is not exactly equal to the current value of the <code title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute, then run these substeps:</p> <ol><li> <p>If the current value is an IP address, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</p> </li> <li> <p>If <var title="">new value</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end of the current value, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</p> </li> <li> <p>If <var title="">new value</var> matches a suffix in the Public Suffix List, or, if <var title="">new value</var>, prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List, then throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps. <a href=#refsPSL>[PSL]</a></p> <p>Suffixes must be compared after applying the IDNA ToASCII algorithm to them, with both the AllowUnassigned and UseSTD3ASCIIRules flags set, in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner. <a href=#refsRFC3490>[RFC3490]</a></p> </li> </ol></li> <li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li> <li> <p>Set the attribute's value to <var title="">new value</var>.</p> </li> <li> <p>Set the host part of the <a href=#effective-script-origin>effective script origin</a> tuple of the <code><a href=#document>Document</a></code> to <var title="">new value</var>.</p> </li> <li> <p>Set the port part of the <a href=#effective-script-origin>effective script origin</a> tuple of the <code><a href=#document>Document</a></code> to "manual override" (a value that, for the purposes of <a href=#same-origin title="same origin">comparing origins</a>, is identical to "manual override" but not identical to any other value).</p> </li> </ol><p>The <dfn id="the-document's-domain" title="the document's domain">domain</dfn> of a <code><a href=#document>Document</a></code> is the host part of the document's <a href=#origin>origin</a>, if that is a scheme/host/port tuple. If it isn't, then the document does not have a domain.</p> </div> <p class=note>The <code title=dom-document-domain><a href=#dom-document-domain>domain</a></code> attribute is used to enable pages on different hosts of a domain to access each others' DOMs.</p> <p class=warning>Do not use the <code title=dom-document-domain><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 title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute has been used.</p> <h3 id=history><span class=secno>6.4 </span>Session history and navigation</h3> <h4 id=the-session-history-of-browsing-contexts><span class=secno>6.4.1 </span>The session history of browsing contexts</h4> <p>The sequence of <code><a href=#document>Document</a></code>s in a <a href=#browsing-context>browsing context</a> is its <dfn id=session-history>session history</dfn>.</p> <p><code><a href=#history-0>History</a></code> objects provide a representation of the pages in the session history of <a href=#browsing-context title="browsing context">browsing contexts</a>. Each <a href=#browsing-context>browsing context</a>, including <a href=#nested-browsing-context title="nested browsing context">nested browsing contexts</a>, has a distinct session history.</p> <p>Each <code><a href=#document>Document</a></code> object in a <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> is associated with a unique instance of the <code><a href=#history-0>History</a></code> object, although they all must model the same underlying <a href=#session-history>session history</a>.</p> <div class=impl> <p>The <dfn id=dom-history title=dom-history><code>history</code></dfn> attribute of the <code><a href=#window>Window</a></code> interface must return the object implementing the <code><a href=#history-0>History</a></code> interface for that <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>.</p> </div> <p><code><a href=#history-0>History</a></code> objects represent their <a href=#browsing-context>browsing context</a>'s session history as a flat list of <a href=#session-history-entry title="session history entry">session history entries</a>. Each <dfn id=session-history-entry>session history entry</dfn> consists of either a <a href=#url>URL</a> or a <a href=#state-object>state object</a>, or both<span class=impl>, and may in addition have a title, a <code><a href=#document>Document</a></code> object, form data, a scroll position, and other information associated with it</span>.</p> <div class=impl> <p class=note>This does not imply that the user interface need be linear. See the <a href=#history-notes>notes below</a>.</p> </div> <p class=note>Titles associated with <a href=#session-history-entry title="session history entry">session history entries</a> need not have any relation with the current <code><a href=#the-title-element>title</a></code> of the <code><a href=#document>Document</a></code>. The title of a <a href=#session-history-entry>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=#state-object title="state object">state objects</a> are added to the session history as the user (or script) navigates from page to page.</p> <p>A <dfn id=state-object>state object</dfn> is an object representing a user interface state.</p> <p>Pages can <a href=#dom-history-pushstate title=dom-history-pushState>add</a> <a href=#state-object title="state object">state objects</a> between their entry in the session history and the next ("forward") entry. These are then <a href=#event-popstate title=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=#state-object title="state object">State objects</a> are intended to be used for two main purposes: first, storing a preparsed description of the state in the <a href=#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=#url title=URL>URLs</a> passed around by users, so it's only a minor optimization), and second, so that the author can store state that one wouldn't store in the URL because it only applies to the current <code><a href=#document>Document</a></code> instance and it would have to be reconstructed if a new <code><a href=#document>Document</a></code> were opened.</p> <p>An example of the latter would be something like keeping track of the precise coordinate from which a popup <code><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 href=#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>active document</a> of the <a href=#browsing-context>browsing context</a>. The <a href=#current-entry>current entry</a> is usually an entry for the <a href=#dom-location-href title=dom-location-href>location</a> of the <code><a href=#document>Document</a></code>. However, it can also be one of the entries for <a href=#state-object title="state object">state objects</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 title=attr-dir><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>Entries that consist of <a href=#state-object title="state object">state objects</a> share the same <code><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 fragment identifier also share the same <code><a href=#document>Document</a></code>.</p> <p class=note>All entries that share the same <code><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><a href=#document>Document</a></code> in a <a href=#browsing-context>browsing context</a> also has a <dfn id=latest-entry>latest entry</dfn>. This is the entry or that <code><a href=#document>Document</a></code> that was most the recently traversed to. When a <code><a href=#document>Document</a></code> is created, it initially has no <a href=#latest-entry>latest entry</a>.</p> <div class=impl> <p>User agents may <a href=#discard-a-document title="discard a Document">discard</a> the <code><a href=#document>Document</a></code> objects of entries other than the <a href=#current-entry>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><a href=#document>Document</a></code> objects and when they should cache them.</p> <p>Entries that have had their <code><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><a href=#document>Document</a></code> object with it must share the new object as well.</p> </div> <h4 id=the-history-interface><span class=secno>6.4.2 </span>The <code><a href=#history-0>History</a></code> interface</h4> <pre class=idl>interface <dfn id=history-0>History</dfn> { readonly attribute long <a href=#dom-history-length title=dom-history-length>length</a>; readonly attribute any <a href=#dom-history-state title=dom-history-state>state</a>; void <a href=#dom-history-go title=dom-history-go>go</a>(optional long delta); void <a href=#dom-history-back title=dom-history-back>back</a>(); void <a href=#dom-history-forward title=dom-history-forward>forward</a>(); void <a href=#dom-history-pushstate title=dom-history-pushState>pushState</a>(any data, DOMString title, optional DOMString url); void <a href=#dom-history-replacestate title=dom-history-replaceState>replaceState</a>(any data, DOMString title, optional DOMString url); };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-length><a href=#dom-history-length>length</a></code></dt> <dd> <p>Returns the number of entries in the <a href=#joint-session-history>joint session history</a>.</p> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-state><a href=#dom-history-state>state</a></code></dt> <dd> <p>Returns the current <a href=#state-object>state object</a>.</p> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-go><a href=#dom-history-go>go</a></code>( [ <var title="">delta</var> ] )</dt> <dd> <p>Goes back or forward the specified number of steps in the <a href=#joint-session-history>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> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-back><a href=#dom-history-back>back</a></code>()</dt> <dd> <p>Goes back one step in the <a href=#joint-session-history>joint session history</a>.</p> <p>If there is no previous page, does nothing.</p> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-forward><a href=#dom-history-forward>forward</a></code>()</dt> <dd> <p>Goes forward one step in the <a href=#joint-session-history>joint session history</a>.</p> <p>If there is no next page, does nothing.</p> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState</a></code>(<var title="">data</var>, <var title="">title</var> [, <var title="">url</var> ] )</dt> <dd> <p>Pushes the given data onto the session history, with the given title, and, if provided, the given URL.</p> </dd> <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState</a></code>(<var title="">data</var>, <var title="">title</var> [, <var title="">url</var> ] )</dt> <dd> <p>Updates the current entry in the session history to have the given data, title, and, if provided, URL.</p> </dd> </dl><p>The <dfn id=joint-session-history>joint session history</dfn> of a <code><a href=#history-0>History</a></code> object is the union of all the <a href=#session-history title="session history">session histories</a> of all <a href=#browsing-context title="browsing context">browsing contexts</a> of all the <a href=#fully-active>fully active</a> <code><a href=#document>Document</a></code> objects that share the <code><a href=#history-0>History</a></code> object's <a href=#top-level-browsing-context>top-level browsing context</a>, with all the entries that are <a href=#current-entry title="current entry">current entries</a> in their respective <a href=#session-history title="session history">session histories</a> removed except for the <a href=#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>current entry</a> in its <a href=#session-history>session history</a>.</p> <p>Entries in the <a href=#joint-session-history>joint session history</a> are ordered chronologically by the time they were added to their respective <a href=#session-history title="session history">session histories</a>. (Since all these <a href=#browsing-context title="browsing context">browsing contexts</a> by definition share an <a href=#event-loop>event loop</a>, there is always a well-defined sequential order in which their <a href=#session-history title="session history">session histories</a> had their entries added.) 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> <div class=impl> <p>The <dfn id=dom-history-length title=dom-history-length><code>length</code></dfn> attribute of the <code><a href=#history-0>History</a></code> interface must return the number of entries in the <a href=#joint-session-history>joint session history</a>.</p> <p>The actual entries are not accessible from script.</p> <p>The <dfn id=dom-history-state title=dom-history-state><code>state</code></dfn> attribute of the <code><a href=#history-0>History</a></code> interface must return the last value it was set to by the user agent. Initially, its value must be null.</p> <p>When the <dfn id=dom-history-go title=dom-history-go><code>go(<var title="">delta</var>)</code></dfn> method is invoked, if the argument to the method was omitted or has the value zero, the user agent must act as if the <code title=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>traverse the history by a delta</a> whose value is the value of the method's argument.</p> <p>When the <dfn id=dom-history-back title=dom-history-back><code>back()</code></dfn> method is invoked, the user agent must <a href=#traverse-the-history-by-a-delta>traverse the history by a delta</a> −1.</p> <p>When the <dfn id=dom-history-forward title=dom-history-forward><code>forward()</code></dfn>method is invoked, the user agent must <a href=#traverse-the-history-by-a-delta>traverse the history by a delta</a> +1.</p> <p>To <dfn id=traverse-the-history-by-a-delta>traverse the history by a delta</dfn> <var title="">delta</var>, the user agent must <a href=#queue-a-task>queue a task</a> to run the following steps. The <a href=#task-source>task source</a> for the queued task is the <a href=#history-traversal-task-source>history traversal task source</a>.</p> <ol><li><p>Let <var title="">delta</var> be the argument to the method.</li> <li><p>If the index of the <a href=#current-entry-of-the-joint-session-history>current entry of the joint session history</a> plus <var title="">delta</var> is less than zero or greater than or equal to the number of items in the <a href=#joint-session-history>joint session history</a>, then abort these steps.</p> <li><p>Let <var title="">specified entry</var> be the entry in the <a href=#joint-session-history>joint session history</a> whose index is the sum of <var title="">delta</var> and the index of the <a href=#current-entry-of-the-joint-session-history>current entry of the joint session history</a>.</li> <li><p>Let <var title="">specified browsing context</var> be the <a href=#browsing-context>browsing context</a> of the <var title="">specified entry</var>.</li> <li> <p>If the <var title="">specified browsing context</var>'s <a href=#active-document>active document</a> is not the same <code><a href=#document>Document</a></code> as the <code><a href=#document>Document</a></code> of the <var title="">specified entry</var>, then run these substeps:</p> <ol><li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to unload</a> the <a href=#active-document>active document</a> of the <var title="">specified browsing context</var>. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then abort these steps.</li> <li><p><a href=#unload-a-document title="unload a document">Unload</a> the <a href=#active-document>active document</a> of the <var title="">specified browsing context</var> with the <var title="">recycle</var> parameter set to false.</li> </ol></li> <li><p><a href=#traverse-the-history>Traverse the history</a> of the <var title="">specified browsing context</var> to the <var title="">specified entry</var>.</p> </ol><p>When the user navigates through a <a href=#browsing-context>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>traverse the history by a delta</a> equivalent to the action specified by the user.</p> <hr><p>The <dfn id=dom-history-pushstate title=dom-history-pushState><code>pushState(<var title="">data</var>, <var title="">title</var>, <var title="">url</var>)</code></dfn> method adds a state object entry to the history.</p> <p>The <dfn id=dom-history-replacestate title=dom-history-replaceState><code>replaceState(<var title="">data</var>, <var title="">title</var>, <var title="">url</var>)</code></dfn> method updates the state object, title, and optionally the <a href=#url>URL</a> of the <a href=#current-entry>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 title="">cloned data</var> be a <a href=#structured-clone>structured clone</a> of the specified <var title="">data</var>. If this throws an exception, then rethrow that exception and abort these steps.</li> <li> <p>If a third argument is specified, run these substeps:</p> <ol><li><a href=#resolve-a-url title="resolve a url">Resolve</a> the value of the third argument, relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>.</li> <li>If that fails, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</li> <li>Compare the resulting <a href=#absolute-url>absolute URL</a> to <a href="#the-document's-address">the document's address</a>. If any part of these two <a href=#url title=URL>URLs</a> differ other than the <a href=#url-path title=url-path><path></a>, <a href=#url-query title=url-query><query></a>, and <a href=#url-fragment title=url-fragment><fragment></a> components, then throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</li> <li>If the <a href=#origin>origin</a> of the resulting <a href=#absolute-url>absolute URL</a> is not the same as the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a>'s <a href="#script's-document" title="script's document">document</a>, and either the <a href=#url-path title=url-path><path></a> or <a href=#url-query title=url-query><query></a> components of the two <a href=#url title=URL>URLs</a> compared in the previous step differ, throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps. (This prevents sandboxed content from spoofing other pages on the same origin.)</li> </ol><p>For the purposes of the comparisons in the above substeps, the <a href=#url-path title=url-path><path></a> and <a href=#url-query title=url-query><query></a> components can only be the same if the URLs are both <a href=#hierarchical-url title="hierarchical URL">hierarchical URLs</a>.</p> </li> <li> <p>If the method invoked was the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> method:</p> <ol><li> <p>Remove all the entries in the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> after the <a href=#current-entry>current entry</a>. If the <a href=#current-entry>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> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> queued by the <a href=#history-traversal-task-source>history traversal task source</a>.</li> <li><p>If appropriate, update the <a href=#current-entry>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>an entry with persisted user state</a>.</li> <li><p>Add a <a href=#state-object>state object</a> entry to the session history, after the <a href=#current-entry>current entry</a>, with <var title="">cloned data</var> as the <a href=#state-object>state object</a>, the given <var title="">title</var> as the title, and, if the third argument is present, the <a href=#absolute-url>absolute URL</a> that was found earlier in this algorithm as the <a href=#url>URL</a> of the entry.</li> <li><p>Update the <a href=#current-entry>current entry</a> to be this newly added entry.</li> </ol><p>Otherwise, if the method invoked was the <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState()</a></code> method:</p> <ol><li><p>Update the <a href=#current-entry>current entry</a> in the session history so that <var title="">cloned data</var> is the entry's new state object, the given <var title="">title</var> is the new title, and, if the third argument is present, the <a href=#absolute-url>absolute URL</a> that was found earlier in this algorithm is the entry's new <a href=#url>URL</a>.</li> </ol></li> <li><p>If the <a href=#current-entry>current entry</a> in the session history represents a non-GET request (e.g. it was the result of a POST submission) then update it to instead represent a GET request (<a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>).</li> <li> <p>If the third argument is present, set <a href="#the-document's-current-address">the document's current address</a> to the <a href=#absolute-url>absolute URL</a> that was found earlier in this algorithm.</p> <p class=note>Since this is neither a <a href=#navigate title=navigate>navigation</a> of the <a href=#browsing-context>browsing context</a> nor a <a href=#traverse-the-history title="traverse the history">history traversal</a>, it does not cause a <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code> event to be fired.</p> </li> <li> <p>Set <code title=dom-history-state><a href=#dom-history-state>history.state</a></code> to a <a href=#structured-clone>structured clone</a> of <var title="">cloned data</var>.</p> <!-- it's a clone of /cloned data/, not /data/, so that there's no risk of running scripts again --> </li> <li> <p>Let the <a href=#latest-entry>latest entry</a> of the <code><a href=#document>Document</a></code> of the <a href=#current-entry>current entry</a> be the <a href=#current-entry>current entry</a>.</p> </li> </ol><p class=note>The <var title="">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><a href=#document>Document</a></code> object in the session history after having added the new entry. (Thus the state history acts as a FIFO buffer for eviction, but as a LIFO buffer for navigation.)</p> </div> <div 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><!DOCTYPE HTML> <!-- this is http://example.com/line?x=5 --> <title>Line Game - 5</title> <p>You are at coordinate 5 on the line.</p> <p> <a href="?x=6">Advance to 6</a> or <a href="?x=4">retreat to 4</a>? </p></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><!DOCTYPE HTML> <!-- this starts off as http://example.com/line?x=5 --> <title>Line Game - 5</title> <p>You are at coordinate <span id="coord">5</span> on the line.</p> <p> <a href="?x=6" onclick="go(1); return false;">Advance to 6</a> or <a href="?x=4" onclick="go(-1); return false;">retreat to 4</a>? </p> <script> var currentPage = 5; // prefilled by server function go(d) { setupPage(currentPage + d); history.pushState(currentPage, document.title, '?x=' + currentPage); } onpopstate = function(event) { setupPage(event.state); } function setupPage(page) { currentPage = page; document.title = 'Line Game - ' + currentPage; document.getElementById('coord').textContent = currentPage; document.links[0].href = '?x=' + (currentPage+1); document.links[0].textContent = 'Advance to ' + (currentPage+1); document.links[1].href = '?x=' + (currentPage-1); document.links[1].textContent = 'retreat to ' + (currentPage-1); } </script></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 title="">data</var> argument to the <code title=dom-history-pushState><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>session history entry</a> as the value of the document's <code><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><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><!DOCTYPE HTML> <TITLE>Line</TITLE> <SCRIPT> setInterval(function () { document.title = 'Line - ' + new Date(); }, 1000); var i = 1; function inc() { set(i+1); history.pushState(i, 'Line - ' + i); } function set(newI) { i = newI; document.forms.F.I.value = newI; } </SCRIPT> <BODY ONPOPSTATE="set(event.state)"> <FORM NAME=F> State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON ONCLICK="inc()"> </FORM></pre> </div> <h4 id=the-location-interface><span class=secno>6.4.3 </span>The <code><a href=#location>Location</a></code> interface</h4> <p>Each <code><a href=#document>Document</a></code> object in a <a href=#browsing-context>browsing context</a>'s session history is associated with a unique instance of a <code><a href=#location>Location</a></code> object.</p> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-location><a href=#dom-document-location>location</a></code> [ = <var title="">value</var> ]</dt> <dt><var title="">window</var> . <code title=dom-location><a href=#dom-location>location</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns a <code><a href=#location>Location</a></code> object with the current page's location.</p> <p>Can be set, to navigate to another page.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-location title=dom-document-location><code>location</code></dfn> attribute of the <code><a href=#document>Document</a></code> interface must return the <code><a href=#location>Location</a></code> object for that <code><a href=#document>Document</a></code> object, if it is in a <a href=#browsing-context>browsing context</a>, and null otherwise.</p> <p>The <dfn id=dom-location title=dom-location><code>location</code></dfn> attribute of the <code><a href=#window>Window</a></code> interface must return the <code><a href=#location>Location</a></code> object for that <code><a href=#window>Window</a></code> object's <code><a href=#document>Document</a></code>.</p> </div> <p><code><a href=#location>Location</a></code> objects provide a representation of <a href="#the-document's-current-address" title="the document's current address">their document's current address</a>, and allow the <a href=#current-entry>current entry</a> of the <a href=#browsing-context>browsing context</a>'s session history to be changed, by adding or replacing entries in the <code title=dom-history><a href=#dom-history>history</a></code> object.</p> <pre class=idl>interface <dfn id=location>Location</dfn> { stringifier attribute DOMString <a href=#dom-location-href title=dom-location-href>href</a>; void <a href=#dom-location-assign title=dom-location-assign>assign</a>(DOMString url); void <a href=#dom-location-replace title=dom-location-replace>replace</a>(DOMString url); void <a href=#dom-location-reload title=dom-location-reload>reload</a>(); // <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> <!-- blame brendan for these "innovative" names --> attribute DOMString <a href=#dom-location-protocol title=dom-location-protocol>protocol</a>; attribute DOMString <a href=#dom-location-host title=dom-location-host>host</a>; attribute DOMString <a href=#dom-location-hostname title=dom-location-hostname>hostname</a>; attribute DOMString <a href=#dom-location-port title=dom-location-port>port</a>; attribute DOMString <a href=#dom-location-pathname title=dom-location-pathname>pathname</a>; attribute DOMString <a href=#dom-location-search title=dom-location-search>search</a>; attribute DOMString <a href=#dom-location-hash title=dom-location-hash>hash</a>; };</pre> <dl class=domintro><dt><var title="">location</var> . <code title=dom-location-href><a href=#dom-location-href>href</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current page's location.</p> <p>Can be set, to navigate to another page.</p> </dd> <dt><var title="">location</var> . <code title=dom-location-assign><a href=#dom-location-assign>assign</a></code>(<var title="">url</var>)</dt> <dd> <p>Navigates to the given page.</p> </dd> <dt><var title="">location</var> . <code title=dom-location-replace><a href=#dom-location-replace>replace</a></code>(<var title="">url</var>)</dt> <dd> <p>Removes the current page from the session history and navigates to the given page.</p> </dd> <dt><var title="">location</var> . <code title=dom-location-reload><a href=#dom-location-reload>reload</a></code>()</dt> <dd> <p>Reloads the current page.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-location-href title=dom-location-href><code>href</code></dfn> attribute must return <a href="#the-document's-current-address" title="the document's current address">the current address</a> of the associated <code><a href=#document>Document</a></code> object, as an <a href=#absolute-url>absolute URL</a>.</p> <p>On setting, if the <code><a href=#location>Location</a></code> object's associated <code><a href=#document>Document</a></code> object has <a href=#completely-loaded>completely loaded</a>, then the user agent must act as if the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> method had been called with the new value as its argument. Otherwise, the user agent must act as if the <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> method had been called with the new value as its argument.</p> <!--DONAV location.href, defined in terms of the paragraphs below--> <p>When the <dfn id=dom-location-assign title=dom-location-assign><code>assign(<var title="">url</var>)</code></dfn> method is invoked, the UA must <a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>, and if that is successful, must <a href=#navigate>navigate</a><!--DONAV location.href/assign--> the <a href=#browsing-context>browsing context</a> to the specified <var title="">url</var>. If the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> contains only one <code><a href=#document>Document</a></code>, and that was the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> created when the <a href=#browsing-context>browsing context</a> was created, then the navigation must be done with <a href=#replacement-enabled>replacement enabled</a>.</p> <!-- READ ME WHEN EDITING THIS: IE and Firefox only seem to treat it that way if the DOM is still a virgin DOM; Safari doesn't check that. Thus this might need changing if testing shows the IE/Firefox behaviour is required here. --> <p>When the <dfn id=dom-location-replace title=dom-location-replace><code>replace(<var title="">url</var>)</code></dfn> method is invoked, the UA must <a href=#resolve-a-url title="resolve a url">resolve</a> the argument, relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>, and if that is successful, <a href=#navigate>navigate</a><!--DONAV location.href/replace--> the <a href=#browsing-context>browsing context</a> to the specified <var title="">url</var> with <a href=#replacement-enabled>replacement enabled</a>.</p> <p>Navigation for the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> and <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> methods must be done with the <a href="#script's-browsing-context" title="script's browsing context">browsing context</a> of the script that invoked the method as the <a href=#source-browsing-context>source browsing context</a>.</p> <p>If the <a href=#resolve-a-url title="resolve a url">resolving</a> step of the <code title=dom-location-assign><a href=#dom-location-assign>assign()</a></code> and <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> methods is not successful, then the user agent must instead throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p> <p>When the <dfn id=dom-location-reload title=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 the currently executing <a href=#concept-task title=concept-task>task</a> is the dispatch of a <code title=event-resize>resize</code> event in response to the user resizing the <a href=#browsing-context>browsing context</a></dt> <dd><p>Repaint the <a href=#browsing-context>browsing context</a> and abort these steps.</dd> <!-- this theoretically would have no effect but in practice can be useful to work around rendering bugs. --> <dt>If the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> is <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a></dt> <dd><p><a href=#process-the-iframe-attributes title="process the iframe attributes">Reprocess the <code>iframe</code> attributes</a> of the <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-container>browsing context container</a>.</dd> <dt>If the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> has its <a href=#reload-override-flag>reload override flag</a> set</dt> <dd><p>Perform <a href=#an-overridden-reload>an overridden reload</a>.</dd> <dt>Otherwise</dt> <dd><p><a href=#navigate>Navigate</a><!--DONAV location.reload()--> the <a href=#browsing-context>browsing context</a> to <a href="#the-document's-current-address">the document's current address</a> with <a href=#replacement-enabled>replacement enabled</a>. The <a href=#source-browsing-context>source browsing context</a> must be the <a href=#browsing-context>browsing context</a> being navigated.</dd> <!-- it appears that document.reload() always uses GET and does not, e.g., re-POST. --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/141 --> </dl><p>When a user requests that the current page of a <a href=#browsing-context>browsing context</a> be reloaded through a user interface element, the user agent should <a href=#navigate>navigate</a><!--DONAV user reload--> the <a href=#browsing-context>browsing context</a> to the same resource as <code><a href=#document>Document</a></code>, with <a href=#replacement-enabled>replacement enabled</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. If <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>'s <a href=#reload-override-flag>reload override flag</a> is set, then the user agent may instead perform <a href=#an-overridden-reload>an overridden reload</a> rather than the navigation described in this paragraph.</p> </div> <p>The <code><a href=#location>Location</a></code> interface also has the complement of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, <dfn id=dom-location-protocol title=dom-location-protocol><code>protocol</code></dfn>, <dfn id=dom-location-host title=dom-location-host><code>host</code></dfn>, <dfn id=dom-location-port title=dom-location-port><code>port</code></dfn>, <dfn id=dom-location-hostname title=dom-location-hostname><code>hostname</code></dfn>, <dfn id=dom-location-pathname title=dom-location-pathname><code>pathname</code></dfn>, <dfn id=dom-location-search title=dom-location-search><code>search</code></dfn>, and <dfn id=dom-location-hash title=dom-location-hash><code>hash</code></dfn>. <span class=impl>These must follow the rules given for <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, with the <a href=#concept-uda-input title=concept-uda-input>input</a> being <a href="#the-document's-current-address" title="the document's current address">the current address</a> of the associated <code><a href=#document>Document</a></code> object, as an <a href=#absolute-url>absolute URL</a> (same as the <code title=dom-location-href><a href=#dom-location-href>href</a></code> attribute), and the <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> being the same as setting the <code title=dom-location-href><a href=#dom-location-href>href</a></code> attribute to the new output value.</span></p> <div class=impl> <h5 id=security-location><span class=secno>6.4.3.1 </span>Security</h5> <p id=security-3>User agents must throw a <code><a href=#securityerror>SecurityError</a></code> exception whenever any of the members of a <code><a href=#location>Location</a></code> object are accessed by scripts whose <a href=#effective-script-origin>effective script origin</a> is not the <a href=#same-origin title="same origin">same</a> as the <code><a href=#location>Location</a></code> object's associated <code><a href=#document>Document</a></code>'s <a href=#effective-script-origin>effective script origin</a>, with the following exceptions:</p> <ul><li>The <code title=dom-location-href><a href=#dom-location-href>href</a></code> setter, if the script is running in a <a href=#browsing-context>browsing context</a> that is <a href=#allowed-to-navigate>allowed to navigate</a> the browsing context with which the <code><a href=#location>Location</a></code> object is associated <li>The <code title=dom-location-replace><a href=#dom-location-replace>replace()</a></code> method, if the script is running in a <a href=#browsing-context>browsing context</a> that is <a href=#allowed-to-navigate>allowed to navigate</a> the browsing context with which the <code><a href=#location>Location</a></code> object is associated </ul></div> <div class=impl> <h4 id=history-notes><span class=secno>6.4.4 </span>Implementation notes for session history</h4> <!-- don't change the ID without updating multiple internal links --> <p><i>This section is non-normative.</i></p> <p>The <code><a href=#history-0>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 title=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><a href=#the-iframe-element>iframe</a></code>s has a <code title=dom-history><a href=#dom-history>history</a></code> object distinct from the <code><a href=#the-iframe-element>iframe</a></code>s' <code title=dom-history><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 title=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>In addition, a user agent could ignore calls to <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> that are invoked on a timer, or from event listeners that are not triggered in response to a clear user action, or that are invoked in rapid succession.</p> </div> <h3 id=browsing-the-web><span class=secno>6.5 </span>Browsing the Web</h3> <div class=impl> <h4 id=navigating-across-documents><span class=secno>6.5.1 </span>Navigating across documents</h4> <p>Certain actions cause the <a href=#browsing-context>browsing context</a> to <i><a href=#navigate>navigate</a></i> to a new resource. Navigation always involves <dfn id=source-browsing-context>source browsing context</dfn>, which is the browsing context which was responsible for starting the navigation.</p> <p class=example>For example, <a href=#following-hyperlinks title="following hyperlinks">following a hyperlink</a>, <a href=#concept-form-submit title=concept-form-submit>form submission</a>, and the <code title=dom-open><a href=#dom-open>window.open()</a></code> and <code title=dom-location-assign><a href=#dom-location-assign>location.assign()</a></code> methods can all cause a browsing context to navigate.</p> <p>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> <!-- NAVIGATE <dfn>navigate</dfn> --> <!-- For places that _call_ this, as opposed to just referring to it, search for "DONAV" --> <p>When a browsing context is <dfn id=navigate title=navigate>navigated</dfn> to a new resource, the user agent must run the following steps:</p> <ol><li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li> <li id=sandboxLinks> <p>If the <a href=#source-browsing-context>source browsing context</a> is not the same as the <a href=#browsing-context>browsing context</a> being navigated, and the <a href=#source-browsing-context>source browsing context</a> is not one of the <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor browsing contexts</a> of the <a href=#browsing-context>browsing context</a> being navigated, and the <a href=#browsing-context>browsing context</a> being navigated is not both a <a href=#top-level-browsing-context>top-level browsing context</a> and one of the <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor browsing contexts</a> of the <a href=#source-browsing-context>source browsing context</a>, and the <a href=#source-browsing-context>source browsing context</a> had its <a href=#sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> set when its <a href=#active-document>active document</a> was created, then abort these steps.</p> <p>Otherwise, if the <a href=#browsing-context>browsing context</a> being navigated is a <a href=#top-level-browsing-context>top-level browsing context</a>, and is one of the <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor browsing contexts</a> of the <a href=#source-browsing-context>source browsing context</a>, and the <a href=#source-browsing-context>source browsing context</a> had its <a href=#sandboxed-top-level-navigation-browsing-context-flag>sandboxed top-level navigation browsing context flag</a> set when its <a href=#active-document>active document</a> was created, then abort these steps.</p> <p>In both cases, the user agent may additionally offer to open the new resource in a new <a href=#top-level-browsing-context>top-level browsing context</a> or in the <a href=#top-level-browsing-context>top-level browsing context</a> of the <a href=#source-browsing-context>source browsing context</a>, at the user's option, in which case the user agent must <a href=#navigate>navigate</a><!--DONAV sandbox manual load--> that designated <a href=#top-level-browsing-context>top-level browsing context</a> to the new resource as if the user had requested it independently.</p> </li> <li id=seamlessLinks><p>If the <a href=#source-browsing-context>source browsing context</a> is the same as the <a href=#browsing-context>browsing context</a> being navigated, and this browsing context has its <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> set, and the <a href=#browsing-context>browsing context</a> being navigated was not chosen using an <a href=#explicit-self-navigation-override>explicit self-navigation override</a>, then find the nearest <a href=#ancestor-browsing-context>ancestor browsing context</a> that does not have its <a href=#seamless-browsing-context-flag>seamless browsing context flag</a> set, and continue these steps as if <em>that</em> <a href=#browsing-context>browsing context</a> was the one that was going to be <a href=#navigate title=navigate>navigated</a> instead.</li> <li><p>If there is a preexisting attempt to navigate the <a href=#browsing-context>browsing context</a>, and the <a href=#source-browsing-context>source browsing context</a> is the same as the <a href=#browsing-context>browsing context</a> being navigated, and that attempt is currently running the <a href=#unload-a-document>unload a document</a> algorithm, and the <a href=#origin>origin</a> of the <a href=#url>URL</a> of the resource being loaded in that navigation is not the <a href=#same-origin>same origin</a> as the <a href=#origin>origin</a> of the <a href=#url>URL</a> of the resource being loaded in <em>this</em> navigation, then abort these steps without affecting the preexisting attempt to navigate the <a href=#browsing-context>browsing context</a>.</li> <!-- http://www.hixie.ch/tests/adhoc/html/navigation/unload/ --> <li><p>If a <a href=#concept-task title=concept-task>task</a> queued by the <a href=#traverse-the-history-by-a-delta>traverse the history by a delta</a> algorithm is running the <a href=#unload-a-document>unload a document</a> algorithm for the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> being navigated, then abort these steps without affecting the <a href=#unload-a-document>unload a document</a> algorithm or the aforementioned history traversal task.</li> <!-- this stops pages from hijacking the back/forward button --> <li><p>If there is a preexisting attempt to navigate the <a href=#browsing-context>browsing context</a>, and either that attempt has not yet <a href=#concept-navigate-mature title=concept-navigate-mature>matured</a> (i.e. it has not passed the point of making its <code><a href=#document>Document</a></code> the <a href=#active-document>active document</a>), or that navigation's resource is not to be fetched using HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, or its resource's <a href=#absolute-url>absolute URL</a> differs from this attempt's by more than the presence, absence, or value of the <a href=#url-fragment title=url-fragment><fragment></a> component, then cancel that preexisting attempt to navigate the <a href=#browsing-context>browsing context</a>.</li> <li id=navigate-fragid-step><p><i>Fragment identifiers</i>: If the <a href=#absolute-url>absolute URL</a> of the new resource is the same as the <a href="#the-document's-address" title="the document's address">address</a> of the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> being navigated, ignoring any <a href=#url-fragment title=url-fragment><fragment></a> components of those <a href=#url title=URL>URLs</a>, and the new resource is to be fetched using HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, and the <a href=#absolute-url>absolute URL</a> of the new resource has a <a href=#url-fragment title=url-fragment><fragment></a> component (even if it is empty), then <a href=#scroll-to-fragid title=navigate-fragid>navigate to that fragment identifier</a> and abort these steps.</li> <li><p>Cancel <em>any</em> preexisting attempt to navigate the <a href=#browsing-context>browsing context</a>, including canceling any instances of the <a href=#fetch>fetch</a> algorithm started by those attempts. If one of those attempts has already <a href=#create-a-document-object title="create a document object">created a new <code>Document</code> object</a>, <a href=#abort-a-document title="abort a document">abort</a> that <code><a href=#document>Document</a></code> also. (Previous navigation attempts whose <a href=#fetch>fetch</a> requests have <em>finished</em> are unaffected, however.)</li> <li><p>If the new resource is to be handled using a mechanism that does not affect the browsing context, e.g. ignoring the navigation request altogether because the specified scheme is not one of the supported protocols, then abort these steps and proceed with that mechanism instead.</li> <li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to unload</a> the <code><a href=#document>Document</a></code> object. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then these steps must be aborted.</li> <li><p><a href=#abort-a-document title="abort a document">Abort</a> the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>.</li> <li> <p>If the new resource 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 title=dom-navigator-registerProtocolHandler>a registered handler</a> for the given scheme, then <a href=#read-ua-inline title=navigate-ua-inline>display the inline content</a> and abort these steps.</p> <p class=note>In the case of a registered handler being used, the algorithm will be reinvoked with a new URL to handle the request.</p> </li> <li> <p>If the resource has already been obtained (e.g. because it is being used to populate an <code><a href=#the-object-element>object</a></code> element's new <a href=#child-browsing-context>child browsing context</a>), then skip this step.</p> <p>Otherwise:</p> <p>If the new resource is to be fetched using HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, and there are <a href=#relevant-application-cache title="relevant application cache">relevant application caches</a> that are identified by a URL with the <a href=#same-origin>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 title=concept-appcache-foreign>foreign</a>, then get the resource from the <a href=#concept-appcache-selection title=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>Otherwise, <a href=#fetch>fetch</a> the new resource, with the <i>manual redirect flag</i> set.</p> <p>If the resource is being fetched using a method other than one <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>equivalent to</a> HTTP's GET<!-- or HEAD (but that can't happen) -->, or, if the <a href=#navigate title=navigate>navigation algorithm</a> was invoked as a result of the <a href=#concept-form-submit title=concept-form-submit>form submission algorithm</a>, then the <a href=#fetch title=fetch>fetching algorithm</a> must be invoked from the <a href=#origin>origin</a> of the <a href=#active-document>active document</a> of the <a href=#source-browsing-context>source browsing context</a>, if any.</p> <!-- potentially http-origin privacy sensitive --> <p>If the <a href=#browsing-context>browsing context</a> being navigated is a <a href=#child-browsing-context>child browsing context</a> for an <code><a href=#the-iframe-element>iframe</a></code> or <code><a href=#the-object-element>object</a></code> element, then the <a href=#fetch title=fetch>fetching algorithm</a> must be invoked from the <code><a href=#the-iframe-element>iframe</a></code> or <code><a href=#the-object-element>object</a></code> element's <a href=#browsing-context-scope-origin>browsing context scope origin</a>, if it has one.</p> <!-- potentially http-origin privacy sensitive --> <p>The <a href=#fetch>fetch</a> algorithm must <a href=#delay-the-load-event>delay the load event</a> of the <a href=#browsing-context>browsing context</a>.</p> <!-- this is what makes <iframe> elements delay the load event of their parent browsing context when their child browsing context is in between this step and the step that starts the parser. --> </li> <li> <p>At this point, unless this step has already been reached once before in the execution of this instance of the algorithm, the user agents must return to whatever algorithm invoked the navigation steps and must continue these steps asynchronously.</p> </li> <li> <p>If fetching the resource results in a redirect, and either the <a href=#url>URL</a> of the target of the redirect has the <a href=#same-origin>same origin</a> as the original resource, or the resource is being obtained using the POST method or a safe method (in HTTP terms), return to <a href=#navigate-fragid-step>the step labeled "fragment identifiers"</a> with the new resource, except that if the <a href=#url>URL</a> of the target of the redirect does not have a fragment identifier and the <a href=#url>URL</a> of the resource that led to the redirect does, then the fragment identifier of the resource that led to the redirect must be propagated to the <a href=#url>URL</a> of the target of the redirect.</p> <p class=example>So for instance, if the original URL was "<code title="">http://example.com/#!sample</code>" and "<code title="">http://example.com/</code>" is found to redirect to "<code title="">https://example.com/</code>", the URL of the new resource will be "<code title="">https://example.com/#!sample</code>".</p> <p>Otherwise, if fetching the resource results in a redirect but the <a href=#url>URL</a> of the target of the redirect does not have the <a href=#same-origin>same origin</a> as the original resource and the resource is being obtained using a method that is neither the POST method nor a safe method (in HTTP terms), then abort these steps. The user agent may indicate to the user that the navigation has been aborted for security reasons.</p> </li> <li><p>Wait for one or more bytes to be available or for the user agent to establish that the resource in question is empty. During this time, the user agent may allow the user to cancel this navigation attempt or start other navigation attempts.</li> <li> <p>If the resource was not fetched from an <a href=#application-cache>application cache</a>, and was to be fetched using HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, and its URL <a href=#concept-appcache-matches-fallback title=concept-appcache-matches-fallback>matches the fallback namespace</a> of one or more <a href=#relevant-application-cache title="relevant application cache">relevant application caches</a>, and the <a href=#concept-appcache-selection title=concept-appcache-selection>most appropriate application cache</a> of those that match does not have an entry in its <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> that has the <a href=#same-origin>same origin</a> as the resource's URL and that is a <a href=#prefix-match>prefix match</a> for the resource's URL, and the user didn't cancel the navigation attempt during the previous step, and the navigation attempt failed (e.g. the server returned a 4xx or 5xx status code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, or there was a DNS error), then:</p> <!-- note that a redirect can never reach this point as it is handled earlier, meaning that a captive portal captures URLs in fallback namespaces and you can't ever get to the fallback file of a resource if you have a captive portal --> <p>Let <var title="">candidate</var> be the <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback resource</a> specified for the <a href=#concept-appcache-fallback-ns title=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 title=concept-appcache-selection>most appropriate application cache</a> of those that match.</p> <p>If <var title="">candidate</var> is not marked as <a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>, then the user agent must discard the failed load and instead continue along these steps using <var title="">candidate</var> as the resource. <a href="#the-document's-address">The document's address</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 resource, and what the URL of the fallback resource actually is.</p> </li> <li> <p><i>Resource handling</i>: If the resource's out-of-band metadata (e.g. HTTP headers), not counting any <a href=#content-type title=Content-Type>type information</a> (such as the Content-Type HTTP header), requires some sort of processing that will not affect the browsing context, then perform that processing and abort these steps.</p> <div class=note> <p>Such processing might be triggered by, amongst other things, the following:</p> <ul class=brief><li>HTTP status codes (e.g. 204 No Content or 205 Reset Content)</li> <li>Network errors (e.g. the network interface being unavailable)</li> <li>Cryptographic protocol failures (e.g. an incorrect TLS certificate)</li> <!-- Other schemes are handled earlier --> <!-- Content-Disposition is handled below --> <!-- Content-Type is handled in subsequent steps --> <!-- ...and I can't think of any others. --> </ul></div> <!--DOWNLOAD--> <p>Responses with HTTP <code title=http-content-disposition>Content-Disposition</code> headers specifying the <code title="">attachment</code> disposition type must be handled <a href=#as-a-download>as a download</a>.</p> <!--DOWNLOAD--> <!-- theoretically, HTTP 205 processing would occur here, resetting all forms with no other effect. However, it seems nobody actually wants to use this ability, so requiring it here seems like unnecessary work. --> <p>HTTP 401 responses that do not include a challenge recognized by the user agent must be processed as if they had no challenge, e.g. rendering the entity body as if the response had been 200 OK.</p> <p>User agents may show the entity body of an HTTP 401 response even when the response does include a recognized challenge, with the option to login being included in a non-modal fashion, to enable the information provided by the server to be used by the user before authenticating. Similarly, user agents should allow the user to authenticate (in a non-modal fashion) against authentication challenges included in other responses such as HTTP 200 OK responses, effectively allowing resources to present HTTP login forms without requiring their use.</p> </li> <li><p>Let <var title="">type</var> be <a href=#content-type-sniffing-0 title="Content-Type sniffing">the sniffed type of the resource</a>.</li> <li><p>If the user agent has been configured to process resources of the given <var title="">type</var> using some mechanism other than rendering the content in a <a href=#browsing-context>browsing context</a>, then skip this step. Otherwise, if the <var title="">type</var> is one of the following types, jump to the appropriate entry in the following list, and process the resource as described there:</p> <dl class=switch><!-- an <span>HTML MIME type</span> --><dt>"<code><a href=#text/html>text/html</a></code>"</dt> <dd>Follow the steps given in the <a href=#read-html title=navigate-html>HTML document</a> section, and abort these steps.</dd> <!-- an <span>XML MIME type</span> --> <dt>"<code>application/xml</code>"</dt> <dt>"<code>text/xml</code>"</dt> <dt>"<code>image/svg+xml</code>"</dt> <dt>"<code><a href=#application/xhtml+xml>application/xhtml+xml</a></code>"</dt> <dt>Any other type ending in "<code title="">+xml</code>" that is not an <a href=#explicitly-supported-xml-type>explicitly supported XML type</a></dt> <!-- no need to say that the _subtype_ ends in "+xml" so long as the "sniffed type" algorithm continues to drop parameters --> <dd>Follow the steps given in the <a href=#read-xml title=navigate-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, abort these steps.</dd> <dt>"<code>text/plain</code>"</dt> <dd>Follow the steps given in the <a href=#read-text title=navigate-text>plain text file</a> section, and abort these steps.</dd> <dt>"<code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code>"</dt> <dd>Follow the steps given in the <a href=#read-multipart-x-mixed-replace title=navigate-multipart-x-mixed-replace>multipart/x-mixed-replace</a> section, and abort these steps.</dd> <dt>A supported image, video, or audio type</dt> <dd>Follow the steps given in the <a href=#read-media title=navigate-media>media</a> section, and abort these steps.</dd> <dt>A type that will use an external application to render the content in the <a href=#browsing-context>browsing context</a></dt> <dd>Follow the steps given in the <a href=#read-plugin title=navigate-plugin>plugin</a> section, and abort these steps.</dd> </dl><p>An <dfn id=explicitly-supported-xml-type>explicitly supported XML type</dfn> is one for which the user agent is configured to use an external application to render the content (either a <a href=#plugin>plugin</a> rendering directly in the <a href=#browsing-context>browsing context</a>, 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>application/atom+xml</code> MIME type), or one for which the user agent has a dedicated handler (e.g. one registered using <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code>).</p> <p><dfn id="set-the-document's-address" title="set the document's address">Setting the document's address</dfn>: If there is no <dfn id=override-url>override URL</dfn>, then any <code><a href=#document>Document</a></code> created by these steps must have its <a href="#the-document's-address" title="the document's address">address</a> set to the <a href=#url>URL</a> that was originally to be <a href=#fetch title=fetch>fetched</a>, ignoring any other data that was used to obtain the resource (e.g. the entity body in the case of a POST submission is not part of <a href="#the-document's-address">the document's address</a>, nor is the URL of the fallback resource in the case of the original load having failed and that URL having been found to match a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a>). However, if there <em>is</em> an <a href=#override-url>override URL</a>, then any <code><a href=#document>Document</a></code> created by these steps must have its <a href="#the-document's-address" title="the document's address">address</a> set to that <a href=#url>URL</a> instead.</p> <p class=note>An <a href=#override-url title="override URL">override URL</a> is set when <a href=#concept-js-deref title=concept-js-deref>dereferencing a <code>javascript:</code> URL</a>.</p> <p><dfn id=create-a-document-object title="create a Document object">Creating a new <code>Document</code> object</dfn>: When a <code><a href=#document>Document</a></code> is created as part of the above steps, a new <code><a href=#window>Window</a></code> object must be created and associated with the <code><a href=#document>Document</a></code>, with one exception: if the <a href=#browsing-context>browsing context</a>'s only entry in its <a href=#session-history>session history</a> is the <code><a href=#about:blank>about:blank</a></code> <code><a href=#document>Document</a></code> that was added when the <a href=#browsing-context>browsing context</a> was created, and navigation is occurring with <a href=#replacement-enabled>replacement enabled</a>, and that <code><a href=#document>Document</a></code> has the <a href=#same-origin>same origin</a> as the new <code><a href=#document>Document</a></code>, then the <code><a href=#window>Window</a></code> object of that <code><a href=#document>Document</a></code> must be used instead, and the <code title=dom-document><a href=#dom-document>document</a></code> attribute of the <code><a href=#window>Window</a></code> object must be changed to point to the new <code><a href=#document>Document</a></code> instead.</p> </li> <li id=navigate-non-Document> <p><i>Non-document content</i>: If, given <var title="">type</var>, the new resource is to be handled by displaying some sort of inline content, e.g. a native rendering of the content, an error message because the specified type is not supported, or an inline prompt to allow the user to select <a href=#dom-navigator-registercontenthandler title=dom-navigator-registerContentHandler>a registered handler</a> for the given type, then <a href=#read-ua-inline title=navigate-ua-inline>display the inline content</a> and abort these steps.</p> <p class=note>In the case of a registered handler being used, the algorithm will be reinvoked with a new URL to handle the request.</p> </li> <li><p>Otherwise, the document's <var title="">type</var> is such that the resource will not affect the browsing context, 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>as a download</a>. Process the resource appropriately.</p> </ol><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>queue a task</a> (associated with the <code><a href=#document>Document</a></code> object of the <a href=#current-entry>current entry</a>, not the new one) to run the following steps:</p> <ol><li><p><a href=#unload-a-document title="unload a document">Unload</a> the <code><a href=#document>Document</a></code> object of the <a href=#current-entry>current entry</a>, with the <var title="">recycle</var> parameter set to false.</li> <li> <dl><dt>If the navigation was initiated for <dfn id=entry-update>entry update</dfn> of an entry</dt> <dd> <ol><li><p>Replace the <code><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><a href=#document>Document</a></code>.</li> <li><p><a href=#traverse-the-history>Traverse the history</a> to the new entry.</li> </ol><p class=note>This can only happen if the entry being updated is no the <a href=#current-entry>current entry</a>, and can never happen with <a href=#replacement-enabled>replacement enabled</a>. (It happens when the user tried to traverse to a session history entry that no longer had a <code><a href=#document>Document</a></code> object.)</p> </dd> <dt>Otherwise</dt> <dd> <ol><li> <p>Remove all the entries in the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> after the <a href=#current-entry>current entry</a>. If the <a href=#current-entry>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> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> queued by the <a href=#history-traversal-task-source>history traversal task source</a>.</li> <!-- so the network is racing history.back(), in the case of setting location.href="" and then calling history.back() --> <li><p>Append a new entry at the end of the <code><a href=#history-0>History</a></code> object representing the new resource and its <code><a href=#document>Document</a></code> object and related state.</li> <li><p><a href=#traverse-the-history>Traverse the history</a> to the new entry. If the navigation was initiated with <a href=#replacement-enabled>replacement enabled</a>, then the traversal must itself be initiated with <a href=#replacement-enabled>replacement enabled</a>.</p> </li> </ol></dd> </dl></li> <li><p>The <a href=#navigate title=navigate>navigation algorithm</a> has now <dfn id=concept-navigate-mature title=concept-navigate-mature>matured</dfn>.</li> <li><p><i>Fragment identifier loop</i>: <a href=#spin-the-event-loop>Spin the event loop</a> for a user-agent-defined amount of time, as desired by the user agent implementor. (This is intended to allow the user agent to optimize the user experience in the face of performance concerns.)</li> <li><p>If the <code><a href=#document>Document</a></code> object has no parser, or its parser has <a href=#stop-parsing title="stop parsing">stopped parsing</a>, or the user agent has reason to believe the user is no longer interested in scrolling to the fragment identifier, then abort these steps.</li> <li><p><a href=#scroll-to-the-fragment-identifier>Scroll to the fragment identifier</a> given in <a href="#the-document's-current-address">the document's current address</a>. If this fails to find <a href=#the-indicated-part-of-the-document title="the indicated part of the document">an indicated part of the document</a>, then return to the <i>fragment identifier loop</i> step.</li> </ol><p>The <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#networking-task-source>networking task source</a>.</p> <h4 id=read-html><span class=secno>6.5.2 </span><dfn title=navigate-html>Page load processing model for HTML files</dfn></h4> <p>When an HTML document is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, set its <a href=#concept-document-media-type title=concept-document-media-type>media type</a> to "<code title="">text/html</code>", create an <a href=#html-parser>HTML parser</a>, and associate it with the document. Each <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> while the <a href=#fetch title=fetch>fetching algorithm</a> runs must then fill the parser's <a href=#the-input-stream>input stream</a> with the fetched bytes and cause the <a href=#html-parser>HTML parser</a> to perform the appropriate processing of the input stream.</p> <p class=note>The <a href=#the-input-stream>input stream</a> converts bytes into characters for use in the <a href=#tokenization title=tokenization>tokenizer</a>. This process relies, in part, on character encoding information found in the real <a href=#content-type title=Content-Type>Content-Type metadata</a> of the resource; the "sniffed type" is not used for this purpose.</p> <!-- next two paragraphs are nearly identical to the navigate-text section, keep them in sync --> <p>When no more bytes are available, the user agent must <a href=#queue-a-task>queue a task</a> for the parser to process the implied EOF character, which eventually causes a <code title=event-load>load</code> event to be fired.</p> <p>After creating the <code><a href=#document>Document</a></code> object, but before any script execution, certainly before the parser <a href=#stop-parsing title="stop parsing">stops</a>, the user agent must <a href=#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 title=concept-appcache-init>Application cache selection</a> happens <a href=#parser-appcache>in the HTML parser</a>.</p> <p>The <a href=#task-source>task source</a> for the two tasks mentioned in this section must be the <a href=#networking-task-source>networking task source</a>.</p> <h4 id=read-xml><span class=secno>6.5.3 </span><dfn title=navigate-xml>Page load processing model for XML files</dfn></h4> <p>When faced with displaying an XML file inline, user agents must first <a href=#create-a-document-object>create a <code>Document</code> object</a>, following the requirements of the XML and Namespaces in XML recommendations, RFC 3023, DOM Core, and other relevant specifications. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a> <a href=#refsRFC3023>[RFC3023]</a> <a href=#refsDOMCORE>[DOMCORE]</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 href="#document's-character-encoding">document's character encoding</a> must be set to that character encoding.</p> <p>If the root element, as parsed according to the XML specifications cited above, is found to be an <code><a href=#the-html-element>html</a></code> element with an attribute <code title=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 title="insert an element into a document">inserted into the document</a>, the user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of that attribute relative to that element, and if that is successful, must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with the resulting <a href=#absolute-url>absolute URL</a> with any <a href=#url-fragment title=url-fragment><fragment></a> component removed as the manifest URL, and passing in the newly-created <code><a href=#document>Document</a></code>. Otherwise, if the attribute is absent, its value is the empty string, or resolving its value fails, then as soon as the root element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the document</a>, the user agent must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, and passing in the <code><a href=#document>Document</a></code>.</p> <p class=note>Because the processing of the <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute happens only once the root element is parsed, any URLs referenced by processing instructions before the root element (such as <code title=""><?xml-stylesheet?></code> and <code title=""><?xbl?></code> PIs) will be fetched from the network and cannot be cached.</p><!-- v2: fix this somehow --> <p>User agents may examine the namespace of the root <code><a href=#element>Element</a></code> node of this <code><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 "non-document content") in the <a href=#navigate>navigate</a> steps above.</p> <p>Otherwise, then, with the newly created <code><a href=#document>Document</a></code>, the user agents must <a href=#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><a href=#document>Document</a></code>.</p> <h4 id=read-text><span class=secno>6.5.4 </span><dfn title=navigate-text>Page load processing model for text files</dfn></h4> <p>When a plain text document is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, set its <a href=#concept-document-media-type title=concept-document-media-type>media type</a> to "<code title="">text/plain</code>", create an <a href=#html-parser>HTML parser</a>, associate it with the document, 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<!-- to get eaten, so that a leading LF in the text/plain stream doesn't get eaten itself-->, and switch the <a href=#html-parser>HTML parser</a>'s tokenizer to the <a href=#plaintext-state>PLAINTEXT state</a>. Each <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> while the <a href=#fetch title=fetch>fetching algorithm</a> runs must then fill the parser's <a href=#the-input-stream>input stream</a> with the fetched bytes and cause the <a href=#html-parser>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 in RFC 2046, RFC 3676, and subsequent versions thereof. <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC3676>[RFC3676]</a></p> <p>The <a href="#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><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, and passing in the newly-created <code><a href=#document>Document</a></code>.</p> <!-- next two paragraphs are nearly identical to the navigate-html section and similar to the "navigate-ua-inline" section, and the next three are similar to the navigate-media and navigate-plugin sections; keep them all in sync --> <p>When no more bytes are available, the user agent must <a href=#queue-a-task>queue a task</a> for the parser to process the implied EOF character, which eventually causes a <code title=event-load>load</code> event to be fired.</p> <p>After creating the <code><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>update the session history with the new page</a>.</p> <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of the <code><a href=#document>Document</a></code>, e.g. linking to a style sheet or an XBL binding, providing script, giving the document a <code><a href=#the-title-element>title</a></code>, etc.</p> <p class=note>In particular, if the user agent supports the <code title="">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., an XBL binding or a CSS extension.</p> <p>The <a href=#task-source>task source</a> for the two tasks mentioned in this section must be the <a href=#networking-task-source>networking task source</a>.</p> <h4 id=read-multipart-x-mixed-replace><span class=secno>6.5.5 </span><dfn title=navigate-multipart-x-mixed-replace>Page load processing model for <code>multipart/x-mixed-replace</code> resources</dfn></h4> <p>When a resource with the type <code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code> is to be loaded in a <a href=#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 new instance of the <a href=#navigate>navigate</a> algorithm, starting from the <i>resource handling</i> step, using the new body part as the resource being navigated, with <a href=#replacement-enabled>replacement enabled</a> if a previous body part from the same resource resulted in a <code><a href=#document>Document</a></code> object being <a href=#create-a-document-object title="create a document object">created</a>, and otherwise using the same setup as the <a href=#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 title=event-load>load</code> events (and for that matter <code title=event-unload>unload</code> events) do fire for each body part loaded.</p> <h4 id=read-media><span class=secno>6.5.6 </span><dfn title=navigate-media>Page load processing model for media</dfn></h4> <p>When an image, video, or audio resource is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent should <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, set its <a href=#concept-document-media-type title=concept-document-media-type>media type</a> to the sniffed MIME type of the resource (<var title="">type</var> in the <a href=#navigate>navigate</a> algorithm), append an <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>, append a <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element>body</a></code> element to the <code><a href=#the-html-element>html</a></code> element, append an element <var title="">host element</var> for the media, as described below, to the <code><a href=#the-body-element>body</a></code> element, and set the appropriate attribute of the element <var title="">host element</var>, as described below, to the address of the image, video, or audio resource.</p> <p>The element <var title="">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 <tr><td> Image <td> <code><a href=#the-img-element>img</a></code> <td> <code title=attr-img-src><a href=#attr-img-src>src</a></code> <tr><td> Video <td> <code><a href=#the-video-element>video</a></code> <td> <code title=attr-media-src><a href=#attr-media-src>src</a></code> <tr><td> Audio <td> <code><a href=#the-audio-element>audio</a></code> <td> <code title=attr-media-src><a href=#attr-media-src>src</a></code> </thead></table><!-- next three paragraphs are similar to the navigate-text section, keep them in sync --><p>Then, the user agent must act as if it had <a href=#stop-parsing title="stop parsing">stopped parsing</a>.</p> <p>Upon creation of the <code><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, and passing in the newly-created <code><a href=#document>Document</a></code>.</p> <p>After creating the <code><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>update the session history with the new page</a>.</p> <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of the <code><a href=#document>Document</a></code>, or attributes to the element <var title="">host element</var>, e.g. to link to a style sheet or an XBL binding, to provide a script, to give the document a <code><a href=#the-title-element>title</a></code>, to make the media <a href=#attr-media-autoplay title=attr-media-autoplay>autoplay</a>, etc.</p> <h4 id=read-plugin><span class=secno>6.5.7 </span><dfn title=navigate-plugin>Page load processing model for content that uses plugins</dfn></h4> <p>When a resource that requires an external resource to be rendered is to be loaded in a <a href=#browsing-context>browsing context</a>, the user agent should <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, set its <a href=#concept-document-media-type title=concept-document-media-type>media type</a> to the sniffed MIME type of the resource (<var title="">type</var> in the <a href=#navigate>navigate</a> algorithm), append an <code><a href=#the-html-element>html</a></code> element to the <code><a href=#document>Document</a></code>, append a <code><a href=#the-head-element>head</a></code> element and a <code><a href=#the-body-element>body</a></code> element to the <code><a href=#the-html-element>html</a></code> element, append an <code><a href=#the-embed-element>embed</a></code> to the <code><a href=#the-body-element>body</a></code> element, and set the <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute of the <code><a href=#the-embed-element>embed</a></code> element to the address of the resource.</p> <!-- next three paragraphs are similar to the navigate-text section, keep them in sync --> <p>Then, the user agent must act as if it had <a href=#stop-parsing title="stop parsing">stopped parsing</a>.</p> <p>Upon creation of the <code><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, and passing in the newly-created <code><a href=#document>Document</a></code>.</p> <p>After creating the <code><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>update the session history with the new page</a>.</p> <p>User agents may add content to the <code><a href=#the-head-element>head</a></code> element of the <code><a href=#document>Document</a></code>, or attributes to the <code><a href=#the-embed-element>embed</a></code> element, e.g. to link to a style sheet or an XBL binding, or to give the document a <code><a href=#the-title-element>title</a></code>.</p> <p class=note id=sandboxPluginNavigate>If the <a href=#sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> was set on the <a href=#browsing-context>browsing context</a> when the <code><a href=#document>Document</a></code> was created, the synthesized <code><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>plugin</a> cannot be <a href=#concept-plugin-secure title=concept-plugin-secure>secured</a>.</p> <h4 id=read-ua-inline><span class=secno>6.5.8 </span><dfn title=navigate-ua-inline>Page load processing model for inline content that doesn't have a DOM</dfn></h4> <p>When the user agent is to display a user agent page inline in a <a href=#browsing-context>browsing context</a>, the user agent should <a href=#create-a-document-object>create a <code>Document</code> object</a>, mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>, set its <a href=#concept-document-media-type title=concept-document-media-type>media type</a> to "<code title="">text/html</code>", and then either associate that <code><a href=#document>Document</a></code> with a custom rendering that is not rendered using the normal <code><a href=#document>Document</a></code> rendering rules, or mutate that <code><a href=#document>Document</a></code> until it represents the content the user agent wants to render.</p> <!-- next two paragraphs are similar to the navigate-text section, keep them in sync --> <p>Once the page has been set up, the user agent must act as if it had <a href=#stop-parsing title="stop parsing">stopped parsing</a>.</p> <p>Upon creation of the <code><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, passing in the newly-created <code><a href=#document>Document</a></code>.</p> <p>After creating the <code><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>update the session history with the new page</a>.</p> <h4 id=scroll-to-fragid><span class=secno>6.5.9 </span><dfn title=navigate-fragid>Navigating to a fragment identifier</dfn></h4> <p>When a user agent is supposed to navigate to a fragment identifier, then the user agent must <a href=#queue-a-task>queue a task</a> to run the following steps:</p> <ol><li> <p>Remove all the entries in the <a href=#browsing-context>browsing context</a>'s <a href=#session-history>session history</a> after the <a href=#current-entry>current entry</a>. If the <a href=#current-entry>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> <li><p>Remove any <a href=#concept-task title=concept-task>tasks</a> queued by the <a href=#history-traversal-task-source>history traversal task source</a>.</li> <li><p>Append a new entry at the end of the <code><a href=#history-0>History</a></code> object representing the new resource and its <code><a href=#document>Document</a></code> object and related state. Its <a href=#url>URL</a> must be set to the address to which the user agent was <a href=#navigate title=navigate>navigating</a>. The title must be left unset.</li> <li><p><a href=#traverse-the-history>Traverse the history</a> to the new entry. This will <a href=#scroll-to-the-fragment-identifier>scroll to the fragment identifier</a> given in what is now <a href="#the-document's-current-address">the document's current address</a>.</li> </ol><p class=note>If the scrolling fails because the relevant <a href=#concept-id title=concept-id>ID</a> has not yet been parsed, then the original <a href=#navigate title=navigate>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>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 identifier</dfn>, it must change the scrolling position of the document using the <a href=#scroll-an-element-into-view>scroll an element into view</a> algorithm defined in the CSSOM View specification, or perform some other action, such that <a href=#the-indicated-part-of-the-document>the indicated part of the document</a> is brought to the user's attention. If there is no indicated part, then the user agent must not scroll anywhere. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a></p> <p><dfn id=the-indicated-part-of-the-document>The indicated part of the document</dfn> is the one that the fragment identifier, if any, identifies. The semantics of the fragment identifier in terms of mapping it to a specific DOM Node is defined by the specification that defines the <a href=#mime-type>MIME type</a> used by the <code><a href=#document>Document</a></code> (for example, the processing of fragment identifiers for <a href=#xml-mime-type title="XML MIME type">XML MIME types</a> is the responsibility of RFC3023). <a href=#refsRFC3023>[RFC3023]</a></p> <p>For HTML documents (and <a href=#html-mime-type title="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>the indicated part of the document</a> is.</p> <ol><li><p><a href=#parse-a-url title="parse a url">Parse</a> the <a href=#url>URL</a>, and let <var title="">fragid</var> be the <a href=#url-fragment title=url-fragment><fragment></a> component of the URL.</li><!-- parsing can't fail, since we checked earlier on when navigating --> <li><p>If <var title="">fragid</var> is the empty string, then <a href=#the-indicated-part-of-the-document>the indicated part of the document</a> is the top of the document; stop the algorithm here.</li> <li><p>Let <var title="">decoded fragid</var> be the result of expanding any sequences of percent-encoded octets in <var title="">fragid</var> that are valid UTF-8 sequences into Unicode characters as defined by UTF-8. If any percent-encoded octets in that string are not valid UTF-8 sequences (e.g. they expand to surrogate code points), then skip this step and the next one.</p> <li><p>If this step was not skipped and there is an element in the DOM that has an <a href=#concept-id title=concept-id>ID</a> exactly equal to <var title="">decoded fragid</var>, then the first such element in tree order is <a href=#the-indicated-part-of-the-document>the indicated part of the document</a>; stop the algorithm here.</li> <li><p>If there is an <code><a href=#the-a-element>a</a></code> element in the DOM that has a <code title=attr-a-name><a href=#attr-a-name>name</a></code> attribute whose value is exactly equal to <var title="">fragid</var> (<em>not</em> <var title="">decoded fragid</var>), then the first such element in tree order is <a href=#the-indicated-part-of-the-document>the indicated part of the document</a>; stop the algorithm here.</li> <li><p>If <var title="">fragid</var> is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string <code title="">top</code>, then <a href=#the-indicated-part-of-the-document>the indicated part of the document</a> is the top of the document; stop the algorithm here.</li> <li><p>Otherwise, there is no <a href=#the-indicated-part-of-the-document title="the indicated part of the document">indicated part of the document</a>.</li> </ol><p>For the purposes of the interaction of HTML with Selectors' <code title=selector-target>:target</code> pseudo-class, the <dfn id=target-element><i>target element</i></dfn> is <a href=#the-indicated-part-of-the-document>the indicated part of the document</a>, if that is an element; otherwise there is no <i><a href=#target-element>target element</a></i>. <a href=#refsSELECTORS>[SELECTORS]</a></p> </div> <h4 id=history-traversal><span class=secno>6.5.10 </span>History traversal</h4> <!-- session history --> <div class=impl> <p>When a user agent is required to <dfn id=traverse-the-history>traverse the history</dfn> to a <var title="">specified entry</var>, optionally with <a href=#replacement-enabled>replacement enabled</a>, the user agent must act as follows.</p> <p class=note>This algorithm is not just invoked when <a href=#traverse-the-history-by-a-delta title="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 title=navigate>navigating a browsing context</a>, as part of <a href=#update-the-session-history-with-the-new-page title="update the session history with the new page">updating the session history with the new page</a>.</p> <ol><li><p>If there is no longer a <code><a href=#document>Document</a></code> object for the entry in question, the user agent must <a href=#navigate>navigate</a><!--DONAV history traversal after eviction--> the browsing context to the location for that entry to perform an <a href=#entry-update>entry update</a> of that entry, and abort these steps. The "<a href=#navigate>navigate</a>" algorithm reinvokes this "traverse" algorithm to complete the traversal, at which point there <em>is</em> a <code><a href=#document>Document</a></code> object and so this step gets skipped. The navigation must be done using the same <a href=#source-browsing-context>source browsing context</a> as was used the first time this entry was created. (This can never happen with <a href=#replacement-enabled>replacement enabled</a>.)</li> <li><p>If the <a href=#current-entry>current entry</a>'s title was not set by the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> or <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState()</a></code> methods, then set its title to the value returned by the <code title=dom-document-title><a href=#document.title>document.title</a></code> IDL attribute.</li> <li><p>If appropriate, update the <a href=#current-entry>current entry</a> in the <a href=#browsing-context>browsing context</a>'s <code><a href=#document>Document</a></code> object's <code><a href=#history-0>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>an entry with persisted user state</a>.</li> <li><p>If the <var title="">specified entry</var> has a different <code><a href=#document>Document</a></code> object than the <a href=#current-entry>current entry</a> then the user agent must run the following substeps:</p> <ol><li>If the browsing context is a <a href=#top-level-browsing-context>top-level browsing context</a>, but not an <a href=#auxiliary-browsing-context>auxiliary browsing context</a>, and the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of the <var title="">specified entry</var> is not the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of the <a href=#current-entry>current entry</a>, then the following sub-sub-steps must be run: <ol><li>The current <a href=#browsing-context-name>browsing context name</a> must be stored with all the entries in the history that are associated with <code><a href=#document>Document</a></code> objects with the <a href=#same-origin>same origin</a> as the <a href=#active-document>active document</a> <em>and</em> that are contiguous with the <a href=#current-entry>current entry</a>.</li> <li id=resetBCName>The browsing context's <a href=#browsing-context-name>browsing context name</a> must be unset.</li> </ol></li> <li id=appcache-history-2>The user agent must make the <var title="">specified entry</var>'s <code><a href=#document>Document</a></code> object the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>.</li> <li>If the <var title="">specified entry</var> has a <a href=#browsing-context-name>browsing context name</a> stored with it, then the following sub-sub-steps must be run: <ol><li>The browsing context's <a href=#browsing-context-name>browsing context name</a> must be set to the name stored with the specified entry.</li> <li>Any <a href=#browsing-context-name>browsing context name</a> stored with the entries in the history that are associated with <code><a href=#document>Document</a></code> objects with the <a href=#same-origin>same origin</a> as the new <a href=#active-document>active document</a>, and that are contiguous with the specified entry, must be cleared.</li> </ol></li> <li id=history-autocomplete><p>If the <var title="">specified entry</var>'s <code><a href=#document>Document</a></code> has any <code><a href=#the-input-element>input</a></code> elements whose <a href=#resulting-autocompletion-state>resulting autocompletion state</a> is <i title="">off</i>, invoke the <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> of each of those elements.</li> <li><p>If the <a href=#current-document-readiness>current document readiness</a> of the <var title="">specified entry</var>'s <code><a href=#document>Document</a></code> is "<code title="">complete</code>", <a href=#queue-a-task>queue a task</a> to fire a <code title=event-pageshow><a href=#event-pageshow>pageshow</a></code> event at the <code><a href=#window>Window</a></code> object of that <code><a href=#document>Document</a></code>, but with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the <code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the <code><a href=#window>Window</a></code> object), using the <code><a href=#pagetransitionevent>PageTransitionEvent</a></code> interface, with the <code title=dom-PageTransitionEvent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to true. This event must not bubble, must not be cancelable, and has no default action.</li> <!-- an interesting thing to test would be to traverse back during onload, before the first pageshow has fired, and then to traverse forward again, and see if we get _two_ pageshows. If so, it indicates that the history traversal task source has a higher priority than the DOM manipulation task source. --> </ol></li> <li><p>Set <a href="#the-document's-current-address">the document's current address</a> to the URL of the <var title="">specified entry</var>.</li> <li><p>If the <var title="">specified entry</var> has a URL whose fragment identifier differs from that of the <a href=#current-entry>current entry</a>'s when compared in a <a href=#case-sensitive>case-sensitive</a> manner, and the two share the same <code><a href=#document>Document</a></code> object, then let <var title="">hash changed</var> be true, and let <var title="">old URL</var> be the URL of the <a href=#current-entry>current entry</a> and <var title="">new URL</var> be the URL of the <var title="">specified entry</var>. Otherwise, let <var title="">hash changed</var> be false.</li> <li><p>If the traversal was initiated with <dfn id=replacement-enabled>replacement enabled</dfn>, remove the entry immediately before the <var title="">specified entry</var> in the session history.</p> <li><p>If the <var title="">specified entry</var> is not <a href=#an-entry-with-persisted-user-state>an entry with persisted user state</a>, but its URL has a fragment identifier, <a href=#scroll-to-the-fragment-identifier>scroll to the fragment identifier</a>.</li> <li> <p>If the entry is <a href=#an-entry-with-persisted-user-state>an entry with persisted user state</a>, the user agent may update aspects of the document and its rendering, for instance the scroll position or values of form fields, that it had previously recorded.</p> <!-- see similar paragraphs in the textarea and input sections --> <p class=note>This can even include updating the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> attribute of <code><a href=#the-textarea-element>textarea</a></code> elements or <code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in either the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state or the <a href=#text-state-and-search-state title=attr-input-type-search>Search</a> state, if the persisted state includes the directionality of user input in such controls.</p> </li> <li><p>If the entry is a <a href=#state-object>state object</a> entry, let <var title="">state</var> be a <a href=#structured-clone>structured clone</a> of that state object. Otherwise, let <var title="">state</var> be null.</li> <li><p>Set <code title=dom-history-state><a href=#dom-history-state>history.state</a></code> to <var title="">state</var>.</li> <li><p>Let <var title="">state changed</var> be true if the <a href=#latest-entry>latest entry</a> of the <code><a href=#document>Document</a></code> of the <var title="">specified entry</var> is not the <var title="">specified entry</var>; otherwise let it be false. (If the <code><a href=#document>Document</a></code> has no <a href=#latest-entry>latest entry</a> then by definition its <a href=#latest-entry>latest entry</a> is not the <var title="">specified entry</var>.)</p> <li><p>Let the <a href=#latest-entry>latest entry</a> of the <code><a href=#document>Document</a></code> of the <var title="">specified entry</var> be the <var title="">specified entry</var>.</li> <li><p>If <var title="">state changed</var> is true, fire a <code title=event-popstate><a href=#event-popstate>popstate</a></code> event at the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, using the <code><a href=#popstateevent>PopStateEvent</a></code> interface, with the <code title=dom-PopStateEvent-state><a href=#dom-popstateevent-state>state</a></code> attribute initialized to the value of <var title="">state</var>. This event must bubble but not be cancelable and has no default action.</li> <li><p>If <var title="">hash changed</var> is true, then fire a <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code> event at the <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code> object, using the <code><a href=#hashchangeevent>HashChangeEvent</a></code> interface, with the <code title=dom-HashChangeEvent-oldURL><a href=#dom-hashchangeevent-oldurl>oldURL</a></code> attribute initialized to <var title="">old URL</var> and the <code title=dom-HashChangeEvent-newURL><a href=#dom-hashchangeevent-newurl>newURL</a></code> attribute initialized to <var title="">new URL</var>. This event must bubble but not be cancelable and has no default action.</li> <li><p>The <a href=#current-entry>current entry</a> is now the <var title="">specified entry</var>.</li> </ol><p>The <a href=#task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <h5 id=event-definitions-0><span class=secno>6.5.10.1 </span>Event definitions</h5> </div> <p>The <dfn id=event-popstate title=event-popstate><code>popstate</code></dfn> event is fired in certain cases when navigating to a <a href=#session-history-entry>session history entry</a>.</p> <pre class=idl>[Constructor(DOMString type, optional <a href=#popstateeventinit>PopStateEventInit</a> eventInitDict)] interface <dfn id=popstateevent>PopStateEvent</dfn> : <a href=#event>Event</a> { readonly attribute any <a href=#dom-popstateevent-state title=dom-PopStateEvent-state>state</a>; }; dictionary <dfn id=popstateeventinit>PopStateEventInit</dfn> : <a href=#eventinit>EventInit</a> { any state; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-PopStateEvent-state><a href=#dom-popstateevent-state>state</a></code></dt> <dd> <p>Returns a copy of the information that was provided to <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> or <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState()</a></code>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-popstateevent-state title=dom-PopStateEvent-state><code>state</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the context information for the event, or null, if the state represented is the initial state of the <code><a href=#document>Document</a></code>.</p> </div> <hr><p>The <dfn id=event-hashchange title=event-hashchange><code>hashchange</code></dfn> event is fired when navigating to a <a href=#session-history-entry>session history entry</a> whose <a href=#url>URL</a> differs from that of the previous one only in the fragment identifier.</p> <pre class=idl>[Constructor(DOMString type, optional <a href=#hashchangeeventinit>HashChangeEventInit</a> eventInitDict)] interface <dfn id=hashchangeevent>HashChangeEvent</dfn> : <a href=#event>Event</a> { readonly attribute DOMString <a href=#dom-hashchangeevent-oldurl title=dom-HashChangeEvent-oldURL>oldURL</a>; readonly attribute DOMString <a href=#dom-hashchangeevent-newurl title=dom-HashChangeEvent-newURL>newURL</a>; }; dictionary <dfn id=hashchangeeventinit>HashChangeEventInit</dfn> : <a href=#eventinit>EventInit</a> { DOMString oldURL; DOMString newURL; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-HashChangeEvent-oldURL><a href=#dom-hashchangeevent-oldurl>oldURL</a></code></dt> <dd> <p>Returns the <a href=#url>URL</a> of the <a href=#session-history-entry>session history entry</a> that was previously current.</p> </dd> <dt><var title="">event</var> . <code title=dom-HashChangeEvent-newURL><a href=#dom-hashchangeevent-newurl>newURL</a></code></dt> <dd> <p>Returns the <a href=#url>URL</a> of the <a href=#session-history-entry>session history entry</a> that is now current.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-hashchangeevent-oldurl title=dom-HashChangeEvent-oldURL><code>oldURL</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents context information for the event, specifically the URL of the <a href=#session-history-entry>session history entry</a> that was traversed from.</p> <p>The <dfn id=dom-hashchangeevent-newurl title=dom-HashChangeEvent-newURL><code>newURL</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents context information for the event, specifically the URL of the <a href=#session-history-entry>session history entry</a> that was traversed to.</p> </div> <hr><p>The <dfn id=event-pageshow title=event-pageshow><code>pageshow</code></dfn> event is fired when traversing <em>to</em> a <a href=#session-history-entry>session history entry</a>.</p> <p>The <dfn id=event-pagehide title=event-pagehide><code>pagehide</code></dfn> event is fired when traversing <em>from</em> a <a href=#session-history-entry>session history entry</a>.</p> <pre class=idl>[Constructor(DOMString type, optional <a href=#pagetransitioneventinit>PageTransitionEventInit</a> eventInitDict)] interface <dfn id=pagetransitionevent>PageTransitionEvent</dfn> : <a href=#event>Event</a> { readonly attribute boolean <a href=#dom-pagetransitionevent-persisted title=dom-PageTransitionEvent-persisted>persisted</a>; }; dictionary <dfn id=pagetransitioneventinit>PageTransitionEventInit</dfn> : <a href=#eventinit>EventInit</a> { boolean persisted; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-PageTransitionEvent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code></dt> <dd> <p>Returns false if the page is newly being loaded (and the <code title=event-load>load</code> event will fire). Otherwise, returns true.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-pagetransitionevent-persisted title=dom-PageTransitionEvent-persisted><code>persisted</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to false. It represents the context information for the event.</p> </div> <h4 id=unloading-documents><span class=secno>6.5.11 </span>Unloading documents</h4> <div class=impl> <p>A <code><a href=#document>Document</a></code> has a <dfn id=concept-document-salvageable title=concept-document-salvageable><var>salvageable</var></dfn> state, which is initially true.</p> <p>When a user agent is to <dfn id=prompt-to-unload-a-document>prompt to unload a document</dfn>, it must run the following steps.</p> <ol><li><p>Let <var title="">event</var> be a new <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> event object with the name <code title=event-beforeunload>beforeunload</code>, which does not bubble but is cancelable.</li> <li><p><i>Dispatch</i>: Dispatch <var title="">event</var> at the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li> <li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li> <li><p>If any event listeners were triggered by the earlier <i>dispatch</i> step, then set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</li> <li> <p>If the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute of the <var title="">event</var> object is not the empty string, or if the event was canceled, then the user agent should ask the user to confirm that they wish to unload the document.</p> <p>The prompt shown by the user agent may include the string of the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute, or some leading subset thereof. (A user agent may want to truncate the string to 1024 characters for display, for instance.)</p> <p>The user agent must <a href=#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> <li><p>If this algorithm was invoked by another instance of the "prompt to unload a document" algorithm (i.e. through the steps below that invoke this algorithm for all descendant browsing contexts), then abort these steps here.</li> <li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the <code><a href=#document>Document</a></code>.</li> <li> <p>If <var title="">descendants</var> is not an empty list, then for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in <var title="">descendants</var> run the following substeps:</p> <ol><li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to unload</a> the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> <var title="">b</var>. If the user <a href=#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 title="refused to allow the document to be unloaded">refused to allow <em>this</em> document to be unloaded</a>; abort these steps.</p> <li><p>If <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state of the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> <var title="">b</var> is false, then set the <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state of <em>this</em> document to false also.</li> </ol></li> </ol><p>When a user agent is to <dfn id=unload-a-document>unload a document</dfn>, it must run the following steps. These steps are passed an argument, <var title="">recycle</var>, which is either true or false, indicating whether the <code><a href=#document>Document</a></code> object is going to be re-used. (This is set by the <code title=dom-document-open><a href=#dom-document-open>document.open()</a></code> method.)</p> <ol><li><p>Fire a <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event at the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, but with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the <code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the <code><a href=#window>Window</a></code> object), using the <code><a href=#pagetransitionevent>PageTransitionEvent</a></code> interface, with the <code title=dom-PageTransitionEvent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to true. This event must not bubble, must not be cancelable, and has no default action.</li> <li><p><i>Unload event</i>: <a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-unload>unload</code> at the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li> <li><p>Release the <a href=#storage-mutex>storage mutex</a>.</li> <li><p>If any event listeners were triggered by the earlier <i>unload event</i> step, then set the <code><a href=#document>Document</a></code> object's <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</li> <li><p>Run any <a href=#unloading-document-cleanup-steps>unloading document cleanup steps</a> for <code><a href=#document>Document</a></code> that are defined by this specification and <a href=#other-applicable-specifications>other applicable specifications</a>.</li> <li><p>If this algorithm was invoked by another instance of the "unload a document" algorithm (i.e. through the steps below that invoke this algorithm for all descendant browsing contexts), then abort these steps here.</li> <li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the <code><a href=#document>Document</a></code>.</li> <li> <p>If <var title="">descendants</var> is not an empty list, then for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in <var title="">descendants</var> run the following substeps:</p> <ol><li><p><a href=#unload-a-document title="unload a document">Unload</a> the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> <var title="">b</var> with the <var title="">recycle</var> parameter set to false.</li> <li><p>If <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state of the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> <var title="">b</var> is false, then set the <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state of <em>this</em> document to false also.</li> </ol></li> <li><p>If <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> and <var title="">recycle</var> are both false, then the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> must <a href=#discard-a-document title="discard a document">discard the <code>Document</code></a>.</li> </ol><p>This specification defines the following <dfn id=unloading-document-cleanup-steps>unloading document cleanup steps</dfn>. Other specifications can define more.</p> <ol><li> <p><a href=#make-disappear>Make disappear</a> any <code><a href=#websocket>WebSocket</a></code> objects that were created by the <code title=dom-WebSocket><a href=#dom-websocket>WebSocket()</a></code> constructor whose global object is the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object. </p> <p>If this affected any <code><a href=#websocket>WebSocket</a></code> objects, the set <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</p> </li> <li> <p>If the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object <a href=#concept-peerconnection-owner title=concept-PeerConnection-owner>owns</a> any <code><a href=#peerconnection>PeerConnection</a></code> objects whose <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is not <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code>, then set <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</p> </li> <li><p>If the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state is false, <a href=#concept-eventsource-forcibly-close title=concept-EventSource-forcibly-close>forcibly close</a> any <code><a href=#eventsource>EventSource</a></code> objects that whose constructor was invoked from the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.</li> <li><p>If the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state is false, empty the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code>'s <a href=#list-of-active-timeouts>list of active timeouts</a> and its <a href=#list-of-active-intervals>list of active intervals</a>.</li> </ol><h5 id=event-definition><span class=secno>6.5.11.1 </span>Event definition</h5> </div> <pre class=idl>interface <dfn id=beforeunloadevent>BeforeUnloadEvent</dfn> : <a href=#event>Event</a> { attribute DOMString <a href=#dom-beforeunloadevent-returnvalue title=dom-BeforeUnloadEvent-returnValue>returnValue</a>; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current return value of the event (the message to show the user).</p> <p>Can be set, to update the message.</p> </dd> </dl><p class=note>There are no <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>-specific initialization methods.</p> <div class=impl> <p>The <dfn id=dom-beforeunloadevent-returnvalue title=dom-BeforeUnloadEvent-returnValue><code>returnValue</code></dfn> attribute represents the message to show the user. When the event is created, the attribute must be set to the empty string. On getting, it must return the last value it was set to. On setting, the attribute must be set to the new value.</p> </div> <div class=impl> <h4 id=aborting-a-document-load><span class=secno>6.5.12 </span>Aborting a document load</h4> <p>If a <code><a href=#document>Document</a></code> is <dfn id=abort-a-document title="abort a document">aborted</dfn>, the user agent must run the following steps:</p> <ol><li><p><a href=#abort-a-document title="abort a document">Abort</a> the <a href=#active-document title="active document">active documents</a> of every <a href=#child-browsing-context>child browsing context</a>.</li> <li><p>Cancel any instances of the <a href=#fetch title=fetch>fetch</a> algorithm in the context of this <code><a href=#document>Document</a></code>, discarding any <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a task">queued</a> for them, and discarding any further data received from the network for them.</li> <li><p>If the <code><a href=#document>Document</a></code> has an <a href=#active-parser>active parser</a>, then <a href=#abort-a-parser title="abort a parser">abort that parser</a>.</li> <li><p>Set the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to false.</li> <!-- we could also stop all script, or stop animations --> </ol><p>User agents may allow users to explicitly invoke the <a href=#abort-a-document title="abort a document">abort a document</a> algorithm for a <code><a href=#document>Document</a></code>. If the user does so, then, if that <code><a href=#document>Document</a></code> is an <a href=#active-document>active document</a>, the user agent should <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-abort>abort</code> at that <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object before invoking the <a href=#abort-a-document title="abort a document">abort</a> algorithm.</p> <!-- I'd love to make this more precise, anyone have any suggestions on what it should say? --> </div> <h3 id=offline><span class=secno>6.6 </span>Offline Web applications</h3> <!-- v2 ideas for appcache: * A way to limit what gets download when the user agent is updating the application cache and it turns out the server has changed EVERY page because every page has a dynamic "site last modified" date on it. http://groups.google.com/group/gears-users/browse_thread/thread/efbd808325df607a/c73adb34f9b63cf7?hl=en&q=whatwg#c73adb34f9b63cf7 * Multiuser appcaches. If the application code (HTML, JS, CSS) is all the same for two users, then appcache works for multiple users by just having the data for the users separate from the logic. This is the expected model for most apps. For example, your typical blog has just one set of CSS for all users. For systems where the user affects what HTML, JS, and CSS is served back, the spec as written pretty much requires that there be one app per user, and one generic "login" app that then redirects to one of those other apps - and where each app has a different base URL, separate manifest, etc. An alternative that we could explore in a future version is to have the manifest include a manifest name, and then have script that allows you to "activate" a particular manifest name for a given appcache. So each appcache group would be futher subdivided into named subgroups, and for a given manifest URL with such a group of subgroups, one subgroup would be the default one at a time. The inactive ones would just lie dormant, but and the active ones would act like now, but there'd be a scripted way to change the default (and maybe query what available variants exist for the current appcache), so that you could log back in as someone else by just making the script pick the other user's variant, and then reloading. * Add and remove specific additional files from the cache (e.g. precaching new master entries). --> <h4 id=introduction-6><span class=secno>6.6.1 </span>Introduction</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 title="">clock.html</code>", a CSS style sheet "<code title="">clock.css</code>", and a JavaScript script "<code title="">clock.js</code>".</p> <p>Before adding the manifest, these three files might look like this:</p> <pre><!-- clock.html --> <!DOCTYPE HTML> <html> <head> <title>Clock</title> <script src="clock.js"></script> <link rel="stylesheet" href="clock.css"> </head> <body> <p>The time is: <output id="clock"></output></p> </body> </html></pre> <pre>/* clock.css */ output { font: 2em sans-serif; }</pre> <pre>/* clock.js */ setTimeout(function () { document.getElementById('clock').value = new Date(); }, 1000);</pre> <p>If the user tries to open the "<code title="">clock.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 title="">clock.appcache</code>":</p> <pre>CACHE MANIFEST clock.html clock.css clock.js</pre> <p>With a small change to the HTML file, the manifest (served as <code><a href=#text/cache-manifest>text/cache-manifest</a></code>) is linked to the application:</p> <pre><!-- clock.html --> <!DOCTYPE HTML> <html manifest="clock.appcache"> <head> <title>Clock</title> <script src="clock.js"></script> <link rel="stylesheet" href="clock.css"> </head> <body> <p>The time is: <output id="clock"></output></p> </body> </html></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 title="">https:</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> <!--(doesn't currently function) <p><a href="http://www.whatwg.org/demos/offline/clock/clock2.html">View this example online</a>.</p> --> <h5 id=appcacheevents><span class=secno>6.6.1.1 </span>Event summary</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><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 title=event-appcache-checking><code>checking</code></dfn> <td> <code><a href=#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 title=event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code>, <code title=event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code>, <code title=event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code>, <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> <tr><td> <dfn id=event-appcache-noupdate title=event-appcache-noupdate><code>noupdate</code></dfn> <td> <code><a href=#event>Event</a></code> <td> The manifest hadn't changed. <td> Last event in sequence. <tr><td> <dfn id=event-appcache-downloading title=event-appcache-downloading><code>downloading</code></dfn> <td> <code><a href=#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 title=event-appcache-progress><a href=#event-appcache-progress>progress</a></code>, <code title=event-appcache-error><a href=#event-appcache-error>error</a></code>, <code title=event-appcache-cached><a href=#event-appcache-cached>cached</a></code>, <code title=event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> <tr><td> <dfn id=event-appcache-progress title=event-appcache-progress><code>progress</code></dfn> <td> <code>ProgressEvent</code> <td> The user agent is downloading resources listed by the manifest. <td> <code title=event-appcache-progress><a href=#event-appcache-progress>progress</a></code>, <code title=event-appcache-error><a href=#event-appcache-error>error</a></code>, <code title=event-appcache-cached><a href=#event-appcache-cached>cached</a></code>, <code title=event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> <tr><td> <dfn id=event-appcache-cached title=event-appcache-cached><code>cached</code></dfn> <td> <code><a href=#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 title=event-appcache-updateready><code>updateready</code></dfn> <td> <code><a href=#event>Event</a></code> <td> The resources listed in the manifest have been newly redownloaded, and the script can use <code title=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 title=event-appcache-obsolete><code>obsolete</code></dfn> <td> <code><a href=#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 title=event-appcache-error><code>error</code></dfn> <td rowspan=4> <code><a href=#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><div class=impl> <h4 id=appcache><span class=secno>6.6.2 </span>Application caches</h4> <p>An <dfn id=application-cache>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 title=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>browsing context</a> was <a href=#navigate title=navigate>navigated</a> to that document and the document indicated that this was its cache, using the <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute.</p> <dt><dfn id=concept-appcache-manifest title=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><a href=#the-html-element>html</a></code> element's <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute. The manifest is fetched and processed during the <a href=#application-cache-download-process>application cache download process</a>. All the <a href=#concept-appcache-master title=concept-appcache-master>master entries</a> have the <a href=#same-origin title="same origin">same origin</a> as the manifest.</p> <dt><dfn id=concept-appcache-explicit title=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 title=concept-appcache-manifest>manifest</a> in an <a href=#concept-appcache-manifest-explicit title=concept-appcache-manifest-explicit>explicit section</a>.</p> <dt><dfn id=concept-appcache-fallback title=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 title=concept-appcache-manifest>manifest</a> in a <a href=#concept-appcache-manifest-fallback title=concept-appcache-manifest-fallback>fallback section</a>.</p> </dl><p><a href=#concept-appcache-explicit title=concept-appcache-explicit>Explicit entries</a> and <a href=#concept-appcache-fallback title=concept-appcache-fallback>Fallback entries</a> can be marked as <dfn id=concept-appcache-foreign title=concept-appcache-foreign>foreign</dfn>, which means that they have a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute but that it doesn't point at this cache's <a href=#concept-appcache-manifest title=concept-appcache-manifest>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> <li> <p>Zero or more <dfn id=concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespaces</dfn>, each of which is mapped to a <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entry</a>.</p> <p class=note>These are URLs used as <a href=#concept-appcache-matches-fallback title=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 title=concept-appcache-fallback>fallback entry</a> if not. Each namespace URL has the <a href=#same-origin>same origin</a> as <a href=#concept-appcache-manifest title=concept-appcache-manifest>the manifest</a>.</p> </li> <li> <p>Zero or more URLs that form the <dfn id=concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespaces</dfn>.</p> <p class=note>These are used as prefix match patterns, and declare URLs that the user agent will never load from the cache but will instead always attempt to obtain from the network.</p> </li> <li> <p>An <dfn id=concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</dfn>, which is either <i title="">open</i> or <i title="">blocking</i>.</p> <p class=note>The <i title="">open</i> state indicates that any URL not listed as cached is to be implicitly treated as being in the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespaces</a>; the <i title="">blocking</i> state indicates that URLs not listed explicitly in the manifest are to be treated as unavailable.</p> </li> </ul><p>Each <a href=#application-cache>application cache</a> has a <dfn id=concept-appcache-completeness title=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 title="application cache">application caches</a>, identified by the <a href=#absolute-url>absolute URL</a> of a resource <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a> which is used to populate the caches in the group.</p> <p>An <a href=#application-cache>application cache</a> is <dfn id=concept-appcache-newer title=concept-appcache-newer>newer</dfn> than another if it was created after the other (in other words, <a href=#application-cache title="application cache">application caches</a> in an <a href=#application-cache-group>application cache group</a> have a chronological order).</p> <p>Only the newest <a href=#application-cache>application cache</a> in an <a href=#application-cache-group>application cache group</a> can have its <a href=#concept-appcache-completeness title=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>application cache group</a> has an <dfn id=concept-appcache-status title=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>application cache</a> that is the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> in its <a href=#application-cache-group title="application cache group">group</a> to be <i>complete</i>.</p> <p>Each <a href=#application-cache-group>application cache group</a> has a <dfn id=concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</dfn>. Each entry in this list consists of a resource and a corresponding <code><a href=#document>Document</a></code> object. It is used during the <a href=#application-cache-download-process>application cache download process</a> to ensure that new master entries are cached even if the <a href=#application-cache-download-process>application cache download process</a> was already running for their <a href=#application-cache-group>application cache group</a> when they were loaded.</p> <p>An <a href=#application-cache-group>application cache group</a> can be marked as <dfn id=concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</dfn>, meaning that it must be ignored when looking at what <a href=#application-cache-group title="application cache group">application cache groups</a> exist.</p> <hr><p>A <dfn id=cache-host>cache host</dfn> is a <code><a href=#document>Document</a></code> or a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object. A <a href=#cache-host>cache host</a> can be associated with an <a href=#application-cache>application cache</a>. </p> <p>A <code><a href=#document>Document</a></code> initially is not associated with an <a href=#application-cache>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 title=navigate>navigation</a> sections cause <a href=#concept-appcache-init title=concept-appcache-init>cache selection</a> to occur.</p> <p>A <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> can be associated with an <a href=#application-cache>application cache</a> when it is created. </p> <p>Each <a href=#cache-host>cache host</a> has an associated <code><a href=#applicationcache>ApplicationCache</a></code> object.</p> <hr><p>Multiple <a href=#application-cache title="application cache">application caches</a> in different <a href=#application-cache-group title="application cache group">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 title=concept-appcache-selection>select an application cache</dfn> from a list of <a href=#relevant-application-cache title="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 title=concept-appcache-matches-fallback>matches a fallback namespace</dfn> if there exists a <a href=#relevant-application-cache>relevant application cache</a> whose <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a>'s URL has the <a href=#same-origin>same origin</a> as the URL in question, and that has a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> that is a <a href=#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 title="">http://example.com/app1/manifest</code> declares that <code title="">http://example.com/resources/images</code> is a fallback namespace, and the user navigates to <code title="">HTTP://EXAMPLE.COM:80/resources/images/cat.png</code>, then the user agent will decide that the application cache identified by <code title="">http://example.com/app1/manifest</code> contains a namespace with a match for that URL.</p> <!-- "resolve a url" canonicalises the case for the scheme and host and removes the port if it is the default --> </div> </div> <h4 id=manifests><span class=secno>6.6.3 </span>The cache manifest syntax</h4> <h5 id=some-sample-manifests><span class=secno>6.6.3.1 </span>Some sample manifests</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 whitelists 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 whitelist -- 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 http://img.example.com/logo.png http://img.example.com/check.png http://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-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a> is <i title="">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>6.6.3.2 </span>Writing cache manifests</h5> <p>Manifests must be served using the <code><a href=#text/cache-manifest>text/cache-manifest</a></code> <a href=#mime-type>MIME type</a>. All resources served using the <code><a href=#text/cache-manifest>text/cache-manifest</a></code> <a href=#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=#refsRFC3629>[RFC3629]</a></p> <p class=note>This is a <a href=#willful-violation>willful violation</a> of RFC 2046, which requires all <code title="">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 must 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 fragment identifier.</p> <dt>A section header <dd> <p>Section headers change the current section. There are three possible section headers: <dl><dt><code>CACHE:</code> <dd>Switches to the <dfn id=concept-appcache-manifest-explicit title=concept-appcache-manifest-explicit>explicit section</dfn>. <dt><code>FALLBACK:</code> <dd>Switches to the <dfn id=concept-appcache-manifest-fallback title=concept-appcache-manifest-fallback>fallback section</dfn>. <dt><code>NETWORK:</code> <dd>Switches to the <dfn id=concept-appcache-manifest-network title=concept-appcache-manifest-network>online whitelist 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 title=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 title=concept-appcache-manifest-explicit>explicit section</a>, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters, a <a href=#valid-url>valid URL</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 title=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 href=#valid-url>valid URL</a> identifying a resource other than the manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters, another <a href=#valid-url>valid URL</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 title=concept-appcache-manifest-network>online whitelist 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 (*) <!-- concept-appcache-onlinewhitelist-wildcard --> or a <a href=#valid-url>valid URL</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 class="note">The URLs in data lines can't be empty strings, since those would be relative URLs to the manifest itself. Such lines would be confused with blank or invalid lines, anyway.</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 title=concept-appcache-fallback-ns>fallback namespaces</a>, and those namespaces themselves, must be given in <a href=#concept-appcache-manifest-fallback title=concept-appcache-manifest-fallback>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 title=concept-appcache-manifest-explicit>explicit sections</a>.</p> <p><a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>Fallback namespaces</a> and <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entries</a> must have the <a href=#same-origin>same origin</a> as the manifest itself.</p> <p>A <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>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-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> must all be specified in <a href=#concept-appcache-manifest-network title=concept-appcache-manifest-network>online whitelist 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 whitelisted in this way, a U+002A ASTERISK character (*) may be specified as one of the URLs. <!-- concept-appcache-onlinewhitelist-wildcard --></p> <p>Authors should not include namespaces in the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> for which another namespace in the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> is a <a href=#prefix-match>prefix match</a>.</p> <p>Relative URLs must be given relative to the manifest's own URL. All URLs in the manifest must have the same <a href=#url-scheme title=url-scheme><scheme></a> as the manifest itself (either explicitly or implicitly, through the use of relative URLs).</p> <p>URLs in manifests must not have fragment identifiers (i.e. the U+0023 NUMBER SIGN character isn't allowed in URLs in manifests).</p> <p><a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>Fallback namespaces</a> and namespaces in the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> are matched by <a href=#prefix-match>prefix match</a>.</p> <div class=impl> <h5 id=parsing-cache-manifests><span class=secno>6.6.3.3 </span>Parsing cache manifests</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>The user agent must decode the byte stream corresponding with the manifest to be parsed <a href=#decoded-as-utf-8,-with-error-handling title="decoded as UTF-8, with error handling">as UTF-8, with error handling</a>. <!--All U+0000 NULL characters must be replaced by U+FFFD REPLACEMENT CHARACTERs. (this isn't black-box testable since neither U+0000 nor U+FFFD are valid anywhere in the syntax and thus both will be treated the same anyway)--></li> <li><p>Let <var title="">base URL</var> be the <a href=#absolute-url>absolute URL</a> representing the manifest.</li> <li><p>Let <var title="">explicit URLs</var> be an initially empty list of <a href=#absolute-url title="absolute URL">absolute URLs</a> for <a href=#concept-appcache-explicit title=concept-appcache-explicit>explicit entries</a>.</li> <li><p>Let <var title="">fallback URLs</var> be an initially empty mapping of <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespaces</a> to <a href=#absolute-url title="absolute URL">absolute URLs</a> for <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entries</a>.</li> <li><p>Let <var title="">online whitelist namespaces</var> be an initially empty list of <a href=#absolute-url title="absolute URL">absolute URLs</a> for an <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a>.</li> <li><p>Let <var title="">online whitelist wildcard flag</var> be <i title="">blocking</i>. <!-- concept-appcache-onlinewhitelist-wildcard --></li> <li><p>Let <var title="">input</var> be the decoded text of the manifest's byte stream.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the first character.</li> <li><p>If <var title="">position</var> is pointing at a U+FEFF BYTE ORDER MARK (BOM) character, then advance <var title="">position</var> to the next character.</li> <li><p>If the characters starting from <var title="">position</var> are "CACHE", followed by a U+0020 SPACE character, followed by "MANIFEST", then advance <var title="">position</var> to the next character after those. Otherwise, this isn't a cache manifest; abort this algorithm with a failure while checking for the magic signature.</li> <li><p>If the character at <var title="">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; abort this algorithm with a failure while checking for the magic signature.</li> <li><p>This is a cache manifest. The algorithm cannot fail beyond this point (though bogus lines can get ignored).</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters, and ignore those characters. (Extra text on the first line, after the signature, is ignored.)</li> <li><p>Let <var title="">mode</var> be "explicit".</li> <li><p><i>Start of line</i>: If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the last step. Otherwise, <a href=#collect-a-sequence-of-characters>collect a sequence of characters</a> that are U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, or U+0009 CHARACTER TABULATION (tab) characters.</li> <!-- strips leading spaces, ignores space-only lines, ignores blank lines --> <li><p>Now, <a href=#collect-a-sequence-of-characters>collect a sequence of characters</a> that are <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters, and let the result be <var title="">line</var>.</li> <li><p>Drop any trailing U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters at the end of <var title="">line</var>.</li> <li><p>If <var title="">line</var> is the empty string, then jump back to the step labeled "start of line".</li> <li><p>If the first character in <var title="">line</var> is a U+0023 NUMBER SIGN character (#), then jump back to the step labeled "start of line".</li> <li><p>If <var title="">line</var> equals "CACHE:" (the word "CACHE" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "explicit" and jump back to the step labeled "start of line".</li> <li><p>If <var title="">line</var> equals "FALLBACK:" (the word "FALLBACK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "fallback" and jump back to the step labeled "start of line".</li> <li><p>If <var title="">line</var> equals "NETWORK:" (the word "NETWORK" followed by a U+003A COLON character (:)), then set <var title="">mode</var> to "online whitelist" and jump back to the step labeled "start of line".</li> <li><p>If <var title="">line</var> ends with a U+003A COLON character (:), then set <var title="">mode</var> to "unknown" and jump back to the step labeled "start of line".</li> <li><p>This is either a data line or it is syntactically incorrect.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">line</var>, initially pointing at the start of the string.</li> <li><p>Let <var title="">tokens</var> be a list of strings, initially empty.</li> <li> <p>While <var title="">position</var> doesn't point past the end of <var title="">line</var>:</p> <ol><li><p>Let <var title="">current token</var> be an empty string.</li> <li><p>While <var title="">position</var> doesn't point past the end of <var title="">line</var> and the character at <var title="">position</var> is neither a U+0020 SPACE nor a U+0009 CHARACTER TABULATION (tab) character, add the character at <var title="">position</var> to <var title="">current token</var> and advance <var title="">position</var> to the next character in <var title="">input</var>.</li> <li><p>Add <var title="">current token</var> to the <var title="">tokens</var> list.</li> <li><p>While <var title="">position</var> doesn't point past the end of <var title="">line</var> and the character at <var title="">position</var> is either a U+0020 SPACE or a U+0009 CHARACTER TABULATION (tab) character, advance <var title="">position</var> to the next character in <var title="">input</var>.</li> </ol></li> <li> <p>Process <var title="">tokens</var> as follows:</p> <dl class=switch><dt>If <var title="">mode</var> is "explicit"</dt> <dd> <p><a href=#resolve-a-url title="resolve a url">Resolve</a> the first item in <var title="">tokens</var>, relative to <var title="">base URL</var>; ignore the rest.</p> <p>If this fails, then jump back to the step labeled "start of line".</p> <p>If the resulting <a href=#absolute-url>absolute URL</a> has a different <a href=#url-scheme title=url-scheme><scheme></a> component than the manifest's URL (compared in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner), then jump back to the step labeled "start of line".</p> <p>Drop the <a href=#url-fragment title=url-fragment><fragment></a> component of the resulting <a href=#absolute-url>absolute URL</a>, if it has one.</p> <p>Add the resulting <a href=#absolute-url>absolute URL</a> to the <var title="">explicit URLs</var>.</p> </dd> <dt>If <var title="">mode</var> is "fallback"</dt> <dd> <p>Let <var title="">part one</var> be the first token in <var title="">tokens</var>, and let <var title="">part two</var> be the second token in <var title="">tokens</var>.</p> <p><a href=#resolve-a-url title="resolve a url">Resolve</a> <var title="">part one</var> and <var title="">part two</var>, relative to <var title="">base URL</var>.</p> <p>If either fails, then jump back to the step labeled "start of line".</p> <p>If the <a href=#absolute-url>absolute URL</a> corresponding to either <var title="">part one</var> or <var title="">part two</var> does not have the <a href=#same-origin>same origin</a> as the manifest's URL, then jump back to the step labeled "start of line".</p> <!-- SECURITY --> <p>Drop any <a href=#url-fragment title=url-fragment><fragment></a> components of the resulting <a href=#absolute-url title="absolute URL">absolute URLs</a>.</p> <p>If the <a href=#absolute-url>absolute URL</a> corresponding to <var title="">part one</var> is already in the <var title="">fallback URLs</var> mapping as a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a>, then jump back to the step labeled "start of line".</p> <p>Otherwise, add the <a href=#absolute-url>absolute URL</a> corresponding to <var title="">part one</var> to the <var title="">fallback URLs</var> mapping as a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a>, mapped to the <a href=#absolute-url>absolute URL</a> corresponding to <var title="">part two</var> as the <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entry</a>.</p> </dd> <dt>If <var title="">mode</var> is "online whitelist"</dt> <dd> <p>If the first item in <var title="">tokens</var> is a U+002A ASTERISK character (*), then set <var title="">online whitelist wildcard flag</var> to <i title="">open</i> and jump back to the step labeled "start of line".</p> <p>Otherwise, <a href=#resolve-a-url title="resolve a url">resolve</a> the first item in <var title="">tokens</var>, relative to <var title="">base URL</var>; ignore the rest.</p> <p>If this fails, then jump back to the step labeled "start of line".</p> <p>If the resulting <a href=#absolute-url>absolute URL</a> has a different <a href=#url-scheme title=url-scheme><scheme></a> component than the manifest's URL (compared in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner), then jump back to the step labeled "start of line".</p> <p>Drop the <a href=#url-fragment title=url-fragment><fragment></a> component of the resulting <a href=#absolute-url>absolute URL</a>, if it has one.</p> <p>Add the resulting <a href=#absolute-url>absolute URL</a> to the <var title="">online whitelist namespaces</var>.</p> </dd> <dt>If <var title="">mode</var> is "unknown"</dt> <dd> <p>Do nothing. The line is ignored.</p> </dd> </dl></li> <li><p>Jump back to the step labeled "start of line". (That step jumps to the next, and last, step when the end of the file is reached.)</li> <li><p>Return the <var title="">explicit URLs</var> list, the <var title="">fallback URLs</var> mapping, the <var title="">online whitelist namespaces</var>, and the <var title="">online whitelist wildcard flag</var>.</li> </ol><div class=note> <p>The resource that declares the manifest (with the <code title=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-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespace</a>.</p> <p>If a resource is listed in the <a href=#concept-appcache-manifest-explicit title=concept-appcache-manifest-explicit>explicit section</a> or as a <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entry</a> in the <a href=#concept-appcache-manifest-fallback title=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 title=concept-appcache-fallback-ns>fallback namespaces</a> or <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespaces</a>.</p> <p>When a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> and an <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespace</a> overlap, the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespace</a> has priority.</p> <p>The <a href=#concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a> is applied last, only for URLs that match neither the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist namespace</a> nor the <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> and that are not listed in the <a href=#concept-appcache-manifest-explicit title=concept-appcache-manifest-explicit>explicit section</a>.</p> </div> <h4 id=downloading-or-updating-an-application-cache><span class=secno>6.6.4 </span>Downloading or updating an application cache</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 href=#absolute-url>absolute URL</a> purported to identify a <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a>, or for an <a href=#application-cache-group>application cache group</a>, potentially given a particular <a href=#cache-host>cache host</a>, and potentially given a <a href=#concept-appcache-master title=concept-appcache-master>master</a> resource, the user agent must run the steps below. These steps are always run asynchronously, in parallel with the <a href=#event-loop>event loop</a> <a href=#concept-task title=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>application cache download process</a> allow the script to override the display of such an interface. 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 class=note>These events are delayed until after the <code title=event-load>load</code> event has fired.</p> <p>The <a href=#application-cache-download-process>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>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> <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 href=#absolute-url>absolute URL</a> purported to identify a <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a></dt> <dd> <p>Let <var title="">manifest URL</var> be that <a href=#absolute-url>absolute URL</a>.</p> <p>If there is no <a href=#application-cache-group>application cache group</a> identified by <var title="">manifest URL</var>, then create a new <a href=#application-cache-group>application cache group</a> identified by <var title="">manifest URL</var>. Initially, it has no <a href=#application-cache title="application cache">application caches</a>. One will be created later in this algorithm.</p> </dd> <dt>If these steps were invoked with an <a href=#application-cache-group>application cache group</a></dt> <dd> <p>Let <var title="">manifest URL</var> be the <a href=#absolute-url>absolute URL</a> of the <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a> used to identify the <a href=#application-cache-group>application cache group</a> to be updated.</p> <p>If that <a href=#application-cache-group>application cache group</a> is <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>, then abort this instance of the <a href=#application-cache-download-process>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> </dd> </dl></li> <li><p>Let <var title="">cache group</var> be the <a href=#application-cache-group>application cache group</a> identified by <var title="">manifest URL</var>.</li> <li><p>If these steps were invoked with a <a href=#concept-appcache-master title=concept-appcache-master>master</a> resource, then add the resource, along with the resource's <code><a href=#document>Document</a></code>, to <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>.</li> <li><p>If these steps were invoked with a <a href=#cache-host>cache host</a>, and the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> is <i>checking</i> or <i>downloading</i>, then <a href=#queue-a-post-load-task>queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-appcache-checking><a href=#event-appcache-checking>checking</a></code> that is cancelable at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host>cache host</a>. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent is checking to see if it can download the application.</li> <li><p>If these steps were invoked with a <a href=#cache-host>cache host</a>, and the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> is <i>downloading</i>, then also <a href=#queue-a-post-load-task>queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code> that is cancelable at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host>cache host</a>. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user the application is being downloaded.</li> <li><p>If the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of the <var title="">cache group</var> is either <i>checking</i> or <i>downloading</i>, then abort this instance of the <a href=#application-cache-download-process>application cache download process</a>, as an update is already in progress.</li> <li><p>Set the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> to <i>checking</i>.</p> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, <a href=#queue-a-post-load-task>queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-checking><a href=#event-appcache-checking>checking</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent is checking for the availability of updates.</li> </ol><p class=note>The remainder of the steps run asynchronously.</p> <p>If <var title="">cache group</var> already has an <a href=#application-cache>application cache</a> in it, then this is an <dfn id=concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</dfn>. Otherwise, this is a <dfn id=concept-appcache-cache title=concept-appcache-cache>cache attempt</dfn>.</p> </li> <li><p>If this is a <a href=#concept-appcache-cache title=concept-appcache-cache>cache attempt</a>, then this algorithm was invoked with a <a href=#cache-host>cache host</a>; <a href=#queue-a-post-load-task>queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-appcache-checking><a href=#event-appcache-checking>checking</a></code> that is cancelable at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host>cache host</a>. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent is checking for the availability of updates.</li> <li> <p><i>Fetching the manifest</i>: <a href=#fetch>Fetch</a> the resource from <var title="">manifest URL</var> with the <i>synchronous flag</i> set, and let <var title="">manifest</var> be that resource. HTTP caching semantics should be honored for this request.</p> <!-- http-origin privacy sensitive, though it doesn't matter, since this can never be cross-origin --> <p>If the resource is labeled with the <a href=#mime-type>MIME type</a> <code><a href=#text/cache-manifest>text/cache-manifest</a></code>, either with no parameters or with a single parameter with the name "<code title="">charset</code>" whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">utf-8</code>", parse <var title="">manifest</var> according to the <a href=#parse-a-manifest title="parse a manifest">rules for parsing manifests</a>, obtaining a list of <a href=#concept-appcache-explicit title=concept-appcache-explicit>explicit entries</a>, <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entries</a> and the <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespaces</a> that map to them, entries for the <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a>, and a value for the <a href=#concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a>.</p> </li> <li> <p>If <i>fetching the manifest</i> fails due to a 404 or 410 response <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, then run these substeps:</p> <ol><li><p>Mark <var title="">cache group</var> as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>. This <var title="">cache group</var> no longer exists for any purpose other than the processing of <code><a href=#document>Document</a></code> objects already associated with an <a href=#application-cache>application cache</a> in the <var title="">cache group</var>.</li> <li><p>Let <var title="">task list</var> be an empty list of <a href=#concept-task title=concept-task>tasks</a>.</p> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code> that is cancelable at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the application is no longer available for offline use.</li> <li><p>For each entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> (not <code title=event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code>!) at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a> the <code><a href=#document>Document</a></code> for this entry, if there still is one, and append it to <var title="">task list</var>. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent failed to save the application for offline use.</li> <li><p>If <var title="">cache group</var> has an <a href=#application-cache>application cache</a> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>incomplete</i>, then discard that <a href=#application-cache>application cache</a>.</p> <li><p>If appropriate, remove any user interface indicating that an update for this cache is in progress.</li> <li><p>Let the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> be <i>idle</i>.</li> <li><p>For each <a href=#concept-task title=concept-task>task</a> in <var title="">task list</var>, <a href=#queue-a-post-load-task title="queue a post-load task">queue that task as a post-load task</a>.</li> <li><p>Abort the <a href=#application-cache-download-process>application cache download process</a>.</li> </ol></li> <li> <p>Otherwise, if <i>fetching the manifest</i> fails in some other way (e.g. the server returns another 4xx or 5xx response <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, 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, or if the resource is labeled with a <a href=#mime-type>MIME type</a> other than <code><a href=#text/cache-manifest>text/cache-manifest</a></code> or has parameters that do not match the conditions listed earlier, then run the <a href=#cache-failure-steps>cache failure steps</a>. <a href=#refsHTTP>[HTTP]</a></p> </li> <li> <p>If this is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</a> and the newly downloaded <var title="">manifest</var> is byte-for-byte identical to the manifest found in the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in <var title="">cache group</var>, or the server reported it as "304 Not Modified" <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, then run these substeps:</p> <ol><li><p>Let <var title="">cache</var> be the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in <var title="">cache group</var>.</li> <li><p>Let <var title="">task list</var> be an empty list of <a href=#concept-task title=concept-task>tasks</a>.</p> <li> <p>For each entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>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 <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, 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 title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a> the <code><a href=#document>Document</a></code> for this entry, if there still is one, and append it to <var title="">task list</var>. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent failed to save the application for offline use.</p> <p>Otherwise, associate the <code><a href=#document>Document</a></code> for this entry with <var title="">cache</var>; store the resource for this entry in <var title="">cache</var>, if it isn't already there, and categorize its entry as a <a href=#concept-appcache-master title=concept-appcache-master>master entry</a>. If the resource's <a href=#url>URL</a> has a <a href=#url-fragment title=url-fragment><fragment></a> component, it must be removed from the entry in <var title="">cache</var> (application caches never include fragment identifiers).</p> </li> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the application is up to date.</li> <li><p>Empty <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>.</li> <li><p>If appropriate, remove any user interface indicating that an update for this cache is in progress.</li> <li><p>Let the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> be <i>idle</i>.</li> <li><p>For each <a href=#concept-task title=concept-task>task</a> in <var title="">task list</var>, <a href=#queue-a-post-load-task title="queue a post-load task">queue that task as a post-load task</a>.</li> <li><p>Abort the <a href=#application-cache-download-process>application cache download process</a>.</li> </ol></li> <li><p>Let <var title="">new cache</var> be a newly created <a href=#application-cache>application cache</a> in <var title="">cache group</var>. Set its <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> to <i>incomplete</i>.</li> <li><p>For each entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>, associate the <code><a href=#document>Document</a></code> for this entry with <var title="">new cache</var>.</li> <li><p>Set the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> to <i>downloading</i>.</li> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, <a href=#queue-a-post-load-task>queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that a new version is being downloaded.</li> <li><p>Let <var title="">file list</var> be an empty list of URLs with flags.</li> <li><p>Add all the URLs in the list of <a href=#concept-appcache-explicit title=concept-appcache-explicit>explicit entries</a> obtained by parsing <var title="">manifest</var> to <var title="">file list</var>, each flagged with "explicit entry".</li> <li><p>Add all the URLs in the list of <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entries</a> obtained by parsing <var title="">manifest</var> to <var title="">file list</var>, each flagged with "fallback entry".</li> <li><p>If this is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</a>, then add all the URLs of <a href=#concept-appcache-master title=concept-appcache-master>master entries</a> in the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in <var title="">cache group</var> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>complete</i> to <var title="">file list</var>, each flagged with "master entry".</li> <li><p>If any URL is in <var title="">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> <li> <p>For each URL in <var title="">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><a href=#applicationcache>ApplicationCache</a></code> object's <code title=dom-appcache-abort><a href=#dom-appcache-abort>abort()</a></code> method <a href=#send-a-signal title="send a signal">sends a signal</a> to this instance of the <a href=#application-cache-download-process>application cache download process</a> algorithm, then run the <a href=#cache-failure-steps>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, implementors are urged to use an approach that expires lesser-used resources first.</p> </li> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, <a href=#queue-a-post-load-task>queue a post-load task</a> to fire an event with the name <code title=event-appcache-progress><a href=#event-appcache-progress>progress</a></code>, which does not bubble, which is cancelable, and which uses the <code>ProgressEvent</code> interface, at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>. The <code title=dom-ProgressEvents-lengthComputable>lengthComputable</code> attribute must be set to true, the <code title=dom-ProgressEvents-total>total</code> attribute must be set to the number of files in <var title="">file list</var>, and the <code title=dom-ProgressEvents-loaded>loaded</code> attribute must be set to the number of files in <var title="">file list</var> that have been either downloaded or skipped so far. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that a file is being downloaded in preparation for updating the application. <a href=#refsPROGRESS>[PROGRESS]</a></li> <li> <p><a href=#fetch>Fetch</a> the resource, from the <a href=#origin>origin</a> of the <a href=#url>URL</a> <var title="">manifest URL</var>, with the <i>synchronous flag</i> set and the <i>manual redirect flag</i> set. If this is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</a>, then use the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in <var title="">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.</p> <!-- not http-origin privacy sensitive --> <p class=note>If the resource in question is already being downloaded for other reasons then the existing download process can sometimes be used for the purposes of this step, as defined by the <a href=#fetch title=fetch>fetching</a> algorithm.</p> <p class=example>An example of a resource that might already be being downloaded is a large image on a Web page that is being seen for the first time. The image would get downloaded to satisfy the <code><a href=#the-img-element>img</a></code> element on the page, as well as being listed in the cache manifest. According to the rules for <a href=#fetch title=fetch>fetching</a> that image only need be downloaded once, and it can be used both for the cache and for the rendered Web page.</p> </li> <li> <p>If the previous step fails (e.g. the server returns a 4xx or 5xx response <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, 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"</dt> <dd> <p>If these steps are being run in parallel for any other URLs in <var title="">file list</var>, then abort these steps for those other URLs. Run the <a href=#cache-failure-steps>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> </dd> <dt>If the error was a 404 or 410 HTTP response <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a></dt> <dt>If the resource was labeled with the "no-store" cache directive</dt> <dd> <p>Skip this resource. It is dropped from the cache.</p> </dd> <dt>Otherwise</dt> <dd> <p>Copy the resource and its metadata from the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in <var title="">cache group</var> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>complete</i>, and act as if that was the fetched resource, ignoring the resource obtained from the network.</p> </dd> </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>application cache download process</a>.</p> </li> <li> <p>Otherwise, the fetching succeeded. Store the resource in the <var title="">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>cache failure steps</a>.</p> </li> <li><p>If the URL being processed was flagged as an "explicit entry" in <var title="">file list</var>, then categorize the entry as an <a href=#concept-appcache-explicit title=concept-appcache-explicit>explicit entry</a>.</li> <li><p>If the URL being processed was flagged as a "fallback entry" in <var title="">file list</var>, then categorize the entry as a <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entry</a>.</li> <li><p>If the URL being processed was flagged as an "master entry" in <var title="">file list</var>, then categorize the entry as a <a href=#concept-appcache-master title=concept-appcache-master>master entry</a>.</li> <li><p>As an optimization, if the resource is an HTML or XML file whose root element is an <code><a href=#the-html-element>html</a></code> element with a <code title=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 title=concept-appcache-foreign>foreign</a>.</p> </ol></li> <li><p>For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, <a href=#queue-a-post-load-task>queue a post-load task</a> to fire an event with the name <code title=event-appcache-progress><a href=#event-appcache-progress>progress</a></code>, which does not bubble, which is cancelable, and which uses the <code>ProgressEvent</code> interface, at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>. The <code title=dom-ProgressEvents-lengthComputable>lengthComputable</code> attribute must be set to true, the <code title=dom-ProgressEvents-total>total</code> and the <code title=dom-ProgressEvents-loaded>loaded</code> attributes must be set to the number of files in <var title="">file list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that all the files have been downloaded. <a href=#refsPROGRESS>[PROGRESS]</a></li> <li><p>Store the list of <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespaces</a>, and the URLs of the <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback entries</a> that they map to, in <var title="">new cache</var>.</li> <li><p>Store the URLs that form the new <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> in <var title="">new cache</var>.</li> <li><p>Store the value of the new <a href=#concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a> in <var title="">new cache</var>.</li> <li> <p>For each entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>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 <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, 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><a href=#document>Document</a></code> for this entry from <var title="">new cache</var>.</li> <li><p><a href=#queue-a-post-load-task>Queue a post-load task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <code><a href=#document>Document</a></code> for this entry, if there still is one. The default action of this event must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent failed to save the application for offline use.</p> <li> <p>If this is a <a href=#concept-appcache-cache title=concept-appcache-cache>cache attempt</a> and this entry is the last entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>, then run these further substeps:</p> <ol><li><p>Discard <var title="">cache group</var> and its only <a href=#application-cache>application cache</a>, <var title="">new cache</var>.</p> <li><p>If appropriate, remove any user interface indicating that an update for this cache is in progress.</li> <li><p>Abort the <a href=#application-cache-download-process>application cache download process</a>.</li> </ol></li> <li><p>Otherwise, remove this entry from <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>.</li> </ol><p>Otherwise, store the resource for this entry in <var title="">new cache</var>, if it isn't already there, and categorize its entry as a <a href=#concept-appcache-master title=concept-appcache-master>master entry</a>.</p> </li> <li> <p><a href=#fetch>Fetch</a> the resource from <var title="">manifest URL</var> again, with the <i>synchronous flag</i> set, and let <var title="">second manifest</var> be that resource. HTTP caching semantics should again be honored for this request.</p> <!-- http-origin privacy sensitive, though it doesn't matter, since this can never be cross-origin --> <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> <li> <p>If the previous step failed for any reason, or if the fetching attempt involved a redirect, or if <var title="">second manifest</var> and <var title="">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>cache failure steps</a>.</p> </li> <li> <p>Otherwise, store <var title="">manifest</var> in <var title="">new cache</var>, if it's not there already, and categorize its entry as <a href=#concept-appcache-manifest title=concept-appcache-manifest>the manifest</a>.</p> </li> <li><p>Set the <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> of <var title="">new cache</var> to <i>complete</i>.</li> <li><p>Let <var title="">task list</var> be an empty list of <a href=#concept-task title=concept-task>tasks</a>.</p> <li> <p>If this is a <a href=#concept-appcache-cache title=concept-appcache-cache>cache attempt</a>, then for each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-cached><a href=#event-appcache-cached>cached</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the application has been cached and that they can now use it offline.</p> <p>Otherwise, it is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</a>. For each <a href=#cache-host>cache host</a> associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of 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.</p> </li> <li><p>If appropriate, remove any user interface indicating that an update for this cache is in progress.</li> <li><p>Set the <a href=#concept-appcache-status title=concept-appcache-status>update status</a> of <var title="">cache group</var> to <i>idle</i>.</li> <li><p>For each <a href=#concept-task title=concept-task>task</a> in <var title="">task list</var>, <a href=#queue-a-post-load-task title="queue a post-load task">queue that task as a post-load task</a>.</li> </ol><p>The <dfn id=cache-failure-steps>cache failure steps</dfn> are as follows:</p> <ol><li><p>Let <var title="">task list</var> be an empty list of <a href=#concept-task title=concept-task>tasks</a>.</p> <li> <p>For each entry in <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>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><a href=#document>Document</a></code> for this entry from its <a href=#application-cache>application cache</a>, if it has one.</li> <li><p>Create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <code><a href=#document>Document</a></code> for this entry, if there still is one, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent failed to save the application for offline use.</p> </ol></li> <li><p>For each <a href=#cache-host>cache host</a> still associated with an <a href=#application-cache>application cache</a> in <var title="">cache group</var>, create a <a href=#concept-task title=concept-task>task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that is cancelable named <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> at the <code><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host>cache host</a>, and append it to <var title="">task list</var>. The default action of these events must be, if the user agent <a href=#shows-caching-progress>shows caching progress</a>, the display of some sort of user interface indicating to the user that the user agent failed to save the application for offline use.</li> <li><p>Empty <var title="">cache group</var>'s <a href=#concept-appcache-pending-masters title=concept-appcache-pending-masters>list of pending master entries</a>.</li> <li><p>If <var title="">cache group</var> has an <a href=#application-cache>application cache</a> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>incomplete</i>, then discard that <a href=#application-cache>application cache</a>.</p> <li><p>If appropriate, remove any user interface indicating that an update for this cache is in progress.</li> <li><p>Let the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of <var title="">cache group</var> be <i>idle</i>.</li> <li><p>If this was a <a href=#concept-appcache-cache title=concept-appcache-cache>cache attempt</a>, discard <var title="">cache group</var> altogether.</p> <li><p>For each <a href=#concept-task title=concept-task>task</a> in <var title="">task list</var>, <a href=#queue-a-post-load-task title="queue a post-load task">queue that task as a post-load task</a>.</li> <li><p>Abort the <a href=#application-cache-download-process>application cache download process</a>.</li> </ol><p>Attempts to <a href=#fetch>fetch</a> resources as part of the <a href=#application-cache-download-process>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>application cache download process</a>, in the background, for any <a href=#application-cache>application cache</a>, at any time (with no <a href=#cache-host>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><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 title=event-load>load</code> event has fired. When the <code><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 title="">task</var>, where <var title="">task</var> is a <a href=#concept-task title=concept-task>task</a> that dispatches an event on a target <code><a href=#applicationcache>ApplicationCache</a></code> object <var title="">target</var>, the user agent must run the appropriate steps from the following list:</p> <dl><dt>If <var title="">target</var>'s <code><a href=#document>Document</a></code> is <a href=#ready-for-post-load-tasks>ready for post-load tasks</a></dt> <dd><p><a href=#queue-a-task title="queue a task">Queue</a> the task <var title="">task</var>.</dd> <dt>Otherwise</dt> <dd><p>Add <var title="">task</var> to <var title="">target</var>'s <code><a href=#document>Document</a></code>'s list of <a href=#pending-application-cache-download-process-tasks>pending application cache download process tasks</a>.</dd> </dl><p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#networking-task-source>networking task source</a>.</p> <h4 id=the-application-cache-selection-algorithm><span class=secno>6.6.5 </span>The application cache selection algorithm</h4> <p>When the <dfn id=concept-appcache-init title=concept-appcache-init>application cache selection algorithm</dfn> algorithm is invoked with a <code><a href=#document>Document</a></code> <var title="">document</var> and optionally a manifest <a href=#url>URL</a> <var title="">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 title="">manifest URL</var>, and <var title="">document</var> was loaded from an <a href=#application-cache>application cache</a>, and the URL of the <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a> of that cache's <a href=#application-cache-group>application cache group</a> is <em>not</em> the same as <var title="">manifest URL</var></dt> <dd> <p>Mark the entry for the resource from which <var title="">document</var> was taken in the <a href=#application-cache>application cache</a> from which it was loaded as <a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>.</p> <p>Restart the current navigation from the top of the <a href=#navigate title=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>update the session history with the new page</a> is only ever completed <em>after</em> this <a href=#concept-appcache-init title=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> </dd> <dt>If <var title="">document</var> was loaded from an <a href=#application-cache>application cache</a>, and that <a href=#application-cache>application cache</a> still exists (it is not now <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>)<!--[redundant], and either there is no <var title="">manifest URL</var>, or the URL of the <span title="concept-appcache-manifest">manifest</span> of the cache's <span>application cache group</span> is the same as <var title="">manifest URL</var>--></dt> <dd> <p>Associate <var title="">document</var> with the <a href=#application-cache>application cache</a> from which it was loaded. Invoke, in the background, the <a href=#application-cache-download-process>application cache download process</a> for that <a href=#application-cache>application cache</a>'s <a href=#application-cache-group>application cache group</a>, with <var title="">document</var> as the <a href=#cache-host>cache host</a>.</p> </dd> <dt>If <var title="">document</var> <!--[redundant] was not loaded from an <span>application cache</span>, but it--> was loaded using HTTP GET <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, and, there is a <var title="">manifest URL</var>, and <var title="">manifest URL</var> has the <a href=#same-origin>same origin</a> as <var title="">document</var></dt> <dd> <p>Invoke, in the background, the <a href=#application-cache-download-process>application cache download process</a> for <var title="">manifest URL</var>, with <var title="">document</var> as the <a href=#cache-host>cache host</a> and with the resource from which <var title="">document</var> was parsed as the <a href=#concept-appcache-master title=concept-appcache-master>master</a> resource.</p> </dd> <dt>Otherwise</dt> <!-- not from cache and either no <var title="">manifest URL</var>, or non-GET, or wrong-origin manifest --> <dd> <p>The <code><a href=#document>Document</a></code> is not associated with any <a href=#application-cache>application cache</a>.</p> <p>If there was a <var title="">manifest URL</var>, the user agent may report to the user that it was ignored, to aid in application development.</p> </dd> </dl><h4 id=changesToNetworkingModel><span class=secno>6.6.6 </span>Changes to the networking model</h4> <p>When a <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>complete</i>, any and all loads for resources related to that <a href=#cache-host>cache host</a> other than those for <a href=#child-browsing-context title="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 HTTP GET mechanism <a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a>, or if its <a href=#url>URL</a> has a different <a href=#url-scheme title=url-scheme><scheme></a> component than the <a href=#application-cache>application cache</a>'s <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a>, then <a href=#fetch>fetch</a> the resource normally and abort these steps.</li> <li><p>If the resource's URL is <a href=#concept-appcache-master title=concept-appcache-master>a master entry</a>, <a href=#concept-appcache-manifest title=concept-appcache-manifest>the manifest</a>, <a href=#concept-appcache-explicit title=concept-appcache-explicit>an explicit entry</a>, or <a href=#concept-appcache-fallback title=concept-appcache-fallback>a fallback entry</a> in the <a href=#application-cache>application cache</a>, then get the resource from the cache (instead of fetching it), and abort these steps.</li> <li><p>If there is an entry in the <a href=#application-cache>application cache</a>'s <a href=#concept-appcache-onlinewhitelist title=concept-appcache-onlinewhitelist>online whitelist</a> that has the <a href=#same-origin>same origin</a> as the resource's URL and that is a <a href=#prefix-match>prefix match</a> for the resource's URL, then <a href=#fetch>fetch</a> the resource normally and abort these steps.</li> <li> <p>If the resource's URL has the <a href=#same-origin>same origin</a> as the manifest's URL, and there is a <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> <var title="">f</var> in the <a href=#application-cache>application cache</a> that is a <a href=#prefix-match>prefix match</a> for the resource's URL, then:</p> <p><a href=#fetch>Fetch</a> the resource normally. If this results in a redirect to a resource with another <a href=#origin>origin</a> (indicative of a captive portal), or a 4xx or 5xx status code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>, 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 title=concept-appcache-fallback>fallback entry</a> corresponding to the <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> <var title="">f</var>. Abort these steps.</p> </li> <li><p>If the <a href=#application-cache>application cache</a>'s <a href=#concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a> is <i title="">open</i>, then <a href=#fetch>fetch</a> the resource normally and abort these steps.</li> <li><p>Fail the resource load as if there had been a generic network error.</li> </ol><p class=note>The above algorithm ensures that so long as the <a href=#concept-appcache-onlinewhitelist-wildcard title=concept-appcache-onlinewhitelist-wildcard>online whitelist wildcard flag</a> is <i title="">blocking</i>, resources that are not present in the <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a> will always fail to load (at least, after the <a href=#application-cache>application cache</a> has been primed the first time), making the testing of offline applications simpler.</p> </div> <div class=impl> <h4 id=expiring-application-caches><span class=secno>6.6.7 </span>Expiring application caches</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> </div> <div class=impl> <h4 id=disk-space><span class=secno>6.6.8 </span>Disk space</h4> <p>User agents should consider applying constraints on disk usage of <a href=#application-cache title="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 title="application cache">application caches</a>.</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 asynchronously presenting a user interface while a cache is being updated, or by having an explicit whitelist in the user agent's configuration interface.</p> </div> <h4 id=application-cache-api><span class=secno>6.6.9 </span>Application cache API</h4> <pre class=idl>interface <dfn id=applicationcache>ApplicationCache</dfn> : <a href=#eventtarget>EventTarget</a> { // <a href=#concept-appcache-status title=concept-appcache-status>update status</a> const unsigned short <a href=#dom-appcache-uncached title=dom-appcache-UNCACHED>UNCACHED</a> = 0; const unsigned short <a href=#dom-appcache-idle title=dom-appcache-IDLE>IDLE</a> = 1; const unsigned short <a href=#dom-appcache-checking title=dom-appcache-CHECKING>CHECKING</a> = 2; const unsigned short <a href=#dom-appcache-downloading title=dom-appcache-DOWNLOADING>DOWNLOADING</a> = 3; const unsigned short <a href=#dom-appcache-updateready title=dom-appcache-UPDATEREADY>UPDATEREADY</a> = 4; const unsigned short <a href=#dom-appcache-obsolete title=dom-appcache-OBSOLETE>OBSOLETE</a> = 5; readonly attribute unsigned short <a href=#dom-appcache-status title=dom-appcache-status>status</a>; // updates void <a href=#dom-appcache-update title=dom-appcache-update>update</a>(); void <a href=#dom-appcache-abort title=dom-appcache-abort>abort</a>(); void <a href=#dom-appcache-swapcache title=dom-appcache-swapCache>swapCache</a>(); // events [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onchecking title=handler-appcache-onchecking>onchecking</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onerror title=handler-appcache-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onnoupdate title=handler-appcache-onnoupdate>onnoupdate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-ondownloading title=handler-appcache-ondownloading>ondownloading</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onprogress title=handler-appcache-onprogress>onprogress</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onupdateready title=handler-appcache-onupdateready>onupdateready</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-oncached title=handler-appcache-oncached>oncached</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-appcache-onobsolete title=handler-appcache-onobsolete>onobsolete</a>; };</pre> <dl class=domintro><dt><var title="">cache</var> = <var title="">window</var> . <code title=dom-applicationCache><a href=#dom-applicationcache>applicationCache</a></code></dt> <dd> <p>(In a window.) Returns the <code><a href=#applicationcache>ApplicationCache</a></code> object that applies to the <a href=#active-document>active document</a> of that <code><a href=#window>Window</a></code>.</p> </dd> <dt><var title="">cache</var> = <var title="">self</var> . <code title=dom-applicationCache><a href=#dom-applicationcache>applicationCache</a></code></dt> <dd> <p>(In a shared worker.) Returns the <code><a href=#applicationcache>ApplicationCache</a></code> object that applies to the current shared worker. </p> </dd> <dt><var title="">cache</var> . <code title=dom-appcache-status><a href=#dom-appcache-status>status</a></code></dt> <dd> <p>Returns the current status of the application cache, as given by the constants defined below.</p> </dd> <dt><var title="">cache</var> . <code title=dom-appcache-update><a href=#dom-appcache-update>update</a></code>()</dt> <dd> <p>Invokes the <a href=#application-cache-download-process>application cache download process</a>.</p> <p>Throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception 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 title="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> </dd> <dt><var title="">cache</var> . <code title=dom-appcache-abort><a href=#dom-appcache-abort>abort</a></code>()</dt> <dd> <p>Cancels the <a href=#application-cache-download-process>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> </dd> <dt><var title="">cache</var> . <code title=dom-appcache-swapCache><a href=#dom-appcache-swapcache>swapCache</a></code>()</dt> <dd> <p>Switches to the most recent application cache, if there is a newer one. If there isn't, throws an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</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 title=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 title=dom-appcache-swapCache><a href=#dom-appcache-swapcache>swapCache()</a></code> is just to reload the entire page at a time suitable for the user, using <code title=dom-location-reload><a href=#dom-location-reload>location.reload()</a></code>.</p> </dd> </dl><div class=impl> <p>There is a one-to-one mapping from <a href=#cache-host title="cache host">cache hosts</a> to <code><a href=#applicationcache>ApplicationCache</a></code> objects. The <dfn id=dom-applicationcache title=dom-applicationCache><code>applicationCache</code></dfn> attribute on <code><a href=#window>Window</a></code> objects must return the <code><a href=#applicationcache>ApplicationCache</a></code> object associated with the <code><a href=#window>Window</a></code> object's <a href=#active-document>active document</a>. The <dfn id=dom-sharedworkerglobalscope-applicationcache title=dom-SharedWorkerGlobalScope-applicationCache><code>applicationCache</code></dfn> attribute on <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> objects must return the <code><a href=#applicationcache>ApplicationCache</a></code> object associated with the worker. </p> <p class=note>A <code><a href=#window>Window</a></code> or <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object has an associated <code><a href=#applicationcache>ApplicationCache</a></code> object even if that <a href=#cache-host>cache host</a> has no actual <a href=#application-cache>application cache</a>.</p> <hr><p>The <dfn id=dom-appcache-status title=dom-appcache-status><code>status</code></dfn> attribute, on getting, must return the current state of the <a href=#application-cache>application cache</a> that the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with, if any. This must be the appropriate value from the following list:</p> </div> <dl><dt><dfn id=dom-appcache-uncached title=dom-appcache-UNCACHED><code>UNCACHED</code></dfn> (numeric value 0)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is not associated with an <a href=#application-cache>application cache</a> at this time.</dd> <dt><dfn id=dom-appcache-idle title=dom-appcache-IDLE><code>IDLE</code></dfn> (numeric value 1)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#application-cache-group>application cache group</a>'s <a href=#concept-appcache-status title=concept-appcache-status>update status</a> is <i>idle</i>, and that <a href=#application-cache>application cache</a> is the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> cache in its <a href=#application-cache-group>application cache group</a>, and the <a href=#application-cache-group>application cache group</a> is not marked as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>.</dd> <dt><dfn id=dom-appcache-checking title=dom-appcache-CHECKING><code>CHECKING</code></dfn> (numeric value 2)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#application-cache-group>application cache group</a>'s <a href=#concept-appcache-status title=concept-appcache-status>update status</a> is <i>checking</i>.</dd> <dt><dfn id=dom-appcache-downloading title=dom-appcache-DOWNLOADING><code>DOWNLOADING</code></dfn> (numeric value 3)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#application-cache-group>application cache group</a>'s <a href=#concept-appcache-status title=concept-appcache-status>update status</a> is <i>downloading</i>.</dd> <dt><dfn id=dom-appcache-updateready title=dom-appcache-UPDATEREADY><code>UPDATEREADY</code></dfn> (numeric value 4)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#application-cache-group>application cache group</a>'s <a href=#concept-appcache-status title=concept-appcache-status>update status</a> is <i>idle</i>, and whose <a href=#application-cache-group>application cache group</a> is not marked as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>, but that <a href=#application-cache>application cache</a> is <em>not</em> the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> cache in its group.</dd> <dt><dfn id=dom-appcache-obsolete title=dom-appcache-OBSOLETE><code>OBSOLETE</code></dfn> (numeric value 5)</dt> <dd><p>The <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a> whose <a href=#application-cache-group>application cache group</a> is marked as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>.</dd> </dl><div class=impl> <hr><p>If the <dfn id=dom-appcache-update title=dom-appcache-update><code>update()</code></dfn> method is invoked, the user agent must invoke the <a href=#application-cache-download-process>application cache download process</a>, in the background, for the <a href=#application-cache>application cache</a> with which the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated, but without giving that <a href=#cache-host>cache host</a> to the algorithm. If there is no such <a href=#application-cache>application cache</a>, or if it is marked as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>, then the method must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception instead.</p> <p>If the <dfn id=dom-appcache-abort title=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>application cache download process</a> for the <a href=#application-cache>application cache</a> with which the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated, if any. If there is no such <a href=#application-cache>application cache</a>, or if does not have a current <a href=#application-cache-download-process>application cache download process</a>, then do nothing.</p> <p>If the <dfn id=dom-appcache-swapcache title=dom-appcache-swapCache><code>swapCache()</code></dfn> method is invoked, the user agent must run the following steps: <ol><li><p>Check that <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated with an <a href=#application-cache>application cache</a>. If it is not, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>Let <var title="">cache</var> be the <a href=#application-cache>application cache</a> with which the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> is associated. (By definition, this is the same as the one that was found in the previous step.)</li> <li><p>If <var title="">cache</var>'s <a href=#application-cache-group>application cache group</a> is marked as <a href=#concept-appcache-obsolete title=concept-appcache-obsolete>obsolete</a>, then unassociate the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> from <var title="">cache</var> and abort these steps. (Resources will now load from the network instead of the cache.)</li> <li><p>Check that there is an application cache in the same <a href=#application-cache-group>application cache group</a> as <var title="">cache</var> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>complete</i> and that is <a href=#concept-appcache-newer title=concept-appcache-newer>newer</a> than <var title="">cache</var>. If there is not, then throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>Let <var title="">new cache</var> be the <a href=#concept-appcache-newer title=concept-appcache-newer>newest</a> <a href=#application-cache>application cache</a> in the same <a href=#application-cache-group>application cache group</a> as <var title="">cache</var> whose <a href=#concept-appcache-completeness title=concept-appcache-completeness>completeness flag</a> is <i>complete</i>.</li> <li><p>Unassociate the <code><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host>cache host</a> from <var title="">cache</var> and instead associate it with <var title="">new cache</var>.</li> </ol><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#applicationcache>ApplicationCache</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-appcache-onchecking title=handler-appcache-onchecking><code>onchecking</code></dfn> <td> <code title=event-appcache-checking><a href=#event-appcache-checking>checking</a></code> <tr><td><dfn id=handler-appcache-onerror title=handler-appcache-onerror><code>onerror</code></dfn> <td> <code title=event-appcache-error><a href=#event-appcache-error>error</a></code> <tr><td><dfn id=handler-appcache-onnoupdate title=handler-appcache-onnoupdate><code>onnoupdate</code></dfn> <td> <code title=event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code> <tr><td><dfn id=handler-appcache-ondownloading title=handler-appcache-ondownloading><code>ondownloading</code></dfn> <td> <code title=event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code> <tr><td><dfn id=handler-appcache-onprogress title=handler-appcache-onprogress><code>onprogress</code></dfn> <td> <code title=event-appcache-progress><a href=#event-appcache-progress>progress</a></code> <tr><td><dfn id=handler-appcache-onupdateready title=handler-appcache-onupdateready><code>onupdateready</code></dfn> <td> <code title=event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> <tr><td><dfn id=handler-appcache-oncached title=handler-appcache-oncached><code>oncached</code></dfn> <td> <code title=event-appcache-cached><a href=#event-appcache-cached>cached</a></code> <tr><td><dfn id=handler-appcache-onobsolete title=handler-appcache-onobsolete><code>onobsolete</code></dfn> <td> <code title=event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code> </table></div> <h4 id=browser-state><span class=secno>6.6.10 </span>Browser state</h4> <pre class=idl>[NoInterfaceObject] interface <dfn id=navigatoronline>NavigatorOnLine</dfn> { readonly attribute boolean <a href=#dom-navigator-online title=dom-navigator-onLine>onLine</a>; };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-onLine><a href=#dom-navigator-online>onLine</a></code></dt> <dd> <p>Returns false if the user agent is definitely offline (disconnected from the network). Returns true if the user agent might be online.</p> <p>The events <code title=event-online><a href=#event-online>online</a></code> and <code title=event-offline><a href=#event-offline>offline</a></code> are fired when the value of this attribute changes.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-navigator-online title=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 title=dom-navigator-onLine><a href=#dom-navigator-online>navigator.onLine</a></code> attribute of a <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> changes from true to false, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <dfn id=event-offline title=event-offline><code>offline</code></dfn> at the <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object.</p> <p>On the other hand, when the value that would be returned by the <code title=dom-navigator-onLine><a href=#dom-navigator-online>navigator.onLine</a></code> attribute of a <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> changes from false to true, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <dfn id=event-online title=event-online><code>online</code></dfn> at the <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object.</p> <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#networking-task-source>networking task source</a>.</p> </div> <p class=note>This attribute is inherently unreliable. A computer can be connected to a network without having Internet access.</p> <div class=example> <p>In this example, an indicator is updated as the browser goes online and offline.</p> <pre><!DOCTYPE HTML> <html> <head> <title>Online status</title> <script> function updateIndicator() { document.getElementById('indicator').textContent = navigator.onLine ? 'online' : 'offline'; } </script> </head> <body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()"> <p>The network is: <span id="indicator">(state unknown)</span> </body> </html></pre> </div> <h2 id=webappapis><span class=secno>7 </span>Web application APIs</h2> <h3 id=scripting><span class=secno>7.1 </span>Scripting</h3> <h4 id=introduction-7><span class=secno>7.1.1 </span>Introduction</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><a href=#the-script-element>script</a></code> elements.</li> <li>Processing of inline <code title="javascript protocol"><a href=#javascript-protocol>javascript:</a></code> URLs (e.g. the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of <code><a href=#the-img-element>img</a></code> elements, or an <code title="">@import</code> rule in a CSS <code><a href=#the-style-element>style</a></code> element block).</li> <li>Event handlers, whether registered through the DOM using <code title="">addEventListener()</code>, by explicit <a href=#event-handler-content-attributes>event handler content attributes</a>, by <a href=#event-handler-idl-attributes>event handler IDL attributes</a>, or otherwise.</li> <li>Processing of technologies like XBL or SVG that have their own scripting features.</li> </ul><div class=impl> <h4 id=enabling-and-disabling-scripting><span class=secno>7.1.2 </span>Enabling and disabling scripting</h4> <p><dfn id=concept-bc-script title=concept-bc-script>Scripting is enabled</dfn> in a <em><a href=#browsing-context>browsing context</a></em> when all of the following conditions are true:</p> <ul><li>The user agent supports scripting.</li> <li>The user has not disabled scripting for this <a href=#browsing-context>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.)</li> <li id=sandboxScriptBlocked>The <a href=#browsing-context>browsing context</a> did not have the <a href=#sandboxed-scripts-browsing-context-flag>sandboxed scripts browsing context flag</a> set when the <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a> was created.</li> </ul><p><dfn id=concept-bc-noscript title=concept-bc-noscript>Scripting is disabled</dfn> in a <a href=#browsing-context>browsing context</a> when any of the above conditions are false (i.e. when scripting is not <a href=#concept-bc-script title=concept-bc-script>enabled</a>).</p> <hr><p><dfn id=concept-n-script title=concept-n-script>Scripting is enabled</dfn> for a <em>node</em> if the <code><a href=#document>Document</a></code> object of the node (the node itself, if it is itself a <code><a href=#document>Document</a></code> object) has an associated <a href=#browsing-context>browsing context</a>, and <a href=#concept-bc-script title=concept-bc-script>scripting is enabled</a> in that <a href=#browsing-context>browsing context</a>.</p> <p><dfn id=concept-n-noscript title=concept-n-noscript>Scripting is disabled</dfn> for a node if there is no such <a href=#browsing-context>browsing context</a>, or if <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> in that <a href=#browsing-context>browsing context</a>.</p> </div> <div class=impl> <!-- SCRIPT EXEC (marks areas related to creation of scripts) --> <h4 id=processing-model-1><span class=secno>7.1.3 </span>Processing model</h4> <h5 id=definitions-0><span class=secno>7.1.3.1 </span>Definitions</h5> <p>A <dfn id=concept-script title=concept-script>script</dfn> has:</p> <dl><dt>A <dfn id=script-execution-environment>script execution environment</dfn></dt> <dd> <p>The characteristics of the script execution environment depend on the language, and are not defined by this specification.</p> <p class=example>In JavaScript, the script execution environment consists of the interpreter, the stack of <i>execution contexts</i>, the <i>global code</i> and <i>function code</i> and the Function objects resulting, and so forth.</p> </dd> <dt>A <dfn id=list-of-code-entry-points>list of code entry-points</dfn></dt> <dd> <p>Each code entry-point represents a block of executable code that the script exposes to other scripts and to the user agent.</p> <p class=example>Each Function object in a JavaScript <a href=#script-execution-environment>script execution environment</a> has a corresponding code entry-point, for instance.</p> <p>The main program code of the script, if any, is the <dfn id=initial-code-entry-point><i>initial code entry-point</i></dfn>. Typically, the code corresponding to this entry-point is executed immediately after the script is parsed.</p> <p class=example>In JavaScript, this corresponds to the execution context of the global code.</p> </dd> <dt>A relationship with the <dfn id="script's-global-object">script's global object</dfn></dt> <dd> <p>An object that provides the APIs that the code can use.</p> <p class=example>This is typically a <code><a href=#window>Window</a></code> object. In JavaScript, this corresponds to the <i>global object</i>.</p> <p class=note>When a <a href="#script's-global-object">script's global object</a> is an empty object, it can't do anything that interacts with the environment.</p> <p>If the <a href="#script's-global-object">script's global object</a> is a <code><a href=#window>Window</a></code> object, then in JavaScript, the ThisBinding of the global execution context for this script must be the <code><a href=#window>Window</a></code> object's <code><a href=#windowproxy>WindowProxy</a></code> object, rather than the global object. <a href=#refsECMA262>[ECMA262]</a></p> <p class=note>This is a <a href=#willful-violation>willful violation</a> of the JavaScript specification current at the time of writing (ECMAScript edition 5, as defined in section 10.4.1.1 Initial Global Execution Context, step 3). The JavaScript specification requires that the <code title="">this</code> keyword in the global scope return the global object, but this is not compatible with the security design prevalent in implementations as specified herein. <a href=#refsECMA262>[ECMA262]</a></p> </dd> <dt>A relationship with the <dfn id="script's-browsing-context">script's browsing context</dfn></dt> <dd> <p>A <a href=#browsing-context>browsing context</a> that is assigned responsibility for actions taken by the script.</p> <p class=example>When a script creates and <a href=#navigate title=navigate>navigates</a> a new <a href=#top-level-browsing-context>top-level browsing context</a>, the <code title=dom-opener><a href=#dom-opener>opener</a></code> attribute of the new <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code> object will be set to the <a href="#script's-browsing-context">script's browsing context</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object.</p> </dd> <dt>A relationship with the <dfn id="script's-document">script's document</dfn></dt> <dd> <p>A <code><a href=#document>Document</a></code> that is assigned responsibility for actions taken by the script.</p> <p class=example>When a script <a href=#fetch title=fetch>fetches</a> a resource, the <a href="#the-document's-current-address" title="the document's current address">current address</a> of the <a href="#script's-document">script's document</a> will be used to set the <code title=http-referer>Referer</code> (sic) header.</p> </dd> <dt>A <dfn id="script's-url-character-encoding" title="script's URL character encoding">URL character encoding</dfn></dt> <dd> <p>A character encoding, set when the script is created, used to encode URLs. <span id=sce-not-copy title="">If the character encoding is set from another source, e.g. a <a href="#document's-character-encoding">document's character encoding</a>, then the <a href="#script's-url-character-encoding">script's URL character encoding</a> must follow the source, so that if the source's changes, so does the script's.</span></p> </dd> <dt>A <dfn id="script's-base-url" title="script's base URL">base URL</dfn></dt> <dd> <p>A <a href=#url>URL</a>, set when the script is created, used to resolve relative URLs. <span id=sbu-not-copy title="">If the base URL is set from another source, e.g. a <a href=#document-base-url>document base URL</a>, then the <a href="#script's-base-url">script's base URL</a> must follow the source, so that if the source's changes, so does the script's.</span></p> </dd> </dl></div> <div class=impl> <h5 id=calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</h5> <p>When a user agent is to <dfn id=jump-to-a-code-entry-point>jump to a code entry-point</dfn> for a <a href=#concept-script title=concept-script>script</a>, for example to invoke an event listener defined in that <a href=#concept-script title=concept-script>script</a>, the user agent must run the following steps:</p> <ol><li><p>If the <a href="#script's-global-object">script's global object</a> is a <code><a href=#window>Window</a></code> object whose <code><a href=#document>Document</a></code> object is not <a href=#fully-active>fully active</a>, then abort these steps without doing anything. The callback is not run.</p> <li><p>Set the <a href=#entry-script>entry script</a> to be the <a href=#concept-script title=concept-script>script</a> being invoked.</li> <li><p>Make the <a href=#script-execution-environment title="script execution environment">script execution environment</a> for the <a href=#concept-script title=concept-script>script</a> execute the code for the given code entry-point.</li> <li><p>Set the <a href=#entry-script>entry script</a> back to whatever it was when this algorithm started.</li> </ol><p>This algorithm is not invoked by one script calling another.</p> </div> <div class=impl> <h5 id=creating-scripts><span class=secno>7.1.3.3 </span>Creating scripts</h5> <p>When the specification says that a <a href=#concept-script title=concept-script>script</a> is to be <dfn id=create-a-script title="create a script">created</dfn>, given some script source, its scripting language, a global object, a browsing context, a URL character encoding, and a base URL, the user agent must run the following steps:</p> <ol><li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> for <a href=#browsing-context>browsing context</a> passed to this algorithm, then abort these steps, as if the script did nothing but return void.</p> <li><p>Set up a <a href=#script-execution-environment>script execution environment</a> as appropriate for the scripting language.</li> <li><p>Parse/compile/initialize the source of the script using the <a href=#script-execution-environment>script execution environment</a>, as appropriate for the scripting language, and thus obtain the <a href=#list-of-code-entry-points>list of code entry-points</a> for the script. If the semantics of the scripting language and the given source code are such that there is executable code to be immediately run, then the <i><a href=#initial-code-entry-point>initial code entry-point</a></i> is the entry-point for that code.</li> <li><p>Set up the <a href="#script's-global-object">script's global object</a>, the <a href="#script's-browsing-context">script's browsing context</a>, the <a href="#script's-document">script's document</a>, the <a href="#script's-url-character-encoding">script's URL character encoding</a>, and the <a href="#script's-base-url">script's base URL</a> from the settings passed to this algorithm.</li> <li> <p>If all the steps above succeeded (in particular, if the script was compiled successfully), <a href=#jump-to-a-code-entry-point title="jump to a code entry-point">Jump</a> to the <a href=#concept-script title=concept-script>script</a>'s <i><a href=#initial-code-entry-point>initial code entry-point</a></i>.</p> <p>Otherwise, <a href=#report-the-error>report the error</a> using the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> <a href=#event-handlers title="event handlers">event handler</a> of the <a href="#script's-global-object">script's global object</a>. If the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> after this, then the error may be reported to the user.</p> </li> </ol><hr><p>When the user agent is to <dfn id=create-an-impotent-script>create an impotent script</dfn>, given some script source, its scripting language, and a browsing context, the user agent must <a href=#create-a-script>create a script</a>, using the given script source and scripting language, using a new empty object as the global object, and using the given browsing context as the browsing context. The URL character encoding and base URL for the resulting <a href=#concept-script title=concept-script>script</a> are not important as no APIs are exposed to the script.</p> <hr><p>When the specification says that a <a href=#concept-script title=concept-script>script</a> is to be <dfn id=create-a-script-from-a-node title="create a script from a node">created from a node</dfn> <var title="">node</var>, given some script source and its scripting language, the user agent must <a href=#create-a-script>create a script</a>, using the given script source and scripting language, and using <a href=#the-script-settings-determined-from-the-node>the script settings determined from the node</a> <var title="">node</var>.</p> <p><dfn id=the-script-settings-determined-from-the-node>The script settings determined from the node</dfn> <var title="">node</var> are computed as follows:</p> <ol><li><p>Let <var title="">document</var> be the <code><a href=#document>Document</a></code> of <var title="">node</var> (or <var title="">node</var> itself if it is a <code><a href=#document>Document</a></code>).</li> <li><p>The browsing context is the <a href=#browsing-context>browsing context</a> of <var title="">document</var>.</p> <li><p>The global object is the <code><a href=#window>Window</a></code> object of <var title="">document</var>.</li> <li><p>The URL character encoding is the <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> of <var title="">document</var>. (<a href=#sce-not-copy>This is a reference, not a copy</a>.)</li> <li><p>The base URL is the <a href=#document-base-url title="document base URL">base URL</a> of <var title="">document</var>. (<a href=#sbu-not-copy>This is a reference, not a copy</a>.)</li> </ol></div> <div class=impl> <h5 id=killing-scripts><span class=secno>7.1.3.4 </span>Killing scripts</h5> <p>User agents may impose resource limitations on scripts, for example CPU quotas, memory limits, total execution time limits, or bandwidth limitations. When a script exceeds a limit, the user agent may either throw a <code><a href=#quotaexceedederror>QuotaExceededError</a></code> exception, abort the script 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><script> while (true) { /* loop */ } </script></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 title=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> </div> <div class=impl> <h5 id=runtime-script-errors><span class=secno>7.1.3.5 </span>Runtime script errors</h5> <p>When the user agent is required to <dfn id=report-the-error title="report the error">report an error</dfn> <var title="">error</var> using the <a href=#event-handlers title="event handlers">event handler</a> <var title="">onerror</var>, it must run these steps, after which the error is either <dfn id=concept-error-handled title=concept-error-handled><i>handled</i></dfn> or <dfn id=concept-error-nothandled title=concept-error-nothandled><i>not handled</i></dfn>:</p> <dl class=switch><dt>If the value of <var title="">onerror</var> is a <code><a href=#function>Function</a></code></dt> <dd> <p>The function must be invoked with three arguments. The first two arguments passed to the function must be of type <code>DOMString</code>, and the third must be of type <code>unsigned long</code>. The first must give the message that the UA is considering reporting, the second must give the <a href=#absolute-url>absolute URL</a> of the resource in which the error occurred, and the third must give the line number in that resource on which the error occurred.</p> <p>If the function returns false, then the error is <i title=concept-error-handled><a href=#concept-error-handled>handled</a></i>. Otherwise, the error is <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i>.</p> <p>Any uncaught exceptions thrown or errors caused by this function may be reported to the user immediately after the error that the function was called for; the <a href=#report-the-error title="report the error">report an error</a> algorithm must not be used to handle exceptions thrown or errors caused by this function.</p> </dd> <dt>Otherwise</dt> <dd> <p>The error is <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i>.</p> </dd> </dl><h6 id=runtime-script-errors-in-documents><span class=secno>7.1.3.5.1 </span>Runtime script errors in documents</h6> <p>Whenever an uncaught runtime script error occurs in one of the scripts associated with a <code><a href=#document>Document</a></code>, the user agent must <a href=#report-the-error>report the error</a> using the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> <a href=#event-handlers title="event handlers">event handler</a> of the <a href="#script's-global-object">script's global object</a>. If the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> after this, then the error may be reported to the user.</p> </div> <div class=impl> <h4 id=event-loops><span class=secno>7.1.4 </span>Event loops</h4> <h5 id=definitions-1><span class=secno>7.1.4.1 </span>Definitions</h5> <p>To coordinate events, user interaction, scripts, rendering, networking, and so forth, user agents must use <dfn id=event-loop title="event loop">event loops</dfn> as described in this section.</p> <p>There must be at least one <a href=#event-loop>event loop</a> per user agent, and at most one <a href=#event-loop>event loop</a> per <a href=#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>event loop</a> for a <a href=#unit-of-related-browsing-contexts>unit of related browsing contexts</a>, complications arise when a <a href=#browsing-context>browsing context</a> in that group is <a href=#navigate title=navigate>navigated</a> such that it switches from one <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> to another. This specification does not currently describe how to handle these complications.</p> <p>An <a href=#event-loop>event loop</a> always has at least one <a href=#browsing-context>browsing context</a>. If an <a href=#event-loop>event loop</a>'s <a href=#browsing-context title="browsing context">browsing contexts</a> all go away, then the <a href=#event-loop>event loop</a> goes away as well. A <a href=#browsing-context>browsing context</a> always has an <a href=#event-loop>event loop</a> coordinating its activities.</p> <p>An <a href=#event-loop>event loop</a> has one or more <dfn id=task-queue title="task queue">task queues</dfn>. A <a href=#task-queue>task queue</a> is an ordered list of <dfn id=concept-task title=concept-task>tasks</dfn>, which can be:</p> <dl><dt>Events</dt> <dd> <p>Asynchronously dispatching an <code><a href=#event>Event</a></code> object at a particular <code><a href=#eventtarget>EventTarget</a></code> object is a task.</p> <p class=note>Not all events are dispatched using the <a href=#task-queue>task queue</a>, many are dispatched synchronously during other tasks.</p> </dd> <dt>Parsing</dt> <dd><p>The <a href=#html-parser>HTML parser</a> tokenizing one or more bytes, and then processing any resulting tokens, is typically a task.</dd> <dt>Callbacks</dt> <dd><p>Calling a callback asynchronously is a task.</dd> <dt>Using a resource</dt> <dd><p>When an algorithm <a href=#fetch title=fetch>fetches</a> a resource, if the fetching occurs asynchronously then the processing of the resource once some or all of the resource is available is a task.</dd> <dt>Reacting to DOM manipulation</dt> <dd><p>Some elements have tasks that trigger in response to DOM manipulation, e.g. when that element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the document</a>.</p> </dl><p>When a user agent is to <dfn id=queue-a-task>queue a task</dfn>, it must add the given task to one of the <a href=#task-queue title="task queue">task queues</a> of the relevant <a href=#event-loop>event loop</a>. All the tasks from one particular <dfn id=task-source>task source</dfn> (e.g. the callbacks generated by timers, the events fired for mouse movements, the tasks queued for the parser) must always be added to the same <a href=#task-queue>task queue</a>, but tasks from different <a href=#task-source title="task source">task sources</a> may be placed in different <a href=#task-queue title="task queue">task queues</a>.</p> <p class=example>For example, a user agent could have one <a href=#task-queue>task queue</a> for mouse and key events (the <a href=#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>task source</a> out of order.</p> <p>Each <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> onto a <a href=#task-queue>task queue</a> of an <a href=#event-loop>event loop</a> defined by this specification is associated with a <code><a href=#document>Document</a></code>; if the task was queued in the context of an element, then it is the element's <code><a href=#document>Document</a></code>; if the task was queued in the context of a <a href=#browsing-context>browsing context</a>, then it is the <a href=#browsing-context>browsing context</a>'s <a href=#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 title=concept-script>script</a> then the document is the <a href="#script's-document">script's document</a>.</p> <p>A user agent may have one <dfn id=storage-mutex>storage mutex</dfn>. This mutex is used to control access to shared state like cookies. At any one point, the <a href=#storage-mutex>storage mutex</a> is either free, or owned by a particular <a href=#event-loop>event loop</a> or instance of the <a href=#fetch title=fetch>fetching</a> algorithm.</p> <p>If a user agent does not implement a <a href=#storage-mutex>storage mutex</a>, it is exempt from implementing the requirements that require it to acquire or release it.</p> <p class=note>User agent implementors have to make a choice between two evils. On the one hand, not implementing the storage mutex means that there is a risk of data corruption: 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. On the other hand, implementing the storage mutex has potentially serious performance implications: whenever a site uses Web Storage or cookies, all other sites that try to use Web Storage or cookies are blocked until the first site finishes.</p> <p>Whenever a <a href=#concept-script title=concept-script>script</a> calls into a <a href=#plugin>plugin</a>, and whenever a <a href=#plugin>plugin</a> calls into a <a href=#concept-script title=concept-script>script</a>, the user agent must release the <a href=#storage-mutex>storage mutex</a>.</p> <h5 id=processing-model-2><span class=secno>7.1.4.2 </span>Processing model</h5> <p>An <a href=#event-loop>event loop</a> must continually run through the following steps for as long as it exists:</p> <ol><li><p>Run the oldest <a href=#concept-task title=concept-task>task</a> on one of the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a>, ignoring tasks whose associated <code><a href=#document>Document</a></code>s are not <a href=#fully-active>fully active</a>. The user agent may pick any <a href=#task-queue>task queue</a>.</li> <!-- warning! if you renumber these steps, make sure to update the "spin the event loop" algorith below! --> <li><p>If the <a href=#storage-mutex>storage mutex</a> is now owned by the <a href=#event-loop>event loop</a>, release it so that it is once again free.</li> <li><p>Remove that task from its <a href=#task-queue>task queue</a>.</li> <li><p><a href=#provide-a-stable-state>Provide a stable state</a>.</li> <li><p>If necessary, update the rendering or user interface of any <code><a href=#document>Document</a></code> or <a href=#browsing-context>browsing context</a> to reflect the current state.</li> <li><p>Return to the first step of the <a href=#event-loop>event loop</a>.</li> </ol><hr><p>When the user agent is to <dfn id=provide-a-stable-state>provide a stable state</dfn>, if any asynchronously-running algorithms are <dfn id=await-a-stable-state title="await a stable state">awaiting a stable state</dfn>, then the user agent must run their <dfn id=synchronous-section>synchronous section</dfn> and then resume running their asynchronous algorithm (if appropriate).</p> <p class=note>A <a href=#synchronous-section>synchronous section</a> never mutates the DOM, runs any script, or has any other side-effects.</p> <p class=note>Steps in <a href=#synchronous-section title="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 title="">goal</var> is met, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">task source</var> be the <a href=#task-source>task source</a> of the currently running <a href=#concept-task title=concept-task>task</a>.</li> <li> <p>Stop the currently running <a href=#concept-task title=concept-task>task</a>, allowing the <a href=#event-loop>event loop</a> to resume, but continue these steps asynchronously.</p> <p class=note>This causes the <a href=#event-loop>event loop</a> to move on to the second step of its processing model (defined above).</p> </li> <li><p>Wait until the condition <var title="">goal</var> is met.</li> <li><p><a href=#queue-a-task>Queue a task</a> to continue running these steps, using the <a href=#task-source>task source</a> <var title="">task source</var>. Wait until this task runs before continuing these steps.</li> <li><p>Return to the caller.</li> </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 title=concept-task>task</a> until a condition <var title="">goal</var> is met. This means running the following steps:</p> <ol><li><p>If any asynchronously-running algorithms are <a href=#await-a-stable-state title="await a stable state">awaiting a stable state</a>, then run their <a href=#synchronous-section>synchronous section</a> and then resume running their asynchronous algorithm. (See the <a href=#event-loop>event loop</a> processing model definition above for details.)</p> <li><p>If necessary, update the rendering or user interface of any <code><a href=#document>Document</a></code> or <a href=#browsing-context>browsing context</a> to reflect the current state.</li> <li><p>Wait until the condition <var title="">goal</var> is met. While a user agent has a paused <a href=#concept-task title=concept-task>task</a>, the corresponding <a href=#event-loop>event loop</a> must not run further <a href=#concept-task title=concept-task>tasks</a>, and any script in the currently running <a href=#concept-task title=concept-task>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>event loop</a> will not be doing anything.</li> </ol><hr><p>When a user agent is to <dfn id=obtain-the-storage-mutex>obtain the storage mutex</dfn> as part of running a <a href=#concept-task title=concept-task>task</a>, it must run through the following steps:</p> <ol><li><p>If the <a href=#storage-mutex>storage mutex</a> is already owned by this <a href=#concept-task title=concept-task>task</a>'s <a href=#event-loop>event loop</a>, then abort these steps.</li> <li><p>Otherwise, <a href=#pause>pause</a> until the <a href=#storage-mutex>storage mutex</a> can be taken by the <a href=#event-loop>event loop</a>.</li> <li><p>Take ownership of the <a href=#storage-mutex>storage mutex</a>.</li> </ol></div> <div class=impl> <h5 id=generic-task-sources><span class=secno>7.1.4.3 </span>Generic task sources</h5> <p>The following <a href=#task-source title="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>DOM manipulation task source</dfn></dt> <dd> <p>This <a href=#task-source>task source</a> is used for features that react to DOM manipulations, such as things that happen asynchronously when an element is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into the document</a>.</p> </dd> <dt>The <dfn id=user-interaction-task-source>user interaction task source</dfn></dt> <dd> <p>This <a href=#task-source>task source</a> is used for features that react to user interaction, for example keyboard or mouse input.</p> <p>Asynchronous events sent in response to user input (e.g. <code title=event-click><a href=#event-click>click</a></code> events) must be fired using <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a task">queued</a> with the <a href=#user-interaction-task-source>user interaction task source</a>. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> </dd> <dt>The <dfn id=networking-task-source>networking task source</dfn></dt> <dd> <p>This <a href=#task-source>task source</a> is used for features that trigger in response to network activity.</p> <!-- XHR should use this --> </dd> <dt>The <dfn id=history-traversal-task-source>history traversal task source</dfn></dt> <dd> <p>This <a href=#task-source>task source</a> is used to queue calls to <code title=dom-history-back><a href=#dom-history-back>history.back()</a></code> and similar APIs.</p> </dd> </dl></div> <div class=impl> <!-- SCRIPT EXEC --> <h4 id=javascript-protocol><span class=secno>7.1.5 </span><dfn title="javascript protocol">The <code title="">javascript:</code> URL scheme</dfn></h4> <p>When a <a href=#url>URL</a> using the <code title="">javascript:</code> scheme is <dfn id=concept-js-deref title=concept-js-deref>dereferenced</dfn>, the user agent must run the following steps:</p> <ol><li><p>Let the script source be the string obtained using the content retrieval operation defined for <code title="">javascript:</code> URLs. <a href=#refsJSURL>[JSURL]</a></li> <li> <p>Use the appropriate step from the following list:</p> <dl><dt>If a <a href=#browsing-context>browsing context</a> is being <a href=#navigate title=navigate>navigated</a> to a <code>javascript:</code> URL, and the <a href=#source-browsing-context>source browsing context</a> for that navigation, if any, has <a href=#concept-bc-noscript title=concept-bc-noscript>scripting disabled</a></dt> <dd> <p>Let <var title="">result</var> be void.</p> </dd> <dt>If a <a href=#browsing-context>browsing context</a> is being <a href=#navigate title=navigate>navigated</a> to a <code>javascript:</code> URL, and the <a href=#active-document>active document</a> of that browsing context has the <a href=#same-origin>same origin</a> as the script given by that URL</dt> <dd> <!-- http://www.hixie.ch/tests/adhoc/html/navigation/javascript-url/ --> <p>Let <var title="">address</var> be the <a href="#the-document's-address" title="the document's address">address</a> of the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a> being navigated.</p> <p>If <var title="">address</var> is <code><a href=#about:blank>about:blank</a></code>, and the <a href=#browsing-context>browsing context</a> being navigated has a <a href=#creator-browsing-context>creator browsing context</a>, then let <var title="">address</var> be the <a href="#the-document's-address" title="the document's address">address</a> of the <a href=#creator-document>creator <code>Document</code></a> instead.</p> <p><a href=#create-a-script-from-a-node title="create a script from a node">Create a script</a> from the <code><a href=#document>Document</a></code> node of the <a href=#active-document>active document</a>, using the aforementioned script source, and assuming the scripting language is JavaScript.</p> <p>Let <var title="">result</var> be the return value of the <i><a href=#initial-code-entry-point>initial code entry-point</a></i> of this <a href=#concept-script title=concept-script>script</a>. If an exception was raised, let <var title="">result</var> be void instead. (The result will be void also if <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a>.)</p> <p>When it comes time to <a href="#set-the-document's-address">set the document's address</a> in the <a href=#navigate title=navigate>navigation algorithm</a>, use <var title="">address</var> as the <a href=#override-url>override URL</a>.</p> </dd> <!--(turns out only Firefox does this, and only for <img src=""> and a few others, so it's commented out for now pending someone having a convincing use case) <dt>If the <code>Document</code> object of the element, attribute, or style sheet from which the <code>javascript:</code> URL was reached has an associated <span>browsing context</span></dt> <dd> <p><span>Create an impotent script</span> using the aforementioned script source, with the scripting language set to JavaScript, and with the <code>Document</code>'s object's <span>browsing context</span> as the browsing context.</p> <p>Let <var title="">result</var> be the return value of the <i>initial code entry-point</i> of this <span title="concept-script">script</span>. If an exception was raised, let <var title="">result</var> be void instead. (The result will be void also if <span title="concept-bc-noscript">scripting is disabled</span>.)</p> </dd> --> <dt>Otherwise</dt> <dd> <p>Let <var title="">result</var> be void.</p> </dd> </dl></li> <li> <p>If the result of executing the script is void (there is no return value), then the URL must be treated in a manner equivalent to an HTTP resource with an HTTP 204 No Content response.</p> <p>Otherwise, the URL must be treated in a manner equivalent to an HTTP resource with a 200 OK response whose <a href=#content-type title=Content-Type>Content-Type metadata</a> is <code><a href=#text/html>text/html</a></code> and whose response body is the return value converted to a string value.</p> <p class=note>Certain contexts, in particular <code><a href=#the-img-element>img</a></code> elements, ignore the <a href=#content-type title=Content-Type>Content-Type metadata</a>.</p> </li> </ol><div class=example> <p>So for example a <code title="">javascript:</code> URL for a <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute of an <code><a href=#the-img-element>img</a></code> element would be evaluated in the context of an empty object as soon as the attribute is set; it would then be sniffed to determine the image type and decoded as an image.</p> <p>A <code title="">javascript:</code> URL in an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute of an <code><a href=#the-a-element>a</a></code> element would only be evaluated when the link was <a href=#following-hyperlinks title="following hyperlinks">followed</a>.</p> <p>The <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute of an <code><a href=#the-iframe-element>iframe</a></code> element would be evaluated in the context of the <code><a href=#the-iframe-element>iframe</a></code>'s own <a href=#browsing-context>browsing context</a>; once evaluated, its return value (if it was not void) would replace that <a href=#browsing-context>browsing context</a>'s document, thus changing the variables visible in that <a href=#browsing-context>browsing context</a>.</p> </div> </div> <h4 id=events><span class=secno>7.1.6 </span>Events</h4> <div class=impl> <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers</h5> </div> <!--test: <a href="http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cscript%3E%0Aw(a%3Ddocument.implementation.createDocument(null%2C%20null%2C%20null))%3B%0Aw(a.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'html')))%3B%0Aw(b%3Da.firstChild.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'body')))%3B%0Aw(b.test%20%3D%20w)%3B%0Aw(b.setAttribute('onclick'%2C%20'test(%22fire%3A%20%22%20%2B%20event)'))%3B%0Aw(b.onclick)%3B%0Aw(e%3Da.createEvent('Event'))%3B%0Aw(e.initEvent('click'%2C%20false%2C%20false))%3B%0Aw(b.dispatchEvent(e))%3B%0A%3C%2Fscript%3E">test</a>--> <p>Many objects can have <dfn id=event-handlers>event handlers</dfn> specified. These act as non-capture event listeners for the object on which they are specified. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p>An <a href=#event-handlers title="event handlers">event handler</a> can either have the value null or be set to a <code><a href=#function>Function</a></code> object. <span class=impl>Initially, event handlers must be set to null.</span></p> <p>Event handlers are exposed in one or two ways.</p> <p>The first way, common to all event handlers, is as an <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL attribute</a>.</p> <p>The second way is as an <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a>. Event handlers on <a href=#html-elements>HTML elements</a> and some of the event handlers on <code><a href=#window>Window</a></code> objects are exposed in this way.</p> <div class=impl> <hr><p><dfn id=event-handler-idl-attributes>Event handler IDL attributes</dfn>, on setting, must set the corresponding event handler to their new value, and on getting, must return whatever the current value of the corresponding event handler is (possibly null).</p> <p>If an <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL attribute</a> exposes an <a href=#event-handlers title="event handlers">event handler</a> of an object that doesn't exist, it must always return null on getting and must do nothing on setting.</p> <p class=note>This can happen in particular for <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL attribute</a> on <code><a href=#the-body-element>body</a></code> elements that do not have corresponding <code><a href=#window>Window</a></code> objects.</p> <p class=note>Certain event handler IDL attributes have additional requirements, in particular the <code title=handler-MessagePort-onmessage><a href=#handler-messageport-onmessage>onmessage</a></code> attribute of <code><a href=#messageport>MessagePort</a></code> objects.</p> <hr></div> <p><dfn id=event-handler-content-attributes>Event handler content attributes</dfn>, when specified, must contain valid JavaScript code which, when parsed, would match the <code title="">FunctionBody</code> production after automatic semicolon insertion. <a href=#refsECMA262>[ECMA262]</a></p> <div class=impl> <!-- SCRIPT EXEC --> <p>When an <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a> is set, if the element is owned by a <code><a href=#document>Document</a></code> that is in a <a href=#browsing-context>browsing context</a>, and <a href=#concept-bc-script title=concept-bc-script>scripting is enabled</a> for that <a href=#browsing-context>browsing context</a>, the user agent must run the following steps to create a <a href=#concept-script title=concept-script>script</a> after setting the content attribute to its new value:</p> <ol><li><p>Set the corresponding <a href=#event-handlers title="event handlers">event handler</a> to null.</li> <li><p>Set up a <a href=#script-execution-environment>script execution environment</a> for JavaScript.</li> <li><p>Let <var title="">body</var> be the <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a>'s new value.</li> <li> <p>If <var title="">body</var> is not parsable as <i>FunctionBody</i> or if parsing detects an <i>early error</i> then abort these steps.</p> <p class=note><i>FunctionBody</i> is defined in ECMAScript edition 5 section 13 Function Definition. <i>Early error</i> is defined in ECMAScript edition 5 section 16 Errors. <a href=#refsECMA262>[ECMA262]</a></p> </li> <li> <p>If <var title="">body</var> begins with a Directive Prologue that contains a Use Strict Directive then let <var title="">strict</var> be true, otherwise let <var title="">strict</var> be false.</p> <!-- we can't defer to 10.1.1 since we're not using a Function constructor but doing it ourselves. --> <p class=note>The terms "Directive Prologue" and "Use Strict Directive" are defined in ECMAScript edition 5 section 14.1 Directive Prologues and the Use Strict Directive. <a href=#refsECMA262>[ECMA262]</a></p> </li> <!-- currently this is unnecessary: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11977#c4 <li> <p>If <var title="">strict</var> is true, and anything in <var title="">body</var> is a <code>SyntaxError</code> according to the Strict Mode Restrictions, then abort these steps.</p> <p class="note">The Strict Mode Restrictions are those listed in ECMAScript edition 5 section 13.1 Strict Mode Restrictions. <a href="#refsECMA262">[ECMA262]</a></p> </li> --> <li> <p>Using the script execution environment created above, create a function object (as defined in ECMAScript edition 5 section 13.2 Creating Function Objects), with:</p> <dl><dt>Parameter list <var title="">FormalParameterList</var></dt> <dd> <dl class=switch><dt>If the attribute is the <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> attribute of the <code><a href=#window>Window</a></code> object</dt> <dd>Let the function have three arguments, named <code title="">event</code>, <code title="">source</code>, and <code title="">lineno</code>.</dd> <dt>Otherwise</dt> <dd>Let the function have a single argument called <code title="">event</code>.</dd> </dl></dd> <dt>Function body <var title="">FunctionBody</var></dt> <dd>The result of parsing <var title="">body</var> above.</dd> <dt>Lexical Environment <var title="">Scope</var></dt> <dd> <ol><li>Let <var title="">Scope</var> be the result of NewObjectEnvironment(the element's <code><a href=#document>Document</a></code>, the <var title="">global environment</var>).</li> <li>If the element has a <a href=#form-owner>form owner</a>, let <var title="">Scope</var> be the result of NewObjectEnvironment(the element's <a href=#form-owner>form owner</a>, <var title="">Scope</var>).</li> <li>Let <var title="">Scope</var> be the result of NewObjectEnvironment(the element's object, <var title="">Scope</var>).</li> </ol><p class=note>NewObjectEnvironment() is defined in ECMAScript edition 5 section 10.2.2.3 NewObjectEnvironment (O, E). <a href=#refsECMA262>[ECMA262]</a></p> </dd> <dt>Boolean flag <var title="">Strict</var></dt> <dd>The value of <var title="">strict</var>.</dd> </dl><p>Let this new function be the only entry in the script's <a href=#list-of-code-entry-points>list of code entry-points</a>.</p> </li> <li><p>Set up the <a href="#script's-global-object">script's global object</a>, the <a href="#script's-browsing-context">script's browsing context</a>, the <a href="#script's-document">script's document</a>, the <a href="#script's-url-character-encoding">script's URL character encoding</a>, and the <a href="#script's-base-url">script's base URL</a> from <a href=#the-script-settings-determined-from-the-node>the script settings determined from the node</a> on which the attribute is being set.</li> <li><p>Set the corresponding <a href=#event-handlers title="event handlers">event handler</a> to the aforementioned function.</li> </ol><p>When an event handler content attribute is removed, the user agent must set the corresponding <a href=#event-handlers title="event handlers">event handler</a> to null.</p> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/245 onload http://software.hixie.ch/utilities/js/live-dom-viewer/saved/247 onclick see http://www.w3.org/Bugs/Public/show_bug.cgi?id=7626#c5 for reasoning --> </div> <p class=note>When an <a href=#event-handler-content-attributes title="event handler content attributes">event handler content attribute</a> is set on an element owned by a <code><a href=#document>Document</a></code> that is not in a <a href=#browsing-context>browsing context</a>, the corresponding event handler is not changed.</p> <!-- v2: we should probably support HTML4's Content-Script-Type header here. --> <div class=impl> <hr><p>When an <a href=#event-handlers title="event handlers">event handler</a> <var title="">H</var> of an element or object <var title="">T</var> implementing the <code><a href=#eventtarget>EventTarget</a></code> interface is first set to a non-null <code><a href=#function>Function</a></code> object, the user agent must append an <a href=#concept-event-listener title=concept-event-listener>event listener</a> to the list of <a href=#concept-event-listener title=concept-event-listener>event listeners</a> associated with <var title="">T</var> with <i>type</i> set to the <dfn id=event-handler-event-type>event handler event type</dfn> corresponding to <var title="">H</var>, <i>capture</i> set to false, and <i>listener</i> set to <a href=#the-event-handler-processing-algorithm>the event handler processing algorithm</a> defined below. <a href=#refsDOMCORE>[DOMCORE]</a></p> <p class=note>The <i>listener</i> is emphatically <em>not</em> the <a href=#event-handlers title="event handlers">event handler</a> itself. Every event handler ends up registering the same <i>listener</i>, the algorithm defined below, which takes care of invoking the right callback, and processing the callback's return value.</p> <p class=note>This only happens the first time the <a href=#event-handlers title="event handlers">event handler</a>'s value is set. Since listeners are called in the order they were registered, the order of event listeners for a particular event type will always be first the event listeners registered with <code title=dom-EventTarget-addEventListener>addEventListener()</code> before the first time the <a href=#event-handlers title="event handlers">event handler</a> was set to a non-null value, then the <code><a href=#function>Function</a></code> to which it is currently set, if any, and finally the event listeners registered with <code title=dom-EventTarget-addEventListener>addEventListener()</code> <em>after</em> the first time the <a href=#event-handlers title="event handlers">event handler</a> was set to a non-null value.</p> </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><button id="test">Start Demo</button> <script> var button = document.getElementById('test'); button.addEventListener('click', function () { alert('ONE') }, false); button.setAttribute('onclick', "alert('NOT CALLED')"); // event handler listener is registered here button.addEventListener('click', function () { alert('THREE') }, false); button.onclick = function () { alert('TWO'); }; button.addEventListener('click', function () { alert('FOUR') }, false); </script></pre> </div> <div class=impl> <p class=note>The interfaces implemented by the event object do not influence whether an <a href=#event-handlers title="event handlers">event handler</a> is triggered or not.</p> <p><dfn id=the-event-handler-processing-algorithm>The event handler processing algorithm</dfn> for an <a href=#event-handlers title="event handlers">event handler</a> <var title="">H</var> and an <code><a href=#event>Event</a></code> object <var title="">E</var> is as follows:</p> <ol><li><p>If <var title="">H</var>'s value is null, then abort these steps.</li> <li><p>Let <var title="">callback</var> be <var title="">H</var>'s value, the <code><a href=#function>Function</a></code> object that the <a href=#event-handlers title="event handlers">event handler</a> was last set to.</li> <li><p>Invoke <var title="">callback</var>'s <code title=dom-function-call><a href=#dom-function-call>call()</a></code> operation with one argument, the value of which is the <code><a href=#event>Event</a></code> object <var title="">E</var>, with the <i title=dfn-callback-this-value>callback this value</i> set to the <var title="">E</var>'s <code title=dom-Event-currentTarget>currentTarget</code>. Let the return value be <var title="">return value</var>. <a href=#refsWEBIDL>[WEBIDL]</a></li> <li> <p>Process <var title="">return value</var> as follows:</p> <dl class=switch><dt>If the event type is <code class=event-mouseover>mouseover</code></dt> <dd><p>If <var title="">return value</var> is a boolean with the value true, then cancel the event.</dd> <dt>If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object</dt> <dd><p>If <var title="">return value</var> is a string, and the <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute's value to <var title="">return value</var>.</dd> <dt>Otherwise</dt> <dd><p>If <var title="">return value</var> is a boolean with the value false, then cancel the event.</dd> <!-- IE actually uncancels the event if the function returns true --> </dl></li> </ol></div> <hr><p>The <code><a href=#function>Function</a></code> interface represents a function in the scripting language being used. It is represented in Web IDL as follows:</p> <pre class=idl>[Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=function>Function</dfn> { any <a href=#dom-function-call title=dom-function-call>call</a>(any... arguments); };</pre> <p>The <dfn id=dom-function-call title=dom-function-call><code>call(...)</code></dfn> method is the object's callback.</p> <p class=note>In JavaScript, any <code title="">Function</code> object implements this interface.</p> <div class=example> <p>For example, the following document fragment:</p> <pre><body onload="alert(this)" onclick="alert(this)"></pre> <p>...leads to an alert saying "<code title="">[object Window]</code>" when the document is loaded, and an alert saying "<code title="">[object HTMLBodyElement]</code>" whenever the user clicks something in the page.</p> </div> <p class=note>The return value of the function affects whether the event is canceled or not: <span class=impl>as described above,</span> if the return value is false, the event is canceled (except for <code class=event-mouseover>mouseover</code> events, where the return value has to be true to cancel the event). With <code title=event-beforeunload>beforeunload</code> events, the value is instead used to determine the message to show the user.</p> <h5 id=event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>7.1.6.2 </span>Event handlers on elements, <code><a href=#document>Document</a></code> objects, and <code><a href=#window>Window</a></code> objects</h5> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) <span class=impl>that must be</span> supported by all <a href=#html-elements>HTML elements</a>, as both content attributes and IDL attributes, and on <code><a href=#document>Document</a></code> and <code><a href=#window>Window</a></code> objects, as IDL attributes.</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-onabort title=handler-onabort><code>onabort</code></dfn> <td> <code title=event-abort>abort</code> <tr><td><dfn id=handler-oncanplay title=handler-oncanplay><code>oncanplay</code></dfn> <td> <code title=event-media-canplay><a href=#event-media-canplay>canplay</a></code> <tr><td><dfn id=handler-oncanplaythrough title=handler-oncanplaythrough><code>oncanplaythrough</code></dfn> <td> <code title=event-media-canplaythrough><a href=#event-media-canplaythrough>canplaythrough</a></code> <tr><td><dfn id=handler-onchange title=handler-onchange><code>onchange</code></dfn> <td> <code title=event-change>change</code> <!-- widely used --> <tr><td><dfn id=handler-onclick title=handler-onclick><code>onclick</code></dfn> <td> <code title=event-click><a href=#event-click>click</a></code> <!-- widely used --> <tr><td><dfn id=handler-oncontextmenu title=handler-oncontextmenu><code>oncontextmenu</code></dfn> <td> <code title=event-contextmenu>contextmenu</code> <!-- widely used --> <tr><td><dfn id=handler-oncuechange title=handler-oncuechange><code>oncuechange</code></dfn> <td> <code title=event-cuechange>cuechange</code> <tr><td><dfn id=handler-ondblclick title=handler-ondblclick><code>ondblclick</code></dfn> <td> <code title=event-dblclick>dblclick</code> <!-- widely used --> <tr><td><dfn id=handler-ondrag title=handler-ondrag><code>ondrag</code></dfn> <td> <code title=event-drag><a href=#event-drag>drag</a></code> <tr><td><dfn id=handler-ondragend title=handler-ondragend><code>ondragend</code></dfn> <td> <code title=event-dragend><a href=#event-dragend>dragend</a></code> <tr><td><dfn id=handler-ondragenter title=handler-ondragenter><code>ondragenter</code></dfn> <td> <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> <tr><td><dfn id=handler-ondragleave title=handler-ondragleave><code>ondragleave</code></dfn> <td> <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code> <tr><td><dfn id=handler-ondragover title=handler-ondragover><code>ondragover</code></dfn> <td> <code title=event-dragover><a href=#event-dragover>dragover</a></code> <tr><td><dfn id=handler-ondragstart title=handler-ondragstart><code>ondragstart</code></dfn> <td> <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> <!-- widely used --> <tr><td><dfn id=handler-ondrop title=handler-ondrop><code>ondrop</code></dfn> <td> <code title=event-drop><a href=#event-drop>drop</a></code> <tr><td><dfn id=handler-ondurationchange title=handler-ondurationchange><code>ondurationchange</code></dfn> <td> <code title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> <tr><td><dfn id=handler-onemptied title=handler-onemptied><code>onemptied</code></dfn> <td> <code title=event-media-emptied><a href=#event-media-emptied>emptied</a></code> <tr><td><dfn id=handler-onended title=handler-onended><code>onended</code></dfn> <td> <code title=event-media-ended><a href=#event-media-ended>ended</a></code> <tr><td><dfn id=handler-oninput title=handler-oninput><code>oninput</code></dfn> <td> <code title=event-input>input</code> <tr><td><dfn id=handler-oninvalid title=handler-oninvalid><code>oninvalid</code></dfn> <td> <code title=event-invalid>invalid</code> <tr><td><dfn id=handler-onkeydown title=handler-onkeydown><code>onkeydown</code></dfn> <td> <code title=event-keydown>keydown</code> <!-- widely used --> <tr><td><dfn id=handler-onkeypress title=handler-onkeypress><code>onkeypress</code></dfn> <td> <code title=event-keypress>keypress</code> <!-- widely used --> <tr><td><dfn id=handler-onkeyup title=handler-onkeyup><code>onkeyup</code></dfn> <td> <code title=event-keyup>keyup</code> <!-- widely used --> <tr><td><dfn id=handler-onloadeddata title=handler-onloadeddata><code>onloadeddata</code></dfn> <td> <code title=event-media-loadeddata><a href=#event-media-loadeddata>loadeddata</a></code> <tr><td><dfn id=handler-onloadedmetadata title=handler-onloadedmetadata><code>onloadedmetadata</code></dfn> <td> <code title=event-media-loadedmetadata><a href=#event-media-loadedmetadata>loadedmetadata</a></code> <tr><td><dfn id=handler-onloadstart title=handler-onloadstart><code>onloadstart</code></dfn> <td> <code title=event-media-loadstart><a href=#event-media-loadstart>loadstart</a></code> <tr><td><dfn id=handler-onmousedown title=handler-onmousedown><code>onmousedown</code></dfn> <td> <code title=event-mousedown>mousedown</code> <!-- widely used --> <tr><td><dfn id=handler-onmousemove title=handler-onmousemove><code>onmousemove</code></dfn> <td> <code title=event-mousemove>mousemove</code> <!-- widely used --> <tr><td><dfn id=handler-onmouseout title=handler-onmouseout><code>onmouseout</code></dfn> <td> <code title=event-mouseout>mouseout</code> <!-- widely used --> <tr><td><dfn id=handler-onmouseover title=handler-onmouseover><code>onmouseover</code></dfn> <td> <code title=event-mouseover>mouseover</code> <!-- widely used --> <tr><td><dfn id=handler-onmouseup title=handler-onmouseup><code>onmouseup</code></dfn> <td> <code title=event-mouseup>mouseup</code> <!-- widely used --> <tr><td><dfn id=handler-onmousewheel title=handler-onmousewheel><code>onmousewheel</code></dfn> <td> <code title=event-mousewheel>mousewheel</code> <!-- widely used --> <tr><td><dfn id=handler-onpause title=handler-onpause><code>onpause</code></dfn> <td> <code title=event-media-pause><a href=#event-media-pause>pause</a></code> <tr><td><dfn id=handler-onplay title=handler-onplay><code>onplay</code></dfn> <td> <code title=event-media-play><a href=#event-media-play>play</a></code> <tr><td><dfn id=handler-onplaying title=handler-onplaying><code>onplaying</code></dfn> <td> <code title=event-media-playing><a href=#event-media-playing>playing</a></code> <tr><td><dfn id=handler-onprogress title=handler-onprogress><code>onprogress</code></dfn> <td> <code title=event-media-progress><a href=#event-media-progress>progress</a></code> <tr><td><dfn id=handler-onratechange title=handler-onratechange><code>onratechange</code></dfn> <td> <code title=event-media-ratechange><a href=#event-media-ratechange>ratechange</a></code> <tr><td><dfn id=handler-onreset title=handler-onreset><code>onreset</code></dfn> <td> <code title=event-reset>reset</code> <tr><td><dfn id=handler-onseeked title=handler-onseeked><code>onseeked</code></dfn> <td> <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> <tr><td><dfn id=handler-onseeking title=handler-onseeking><code>onseeking</code></dfn> <td> <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> <tr><td><dfn id=handler-onselect title=handler-onselect><code>onselect</code></dfn> <td> <code title=event-select>select</code> <!-- widely used --> <!-- [CSSOM] --> <tr><td><dfn id=handler-onshow title=handler-onshow><code>onshow</code></dfn> <td> <code title=event-show>show</code> <tr><td><dfn id=handler-onstalled title=handler-onstalled><code>onstalled</code></dfn> <td> <code title=event-media-stalled><a href=#event-media-stalled>stalled</a></code> <tr><td><dfn id=handler-onsubmit title=handler-onsubmit><code>onsubmit</code></dfn> <td> <code title=event-submit>submit</code> <!-- widely used --> <tr><td><dfn id=handler-onsuspend title=handler-onsuspend><code>onsuspend</code></dfn> <td> <code title=event-media-suspend><a href=#event-media-suspend>suspend</a></code> <tr><td><dfn id=handler-ontimeupdate title=handler-ontimeupdate><code>ontimeupdate</code></dfn> <td> <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> <tr><td><dfn id=handler-onvolumechange title=handler-onvolumechange><code>onvolumechange</code></dfn> <td> <code title=event-media-volumechange><a href=#event-media-volumechange>volumechange</a></code> <tr><td><dfn id=handler-onwaiting title=handler-onwaiting><code>onwaiting</code></dfn> <td> <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> <!-- not supported, use dnd: --> <!--<tr><td><dfn title="handler-onbeforecopy"><code>onbeforecopy</code></dfn> <td> <code title="event-beforecopy">beforecopy</code>--> <!-- widely used --> <!--<tr><td><dfn title="handler-oncopy"><code>oncopy</code></dfn> <td> <code title="event-copy">copy</code>--> <!-- widely used --> <!--<tr><td><dfn title="handler-onpaste"><code>onpaste</code></dfn> <td> <code title="event-paste">paste</code>--> <!-- widely used --> <!-- not supported yet (v2?): --> <!--<tr><td><dfn title="handler-onselectstart"><code>onselectstart</code></dfn> <td> <code title="event-selectstart">selectstart</code>--> <!-- widely used --> </table><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) <span class=impl>that must be</span> supported by all <a href=#html-elements>HTML elements</a> other than <code><a href=#the-body-element>body</a></code>, as both content attributes and IDL attributes, and on <code><a href=#document>Document</a></code> objects, as IDL attributes:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-onblur title=handler-onblur><code>onblur</code></dfn> <td> <code title=event-blur>blur</code> <!-- widely used --> <tr><td><dfn id=handler-onerror title=handler-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> <tr><td><dfn id=handler-onfocus title=handler-onfocus><code>onfocus</code></dfn> <td> <code title=event-focus>focus</code> <!-- widely used --> <tr><td><dfn id=handler-onload title=handler-onload><code>onload</code></dfn> <td> <code title=event-load>load</code> <tr><td><dfn id=handler-onscroll title=handler-onscroll><code>onscroll</code></dfn> <td> <code title=event-scroll>scroll</code> </table><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) <span class=impl>that must be</span> supported by <code><a href=#window>Window</a></code> objects, as IDL attributes on the <code><a href=#window>Window</a></code> object, and with corresponding content attributes and IDL attributes exposed on the <code><a href=#the-body-element>body</a></code> and <code><a href=#frameset>frameset</a></code> elements:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-window-onafterprint title=handler-window-onafterprint><code>onafterprint</code></dfn> <td> <code title=event-afterprint>afterprint</code> <tr><td><dfn id=handler-window-onbeforeprint title=handler-window-onbeforeprint><code>onbeforeprint</code></dfn> <td> <code title=event-beforeprint>beforeprint</code> <tr><td><dfn id=handler-window-onbeforeunload title=handler-window-onbeforeunload><code>onbeforeunload</code></dfn> <td> <code title=event-beforeunload>beforeunload</code> <tr><td><dfn id=handler-window-onblur title=handler-window-onblur><code>onblur</code></dfn> <td> <code title=event-blur>blur</code> <tr><td><dfn id=handler-window-onerror title=handler-window-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> <tr><td><dfn id=handler-window-onfocus title=handler-window-onfocus><code>onfocus</code></dfn> <td> <code title=event-focus>focus</code> <tr><td><dfn id=handler-window-onhashchange title=handler-window-onhashchange><code>onhashchange</code></dfn> <td> <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code> <!-- new --> <tr><td><dfn id=handler-window-onload title=handler-window-onload><code>onload</code></dfn> <td> <code title=event-load>load</code> <!-- widely used --> <tr><td><dfn id=handler-window-onmessage title=handler-window-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> <!-- new for postMessage --> <tr><td><dfn id=handler-window-onoffline title=handler-window-onoffline><code>onoffline</code></dfn> <td> <code title=event-offline><a href=#event-offline>offline</a></code> <!-- new --> <tr><td><dfn id=handler-window-ononline title=handler-window-ononline><code>ononline</code></dfn> <td> <code title=event-online><a href=#event-online>online</a></code> <!-- new --> <tr><td><dfn id=handler-window-onpagehide title=handler-window-onpagehide><code>onpagehide</code></dfn> <td> <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> <!-- new --> <tr><td><dfn id=handler-window-onpageshow title=handler-window-onpageshow><code>onpageshow</code></dfn> <td> <code title=event-pageshow><a href=#event-pageshow>pageshow</a></code> <!-- new --> <tr><td><dfn id=handler-window-onpopstate title=handler-window-onpopstate><code>onpopstate</code></dfn> <td> <code title=event-popstate><a href=#event-popstate>popstate</a></code> <!-- new --> <tr><td><dfn id=handler-window-onresize title=handler-window-onresize><code>onresize</code></dfn> <td> <code title=event-resize>resize</code> <!-- widely used --> <!-- [CSSOM] --> <tr><td><dfn id=handler-window-onscroll title=handler-window-onscroll><code>onscroll</code></dfn> <td> <code title=event-scroll>scroll</code> <tr><td><dfn id=handler-window-onstorage title=handler-window-onstorage><code>onstorage</code></dfn> <td> <code title=event-storage><a href=#event-storage>storage</a></code> <!-- new --> <tr><td><dfn id=handler-window-onunload title=handler-window-onunload><code>onunload</code></dfn> <td> <code title=event-unload>unload</code> <!-- widely used --> </table><p class=note>The <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code> handler is also used for <a href=#runtime-script-errors>reporting script errors</a>.</p> <hr><!-- this guy is only on Document and not on HTMLElement because otherwise HTMLScriptElement would have it and that causes compatibility issues since IE fires readystatechange events on <script>, not load events, and we can't fire both, and some sites try to decide which to look for based on the presence of script.onreadystatechange on HTMLScriptElement. http://www.w3.org/Bugs/Public/show_bug.cgi?id=13965 http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-September/033136.html --><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) <span class=impl>that must be</span> supported on <code><a href=#document>Document</a></code> objects as IDL attributes:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-onreadystatechange title=handler-onreadystatechange><code>onreadystatechange</code></dfn> <td> <code title=event-readystatechange><a href=#event-readystatechange>readystatechange</a></code> </table><div class=impl> <h5 id=event-firing><span class=secno>7.1.6.3 </span>Event firing</h5> <p>Certain operations and methods are defined as firing events on elements. For example, the <code title=dom-click><a href=#dom-click>click()</a></code> method on the <code><a href=#htmlelement>HTMLElement</a></code> interface is defined as firing a <code title=event-click><a href=#event-click>click</a></code> event on the element. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> <p><dfn id=fire-a-simple-event title="fire a simple event">Firing a simple event named <var title="">e</var></dfn> means that an event with the name <var title="">e</var>, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the <code><a href=#event>Event</a></code> interface, must be created and dispatched at the given target.</p> <p><dfn id=fire-a-synthetic-mouse-event title="fire a synthetic mouse event">Firing a synthetic mouse event named <var title="">e</var></dfn> means that an event with the name <var title="">e</var>, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the <code><a href=#mouseevent>MouseEvent</a></code> interface, must be created and dispatched at the given target. The event object must have its <code title="">screenX</code>, <code title="">screenY</code>, <code title="">clientX</code>, <code title="">clientY</code>, and <code title="">button</code> attributes initialized to 0, its <code title="">ctrlKey</code>, <code title="">shiftKey</code>, <code title="">altKey</code>, and <code title="">metaKey</code> attributes initialized according to the current state of the key input device, if any (false for any keys that are not available), its <code title="">detail</code> attribute initialized to 1, and its <code title="">relatedTarget</code> attribute initialized to null. The <code title="">getModifierState()</code> method on the object must return values appropriately describing the state of the key input device at the time the event is created.</p> <p><dfn id=fire-a-click-event title="fire a click event">Firing a <code title=event-click>click</code> event</dfn> means <a href=#fire-a-synthetic-mouse-event title="fire a synthetic mouse event">firing a synthetic mouse event named <code title=event-click>click</code></a>, which bubbles and is cancelable.</p> <p>The default action of these events is to do nothing except where otherwise stated.</p> </div> <div class=impl> <h5 id=events-and-the-window-object><span class=secno>7.1.6.4 </span>Events and the <code><a href=#window>Window</a></code> object</h5> <p>When an event is dispatched at a DOM node in a <code><a href=#document>Document</a></code> in a <a href=#browsing-context>browsing context</a>, if the event is not a <code title=event-load>load</code> event, the user agent must act as if, for the purposes of <a href=#concept-event-dispatch title=concept-event-dispatch>event dispatching</a>, the <code><a href=#window>Window</a></code> object is the parent of the <code><a href=#document>Document</a></code> object. <a href=#refsDOMCORE>[DOMCORE]</a></p> </div> <h3 id=atob><span class=secno>7.2 </span>Base64 utility methods</h3> <p>The <code title=dom-windowbase64-atob><a href=#dom-windowbase64-atob>atob()</a></code> and <code title=dom-windowbase64-btoa><a href=#dom-windowbase64-btoa>btoa()</a></code> methods allow authors to transform content to and from the base64 encoding.</p> <!-- v2: actual binary support --> <pre class=idl>[NoInterfaceObject] interface <dfn id=windowbase64>WindowBase64</dfn> { DOMString <a href=#dom-windowbase64-btoa title=dom-windowbase64-btoa>btoa</a>(DOMString btoa); DOMString <a href=#dom-windowbase64-atob title=dom-windowbase64-atob>atob</a>(DOMString atob); }; <a href=#window>Window</a> implements <a href=#windowbase64>WindowBase64</a>;</pre> <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 title="">result</var> = <var title="">window</var> . <code title=dom-windowbase64-btoa><a href=#dom-windowbase64-btoa>btoa</a></code>( <var title="">data</var> )</dt> <dd> <p>Takes the input data, in the form of a Unicode string containing only characters in the range U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and converts it to its base64 representation, which it returns.</p> <p>Throws an <code><a href=#invalidcharactererror>InvalidCharacterError</a></code> exception if the input string contains any out-of-range characters.</p> </dd> <dt><var title="">result</var> = <var title="">window</var> . <code title=dom-windowbase64-atob><a href=#dom-windowbase64-atob>atob</a></code>( <var title="">data</var> )</dt> <dd> <p>Takes the input data, in the form of a Unicode string containing base64-encoded binary data, decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary data.</p> <p>Throws an <code><a href=#invalidcharactererror>InvalidCharacterError</a></code> exception if the input string is not valid base64 data.</p> </dd> </dl><div class=impl> <p class=note>The <code><a href=#windowbase64>WindowBase64</a></code> interface adds to the <code><a href=#window>Window</a></code> interface and the <code><a href=#workerutils>WorkerUtils</a></code> interface (part of Web Workers).</p> <p>The <dfn id=dom-windowbase64-btoa title=dom-windowbase64-btoa><code>btoa()</code></dfn> method must throw an <code><a href=#invalidcharactererror>InvalidCharacterError</a></code> exception if the method's first argument contains any character whose code point is greater than U+00FF. Otherwise, the user agent must convert that argument to a sequence of octets whose <var title="">n</var>th octet is the eight-bit representation of the code point of the <var title="">n</var>th character of the argument, and then must apply the base64 algorithm to that sequence of octets, and return the result. <a href=#refsRFC4648>[RFC4648]</a><!--base64--></p> <!-- Aryeh says: This seems to be what all browsers do as of January 2011 (except IE, which doesn't support these functions at all). --> <p>The <dfn id=dom-windowbase64-atob title=dom-windowbase64-atob><code>atob()</code></dfn> method must run the following steps to parse the string passed in the method's first argument:</p> <ol><!-- Aryeh says: Copies Firefox behavior as of January 2011 (4.0b8). WebKit is somewhat laxer, and Opera throws no exceptions at all. gsnedders reports Opera's behavior causes site-compat problems, and I figure most sites depend on Firefox if on anything, so go with that. --><li><p>Let <var title="">input</var> be the string being parsed.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p>If the length of <var title="">input</var> divides by 4 leaving no remainder, then: if <var title="">input</var> ends with one or two U+003D EQUALS SIGN (=) characters, remove them from <var title="">input</var>.</li> <li><p>If the length of <var title="">input</var> divides by 4 leaving a remainder of 1, throw an <code><a href=#invalidcharactererror>InvalidCharacterError</a></code> exception and abort these steps.</p> <li> <p>If <var title="">input</var> contains a character that is not in the following list of characters and character ranges, throw an <code><a href=#invalidcharactererror>InvalidCharacterError</a></code> exception and abort these steps:</p> <ul class=brief><li>U+002B PLUS SIGN (+) <li>U+002F SOLIDUS (/) <li>U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) <li>U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z <li>U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z </ul></li> <li><p>Let <var title="">output</var> be a string, initially empty.</li> <li><p>Let <var title="">buffer</var> be a buffer that can have bits appended to it, initially empty.</li> <li> <p>While <var title="">position</var> does not point past the end of <var title="">input</var>, run these substeps:</p> <ol><li> <p>Find the character pointed to by <var title="">position</var> in the first column of the following table. Let <var title="">n</var> be the number given in the second cell of the same row.</p> <div id=base64-table> <table><thead><tr><th>Character <th>Number <tbody><tr><td>A<td>0 <tr><td>B<td>1 <tr><td>C<td>2 <tr><td>D<td>3 <tr><td>E<td>4 <tr><td>F<td>5 <tr><td>G<td>6 <tr><td>H<td>7 <tr><td>I<td>8 <tr><td>J<td>9 <tr><td>K<td>10 <tr><td>L<td>11 <tr><td>M<td>12 <tr><td>N<td>13 <tr><td>O<td>14 <tr><td>P<td>15 <tr><td>Q<td>16 <tr><td>R<td>17 <tr><td>S<td>18 <tr><td>T<td>19 <tr><td>U<td>20 <tr><td>V<td>21 <tr><td>W<td>22 <tr><td>X<td>23 <tr><td>Y<td>24 <tr><td>Z<td>25 <tr><td>a<td>26 <tr><td>b<td>27 <tr><td>c<td>28 <tr><td>d<td>29 <tr><td>e<td>30 <tr><td>f<td>31 <tr><td>g<td>32 <tr><td>h<td>33 <tr><td>i<td>34 <tr><td>j<td>35 <tr><td>k<td>36 <tr><td>l<td>37 <tr><td>m<td>38 <tr><td>n<td>39 <tr><td>o<td>40 <tr><td>p<td>41 <tr><td>q<td>42 <tr><td>r<td>43 <tr><td>s<td>44 <tr><td>t<td>45 <tr><td>u<td>46 <tr><td>v<td>47 <tr><td>w<td>48 <tr><td>x<td>49 <tr><td>y<td>50 <tr><td>z<td>51 <tr><td>0<td>52 <tr><td>1<td>53 <tr><td>2<td>54 <tr><td>3<td>55 <tr><td>4<td>56 <tr><td>5<td>57 <tr><td>6<td>58 <tr><td>7<td>59 <tr><td>8<td>60 <tr><td>9<td>61 <tr><td>+<td>62 <tr><td>/<td>63 </table></div> </li> <li><p>Append to <var title="">buffer</var> the six bits corresponding to <var title="">number</var>, most significant bit first.</li> <li><p>If <var title="">buffer</var> has accumulated 24 bits, interpret them as three 8-bit big-endian numbers. Append the three characters with code points equal to those numbers to <var title="">output</var>, in the same order, and then empty <var title="">buffer</var>.</li> <li><p>Advance <var title="">position</var> by one character.</li> </ol></li> <li> <p>If <var title="">buffer</var> is not empty, it contains either 12 or 18 bits. If it contains 12 bits, discard the last four and interpret the remaining eight as an 8-bit big-endian number. If it contains 18 bits, discard the last two and interpret the remaining 16 as two 8-bit big-endian numbers. Append the one or two characters with code points equal to those one or two numbers to <var title="">output</var>, in the same order.</p> <p class=note>The discarded bits mean that, for instance, <code title="">atob("YQ")</code> and <code title="">atob("YR")</code> both return "<code title="">a</code>".</p> </li> <li><p>Return <var title="">output</var>.</li> </ol><!-- Note: this function is defined explicitly here because RFC4648 does not specify how to handle erroneous input, and no preexisting browser implementation simply throws an exception on all erroneous input. --></div> <p class=note>Some base64 encoders add newlines or other whitespace to their output. The <code title=dom-windowbase64-atob><a href=#dom-windowbase64-atob>atob()</a></code> method throws an exception if its input contains characters other than those described by the regular expression bracket expression <code title="">[+/=0-9A-Za-z]</code>, so other characters need to be removed before <code title=dom-windowbase64-atob><a href=#dom-windowbase64-atob>atob()</a></code> is used for decoding.</p> <h3 id=timers><span class=secno>7.3 </span>Timers</h3> <p>The <code title=dom-windowtimers-setTimeout><a href=#dom-windowtimers-settimeout>setTimeout()</a></code> and <code title=dom-windowtimers-setInterval><a href=#dom-windowtimers-setinterval>setInterval()</a></code> methods allow authors to schedule timer-based callbacks.</p> <pre class=idl>[NoInterfaceObject] interface <dfn id=windowtimers>WindowTimers</dfn> { long <a href=#dom-windowtimers-settimeout title=dom-windowtimers-setTimeout>setTimeout</a>(Function handler, optional long timeout, any... args); long <a href=#dom-windowtimers-settimeout title=dom-windowtimers-setTimeout>setTimeout</a>([AllowAny] DOMString handler, optional long timeout, any... args); void <a href=#dom-windowtimers-cleartimeout title=dom-windowtimers-clearTimeout>clearTimeout</a>(long handle); long <a href=#dom-windowtimers-setinterval title=dom-windowtimers-setInterval>setInterval</a>(Function handler, optional long timeout, any... args); long <a href=#dom-windowtimers-setinterval title=dom-windowtimers-setInterval>setInterval</a>([AllowAny] DOMString handler, optional long timeout, any... args); void <a href=#dom-windowtimers-clearinterval title=dom-windowtimers-clearInterval>clearInterval</a>(long handle); }; <a href=#window>Window</a> implements <a href=#windowtimers>WindowTimers</a>;</pre> <!-- Demonstrating the need for wrapping of the timeout argument value treated as long rather than clamping or treating as double: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1228 Demonstrating the need for the timeout argument to be signed rather than unsigned: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1229 --> <dl class=domintro><dt><var title="">handle</var> = <var title="">window</var> . <code title=dom-windowtimers-setTimeout><a href=#dom-windowtimers-settimeout>setTimeout</a></code>( <var title="">handler</var> [, <var title="">timeout</var> [, <var title="">arguments</var>... ] ] )</dt> <dd> <p>Schedules a timeout to run <var title="">handler</var> after <var title="">timeout</var> milliseconds. Any <var title="">arguments</var> are passed straight through to the <var title="">handler</var>.</p> </dd> <dt><var title="">handle</var> = <var title="">window</var> . <code title=dom-windowtimers-setTimeout><a href=#dom-windowtimers-settimeout>setTimeout</a></code>( <var title="">code</var> [, <var title="">timeout</var> ] )</dt> <dd> <p>Schedules a timeout to compile and run <var title="">code</var> after <var title="">timeout</var> milliseconds.</p> </dd> <dt><var title="">window</var> . <code title=dom-windowtimers-clearTimeout><a href=#dom-windowtimers-cleartimeout>clearTimeout</a></code>( <var title="">handle</var> )</dt> <dd> <p>Cancels the timeout set with <code title=dom-windowtimers-setTimeout><a href=#dom-windowtimers-settimeout>setTimeout()</a></code> identified by <var title="">handle</var>.</p> </dd> <dt><var title="">handle</var> = <var title="">window</var> . <code title=dom-windowtimers-setInterval><a href=#dom-windowtimers-setinterval>setInterval</a></code>( <var title="">handler</var> [, <var title="">timeout</var> [, <var title="">arguments</var>... ] ] )</dt> <dd> <p>Schedules a timeout to run <var title="">handler</var> every <var title="">timeout</var> milliseconds. Any <var title="">arguments</var> are passed straight through to the <var title="">handler</var>.</p> </dd> <dt><var title="">handle</var> = <var title="">window</var> . <code title=dom-windowtimers-setInterval><a href=#dom-windowtimers-setinterval>setInterval</a></code>( <var title="">code</var> [, <var title="">timeout</var> ] )</dt> <dd> <p>Schedules a timeout to compile and run <var title="">code</var> every <var title="">timeout</var> milliseconds.</p> </dd> <dt><var title="">window</var> . <code title=dom-windowtimers-clearInterval><a href=#dom-windowtimers-clearinterval>clearInterval</a></code>( <var title="">handle</var> )</dt> <dd> <p>Cancels the timeout set with <code title=dom-windowtimers-setInterval><a href=#dom-windowtimers-setinterval>setInterval()</a></code> identified by <var title="">handle</var>.</p> </dd> </dl><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> <div class=impl> <p class=note>The <code><a href=#windowtimers>WindowTimers</a></code> interface adds to the <code><a href=#window>Window</a></code> interface and the <code><a href=#workerutils>WorkerUtils</a></code> interface (part of Web Workers). </p> <p>Each object that implements the <code><a href=#windowtimers>WindowTimers</a></code> interface has a <dfn id=list-of-active-timeouts>list of active timeouts</dfn> and a <dfn id=list-of-active-intervals>list of active intervals</dfn>. Each entry in these lists is identified by a number, which must be unique within its list for the lifetime of the object that implements the <code><a href=#windowtimers>WindowTimers</a></code> interface.</p> <hr><p>The <dfn id=dom-windowtimers-settimeout title=dom-windowtimers-setTimeout><code>setTimeout()</code></dfn> method must run the following steps: <ol><li><p>Let <var title="">handle</var> be a user-agent-defined integer that is greater than zero that will identify the timeout to be set by this call.</li> <li><p>Add an entry to the <a href=#list-of-active-timeouts>list of active timeouts</a> for <var title="">handle</var>.</li> <li><p><a href=#get-the-timed-task>Get the timed task</a> <var title="">handle</var> in the <a href=#list-of-active-timeouts>list of active timeouts</a>, and let <var title="">task</var> be the result.</li> <li><p>Let <var title="">timeout</var> be the second argument to the method, or zero if the argument was omitted.</li> <li><p>If the currently running <a href=#concept-task title=concept-task>task</a> is a task that was created by the <code title=dom-windowtimers-setTimeout><a href=#dom-windowtimers-settimeout>setTimeout()</a></code> method, and <var title="">timeout</var> is less than 4, then increase <var title="">timeout</var> to 4.</li> <li><p>Return <var title="">handle</var>, and then continue running this algorithm asynchronously.</li> <li> <p>If the <a href=#method-context>method context</a> is a <code><a href=#window>Window</a></code> object, wait until the <code><a href=#document>Document</a></code> associated with the <a href=#method-context>method context</a> has been <a href=#fully-active>fully active</a> for a further <var title="">timeout</var> milliseconds (not necessarily consecutively).</p> <p>Otherwise, if the <a href=#method-context>method context</a> is a <code><a href=#workerutils>WorkerUtils</a></code> object, wait until <var title="">timeout</var> milliseconds have passed with the worker not suspended (not necessarily consecutively).</p> <p>Otherwise, act as described in the specification that defines that the <code><a href=#windowtimers>WindowTimers</a></code> interface is implemented by some other object.</p> </li> <li> <p>Wait until any invocations of this algorithm started before this one whose <var title="">timeout</var> is equal to or less than this one's have completed.</p> <p class=note>Argument conversion as defined by WebIDL (for example, invoking <code title="">toString()</code> methods on objects passed as the first argument) happens in the algorithms defined in WebIDL, 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 title="">ONE TWO </code>":</p> <pre>var log = ''; function logger(s) { log += s + ' '; } setTimeout({ toString: function () { setTimeout("logger('ONE')", 100); return "logger('TWO')"; } }, 100);</pre> </div> </li> <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 optimise the power usage of the device. For example, some processors have a low-power mode where the granularity of timers is reduced; on such platforms, user agents can slow timers down to fit this schedule instead of requiring the processor to use the more accurate mode with its associated higher power usage.</p> </li> <li><p><a href=#queue-a-task title="queue a task">Queue</a> the <var title="">task</var> <a href=#concept-task title=concept-task>task</a>.</li> </ol><p>The <dfn id=dom-windowtimers-cleartimeout title=dom-windowtimers-clearTimeout><code>clearTimeout()</code></dfn> method must clear the entry identified as <var title="">handle</var> from the <a href=#list-of-active-timeouts>list of active timeouts</a> of the <code><a href=#windowtimers>WindowTimers</a></code> object on which the method was invoked, where <var title="">handle</var> is the argument passed to the method, if any. (If <var title="">handle</var> does not identify an entry in the <a href=#list-of-active-timeouts>list of active timeouts</a> of the <code><a href=#windowtimers>WindowTimers</a></code> object on which the method was invoked, the method does nothing.)</p> <hr><p>The <dfn id=dom-windowtimers-setinterval title=dom-windowtimers-setInterval><code>setInterval()</code></dfn> method must run the following steps: <ol><li><p>Let <var title="">handle</var> be a user-agent-defined integer that is greater than zero that will identify the interval to be set by this call.</li> <li><p>Add an entry to the <a href=#list-of-active-intervals>list of active intervals</a> for <var title="">handle</var>.</li> <li><p><a href=#get-the-timed-task>Get the timed task</a> <var title="">handle</var> in the <a href=#list-of-active-intervals>list of active intervals</a>, and let <var title="">task</var> be the result.</li> <li><p>Let <var title="">timeout</var> be the second argument to the method, or zero if the argument was omitted.</li> <li><p>If <var title="">timeout</var> is less than 4, then increase <var title="">timeout</var> to 4.</li> <!-- (but see note below about IE) --> <li><p>Return <var title="">handle</var>, and then continue running this algorithm asynchronously.</li> <!-- Note: IE doesn't actually run intervals with duration zero, it aborts roughly here in the algorithm for them. --> <li> <p><i title="">Wait</i>: If the <a href=#method-context>method context</a> is a <code><a href=#window>Window</a></code> object, wait until the <code><a href=#document>Document</a></code> associated with the <a href=#method-context>method context</a> has been <a href=#fully-active>fully active</a> for a further <var title="">interval</var> milliseconds (not necessarily consecutively).</p> <p>Otherwise, if the <a href=#method-context>method context</a> is a <code><a href=#workerutils>WorkerUtils</a></code> object, wait until <var title="">interval</var> milliseconds have passed with the worker not suspended (not necessarily consecutively).</p> <p>Otherwise, act as described in the specification that defines that the <code><a href=#windowtimers>WindowTimers</a></code> interface is implemented by some other object.</p> </li> <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 optimise the power usage of the device. For example, some processors have a low-power mode where the granularity of timers is reduced; on such platforms, user agents can slow timers down to fit this schedule instead of requiring the processor to use the more accurate mode with its associated higher power usage.</p> </li> <li><p><a href=#queue-a-task title="queue a task">Queue</a> the <var title="">task</var> <a href=#concept-task title=concept-task>task</a>.</li> <li><p>Return to the step labeled <i>wait</i>.</li> </ol><p>The <dfn id=dom-windowtimers-clearinterval title=dom-windowtimers-clearInterval><code>clearInterval()</code></dfn> method must clear the entry identified as <var title="">handle</var> from the <a href=#list-of-active-intervals>list of active intervals</a> of the <code><a href=#windowtimers>WindowTimers</a></code> object on which the method was invoked, where <var title="">handle</var> is the argument passed to the method, if any. (If <var title="">handle</var> does not identify an entry in the <a href=#list-of-active-intervals>list of active intervals</a> of the <code><a href=#windowtimers>WindowTimers</a></code> object on which the method was invoked, the method does nothing.)</p> <hr><p>The <dfn id=method-context>method context</dfn>, when referenced by the algorithms in this section, is the object on which the method for which the algorithm is running is implemented (a <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code> object).</p> <p>When the above methods are invoked and try to <dfn id=get-the-timed-task>get the timed task</dfn> <var title="">handle</var> in list <var title="">list</var>, they must run the following steps:</p> <ol><li> <p>If the first argument to the invoked method is a <code><a href=#function>Function</a></code>, then return a <a href=#concept-task title=concept-task>task</a> that checks if the entry for <var title="">handle</var> in <var title="">list</var> has been cleared, and if it has not, calls the <code><a href=#function>Function</a></code> with as its arguments the third and subsequent arguments to the invoked method (if any) and with an undefined <var title="">thisArg</var>, and abort these steps. <a href=#refsECMA262>[ECMA262]</a></p> <p class=note>Setting <var title="">thisArg</var> to undefined means that the function code will be executed with the <code title="">this</code> keyword bound to the <code><a href=#windowproxy>WindowProxy</a></code> or the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, as if the code was running in the global scope.</p> <p>Otherwise, continue with the remaining steps.</p> </li> <li><p>Let <var title="">script source</var> be the first argument to the method.</li> <li><p>Let <var title="">script language</var> be JavaScript.</li> <li> <p>If the <a href=#method-context>method context</a> is a <code><a href=#window>Window</a></code> object, let <var title="">global object</var> be the <a href=#method-context>method context</a>, let <var title="">browsing context</var> be the <a href=#browsing-context>browsing context</a> with which <var title="">global object</var> is associated, let <var title="">character encoding</var> be the <a href="#document's-character-encoding" title="document's character encoding">character encoding</a> of the <code><a href=#document>Document</a></code> associated with <var title="">global object</var> (<a href=#sce-not-copy>this is a reference, not a copy</a>), and let <var title="">base URL</var> be the <a href=#document-base-url title="document base URL">base URL</a> of the <code><a href=#document>Document</a></code> associated with <var title="">global object</var> (<a href=#sbu-not-copy>this is a reference, not a copy</a>).</p> <p>Otherwise, if the <a href=#method-context>method context</a> is a <code><a href=#workerutils>WorkerUtils</a></code> object, let <var title="">global object</var>, <var title="">browsing context</var>, <var title="">document</var>, <var title="">character encoding</var>, and <var title="">base URL</var> be the <a href="#script's-global-object">script's global object</a>, <a href="#script's-browsing-context">script's browsing context</a>, <a href="#script's-document">script's document</a>, <a href="#script's-url-character-encoding">script's URL character encoding</a>, and <a href="#script's-base-url">script's base URL</a> (respectively) of the <a href=#concept-script title=concept-script>script</a> that the <a href=#run-a-worker>run a worker</a> algorithm created when it created the <a href=#method-context>method context</a>.</p> <p>Otherwise, act as described in the specification that defines that the <code><a href=#windowtimers>WindowTimers</a></code> interface is implemented by some other object.</p> </li> <li><p>Return a <a href=#concept-task title=concept-task>task</a> that checks if the entry for <var title="">handle</var> in <var title="">list</var> has been cleared, and if it has not, <a href=#create-a-script title="create a script">creates a script</a> using <var title="">script source</var> as the script source, <var title="">scripting language</var> as the scripting language, <var title="">global object</var> as the global object, <var title="">browsing context</var> as the browsing context, <var title="">document</var> as the document, <var title="">character encoding</var> as the URL character encoding, and <var title="">base URL</var> as the base URL.</li> </ol><hr><p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <dfn id=timer-task-source>timer task source</dfn>.</p> </div> <h3 id=user-prompts><span class=secno>7.4 </span>User prompts</h3> <!-- v2 ideas: * in-window modal dialogs - escape/enter handling - dragging the window out of the tab * in-window non-modal palettes - with a solution for the mobile space --> <h4 id=simple-dialogs><span class=secno>7.4.1 </span>Simple dialogs</h4> <dl class=domintro><dt><var title="">window</var> . <code title=dom-alert><a href=#dom-alert>alert</a></code>(<var title="">message</var>)</dt> <dd> <p>Displays a modal alert with the given message, and waits for the user to dismiss it.</p> <p>A call to the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method is implied when this method is invoked.</p> </dd> <dt><var title="">result</var> = <var title="">window</var> . <code title=dom-confirm><a href=#dom-confirm>confirm</a></code>(<var title="">message</var>)</dt> <dd> <p>Displays a modal OK/Cancel prompt with the given message, waits for the user to dismiss it, and returns true if the user clicks OK and false if the user clicks Cancel.</p> <p>A call to the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method is implied when this method is invoked.</p> </dd> <dt><var title="">result</var> = <var title="">window</var> . <code title=dom-prompt><a href=#dom-prompt>prompt</a></code>(<var title="">message</var> [, <var title="">default</var>] )</dt> <dd> <p>Displays a modal text field 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> <p>A call to the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method is implied when this method is invoked.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-alert title=dom-alert><code>alert(<var title="">message</var>)</code></dfn> method, when invoked, must release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user. The user agent may make the method wait for the user to acknowledge the message before returning; if so, the user agent must <a href=#pause>pause</a> while the method is waiting.</p> <p>The <dfn id=dom-confirm title=dom-confirm><code>confirm(<var title="">message</var>)</code></dfn> method, when invoked, must release the <a href=#storage-mutex>storage mutex</a> and show the given <var title="">message</var> to the user, and ask the user to respond with a positive or negative response. The user agent must then <a href=#pause>pause</a> as the method waits for the user's response. If the user responds positively, the method must return true, and if the user responds negatively, the method must return false.</p> <p>The <dfn id=dom-prompt title=dom-prompt><code>prompt(<var title="">message</var>, <var title="">default</var>)</code></dfn> method, when invoked, must release the <a href=#storage-mutex>storage mutex</a>, show the given <var title="">message</var> to the user, and ask the user to either respond with a string value or abort. The user agent must then <a href=#pause>pause</a> as the method waits for the user's response. The second argument is optional. If the second argument (<var title="">default</var>) is present, then the response must be defaulted to the value given by <var title="">default</var>. If the user aborts, then the method must return null; otherwise, the method must return the string that the user responded with.</p> </div> <h4 id=printing><span class=secno>7.4.2 </span>Printing</h4> <dl class=domintro><dt><var title="">window</var> . <code title=dom-print><a href=#dom-print>print</a></code>()</dt> <dd> <p>Prompts the user to print the page.</p> <p>A call to the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method is implied when this method is invoked.</p> </dd> </dl><div class=impl> <p>When the <dfn id=dom-print title=dom-print><code>print()</code></dfn> method is invoked, if the <code><a href=#document>Document</a></code> is <a href=#ready-for-post-load-tasks>ready for post-load tasks</a>, then the user agent must synchronously run the <a href=#printing-steps>printing steps</a>. Otherwise, the user agent must only set the <dfn id=print-when-loaded>print when loaded</dfn> flag on the <code><a href=#document>Document</a></code>.</p> <p>User agents should also run the <a href=#printing-steps>printing steps</a> whenever the user asks for the opportunity to <a href=#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 and/or may abort these steps.</p> <p class=example>For instance, a kiosk browser could silently ignore any invocations of the <code title=dom-print><a href=#dom-print>print()</a></code> method.</p> <p class=example>For instance, a browser on a mobile device could detect that there are no printers in the vicinity and display a message saying so before continuing to offer a "save to PDF" option.</p> </li> <li> <p>The user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-beforeprint>beforeprint</code> at the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code> that is being printed, as well as any <a href=#nested-browsing-context title="nested browsing context">nested browsing contexts</a> in it.</p> <p class=example>The <code title=event-beforeprint>beforeprint</code> event can be used to annotate the printed copy, for instance adding the time at which the document was printed.</p> </li> <li> <p>The user agent must release the <a href=#storage-mutex>storage mutex</a>.</p> </li> <li> <p>The user agent should offer the user the opportunity to <a href=#obtain-a-physical-form>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>pause</a> while the method is waiting. Even if the user agent doesn't wait at this point, the user agent must use the state of the relevant documents as they are at this point in the algorithm if and when it eventually creates the alternate form.</p> </li> <li> <p>The user agent must <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-afterprint>afterprint</code> at the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code> that is being printed, as well as any <a href=#nested-browsing-context title="nested browsing context">nested browsing contexts</a> in it.</p> <p class=example>The <code title=event-afterprint>afterprint</code> event can be used to revert annotations added in the earlier event, as well as showing post-printing UI. For instance, if a page is walking the user through the steps of applying for a home loan, the script could automatically advance to the next step after having printed a form or other.</p> </li> </ol></div> <h4 id=dialogs-implemented-using-separate-documents><span class=secno>7.4.3 </span>Dialogs implemented using separate documents</h4> <dl class=domintro><dt><var title="">result</var> = <var title="">window</var> . <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog</a></code>(<var title="">url</var> [, <var title="">argument</var>] )</dt> <dd> <p>Prompts the user with the given page, waits for that page to close, and returns the return value.</p> <p>A call to the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method is implied when this method is invoked.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-showmodaldialog title=dom-showModalDialog><code>showModalDialog(<var title="">url</var>, <var title="">argument</var><!--, <var title="">features</var>-->)</code></dfn> method, when invoked, must cause the user agent to run the following steps:</p> <ol><li> <p><a href=#resolve-a-url title="resolve a url">Resolve</a> <var title="">url</var> relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>.</p> <p>If this fails, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps.</p> </li> <li> <p>Release the <a href=#storage-mutex>storage mutex</a>.</p> </li> <li> <p>If the user agent is configured such that this invocation of <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> is somehow disabled, then return the empty string and abort these steps.</p> <p class=note>User agents are expected to disable this method in certain cases to avoid user annoyance (e.g. as part of their popup blocker feature). For instance, a user agent could require that a site be white-listed before enabling this method, or the user agent could be configured to only allow one modal dialog at a time.</p> </li> <li> <p>If the current browsing context had the <a href=#sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> set when its <a href=#active-document>active document</a> was created, then return the empty string and abort these steps.</p> </li> <li> <p>Let <var title="">the list of background browsing contexts</var> be a list of all the browsing contexts that:</p> <ul><li>are part of the same <a href=#unit-of-related-browsing-contexts>unit of related browsing contexts</a> as the browsing context of the <code><a href=#window>Window</a></code> object on which the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method was called, and that</li> <li>have an <a href=#active-document>active document</a> whose <a href=#origin>origin</a> is the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <a href=#concept-script title=concept-script>script</a> that called the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method at the time the method was called,</li> <!-- Note that changing document.domain to talk to another domain doesn't make you able to block that domain --> </ul><p>...as well as any browsing contexts that are nested inside any of the browsing contexts matching those conditions.</p> </li> <li> <p>Disable the user interface for all the browsing contexts in <var title="">the list of background browsing contexts</var>. This should prevent the user from navigating those browsing contexts, causing events to be sent to those browsing context, or editing any content in those browsing contexts. However, it does not prevent those browsing contexts from receiving events from sources other than the user, from running scripts, from running animations, and so forth.</p> </li> <li> <p>Create a new <a href=#auxiliary-browsing-context>auxiliary browsing context</a>, with the <a href=#opener-browsing-context>opener browsing context</a> being the browsing context of the <code><a href=#window>Window</a></code> object on which the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method was called. The new auxiliary browsing context has no name.</p> <p class=note>This <a href=#browsing-context>browsing context</a>'s <code><a href=#document>Document</a></code>s' <code><a href=#window>Window</a></code> objects all implement the <code><a href=#windowmodal>WindowModal</a></code> interface.</p> </li> <li> <p>Let the <a href=#dialog-arguments>dialog arguments</a> of the new browsing context be set to the value of <var title="">argument</var>, or the 'undefined' value if the argument was omitted.</p> </li> <li> <p>Let the <a href="#dialog-arguments'-origin">dialog arguments' origin</a> be the <a href=#origin>origin</a> of the <a href=#concept-script title=concept-script>script</a> that called the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method.</p> </li> <li> <p><a href=#navigate>Navigate</a><!--DONAV showModalDialog--> the new <a href=#browsing-context>browsing context</a> to the <a href=#absolute-url>absolute URL</a> that resulted from <a href=#resolve-a-url title="resolve a url">resolving</a> <var title="">url</var> earlier, with <a href=#replacement-enabled>replacement enabled</a>, and with the <a href="#script's-browsing-context" title="script's browsing context">browsing context</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the method as the <a href=#source-browsing-context>source browsing context</a>.</p> </li> <li> <p><a href=#spin-the-event-loop>Spin the event loop</a> until the new <a href=#browsing-context>browsing context</a> is closed. (The user agent must allow the user to indicate that the <a href=#browsing-context>browsing context</a> is to be closed.)</p> </li> <li> <p>Reenable the user interface for all the browsing contexts in <var title="">the list of background browsing contexts</var>.</p> </li> <li> <p>Return the <a href=#auxiliary-browsing-context>auxiliary browsing context</a>'s <a href=#return-value>return value</a>.</p> </li> </ol><p>The <code><a href=#window>Window</a></code> objects of <code><a href=#document>Document</a></code>s hosted by <a href=#browsing-context title="browsing context">browsing contexts</a> created by the above algorithm must also implement the <code><a href=#windowmodal>WindowModal</a></code> interface.</p> <p class=note>When this happens, the members of the <code><a href=#windowmodal>WindowModal</a></code> interface, in JavaScript environments, appear to actually be part of the <code><a href=#window>Window</a></code> interface (e.g. they are on the same prototype chain as the <code title=dom-alert><a href=#dom-alert>window.alert()</a></code> method).</p> </div> <pre class=idl>[NoInterfaceObject] interface <dfn id=windowmodal>WindowModal</dfn> { readonly attribute any <a href=#dom-windowmodal-dialogarguments title=dom-WindowModal-dialogArguments>dialogArguments</a>; attribute DOMString <a href=#dom-windowmodal-returnvalue title=dom-WindowModal-returnValue>returnValue</a>; };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-WindowModal-dialogArguments><a href=#dom-windowmodal-dialogarguments>dialogArguments</a></code></dt> <dd> <p>Returns the <var title="">argument</var> argument that was passed to the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method.</p> </dd> <dt><var title="">window</var> . <code title=dom-WindowModal-returnValue><a href=#dom-windowmodal-returnvalue>returnValue</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the current return value for the window.</p> <p>Can be set, to change the value that will be returned by the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method.</p> </dd> </dl><div class=impl> <p>Such browsing contexts have associated <dfn id=dialog-arguments>dialog arguments</dfn>, which are stored along with the <dfn id="dialog-arguments'-origin">dialog arguments' origin</dfn>. These values are set by the <code title=dom-showModalDialog><a href=#dom-showmodaldialog>showModalDialog()</a></code> method in the algorithm above, when the browsing context is created, based on the arguments provided to the method.</p> <p>The <dfn id=dom-windowmodal-dialogarguments title=dom-WindowModal-dialogArguments><code>dialogArguments</code></dfn> IDL attribute, on getting, must check whether its browsing context's <a href=#active-document>active document</a>'s <a href=#origin>origin</a> is the <a href=#same-origin title="same origin">same</a> as the <a href="#dialog-arguments'-origin">dialog arguments' origin</a>. If it is, then the browsing context's <a href=#dialog-arguments>dialog arguments</a> must be returned unchanged. Otherwise, if the <a href=#dialog-arguments>dialog arguments</a> are an object, then the empty string must be returned, and if the <a href=#dialog-arguments>dialog arguments</a> are not an object, then the stringification of the <a href=#dialog-arguments>dialog arguments</a> must be returned. <p>These browsing contexts also have an associated <dfn id=return-value>return value</dfn>. The <a href=#return-value>return value</a> of a browsing context must be initialized to the empty string when the browsing context is created.</p> <p>The <dfn id=dom-windowmodal-returnvalue title=dom-WindowModal-returnValue><code>returnValue</code></dfn> IDL attribute, on getting, must return the <a href=#return-value>return value</a> of its browsing context, and on setting, must set the <a href=#return-value>return value</a> to the given new value.</p> </div> <p class=note>The <code title=dom-window-close><a href=#dom-window-close>window.close()</a></code> method can be used to close the browsing context.</p> <h3 id=system-state-and-capabilities><span class=secno>7.5 </span>System state and capabilities</h3> <h4 id=the-navigator-object><span class=secno>7.5.1 </span>The <code><a href=#navigator>Navigator</a></code> object</h4> <div class=impl> <p>The <dfn id=dom-navigator title=dom-navigator><code>navigator</code></dfn> attribute of the <code><a href=#window>Window</a></code> interface must return an instance of the <code><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 and content handlers:</p> </div> <pre class=idl>interface <dfn id=navigator>Navigator</dfn> { // objects implementing this interface also implement the interfaces given below }; <a href=#navigator>Navigator</a> implements <a href=#navigatorid>NavigatorID</a>; <a href=#navigator>Navigator</a> implements <a href=#navigatoronline>NavigatorOnLine</a>; <a href=#navigator>Navigator</a> implements <a href=#navigatorcontentutils>NavigatorContentUtils</a>; <a href=#navigator>Navigator</a> implements <a href=#navigatorstorageutils>NavigatorStorageUtils</a>;</pre> <!-- v2: cookieEnabled geolocator javaEnabled mozIsLocallyAvailable preference readonly attribute <span>MimeTypeArray</span> <span title="dom-navigator-mimeTypes">mimeTypes</span>; readonly attribute <span>PluginArray</span> <span title="dom-navigator-plugins">plugins</span>; (the latter is used in a <video> element demo now, so we might need to pull this forward from v2!) --> <div class=impl> <p>These interfaces are defined separately so that other specifications can re-use parts of the <code><a href=#navigator>Navigator</a></code> interface.</p> <!-- v2: also, could expose languages: <dt><dfn title="dom-navigator-browserLanguage"><code>browserLanguage</code></dfn></dt> <!- - Opera and IE only - -> <dd><p>Must return either null or a language tag representing the language the browser uses in its interface.</p></dd> <dt><dfn title="dom-navigator-userLanguage"><code>userLanguage</code></dfn></dt> <!- - Opera and IE only - -> <dt><dfn title="dom-navigator-language"><code>language</code></dfn></dt> <!- - Opera, Safari, and Mozilla only - -> <dd><p>Must return either null or a language tag representing the user's preferred language.</p></dd> --> </div> <h5 id=client-identification><span class=secno>7.5.1.1 </span>Client identification</h5> <pre class=idl>[NoInterfaceObject] interface <dfn id=navigatorid>NavigatorID</dfn> {<!-- readonly attribute DOMString <span title="dom-navigator-appCodeName">appCodeName</span>;--> readonly attribute DOMString <a href=#dom-navigator-appname title=dom-navigator-appName>appName</a>; readonly attribute DOMString <a href=#dom-navigator-appversion title=dom-navigator-appVersion>appVersion</a>; readonly attribute DOMString <a href=#dom-navigator-platform title=dom-navigator-platform>platform</a>; readonly attribute DOMString <a href=#dom-navigator-useragent title=dom-navigator-userAgent>userAgent</a>; };</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>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 title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-appName><a href=#dom-navigator-appname>appName</a></code></dt> <dd> <p>Returns the name of the browser.</p> </dd> <dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-appVersion><a href=#dom-navigator-appversion>appVersion</a></code></dt> <dd> <p>Returns the version of the browser.</p> </dd> <dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-platform><a href=#dom-navigator-platform>platform</a></code></dt> <dd> <p>Returns the name of the platform.</p> </dd> <dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-userAgent><a href=#dom-navigator-useragent>userAgent</a></code></dt> <dd> <p>Returns the complete User-Agent header.</p> </dd> </dl><div class=impl> <dl><!-- redundant <dt><dfn title="dom-navigator-appCodeName"><code>appCodeName</code></dfn></dt> <dd><p>Must return the string "<code title="">Mozilla</code>".</p></dd> --><!-- appMinorVersion: IE only. In IE8b1, returns " Beta" (with the space) --><dt><dfn id=dom-navigator-appname title=dom-navigator-appName><code>appName</code></dfn></dt> <dd><p>Must return either the string "<code title="">Netscape</code>" or the full name of the browser, e.g. "<code title="">Mellblom Browsernator</code>".</dd> <dt><dfn id=dom-navigator-appversion title=dom-navigator-appVersion><code>appVersion</code></dfn></dt> <dd><p>Must return either the string "<code title="">4.0</code>" or a string representing the version of the browser in detail, e.g. "<code title="">1.0 (VMS; en-US) Mellblomenator/9000</code>".</dd> <!-- buildID: Mozilla only --> <!-- oscpu: Mozilla only --> <dt><dfn id=dom-navigator-platform title=dom-navigator-platform><code>platform</code></dfn></dt> <dd><p>Must return either the empty string or a string representing the platform on which the browser is executing, e.g. "<code title="">MacIntel</code>", "<code title="">Win32</code>", "<code title="">FreeBSD i386</code>", "<code title="">WebTV OS</code>".</dd> <!-- product: Mozilla and Safari only; always returns "Gecko" --> <!-- productSub: Mozilla and Safari only; returns same as buildID in Mozilla, and returns the fixed string "20030107" in Safari --> <!-- securityPolicy: Mozilla only; always returns "" --> <!-- taintEnabled(): Opera, IE and Mozilla have this function as one that always returns false --> <dt><dfn id=dom-navigator-useragent title=dom-navigator-userAgent><code>userAgent</code></dfn></dt> <dd><p>Must return the string used for the value of the "<code title="">User-Agent</code>" header in HTTP requests, or the empty string if no such header is ever sent.</dd> <!-- vendor: Mozilla and Safari only; always returns "" in Mozilla, and returns the fixed string "Apple Computer, Inc." in Safari --> <!-- vendorSub: Mozilla and Safari only; always returns "" --> </dl><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 implementors are strongly urged to include as little information in this API as possible.</p> </div> <h5 id=custom-handlers><span class=secno>7.5.1.2 </span>Custom scheme and content handlers</h5> <pre class=idl>[NoInterfaceObject] interface <dfn id=navigatorcontentutils>NavigatorContentUtils</dfn> { // content handler registration void <a href=#dom-navigator-registerprotocolhandler title=dom-navigator-registerProtocolHandler>registerProtocolHandler</a>(DOMString scheme, DOMString url, DOMString title); void <a href=#dom-navigator-registercontenthandler title=dom-navigator-registerContentHandler>registerContentHandler</a>(DOMString mimeType, DOMString url, DOMString title); DOMString <a href=#dom-navigator-isprotocolhandlerregistered title=dom-navigator-isProtocolHandlerRegistered>isProtocolHandlerRegistered</a>(DOMString scheme, DOMString url); DOMString <a href=#dom-navigator-iscontenthandlerregistered title=dom-navigator-isContentHandlerRegistered>isContentHandlerRegistered</a>(DOMString mimeType, DOMString url); void <a href=#dom-navigator-unregisterprotocolhandler title=dom-navigator-unregisterProtocolHandler>unregisterProtocolHandler</a>(DOMString scheme, DOMString url); void <a href=#dom-navigator-unregistercontenthandler title=dom-navigator-unregisterContentHandler>unregisterContentHandler</a>(DOMString mimeType, DOMString url); };</pre> <p>The <dfn id=dom-navigator-registerprotocolhandler title=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>sms:</code> scheme, so that if the user clicks on such a link, he is given the opportunity to use that Web site. Analogously, the <dfn id=dom-navigator-registercontenthandler title=dom-navigator-registerContentHandler><code>registerContentHandler()</code></dfn> method allows Web sites to register themselves as possible handlers for content in a particular <a href=#mime-type>MIME type</a>. For example, the same online telephone messaging service could register itself as a handler for <code>text/vcard</code> files, so that if the user has no native application capable of handling vCards, his Web browser can instead suggest he use that site to view contact information stored on vCards that he opens. <a href=#refsRFC5724>[RFC5724]</a> <a href=#refsRFC6350>RFC6350</a></p> <dl class=domintro><dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-registerProtocolHandler><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler</a></code>(<var title="">scheme</var>, <var title="">url</var>, <var title="">title</var>)</dt> <dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler</a></code>(<var title="">mimeType</var>, <var title="">url</var>, <var title="">title</var>)</dt> <dd> <p>Registers a handler for the given scheme or content type, at the given URL, with the given title.</p> <p>The string "<code title="">%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 <code><a href=#securityerror>SecurityError</a></code> exception 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 <code><a href=#syntaxerror>SyntaxError</a></code> if the "<code title="">%s</code>" string is missing in the URL.</p> </dd> </dl><div class=impl> <p>User agents may, within the constraints described in this section, do whatever they like when the methods are 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 his 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 methods 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 raised. (So the exceptions for the first argument take precedence over the exceptions for the second argument.)</p> <dl><dt><var title="">scheme</var> (<code title=dom-navigator-registerProtocolHandler><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code> only)</dt> <dd> <p>A scheme, such as <code>mailto</code> or <code>web+auth</code>. The scheme must be compared in an <a href=#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 title="">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 title=dom-navigator-registerProtocolHandler><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code> method is invoked with a scheme that is neither a <a href=#whitelisted-scheme>whitelisted scheme</a> nor a scheme whose value starts with the substring "<code title="">web+</code>" and otherwise contains only characters in the range U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, the user agent must throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p>The following schemes are the <dfn id=whitelisted-scheme title="whitelisted scheme">whitelisted schemes</dfn>:</p> <ul class=brief><li><code title="">irc</code></li> <li><code title="">mailto</code></li> <li><code title="">mms</code></li> <li><code title="">news</code></li> <li><code title="">nntp</code></li> <li><code title="">sms</code></li> <li><code title="">smsto</code></li> <li><code title="">tel</code></li> <li><code title="">urn</code></li> <li><code title="">webcal</code></li> </ul><p class=note>This list can be changed. If there are schemes that should be added, please send feedback.</p> </dd> <dt><var title="">mimeType</var> (<code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code> only)</dt> <dd> <p>A <a href=#mime-type>MIME type</a>, such as <code>model/vnd.flatland.3dml</code> or <code>application/vnd.google-earth.kml+xml</code>. The <a href=#mime-type>MIME type</a> must be compared in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner by user agents for the purposes of comparing with MIME types of documents that they consider against the list of registered handlers.</p> <p>User agents must compare the given values only to the MIME type/subtype parts of content types, not to the complete type including parameters. Thus, if <var title="">mimeType</var> values passed to this method include characters such as commas or whitespace, or include MIME parameters, then the handler being registered will never be used.</p> <p class=note>The type is compared to the <a href=#mime-type>MIME type</a> used by the user agent <em>after</em> the sniffing algorithms have been applied.</p> <p>If the <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code> method is invoked with a <a href=#mime-type>MIME type</a> that is in the <a href=#type-blacklist>type blacklist</a> or that the user agent has deemed a privileged type, the user agent must throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p>The following <a href=#mime-type title="MIME type">MIME types</a> are in the <dfn id=type-blacklist>type blacklist</dfn>:</p> <ul class=brief><li><code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code></li> <li><code><a href=#application/xhtml+xml>application/xhtml+xml</a></code></li> <li><code>application/xml</code></li> <li><code>image/gif</code></li> <li><code>image/jpeg</code></li> <li><code>image/png</code></li> <li><code>image/svg+xml</code></li> <li><code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code></li> <li><code><a href=#text/cache-manifest>text/cache-manifest</a></code></li> <li><code>text/css</code></li> <li><code><a href=#text/html>text/html</a></code></li> <li><code><a href=#text/ping>text/ping</a></code></li> <li><code>text/plain</code></li> <li><code>text/xml</code></li> <li>All types that the user agent supports displaying natively in a <a href=#browsing-context>browsing context</a> during <a href=#navigate title=navigate>navigation</a>, except for <code>application/rss+xml</code> and <code>application/atom+xml</code></li> </ul><p class=note>This list can be changed. If there are schemes that should be added, please send feedback.</p> </dd> <dt><var title="">url</var></dt> <dd> <p>A string used to build the <a href=#url>URL</a> of the page that will handle the requests.</p> <p>User agents must throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception if the <var title="">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 <code><a href=#syntaxerror>SyntaxError</a></code> if <a href=#resolve-a-url title="resolve a url">resolving</a> the <var title="">url</var> argument relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>, is not successful.</p> <p class=note>The resulting <a href=#absolute-url>absolute URL</a> would by definition not be a <a href=#valid-url>valid URL</a> as it would include the string "<code title="">%s</code>" which is not a valid component in a URL.</p> <p>User agents must throw a <code><a href=#securityerror>SecurityError</a></code> exception if the resulting <a href=#absolute-url>absolute URL</a> has an <a href=#origin>origin</a> that differs from the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a>.</p> <p class=note>This is forcibly the case if the <code title="">%s</code> placeholder is in the scheme, host, or port parts of the URL.</p> <p>The resulting <a href=#absolute-url>absolute URL</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 title="">%s</code>" in the <var title="">url</var> argument with an escaped version of the <a href=#absolute-url>absolute URL</a> of the content in question (as defined below), then <a href=#resolve-a-url title="resolve a url">resolve</a> the resulting URL, relative to the <a href="#script's-base-url" title="script's base URL">base URL</a> of the <a href=#entry-script>entry script</a> at the time the <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code> or <code title=dom-navigator-registerProtocolHandler><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code> methods were invoked, and then <a href=#navigate>navigate</a><!--DONAV user--> an appropriate <a href=#browsing-context>browsing context</a> to the resulting URL using the GET method (<a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a> for non-HTTP URLs).</p> <p>To get the escaped version of the <a href=#absolute-url>absolute URL</a> of the content in question, the user agent must replace every character in that <a href=#absolute-url>absolute URL</a> that doesn't match the <query> production defined in RFC 3986 by the percent-encoded form of that character. <a href=#refsRFC3986>[RFC3986]</a></p> <div class=example> <p>If the user had visited a site at <code title="">http://example.com/</code> that made the following call:</p> <pre>navigator.registerContentHandler('application/x-soup', 'soup?url=%s', 'SoupWeb™')</pre> <p>...and then, much later, while visiting <code title="">http://www.example.net/</code>, clicked on a link such as:</p> <pre><a href="chickenkïwi.soup">Download our Chicken Kïwi soup!</a></pre> <p>...then, assuming this <code>chickenkïwi.soup</code> file was served with the <a href=#mime-type>MIME type</a> <code>application/x-soup</code>, the UA might navigate to the following URL:</p> <pre>http://example.com/soup?url=http://www.example.net/chickenk%C3%AFwi.soup</pre> <p>This site could then fetch the <code>chickenkïwi.soup</code> file and do whatever it is that it does with soup (synthesize it and ship it to the user, or whatever).</p> </div> </dd> <dt><var title="">title</var></dt> <dd> <p>A descriptive title of the handler, which the UA might use to remind the user what the site in question is.</p> </dd> </dl><p>This section does not define how the pages registered by these methods are used, beyond the requirements on how to process the <var title="">url</var> value (see above). To some extent, the <a href=#navigate title=navigate>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> <p>UAs must not use registered content handlers to handle content that was returned as part of a non-GET transaction (or rather, as part of any non-idempotent transaction), as the remote site would not be able to fetch the same data.</p> <hr></div> <p>In addition to the registration methods, there are also methods for determining if particular handlers have been registered, and for unregistering handlers.</p> <dl class=domintro><dt><var title="">state</var> = <var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-isProtocolHandlerRegistered><a href=#dom-navigator-isprotocolhandlerregistered>isProtocolHandlerRegistered</a></code>(<var title="">scheme</var>, <var title="">url</var>)</dt> <dt><var title="">state</var> = <var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-isContentHandlerRegistered><a href=#dom-navigator-iscontenthandlerregistered>isContentHandlerRegistered</a></code>(<var title="">mimeType</var>, <var title="">url</var>)</dt> <dd> <p>Returns one of the following strings describing the state of the handler given by the arguments:</p> <dl><dt><code title="">new</code> <dd>Indicates that no attempt has been made to register the given handler (or that the handler has been unregistered). It would be appropriate to promote the availability of the handler or to just automatically register the handler. <dt><code title="">registered</code> <dd>Indicates that the given handler has been registered or that the site is blocked from registering the handler. Trying to register the handler again would have no effect. <dt><code title="">declined</code> <dd>Indicates that the given handler has been offered but was rejected. Trying to register the handler again may prompt the user again. </dl></dd> <dt><var title="">state</var> = <var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-unregisterProtocolHandler><a href=#dom-navigator-unregisterprotocolhandler>unregisterProtocolHandler</a></code>(<var title="">scheme</var>, <var title="">url</var>)</dt> <dt><var title="">state</var> = <var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-unregisterContentHandler><a href=#dom-navigator-unregistercontenthandler>unregisterContentHandler</a></code>(<var title="">mimeType</var>, <var title="">url</var>)</dt> <dd> <p>Unregisters the handler given by the arguments.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-navigator-isprotocolhandlerregistered title=dom-navigator-isProtocolHandlerRegistered><code>isProtocolHandlerRegistered()</code></dfn> method must return the <a href=#handler-state-string>handler state string</a> that most closely describes the current state of 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 href=#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 href=#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 title=proto-URL>proto-URLs</a> of the relevant handlers to find the described handler.</p> <hr><p>The <dfn id=dom-navigator-iscontenthandlerregistered title=dom-navigator-isContentHandlerRegistered><code>isContentHandlerRegistered()</code></dfn> method must return the <a href=#handler-state-string>handler state string</a> that most closely describes the current state of the handler described by the two arguments to the method, where the first argument gives the <a href=#mime-type>MIME type</a> and the second gives the string used to build the <a href=#url>URL</a> of the page that will handle the requests.</p> <p>The first argument must be compared to the <a href=#mime-type title="MIME type">MIME types</a> for which custom content handlers are registered in an <a href=#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 title=proto-URL>proto-URLs</a> of the relevant handlers to find the described handler.</p> <hr><p>The <dfn id=handler-state-string title="handler state string">handler state strings</dfn> are the following strings. Each string describes several situations, as given by the following list.</p> <dl><dt><code title="">new</code> <dd>The described handler has never been registered for the given scheme or type. <dd>The described handler was once registered for the given scheme or type, but the site has since unregistered it. If the handler were to be reregistered, the user would be notified accordingly. <dd>The described handler was once registered for the given scheme or type, but the site has since unregistered it, but the user has indicated that the site is to be blocked from registering the type again, so the user agent would ignore further registration attempts. <dt><code title="">registered</code> <dd>An attempt was made to register the described handler for the given scheme or type, but the user has not yet been notified, and the user agent would ignore further registration attempts. (Maybe the user agent batches registration requests to display them when the user requests to be notified about them, and the user has not yet requested that the user agent notify it of the previous registration attempt.) <dd>The described handler is registered for the given scheme or type (maybe, or maybe not, as the default handler). <dd>The described handler is permanently blocked from being (re)registered. (Maybe the user marked the registration attempt as spam, or blocked the site for other reasons.) <dt><code title="">declined</code> <dd>An attempt was made to register the described handler for the given scheme or type, but the user has not yet been notified; however, the user might be notified if another registration attempt were to be made. (Maybe the last registration attempt was made while the page was in the background and the user closed the page without looking at it, and the user agent requires confirmation for this registration attempt.) <dd>An attempt was made to register the described handler for the given scheme or type, but the user has not yet responded. <dd>An attempt was made to register the described handler for the given scheme or type, but the user declined the offer. The user has not indicated that the handler is to be permanently blocked, however, so another attempt to register the described handler might result in the user being prompted again. <dd>The described handler was once registered for the given scheme or type, but the user has since removed it. The user has not indicated that the handler is to be permanently blocked, however, so another attempt to register the described handler might result in the user being prompted again. </dl><hr><p>The <dfn id=dom-navigator-unregisterprotocolhandler title=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 href=#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 href=#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 title=proto-URL>proto-URLs</a> of the relevant handlers to find the described handler.</p> <hr><p>The <dfn id=dom-navigator-unregistercontenthandler title=dom-navigator-unregisterContentHandler><code>unregisterContentHandler()</code></dfn> method must unregister the handler described by the two arguments to the method, where the first argument gives the <a href=#mime-type>MIME type</a> and the second gives the string used to build the <a href=#url>URL</a> of the page that will handle the requests.</p> <p>The first argument must be compared to the <a href=#mime-type title="MIME type">MIME types</a> for which custom content handlers are registered in an <a href=#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 title=proto-URL>proto-URLs</a> of the relevant handlers to find the described handler.</p> <hr><p>The second argument of the four methods described above must be preprocessed as follows:</p> <ol><li><p>If the string does not contain the substring "<code title="">%s</code>", abort these steps. There's no matching handler.</li> <li><p><a href=#resolve-a-url title="resolve a URL">Resolve</a> the string relative to the <a href="#script's-base-url" title="script's base URL">base URL</a> of the <a href=#entry-script>entry script</a>.</li> <li><p>If this fails, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception, aborting the method.</li> <li><p>If the resoluting <a href=#absolute-url>absolute URL</a>'s <a href=#origin>origin</a> is not the <a href=#same-origin>same origin</a> as that of the <a href=#entry-script>entry script</a> throw a <a href=#securityerror>SecurityError</a> exception, aborting the method.</li> <li><p>Return the resulting <a href=#absolute-url>absolute URL</a> as the result of preprocessing the argument.</li> </ol></div> <div class=impl> <h5 id=security-and-privacy><span class=secno>7.5.1.3 </span>Security and privacy</h5> <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 <code>http</code> or <code>https</code>, 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> It is strongly recommended that user agents do 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>video/mpeg</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="">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 Content Handler". User agents should therefore use the handler's domain 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 content handler as the default handler for a content type.</li> <li>The user then browses his corporate Intranet site and accesses a document that uses that content type.</li> <li>The user agent contacts the third party and hands the third party the URL to the Intranet content.</li> </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>http://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 secure URLs.</strong> User agents should not send HTTPS URLs to third-party sites registered as content handlers, in the same way that user agents do not send <code title=http-referer>Referer</code> (sic) HTTP headers from secure sites to third-party sites.</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> </div> <div class=impl> <h5 id=sample-handler-impl><span class=secno>7.5.1.4 </span>Sample user interface</h5> <p><i>This section is non-normative.</i></p> <p>A simple implementation of this feature for a desktop Web browser might work as follows.</p> <p>The <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code> method could display a modal dialog box:</p> <p><img alt="The modal dialog box could have the title 'Content Handler Registration', and could say 'This Web page: Kittens at work http://kittens.example.org/ ...would like permission to handle files of type: application/x-meowmeow using the following Web-based application: Kittens-at-work displayer http://kittens.example.org/?show=%s Do you trust the administrators of the "kittens.example.org" domain?' with two buttons, 'Trust kittens.example.org' and 'Cancel'." height=374 src=http://images.whatwg.org/sample-content-handler-registration.png width=534></p> <p>In this dialog box, "Kittens at work" is the title of the page that invoked the method, "http://kittens.example.org/" is the URL of that page, "application/x-meowmeow" is the string that was passed to the <code title=dom-navigator-registerContentHandler><a href=#dom-navigator-registercontenthandler>registerContentHandler()</a></code> method as its first argument (<var title="">mimeType</var>), "http://kittens.example.org/?show=%s" was the second argument (<var title="">url</var>), and "Kittens-at-work displayer" was the third argument (<var title="">title</var>).</p> <p>If the user clicks the Cancel button, then nothing further happens. If the user clicks the "Trust" button, then the handler is remembered.</p> <p>When the user then attempts to fetch a URL that uses the "application/x-meowmeow" <a href=#mime-type>MIME type</a>, then it might display a dialog as follows:</p> <p><img alt="The dialog box could have the title 'Unknown File Type' and could say 'You have attempted to access:' followed by a URL, followed by a prompt such as 'How would you like FerretBrowser to handle this resource?' with three radio buttons, one saying 'Contact the FerretBrowser plugin registry to see if there is an official way to handle this resource.', one saying 'Pass this URL to a local application' with an application selector, and one saying 'Pass this URL to the "Kittens-at-work displayer" application at "kittens.example.org"', with a checkbox labeled 'Always do this for resources using the "application/x-meowmeow" type in future.', and with two buttons, 'Ok' and 'Cancel'." height=428 src=http://images.whatwg.org/sample-content-handler.png width=577></p> <p>In this dialog, the third option is the one that was primed by the site registering itself earlier.</p> <p>If the user does select that option, then the browser, in accordance with the requirements described in the previous two sections, will redirect the user to "http://kittens.example.org/?show=data%3Aapplication/x-meowmeow;base64,S2l0dGVucyBhcmUgdGhlIGN1dGVzdCE%253D".</p> <p>The <code title=dom-navigator-registerProtocolHandler><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code> method would work equivalently, but for schemes instead of unknown content types.</p> </div> <h5 id=manually-releasing-the-storage-mutex><span class=secno>7.5.1.5 </span>Manually releasing the storage mutex</h5> <pre class=idl>[NoInterfaceObject] interface <dfn id=navigatorstorageutils>NavigatorStorageUtils</dfn> { void <a href=#dom-navigator-yieldforstorageupdates title=dom-navigator-yieldForStorageUpdates>yieldForStorageUpdates</a>(); };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>yieldForStorageUpdates</a></code>()</dt> <dd> <p>If a script uses the <code title=dom-document-cookie><a href=#dom-document-cookie>document.cookie</a></code> API, or the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> API, the browser will block other scripts from accessing cookies or storage until the first script finishes. </p> <p>Calling the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code> method tells the user agent to unblock any other scripts that may be blocked, even though the script hasn't returned.</p> <p>Values of cookies and items in the <code><a href=#storage-0>Storage</a></code> objects of <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes can change after calling this method, whence its name. </p> </dd> </dl><div class=impl> <p>The <dfn id=dom-navigator-yieldforstorageupdates title=dom-navigator-yieldForStorageUpdates><code>yieldForStorageUpdates()</code></dfn> method, when invoked, must, if the <a href=#storage-mutex>storage mutex</a> is owned by the <a href=#event-loop>event loop</a> of the <a href=#concept-task title=concept-task>task</a> that resulted in the method being called, release the <a href=#storage-mutex>storage mutex</a> so that it is once again free. Otherwise, it must do nothing.</p> </div> <h4 id=the-external-interface><span class=secno>7.5.2 </span>The <code><a href=#external>External</a></code> interface</h4> <div class=impl> <p>The <dfn id=dom-external title=dom-external><code>external</code></dfn> attribute of the <code><a href=#window>Window</a></code> interface must return an instance of the <code><a href=#external>External</a></code> interface. The same object must be returned each time.</p> </div> <pre class=idl>interface <dfn id=external>External</dfn> { void <a href=#dom-external-addsearchprovider title=dom-external-AddSearchProvider>AddSearchProvider</a>(DOMString engineURL); unsigned long <a href=#dom-external-issearchproviderinstalled title=dom-external-IsSearchProviderInstalled>IsSearchProviderInstalled</a>(DOMString engineURL); };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-external><a href=#dom-external>external</a></code> . <code title=dom-external-AddSearchProvider><a href=#dom-external-addsearchprovider>AddSearchProvider</a></code>( <var title="">url</var> )</dt> <dd> <p>Adds the search engine described by the OpenSearch description document at <var title="">url</var>. <a href=#refsOPENSEARCH>[OPENSEARCH]</a></p> <p>The OpenSearch description document has to be on the same server as the script that calls this method.</p> </dd> <dt><var title="">installed</var> = <var title="">window</var> . <code title=dom-external><a href=#dom-external>external</a></code> . <code title=dom-external-IsSearchProviderInstalled><a href=#dom-external-issearchproviderinstalled>IsSearchProviderInstalled</a></code>( <var title="">url</var> )</dt> <dd> <p>Returns a value based on comparing <var title="">url</var> to the URLs of the results pages of the installed search engines.</p> <dl><dt>0 <dd>None of the installed search engines match <var title="">url</var>. <dt>1 <dd>One or more installed search engines match <var title="">url</var>, but none are the user's default search engine. <dt>2 <dd>The user's default search engine matches <var title="">url</var>. </dl><p>The <var title="">url</var> is compared to the URLs of the results pages of the installed search engines using a prefix match. Only results pages on the same domain as the script that calls this method are checked.</p> </dd> </dl><p class=note>Another way of exposing search engines using OpenSearch description documents is using a <code><a href=#the-link-element>link</a></code> element with the <code title=rel-search><a href=#link-type-search>search</a></code> link type.</p> <div class=impl> <p>The <dfn id=dom-external-addsearchprovider title=dom-external-AddSearchProvider><code>AddSearchProvider()</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>Optionally, abort these steps. User agents may implement the method as a stub method that never does anything, or may arbitrarily ignore invocations with particular arguments for security, privacy, or usability reasons.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the value of the method's first argument relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>.</li> <li><p>If this fails, abort these steps.</li> <li><p>Process the resulting <a href=#absolute-url>absolute URL</a> as the <a href=#url>URL</a> to an OpenSearch description document. <a href=#refsOPENSEARCH>[OPENSEARCH]</a></li> </ol><p>The <dfn id=dom-external-issearchproviderinstalled title=dom-external-IsSearchProviderInstalled><code>IsSearchProviderInstalled()</code></dfn> method, when invoked, must run the following steps:</p> <ol><li><p>Optionally, return 0 and abort these steps. User agents may implement the method as a stub method that never returns a non-zero value, or may arbitrarily ignore invocations with particular arguments for security, privacy, or usability reasons.</li> <li><p>If the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a> is an opaque identifier (i.e. it has no host component), then return 0 and abort these steps.</li> <li><p>Let <var title="">host1</var> be the host component of the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a>.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">scriptURL</var> argument relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>.</li> <li><p>If this fails, return 0 and abort these steps.</li> <li><p>Let <var title="">host2</var> be be the <a href=#url-host title=url-host><host></a> component of the resulting <a href=#absolute-url>absolute URL</a>.</li> <li> <p>If the longest suffix in the Public Suffix List that matches the end of <var title="">host1</var> is different than the longest suffix in the Public Suffix List that matches the end of <var title="">host2</var>, then return 0 and abort these steps. <a href=#refsPSL>[PSL]</a></p> <p>If the next domain component of <var title="">host1</var> and <var title="">host2</var> after their common suffix are not the same, then return 0 and abort these steps.</p> <p>Domain labels must be compared after applying the IDNA ToASCII algorithm to them, with both the AllowUnassigned and UseSTD3ASCIIRules flags set, in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner. <a href=#refsRFC3490>[RFC3490]</a></p> </li> <li><p>Let <var title="">search engines</var> be the list of search engines known by the user agent and made available to the user by the user agent for which the resulting <a href=#absolute-url>absolute URL</a> is a <a href=#prefix-match>prefix match</a> of the search engine's <a href=#url>URL</a>, if any. For search engines registered using OpenSearch description documents, the <a href=#url>URL</a> of the search engine corresponds to the URL given in a <code title="">Url</code> element whose <code title="">rel</code> attribute is "<code title="">results</code>" (the default). <a href=#refsOPENSEARCH>[OPENSEARCH]</a></li> <li><p>If <var title="">search engines</var> is empty, return 0 and abort these steps.</li> <li><p>If the user's default search engine (as determined by the user agent) is one of the search engines in <var title="">search engines</var>, then return 2 and abort these steps.</li> <li><p>Return 1.</li> </ol></div> <h2 id=editing><span class=secno>8 </span><dfn>User interaction</dfn></h2> <h3 id=the-hidden-attribute><span class=secno>8.1 </span>The <dfn title=attr-hidden><code>hidden</code></dfn> attribute</h3> <p>All <a href=#html-elements>HTML elements</a> may have the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> content attribute set. The <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute is a <a href=#boolean-attribute>boolean attribute</a>. When specified on an element, it indicates that the element is not yet, or is no longer, relevant. <span class=impl>User agents should not render elements that have the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute specified.</span></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> <h1>The Example Game</h1> <section id="login"> <h2>Login</h2> <form> ... <!-- calls login() once the user's credentials have been checked --> </form> <script> function login() { // switch screens document.getElementById('login').hidden = true; document.getElementById('game').hidden = false; } </script> </section> <section id="game" hidden> ... </section></pre> </div> <p>The <code title=attr-hidden><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 title=attr-hidden><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 title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code>, it is hidden from all presentations, including, for instance, screen readers.</p> <!-- for example, "<a hidden href=#content>Skip to content</a>" would be inappropriate. --> <!-- (but only add that example if you first add some more good valid examples --> <p>Elements that are not <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> should not link to or refer to elements that are <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code>.</p> <div class=example> <p>For example, it would be incorrect to use the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute to link to a section marked with the <code title=attr-hidden><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 similarly be incorrect to use the ARIA <code title=attr-aria-describedby>aria-describedby</code> attribute to refer to descriptions that are themselves <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code>. Hiding a section means that it is not applicable or relevant to anyone at the current time, so clearly it cannot be a valid description of content the user can interact with.</p> </div> <p>Elements in a section hidden by the <code title=attr-hidden><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> <div class=impl> <p>The <dfn id=dom-hidden title=dom-hidden><code>hidden</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <h3 id=activation><span class=secno>8.2 </span>Activation</h3> <!-- v2 idea: HTMLImageElement.click(x, y); or clickPoint(), if click() can't be done in IE; can this be emulated in IE by posting a synthetic mouse click event with those X and Y coords? (ack Csaba Gabor) --> <dl class=domintro><dt><var title="">element</var> . <code title=dom-click><a href=#dom-click>click</a></code>()</dt> <dd> <p>Acts as if the element was clicked.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-click title=dom-click><code>click()</code></dfn> method must <a href=#run-synthetic-click-activation-steps>run synthetic click activation steps</a> on the element.</p> </div> <h3 id=focus><span class=secno>8.3 </span>Focus</h3> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%20%0A...%3Cform%3E%3Cinput%20name%3Da%20onfocus%3D%22value%2B%3D1%3Bd.name%3D%27a%27%3Bname%3D%27d%27%3Bb.focus()%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22value%2B%3D1%3Bc.focus()%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22value%2B%3D1%3Bd.focus()%22%3E%0A%3Cinput%20name%3Dd%20onfocus%3D%22value%2B%3D1%3Ba.focus()%22%3E --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af1%20%27%3Bb.focus()%3Balert(document.activeElement.name)%3Bt.value%2B%3D%27af2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22t.value%2B%3D%27cf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27cf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27cb%20%27%3B%22%3E%0A --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%20onload%3D%22document.forms%5B0%5D.a.focus()%22%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onblur%3D%22t.value%2B%3D'ab%20'%3B%20b.focus()%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D'bf1%20'%3Ba.focus()%3Bt.value%2B%3D'bf2%20'%3B%22%20onblur%3D%22t.value%2B%3D'bb%20'%3B%22%3E --> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%3E...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab1%20%27%3Bb.focus()%3Bt.value%2B%3D%27ab2%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Ba.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E --> <!-- v2: more things to define, if no other specs define them: - define onfocus/onblur behaviour for Window - Other things to look at are IE's focus APIs (HTMLElement.setActive(), onBeforeActivate, onActivate, onBeforeDeactivate, onDeactivate): https://bugzilla.mozilla.org/show_bug.cgi?id=296471 https://bugzilla.mozilla.org/show_bug.cgi?id=296469 http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setactive.asp http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onbeforeactivate.asp --> <div class=impl> <p>When an element is <i>focused</i>, key events received by the document must be targeted at that element. There may be no element focused; when no element is focused, key events received by the document must be targeted at <a href=#the-body-element-0>the body element</a>, if there is one, or else at the <code><a href=#document>Document</a></code>'s root element, if there is one. If there is no root element, key events must not be fired.</p> <p>User agents may track focus for each <a href=#browsing-context>browsing context</a> or <code><a href=#document>Document</a></code> individually, or may support only one focused element per <a href=#top-level-browsing-context>top-level browsing context</a> — user agents should follow platform conventions in this regard.</p> <p>Which elements within a <a href=#top-level-browsing-context>top-level browsing context</a> currently have focus must be independent of whether or not the <a href=#top-level-browsing-context>top-level browsing context</a> itself has the <i>system focus</i>.</p> <p class=note>When an element is focused, the element matches the CSS <code>:focus</code> pseudo-class.</p> </div> <h4 id=sequential-focus-navigation-and-the-tabindex-attribute><span class=secno>8.3.1 </span>Sequential focus navigation and the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute</h4> <p>The <dfn id=attr-tabindex title=attr-tabindex><code>tabindex</code></dfn> content attribute specifies whether the element is focusable, whether it can be reached using sequential focus navigation, and 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.</p> <p>The <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute, if specified, must have a value that is a <a href=#valid-integer>valid integer</a>.</p> <div class=impl> <p>If the attribute is specified, it must be parsed using the <a href=#rules-for-parsing-integers>rules for parsing integers</a>. The attribute's values have the following meanings:</p> <dl><dt>If the attribute is omitted or parsing the value returns an error</dt> <dd> <p>The user agent should follow platform conventions to determine if the element is to be focusable and, if so, whether the element can be reached using sequential focus navigation, and if so, what its relative order should be.</p> </dd> <dt id=negative-tabindex>If the value is a negative integer</dt> <dd> <p>The user agent must allow the element to be focused, but should not allow the element to be reached using sequential focus navigation.</p> </dd> <dt>If the value is a zero</dt> <dd> <p>The user agent must allow the element to be focused, should allow the element to be reached using sequential focus navigation, and should follow platform conventions to determine the element's relative order.</p> </dd> <dt>If the value is greater than zero</dt> <dd> <p>The user agent must allow the element to be focused, should allow the element to be reached using sequential focus navigation, and should place the element in the sequential focus navigation order so that it is:</p> <ul><li>before any focusable element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has been omitted or whose value, when parsed, returns an error,</li> <li>before any focusable element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has a value equal to or less than zero,</li> <li>after any element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has a value greater than zero but less than the value of the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute on the element,</li> <li>after any element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has a value equal to the value of the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute on the element but that is earlier in the document in <a href=#tree-order>tree order</a> than the element,</li> <li>before any element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has a value equal to the value of the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute on the element but that is later in the document in <a href=#tree-order>tree order</a> than the element, and</li> <li>before any element whose <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute has a value greater than the value of the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute on the element.</li> </ul></dd> </dl><p>An element is <dfn id=specially-focusable>specially focusable</dfn> if the <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute's definition above defines the element to be focusable.</p> <p>An element that is <a href=#specially-focusable>specially focusable</a> but does not otherwise have an <a href=#activation-behavior>activation behavior</a> defined has an <a href=#activation-behavior>activation behavior</a> that does nothing.</p> <p class=note>This means that an element that is only focusable because of its <code title=attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute will fire a <code title=event-click><a href=#event-click>click</a></code> event in response to a non-mouse activation (e.g. hitting the "enter" key while the element is focused).</p> <p>The <dfn id=dom-tabindex title=dom-tabIndex><code>tabIndex</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the value of the <code title=attr-tabindex><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> </div> <div class=impl> <h4 id=focus-management><span class=secno>8.3.2 </span>Focus management</h4> <p>An element is <dfn id=focusable>focusable</dfn> if the user agent's default behavior allows it to be focusable or if the element is <a href=#specially-focusable>specially focusable</a>, but only if the element is either <a href=#being-rendered>being rendered</a> or <!-- CANVAS-FOCUS-FALLBACK --> is a descendant of a <code><a href=#the-canvas-element>canvas</a></code> element that <a href=#represents>represents</a> <a href=#embedded-content>embedded content</a>.</p> <p>User agents should make the following elements <a href=#focusable>focusable</a>, unless platform conventions dictate otherwise:</p> <ul><li><code><a href=#the-a-element>a</a></code> elements that have an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</li> <li><code><a href=#the-link-element>link</a></code> elements that have an <code title=attr-link-href><a href=#attr-link-href>href</a></code> attribute</li> <li><code><a href=#the-button-element>button</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute are not in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-select-element>select</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-textarea-element>textarea</a></code> elements that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a></li> <li><code><a href=#the-command-element>command</a></code> elements that do not have a <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code> attribute</li> <li>Elements with a <code title=attr-draggable><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> <li><a href=#editing-host title="editing host">Editing hosts</a></li> </ul><p>In addition, each shape that is generated for an <code><a href=#the-area-element>area</a></code> element should be <a href=#focusable>focusable</a>, unless platform conventions dictate otherwise. (A single <code><a href=#the-area-element>area</a></code> element can correspond to multiple shapes, since image maps can be reused with multiple images on a page.)</p> <p>The user agent may also make part of a <code><a href=#the-details-element>details</a></code> element's rendering focusable, to enable the element to be opened or closed using keyboard input. However, this is distinct from the <code><a href=#the-details-element>details</a></code> or <code><a href=#the-summary-element>summary</a></code> element being focusable.</p> <hr><p>The <dfn id=focusing-steps>focusing steps</dfn> are as follows:</p> <ol><li><p>If the element is not <a href=#in-a-document title="in a Document">in a <code>Document</code></a>, or if the element's <code><a href=#document>Document</a></code> has no <a href=#browsing-context>browsing context</a>, or if the element's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> has no <a href=#top-level-browsing-context>top-level browsing context</a>, then abort these steps.</p> <li><p>If focusing the element will remove the focus from another element, then run the <a href=#unfocusing-steps>unfocusing steps</a> for that element.</li> <li> <p>Make the element the currently focused element in its <a href=#top-level-browsing-context>top-level browsing context</a>.</p> <p>Some elements, most notably <code><a href=#the-area-element>area</a></code>, can correspond to more than one distinct focusable area. If a particular area was indicated when the element was focused, then that is the area that must get focus; otherwise, e.g. when using the <code title=dom-focus><a href=#dom-focus>focus()</a></code> method, the first such region in tree order is the one that must be focused.</p> </li> <li> <p>The user agent may apply relevant platform-specific conventions for focusing widgets.</p> <p class=note>For example, some platforms select the contents of a text field when that field is focused.</p> </li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-focus>focus</code> at the element.</li> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/723 --> </ol><p>User agents must synchronously run the <a href=#focusing-steps>focusing steps</a> for an element whenever the user moves the focus to a <a href=#focusable>focusable</a> element.</p> <p>The <dfn id=unfocusing-steps>unfocusing steps</dfn> are as follows:</p> <ol><li><p>If the element is an <code><a href=#the-input-element>input</a></code> element, and the <code title=event-input-change><a href=#event-input-change>change</a></code> event applies to the element, and the element does not have a defined <a href=#activation-behavior>activation behavior</a>, and the user has changed the element's <a href=#concept-fe-value title=concept-fe-value>value</a> or its list of <a href=#concept-input-type-file-selected title=concept-input-type-file-selected>selected files</a> while the control was focused without committing that change, then <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at the element.</p> <li><p>Unfocus the element.</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-blur>blur</code> at the element.</li> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/723 --> </ol><p>When an element that is focused stops being a <a href=#focusable>focusable</a> element, or stops being focused without another element being explicitly focused in its stead, the user agent should synchronously run the <a href=#focusing-steps>focusing steps</a> for <a href=#the-body-element-0>the body element</a>, if there is one; if there is not, then the user agent should synchronously run the <a href=#unfocusing-steps>unfocusing steps</a> for the affected element only.</p> <p class=example>For example, this might happen because the element is removed from its <code><a href=#document>Document</a></code>, or has a <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute added. It would also happen to an <code><a href=#the-input-element>input</a></code> element when the element gets <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>.</p> </div> <h4 id=document-level-focus-apis><span class=secno>8.3.3 </span>Document-level focus APIs</h4> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-activeElement><a href=#dom-document-activeelement>activeElement</a></code></dt> <dd> <p>Returns the currently focused element.</p> </dd> <dt><var title="">document</var> . <code title=dom-document-hasFocus><a href=#dom-document-hasfocus>hasFocus</a></code>()</dt> <dd> <p>Returns true if the document has focus; otherwise, returns false.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-focus><a href=#dom-window-focus>focus</a></code>()</dt> <dd> <p>Focuses the window. Use of this method is discouraged. Allow the user to control window focus instead.</p> </dd> <dt><var title="">window</var> . <code title=dom-window-blur><a href=#dom-window-blur>blur</a></code>()</dt> <dd> <p>Unfocuses the window. Use of this method is discouraged. Allow the user to control window focus instead.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-document-activeelement title=dom-document-activeElement><code>activeElement</code></dfn> attribute on <code><a href=#document>Document</a></code> objects must return the element in the document that is focused. If no element in the <code><a href=#document>Document</a></code> is focused, this must return <a href=#the-body-element-0>the body element</a>.</p> <p>The <dfn id=dom-document-hasfocus title=dom-document-hasFocus><code>hasFocus()</code></dfn> method on <code><a href=#document>Document</a></code> objects must return true if the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> is focused, and all its <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor browsing contexts</a> are also focused, and the <a href=#top-level-browsing-context>top-level browsing context</a> has the <i>system focus</i>. If the <code><a href=#document>Document</a></code> has no <a href=#browsing-context>browsing context</a> or if its <a href=#browsing-context>browsing context</a> has no <a href=#top-level-browsing-context>top-level browsing context</a>, then the method will always return false.</p> <p>The <dfn id=dom-window-focus title=dom-window-focus><code>focus()</code></dfn> method on the <code><a href=#window>Window</a></code> object, when invoked, provides a hint to the user agent that the script believes the user might be interested in the contents of the <a href=#browsing-context>browsing context</a> of the <code><a href=#window>Window</a></code> object on which the method was invoked.</p> <p>User agents are encouraged to have this <code title=dom-window-focus><a href=#dom-window-focus>focus()</a></code> method trigger some kind of notification.</p> <p>The <dfn id=dom-window-blur title=dom-window-blur><code>blur()</code></dfn> method on the <code><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>browsing context</a> of the <code><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 title=dom-window-blur><a href=#dom-window-blur>blur()</a></code> method entirely.</p> <p class=note>Historically the <code title=dom-window-blur><a href=#dom-window-blur>focus()</a></code> and <code title=dom-window-blur><a href=#dom-window-blur>blur()</a></code> methods actually affected the system focus, but hostile sites widely abuse this behavior to the user's detriment.</p> </div> <h4 id=element-level-focus-apis><span class=secno>8.3.4 </span>Element-level focus APIs</h4> <dl class=domintro><dt><var title="">element</var> . <code title=dom-focus><a href=#dom-focus>focus</a></code>()</dt> <dd> <p>Focuses the element.</p> </dd> <dt><var title="">element</var> . <code title=dom-blur><a href=#dom-blur>blur</a></code>()</dt> <dd> <p>Unfocuses the element. Use of this method is discouraged. Focus another element instead.</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 'outline' property. (Be aware, however, that this makes the page significantly less usable for some people, especially 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, you could use:</p> <pre>:link:focus, :visited:focus { outline: none; }</pre> </div> </dd> </dl><div class=impl> <p>The <dfn id=dom-focus title=dom-focus><code>focus()</code></dfn> method, when invoked, must run the following algorithm:</p> <ol><li><p>If the element is marked as <i><a href=#locked-for-focus>locked for focus</a></i>, then abort these steps.</li> <li><p>If the element is not <a href=#focusable>focusable</a>, then abort these steps.</li> <li><p>Mark the element as <dfn id=locked-for-focus>locked for focus</dfn>.</li> <li><p>If the element is not already focused, run the <a href=#focusing-steps>focusing steps</a> for the element.</li> <li><p>Unmark the element as <i><a href=#locked-for-focus>locked for focus</a></i>.</li> </ol><p>The <dfn id=dom-blur title=dom-blur><code>blur()</code></dfn> method, when invoked, should run the <a href=#focusing-steps>focusing steps</a> for <a href=#the-body-element-0>the body element</a>, if there is one; if there is not, then it should run the <a href=#unfocusing-steps>unfocusing steps</a> for the element on which the method was called instead. User agents may selectively or uniformly ignore calls to this method for usability reasons.</p> <p class=example>For example, if the <code title=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> </div> <h3 id=assigning-keyboard-shortcuts><span class=secno>8.4 </span>Assigning keyboard shortcuts</h3> <h4 id=introduction-8><span class=secno>8.4.1 </span>Introduction</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 title=attr-accesskey><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 title=attr-accesskey><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 title=attr-accesskey><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 title=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><input type=button value=Collect onclick="collect()" <strong>accesskey="C 1"</strong> id=c></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>function addShortcutKeyLabel(button) { <strong> if (button.accessKeyLabel != '') button.value += ' (' + button.accessKeyLabel + ')';</strong> } addShortcutKeyLabel(document.getElementById('c'));</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 title=dom-accessKeyLabel><a href=#dom-accesskeylabel>accessKeyLabel</a></code> IDL attribute.</p> </div> <h4 id=the-accesskey-attribute><span class=secno>8.4.2 </span>The <dfn title=attr-accesskey><code>accesskey</code></dfn> attribute</h4> <p>All <a href=#html-elements>HTML elements</a> may have the <code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code> content attribute set. The <code title=attr-accesskey><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>ordered set of unique space-separated tokens</a> that are <a href=#case-sensitive>case-sensitive</a>, each of which must be exactly one Unicode 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><nav> <p> <a title="Consortium Activities" accesskey="A" href="/Consortium/activities">Activities</a> | <a title="Technical Reports and Recommendations" accesskey="T" href="/TR/">Technical Reports</a> | <a title="Alphabetical Site Index" accesskey="S" href="/Consortium/siteindex">Site Index</a> | <a title="About This Site" accesskey="B" href="/Consortium/">About Consortium</a> | <a title="Contact Consortium" accesskey="C" href="/Consortium/contact">Contact</a> </p> </nav></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><form action="/search"> <label>Search: <input type="search" name="q" accesskey="s 0"></label> <input type="submit"> </form></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><input type=submit accesskey="N @ 1" value="Compose"> ... <script> function labelButton(button) { if (button.accessKeyLabel) button.value += ' (' + button.accessKeyLabel + ')'; } var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i += 1) { if (inputs[i].type == "submit") labelButton(inputs[i]); } </script></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>assigned access key</a> is, and on how the user agent represents that key combination.</p> </div> <div class=impl> <h4 id=processing-model-3><span class=secno>8.4.3 </span>Processing model</h4> <p>An element's <dfn id=assigned-access-key>assigned access key</dfn> is a key combination derived from the element's <code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code> content attribute. Initially, an element must not have an <a href=#assigned-access-key>assigned access key</a>.</p> <p>Whenever an element's <code title=attr-accesskey><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>assigned access key</a> by running the following steps:</p> <ol><li><p>If the element has no <code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code> attribute, then skip to the <i>fallback</i> step below.</li> <li><p>Otherwise, <a href=#split-a-string-on-spaces title="split a string on spaces">split the attribute's value on spaces</a>, and let <var title="">keys</var> be the resulting tokens.</li> <li> <p>For each value in <var title="">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 Unicode code point in length, then skip the remainder of these steps for this value.</li> <li><p>If the value does not correspond to a key on the system's keyboard, then skip the remainder of these steps for this value.</li> <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>assigned access key</a> and abort these steps.</li> </ol></li> <li><p><i>Fallback</i>: Optionally, the user agent may assign a key combination of its choosing as the element's <a href=#assigned-access-key>assigned access key</a> and then abort these steps.</li> <li><p>If this step is reached, the element has no <a href=#assigned-access-key>assigned access key</a>.</li> </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>assigned access key</a> unless the <code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code> content attribute is changed or the element is moved to another <code><a href=#document>Document</a></code>.</p> <p>When the user presses the key combination corresponding to the <a href=#assigned-access-key>assigned access key</a> for an element, if the element <a href=#concept-command title=concept-command>defines a command</a>, the command's <a href=#command-facet-hiddenstate title=command-facet-HiddenState>Hidden State</a> facet is false (visible), the command's <a href=#command-facet-disabledstate title=command-facet-DisabledState>Disabled State</a> facet is also false (enabled), and the element is <a href=#in-a-document>in a <code>Document</code></a>, then the user agent must trigger the <a href=#command-facet-action title=command-facet-Action>Action</a> of the command.</p> <p class=note>User agents might expose elements that have an <code title=attr-accesskey><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> <!-- the actual conformance criteria for this is in the section that defines commands --> <hr><p>The <dfn id=dom-accesskey title=dom-accessKey><code>accessKey</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-accesskey><a href=#the-accesskey-attribute>accesskey</a></code> content attribute.</p> <p>The <dfn id=dom-accesskeylabel title=dom-accessKeyLabel><code>accessKeyLabel</code></dfn> IDL attribute must return a string that represents the element's <a href=#assigned-access-key>assigned access key</a>, if any. If the element does not have one, then the IDL attribute must return the empty string.</p> </div> <h3 id=editing-0><span class=secno>8.5 </span>Editing</h3> <h4 id=contenteditable><span class=secno>8.5.1 </span>Making document regions editable: The <code title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code> content attribute</h4> <p>The <dfn id=attr-contenteditable title=attr-contenteditable><code>contenteditable</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a> whose keywords are the empty string, <code title="">true</code>, and <code title="">false</code>. The empty string and the <code title="">true</code> keyword map to the <i>true</i> state. The <code title="">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>missing value default</i> (and the <i>invalid value default</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> <dl class=domintro><dt><var title="">element</var> . <code title=dom-contentEditable><a href=#dom-contenteditable>contentEditable</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns "<code title="">true</code>", "<code title="">false</code>", or "<code title="">inherit</code>", based on the state of the <code title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code> attribute.</p> <p>Can be set, to change that state.</p> <p>Throws a <code><a href=#syntaxerror>SyntaxError</a></code> exception if the new value isn't one of those strings.</p> </dd> <dt><var title="">element</var> . <code title=dom-isContentEditable><a href=#dom-iscontenteditable>isContentEditable</a></code></dt> <dd> <p>Returns true if the element is editable; otherwise, returns false.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-contenteditable title=dom-contentEditable><code>contentEditable</code></dfn> IDL attribute, on getting, must return the string "<code title="">true</code>" if the content attribute is set to the true state, "<code title="">false</code>" if the content attribute is set to the false state, and "<code title="">inherit</code>" otherwise. On setting, if the new value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">inherit</code>" then the content attribute must be removed, if the new value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">true</code>" then the content attribute must be set to the string "<code title="">true</code>", if the new value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">false</code>" then the content attribute must be set to the string "<code title="">false</code>", and otherwise the attribute setter must throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p> <p>The <dfn id=dom-iscontenteditable title=dom-isContentEditable><code>isContentEditable</code></dfn> IDL attribute, on getting, must return true if the element is either an <a href=#editing-host>editing host</a> or <a href=#editable>editable</a>, and false otherwise.</p> </div> <h4 id=making-entire-documents-editable:-the-designmode-idl-attribute><span class=secno>8.5.2 </span>Making entire documents editable: The <code title=dom-document-designMode><a href=#designMode>designMode</a></code> IDL attribute</h4> <div class=impl> <p>Documents have a <dfn id=designMode title=dom-document-designMode><code>designMode</code></dfn>, which can be either enabled or disabled.</p> </div> <dl class=domintro><dt><var title="">document</var> . <code title=dom-document-designMode><a href=#designMode>designMode</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns "<code title="">on</code>" if the document is editable, and "<code title="">off</code>" if it isn't.</p> <p>Can be set, to change the document's current state.</p> </dd> </dl><div class=impl> <p>The <code title=dom-document-designMode><a href=#designMode>designMode</a></code> IDL attribute on the <code><a href=#document>Document</a></code> object takes two values, "<code title="">on</code>" and "<code title="">off</code>". When it is set, the new value must be compared in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner to these two values. If it matches the "<code title="">on</code>" value, then <code title=dom-document-designMode><a href=#designMode>designMode</a></code> must be enabled, and if it matches the "<code title="">off</code>" value, then <code title=dom-document-designMode><a href=#designMode>designMode</a></code> must be disabled. Other values must be ignored.</p> <p>When <code title=dom-document-designMode><a href=#designMode>designMode</a></code> is enabled, the IDL attribute must return the value "<code title="">on</code>", and when it is disabled, it must return the value "<code title="">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 title=dom-document-designMode><a href=#designMode>designMode</a></code> disabled.</p> </div> <h4 id=best-practices-for-in-page-editors><span class=secno>8.5.3 </span>Best practices for in-page editors</h4> <p>Authors are encouraged to set the 'white-space' property on <a href=#editing-host title="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 'white-space' 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 'white-space' ('normal'), the resulting markup will either consist of "<samp>yellow&nbsp; ball</samp>" or "<samp>yellow &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 'white-space' 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 'white-space' 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>8.5.4 </span>Editing APIs</h4> <p>The definition of the terms <dfn id=active-range>active range</dfn>, <dfn id=editing-host>editing host</dfn>, and <dfn id=editable>editable</dfn>, the user interface requirements of elements that are <a href=#editing-host title="editing host">editing hosts</a> or <a href=#editable>editable</a>, and the <dfn id=execCommand title=dom-document-execCommand><code>execCommand()</code></dfn>, <dfn id=dom-document-querycommandenabled title=dom-document-queryCommandEnabled><code>queryCommandEnabled()</code></dfn>, <dfn id=dom-document-querycommandindeterm title=dom-document-queryCommandIndeterm><code>queryCommandIndeterm()</code></dfn>, <dfn id=dom-document-querycommandstate title=dom-document-queryCommandState><code>queryCommandState()</code></dfn>, <dfn id=dom-document-querycommandsupported title=dom-document-queryCommandSupported><code>queryCommandSupported()</code></dfn>, and <dfn id=dom-document-querycommandvalue title=dom-document-queryCommandValue><code>queryCommandValue()</code></dfn> methods are defined in the HTML Editing APIs specification. Text selections are defined in the DOM Range specification. The interaction of editing and the undo/redo features in user agents is defined by the UndoManager and DOM Transaction specification. <a href=#refsEDITING>[EDITING]</a> <a href=#refsDOMRANGE>[DOMRANGE]</a> <a href=#refsUNDO>[UNDO]</a></p> <!-- those might get merged in here eventually --> <h4 id=spelling-and-grammar-checking><span class=secno>8.5.5 </span>Spelling and grammar checking</h4> <div class=impl> <p>User agents can support the checking of spelling and grammar of editable text, either in form controls (such as the value of <code><a href=#the-textarea-element>textarea</a></code> elements), or in elements in an <a href=#editing-host>editing host</a> (e.g. using <code title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code>).</p> <p>For each element, user agents must establish a <dfn id=concept-spellcheck-default title=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 title=concept-spellcheck-default-true>true-by-default</dfn> <dd>The element will be checked for spelling and grammar if its contents are editable. <dt><dfn id=concept-spellcheck-default-false title=concept-spellcheck-default-false>false-by-default</dfn> <dd>The element will never be checked for spelling and grammar. <dt><dfn id=concept-spellcheck-default-inherit title=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></div> <p>The <dfn id=attr-spellcheck title=attr-spellcheck><code>spellcheck</code></dfn> attribute is an <a href=#enumerated-attribute>enumerated attribute</a> whose keywords are the empty string, <code title="">true</code> and <code title="">false</code>. The empty string and the <code title="">true</code> keyword map to the <i>true</i> state. The <code title="">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>missing value default</i> (and the <i>invalid value default</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 title=attr-spellcheck><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> <div class=impl> <hr></div> <dl class=domintro><dt><var title="">element</var> . <code title=dom-spellcheck><a href=#dom-spellcheck>spellcheck</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the element is to have its spelling and grammar checked; otherwise, returns false.</p> <p>Can be set, to override the default and set the <code title=attr-spellcheck><a href=#attr-spellcheck>spellcheck</a></code> content attribute.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-spellcheck title=dom-spellcheck><code>spellcheck</code></dfn> IDL attribute, on getting, must return true if the element's <code title=attr-spellcheck><a href=#attr-spellcheck>spellcheck</a></code> content attribute is in the <i>true</i> state, or if the element's <code title=attr-spellcheck><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 title=concept-spellcheck-default>default behavior</a> is <a href=#concept-spellcheck-default-true title=concept-spellcheck-default-true>true-by-default</a>, or if the element's <code title=attr-spellcheck><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 title=concept-spellcheck-default>default behavior</a> is <a href=#concept-spellcheck-default-inherit title=concept-spellcheck-default-inherit>inherit-by-default</a> and the element's parent element's <code title=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 title=dom-spellcheck><a href=#dom-spellcheck>spellcheck</a></code> IDL attribute is not affected by user preferences that override the <code title=attr-spellcheck><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 title=attr-spellcheck><a href=#attr-spellcheck>spellcheck</a></code> content attribute must be set to the literal string "<code title="">true</code>", otherwise it must be set to the literal string "<code title="">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 value of <code><a href=#the-input-element>input</a></code> elements to which the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute applies, whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attributes are not in the <a href=#password-state title=attr-input-type-password>Password</a> state, and that are not <i title=concept-input-immutable><a href=#concept-input-immutable>immutable</a></i> (i.e. that do not have the <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code> attribute specified and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>).</li> <li>The value of <code><a href=#the-textarea-element>textarea</a></code> elements that do not have a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute and that are not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>.</li> <li>Text in <a href=#text-node title="text node">text nodes</a> that are children of <a href=#editing-host title="editing host">editing hosts</a> or <a href=#editable>editable</a> elements.</li> <li>Text in attributes of <a href=#editable>editable</a> elements.</li> </ul><p>For text that is part of a <a href=#text-node>text node</a>, 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><a href=#the-input-element>input</a></code> and <code><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/or grammar-checking enabled, the UA must use the following algorithm:</p> <ol><!-- user override --><li>If the user has disabled the checking for this text, then the checking is disabled.</li> <li>Otherwise, if the user has forced the checking for this text to always be enabled, then the checking is enabled.</li> <!-- content attribute: on, off --> <li>Otherwise, if the element with which the text is associated has a <code title=attr-spellcheck><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> <!-- inherit, if there is one to inherit from --> <li>Otherwise, if there is an ancestor element with a <code title=attr-spellcheck><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 title=attr-spellcheck><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> <!-- default --> <li>Otherwise, if the element's <a href=#concept-spellcheck-default title=concept-spellcheck-default>default behavior</a> is <a href=#concept-spellcheck-default-true title=concept-spellcheck-default-true>true-by-default</a>, then checking is enabled.</li> <li>Otherwise, if the element's <a href=#concept-spellcheck-default title=concept-spellcheck-default>default behavior</a> is <a href=#concept-spellcheck-default-false title=concept-spellcheck-default-false>false-by-default</a>, then checking is disabled.</li> <!-- default inheritance --> <li>Otherwise, if the element's parent element has <em>its</em> checking enabled, then checking is enabled.</li> <li>Otherwise, checking is disabled.</li> </ol><p>If the checking is enabled for a word/sentence/text, the user agent should indicate spelling and/or 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><a href=#the-input-element>input</a></code> element attributes such as <code title=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><div contenteditable="true"> <span spellcheck="false" id="a">Hell</span><em>o!</em> </div></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><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><p spellcheck="true"> <label>Name: <input spellcheck=" false" id="b"></label> </p></pre> </div> </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> <h3 id=dnd><span class=secno>8.6 </span><dfn>Drag and drop</dfn></h3> <!-- v2: ideas for drag and drop: * being able to animate a drop target: > To implement this with simple interface I've proposed, events > should be handled either by existing elements (like list > items that compare their size and position of dragged element > to decide whether element should be dropped before or after) > or handled by container that would probably need to calculate > positions of it's children and create new element to show > drop target. Smooth Mac-like drag'n'drop can be implemented > by animating drop target's padding/margin. So that's quite a > bit of code that's going to be reinvented each time someone > implements reordering. <hyatt> :droptarget <hyatt> or something <hyatt> we don't support a pseudo-class for the drop target but that's a great idea <Hixie_> yeah, thinking about that too <Hixie_> :drop-target, :drop-target(above), :drop-target(below) and having ondragover be able to say "not on me, but next to me maybe" - some way to be able to match an element that is being dragged over. - some way to be able to animate an element as it goes into and out of this state (CSS transitions?), e.g. to be able to animate something "getting out of the way" to let you drop an item between others. - as an extension to the previous feature, a way to distinguish being dragged above or to the left of the drag target vs below or to the right of the drag target. * We should let drop targets communicate back to drag sources if they want to communicate. (e.g. expose Window, and thus postMessage(), on the dataTransfer object on drop.) Or maybe just use a MessagePort! We should let drag sources provide a set of options via a context menu when the drop happens. (So that, e.g., the source can know whether a capabilities URI that it is passing along is supposed to be read-write access or read-only access to the object being dragged.) We should let potential drop targets see the types (but not the contents!) of dragged data so they can establish if they care or not. (dataTransfer.hasType()) Ack: Ben Laurie (@g) * Interop with native apps. In particular, we probably want to whitelist the list of types that a Web page can see, since otherwise we'll end up exposing things like the username (if a user drags a file from their desktop, the path is exposed on some OSes). Other things listed below: DND-v2: more native support: text/html from selections, etc DND-v3: add Blob support DND-v4: add structured clone support DND-v5: add promises (should be able to say "if you accept this drop, then I can provide the File object that corresponds to it eventually") DataTransferPromise.type = 'string' or 'file' or 'blob' or 'data' .onneeddata - can wait until this fires to provide data .setData() - call this once you have data, must be the right type --> <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 title=event-mousedown>mousedown</code> event that is followed by a series of <code title=event-mousemove>mousemove</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> <div class=impl> <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 he cycles 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> </div> <h4 id=introduction-9><span class=secno>8.6.1 </span>Introduction</h4> <p><i>This section is non-normative.</i></p> <p>To make an element draggable is simple: give the element a <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> attribute, and set an event listener for <code title=event-dragstart><a href=#event-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><a href=#datatransfer>DataTransfer</a></code> object and set the allowed effects (copy, move, link, or some combination).</p> <p>For example:</p> <pre><p>What fruits do you like?</p> <ol ondragstart="dragStartHandler(event)"> <li draggable="true" data-value="fruit-apple">Apples</li> <li draggable="true" data-value="fruit-orange">Oranges</li> <li draggable="true" data-value="fruit-pear">Pears</li> </ol> <script> var internalDNDType = 'text/x-example'; // set this to something specific to your site function dragStartHandler(event) { if (event.target instanceof HTMLLIElement) { // use the element's data-value="" attribute as the value to be moving: event.dataTransfer.setData(internalDNDType, event.target.dataset.value); event.dataTransfer.effectAllowed = 'move'; // only allow moves } else { event.preventDefault(); // don't allow selection to be dragged } } </script></pre> <hr><p>To accept a drop, the drop target has to have a <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute and listen to the <code title=drop-event>drop</code> event.</p> <p>The value of the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute specifies what kind of data to accept (e.g. "<code title="">s:text/plain</code>" to accept any text strings, or "<code>f:image/png</code>" to accept a PNG image file) and what kind of feedback to give (e.g. "<code>move</code>" to indicate that the data will be moved).</p> <p class=note>Instead of using the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute, a drop target can handle the <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> event (to report whether or not the drop target is to accept the drop) and the <code title=event-dragover><a href=#event-dragover>dragover</a></code> event (to specify what feedback is to be shown to the user).</p> <p>The <code title=event-drop><a href=#event-drop>drop</a></code> event allows the actual drop to be performed. This event needs to be canceled, so that the <code title=dom-DataTransfer-DropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> attribute's value can be used by the source (otherwise it's reset).</p> <p>For example:</p> <pre><p>Drop your favorite fruits below:</p> <ol dropzone="move s:text/x-example" ondrop="dropHandler(event)"> <-- don't forget to change the "text/x-example" type to something specific to your site --> </ol> <script> var internalDNDType = 'text/x-example'; // set this to something specific to your site function dropHandler(event) { var li = document.createElement('li'); var data = event.dataTransfer.getData(internalDNDType); if (data == 'fruit-apple') { li.textContent = 'Apples'; } else if (data == 'fruit-orange') { li.textContent = 'Oranges'; } else if (data == 'fruit-pear') { li.textContent = 'Pears'; } else { li.textContent = 'Unknown Fruit'; } event.target.appendChild(li); } </script></pre> <hr><p>To remove the original element (the one that was dragged) from the display, the <code title=event-dragend><a href=#event-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><p>What fruits do you like?</p> <ol ondragstart="dragStartHandler(event)" ondragend="dragEndHandler(event)"> <em>...as before...</em> </ol> <script> function dragStartHandler(event) { // <em>...as before...</em> } function dragEndHandler(event) { // remove the dragged element event.target.parentNode.removeChild(event.target); } </script></pre> <h4 id=the-drag-data-store><span class=secno>8.6.2 </span>The drag data store</h4> <p>The data that underlies a drag-and-drop operation, known as the <dfn id=drag-data-store>drag data store</dfn>, consists of the following information:</p> <ul><li><p>A <dfn id=drag-data-store-item-list>drag data store item list</dfn>, which is a list of items representing the dragged data, each consisting of the following information:</p> <dl><dt><dfn id=the-drag-data-item-kind>The drag data item kind</dfn></dt> <dd> <p>The kind of data:</p> <dl><dt><i>Plain Unicode string</i></dt> <dd> <p>Text.</p> </dd> <!-- DND-v3: <dt><i title="">Blob</i></dt> <dd> <p>Binary data.</p> </dd> --> <dt><i title="">File</i></dt> <dd> <p>Binary data with a file name.</p> </dd> <!-- DND-v4: <dt><i>Structured object</i></dt> <dd> <p>An object that will be cloned using the <span>structured clone</span> algorithm.</p> </dd> --> </dl></dd> <dt><dfn id=the-drag-data-item-type-string>The drag data item type string</dfn></dt> <dd> <p>A Unicode string giving the type or format of the data, generally given by a <a href=#mime-type>MIME type</a>. Some values that are not <a href=#mime-type title="MIME type">MIME types</a> are special-cased for legacy reasons. The API does not enforce the use of <a href=#mime-type title="MIME type">MIME types</a>; other values can be used as well. In all cases, however, the values are all <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a> by the API.</p> <p class=note>Strings that contain <a href=#space-character title="space character">space characters</a> cannot be used with the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute, so authors are encouraged to use only <a href=#mime-type title="MIME type">MIME types</a> or custom strings (without spaces).</p> <p>There is a limit of one <i>Plain Unicode string</i> item per <a href=#the-drag-data-item-type-string title="The drag data item type string">item type string</a>.</p> <!-- DND-v4: consider limiting the structured objects too --> </dd> <dt>The actual data</dt> <dd><p>A Unicode or binary string, in some cases with a file name (itself a Unicode string), <!-- (DND-v4:) or an object, --> as per <a href=#the-drag-data-item-kind>the drag data item kind</a>.</dd> </dl><p>The <a href=#drag-data-store-item-list>drag data store item list</a> is ordered in the order that the items were added to the list; most recently added last.</p> </li> <li> <p>The following information, used to generate the UI feedback during the drag:</p> <ul><li>User-agent-defined default feedback information, known as the <dfn id=drag-data-store-default-feedback>drag data store default feedback</dfn>.</li> <li>A list of zero or more elements known as the <dfn id=drag-data-store-elements-list>drag data store elements list</dfn>.</li> <li>Optionally, a bitmap image and the coordinate of a point within that image, known as the <dfn id=drag-data-store-bitmap>drag data store bitmap</dfn> and <dfn id=drag-data-store-hot-spot-coordinate>drag data store hot spot coordinate</dfn>.</li> </ul></li> <li> <p>A <dfn id=drag-data-store-mode>drag data store mode</dfn>, which is one of the following:</p> <dl><dt><dfn id=concept-dnd-rw title=concept-dnd-rw>Read/write mode</dfn></dt> <dd> <p>For the <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> event. New data can be added to the <a href=#drag-data-store>drag data store</a>.</p> </dd> <dt><dfn id=concept-dnd-ro title=concept-dnd-ro>Read-only mode</dfn></dt> <dd> <p>For the <code title=event-drop><a href=#event-drop>drop</a></code> event. The list of items representing dragged data can be read, including the data. No new data can be added.</p> </dd> <dt><dfn id=concept-dnd-p title=concept-dnd-p>Protected mode</dfn></dt> <dd> <p>For all other events. The formats and kinds in the <a href=#drag-data-store>drag data store</a> list of items representing dragged data can be enumerated, but the data itself is unavailable and no new data can be added.</p> </dd> </dl></li> <li> <p>A <dfn id=drag-data-store-allowed-effects-state>drag data store allowed effects state</dfn>, which is a string.</p> </li> </ul><p>When a <a href=#drag-data-store>drag data store</a> is <dfn id=create-a-drag-data-store title="create a drag data store">created</dfn>, it must be initialized such that its <a href=#drag-data-store-item-list>drag data store item list</a> is empty, it has no <a href=#drag-data-store-default-feedback>drag data store default feedback</a>, its <a href=#drag-data-store-elements-list>drag data store elements list</a> is empty, it has no <a href=#drag-data-store-bitmap>drag data store bitmap</a> / <a href=#drag-data-store-hot-spot-coordinate>drag data store hot spot coordinate</a>, its <a href=#drag-data-store-mode>drag data store mode</a> is <a href=#concept-dnd-p title=concept-dnd-p>protected mode</a>, and its <a href=#drag-data-store-allowed-effects-state>drag data store allowed effects state</a> is the string "<code title="">uninitialized</code>".</p> <h4 id=the-datatransfer-interface><span class=secno>8.6.3 </span>The <code><a href=#datatransfer>DataTransfer</a></code> interface</h4> <p><code><a href=#datatransfer>DataTransfer</a></code> objects are used to expose the <a href=#drag-data-store>drag data store</a> that underlies a drag-and-drop operation.</p> <pre class=idl>interface <dfn id=datatransfer>DataTransfer</dfn> { attribute DOMString <a href=#dom-datatransfer-dropeffect title=dom-DataTransfer-dropEffect>dropEffect</a>; attribute DOMString <a href=#dom-datatransfer-effectallowed title=dom-DataTransfer-effectAllowed>effectAllowed</a>; readonly attribute <a href=#datatransferitemlist>DataTransferItemList</a> <a href=#dom-datatransfer-items title=dom-DataTransfer-items>items</a>; void <a href=#dom-datatransfer-setdragimage title=dom-DataTransfer-setDragImage>setDragImage</a>(Element image, long x, long y); void <a href=#dom-datatransfer-addelement title=dom-DataTransfer-addElement>addElement</a>(Element element); /* old interface */ readonly attribute <a href=#domstringlist>DOMStringList</a> <a href=#dom-datatransfer-types title=dom-DataTransfer-types>types</a>; DOMString <a href=#dom-datatransfer-getdata title=dom-DataTransfer-getData>getData</a>(DOMString format); void <a href=#dom-datatransfer-setdata title=dom-DataTransfer-setData>setData</a>(DOMString format, DOMString data); void <a href=#dom-datatransfer-cleardata title=dom-DataTransfer-clearData>clearData</a>(optional DOMString format); readonly attribute <a href=#filelist>FileList</a> <a href=#dom-datatransfer-files title=dom-DataTransfer-files>files</a>; };</pre> <dl class=domintro><dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the kind of operation that is currently selected. If the kind of operation isn't one of those that is allowed by the <code title=dom-DataTransfer-effectAllowed><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 title="">none</code>", "<code title="">copy</code>", "<code title="">link</code>", and "<code title="">move</code>".</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns the kinds of operations that are to be allowed.</p> <p>Can be set, to change the allowed operations.</p> <p>The possible values are "<code title="">none</code>", "<code title="">copy</code>", "<code title="">copyLink</code>", "<code title="">copyMove</code>", "<code title="">link</code>", "<code title="">linkMove</code>", "<code title="">move</code>", "<code title="">all</code>", and "<code title="">uninitialized</code>",</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-items><a href=#dom-datatransfer-items>items</a></code></dt> <dd> <p>Returns a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object, with the drag data.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-setDragImage><a href=#dom-datatransfer-setdragimage>setDragImage</a></code>(<var title="">element</var>, <var title="">x</var>, <var title="">y</var>)</dt> <dd> <p>Uses the given element to update the drag feedback, replacing any previously specified feedback.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-addElement><a href=#dom-datatransfer-addelement>addElement</a></code>(<var title="">element</var>)</dt> <dd> <p>Adds the given element to the list of elements used to render the drag feedback.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-types><a href=#dom-datatransfer-types>types</a></code></dt> <dd> <p>Returns a <code><a href=#domstringlist>DOMStringList</a></code> listing the formats that were set in the <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> event. In addition, if any files are being dragged, then one of the types will be the string "<code title="">Files</code>".</p> </dd> <dt><var title="">data</var> = <var title="">dataTransfer</var> . <code title=dom-DataTransfer-getData><a href=#dom-datatransfer-getdata>getData</a></code>(<var title="">format</var>)</dt> <dd> <p>Returns the specified data. If there is no such data, returns the empty string.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-setData><a href=#dom-datatransfer-setdata>setData</a></code>(<var title="">format</var>, <var title="">data</var>)</dt> <dd> <p>Adds the specified data.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-clearData><a href=#dom-datatransfer-cleardata>clearData</a></code>( [ <var title="">format</var> ] )</dt> <dd> <p>Removes the data of the specified formats. Removes all data if the argument is omitted.</p> </dd> <dt><var title="">dataTransfer</var> . <code title=dom-DataTransfer-files><a href=#dom-datatransfer-files>files</a></code></dt> <dd> <p>Returns a <code><a href=#filelist>FileList</a></code> of the files being dragged, if any.</p> </dd> </dl><p><code><a href=#datatransfer>DataTransfer</a></code> objects are used during the <a href=#dndevents>drag-and-drop events</a>, and are only valid while those events are being fired.</p> <div class=impl> <p>A <code><a href=#datatransfer>DataTransfer</a></code> object is associated with a <a href=#drag-data-store>drag data store</a> while it is valid.</p> <p>The <dfn id=dom-datatransfer-dropeffect title=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><a href=#datatransfer>DataTransfer</a></code> object is created, the <code title=dom-DataTransfer-dropEffect><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 "<code title="">none</code>", "<code title="">copy</code>", "<code title="">link</code>", or "<code title="">move</code>", 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 title=dom-DataTransfer-effectAllowed><code>effectAllowed</code></dfn> attribute is used in the drag-and-drop processing model to initialize the <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> attribute during the <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> and <code title=event-dragover><a href=#event-dragover>dragover</a></code> events. When the <code><a href=#datatransfer>DataTransfer</a></code> object is created, the <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> attribute is set to a string value. On getting, it must return its current value. On setting, if the new value is one of "<code title="">none</code>", "<code title="">copy</code>", "<code title="">copyLink</code>", "<code title="">copyMove</code>", "<code title="">link</code>", "<code title="">linkMove</code>", "<code title="">move</code>", "<code title="">all</code>", or "<code title="">uninitialized</code>", 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-items title=dom-DataTransfer-items><code>items</code></dfn> attribute must return a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object associated with the <code><a href=#datatransfer>DataTransfer</a></code> object. The same object must be returned each time.</p> <p>The <dfn id=dom-datatransfer-setdragimage title=dom-DataTransfer-setDragImage><code>setDragImage(<var title="">element</var>, <var title="">x</var>, <var title="">y</var>)</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, abort these steps. Nothing happens.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is not in the <a href=#concept-dnd-rw title=concept-dnd-rw>read/write mode</a>, abort these steps. Nothing happens.</li> <li><p>If the <var title="">element</var> argument is an <code><a href=#the-img-element>img</a></code> element, then set the <a href=#drag-data-store-bitmap>drag data store bitmap</a> to the element's image (at its intrinsic size); otherwise, set the <a href=#drag-data-store-bitmap>drag data store bitmap</a> to an image generated from the given element (the exact mechanism for doing so is not currently specified).</li> <li><p>Set the <a href=#drag-data-store-hot-spot-coordinate>drag data store hot spot coordinate</a> to the given <var title="">x</var>, <var title="">y</var> coordinate.</li> </ol><p>The <dfn id=dom-datatransfer-addelement title=dom-DataTransfer-addElement><code>addElement(<var title="">element</var>)</code></dfn> method is an alternative way of specifying how the user agent is to <a href=#base-dnd-feedback>render the drag feedback</a>. The method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, abort these steps. Nothing happens.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is not in the <a href=#concept-dnd-rw title=concept-dnd-rw>read/write mode</a>, abort these steps. Nothing happens.</li> <li><p>Add the given <var title="">element</var> to the element's <a href=#drag-data-store-elements-list>drag data store elements list</a>.</li> </ol><p class=note>The difference between <code title=dom-DataTransfer-setDragImage><a href=#dom-datatransfer-setdragimage>setDragImage()</a></code> and <code title=dom-DataTransfer-addElement><a href=#dom-datatransfer-addelement>addElement()</a></code> is that the latter automatically generates the image based on the current rendering of the elements added (potentially keeping it updated as the drag continues, e.g. if the elements include an actively playing video), whereas the former uses the exact specified image at the time the method is invoked.</p> <p>The <dfn id=dom-datatransfer-types title=dom-DataTransfer-types><code>types</code></dfn> attribute must return a <a href=#live>live</a> <code><a href=#domstringlist>DOMStringList</a></code> giving the strings that the following steps would produce. The same object must be returned each time.</p> <ol><li><p>Start with an empty list <var title="">L</var>.</li> <li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, the <code><a href=#domstringlist>DOMStringList</a></code> is empty. Abort these steps; return the empty list <var title="">L</var>.</li> <li><p>For each item in the <a href=#drag-data-store-item-list>drag data store item list</a> <!-- in some order...? --> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i>, add an entry to the list <var title="">L</var> consisting of the item's <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a>.</li> <li><p>If there are any items in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i><a href=#file>File</a></i>, then add an entry to the list <var title="">L</var> consisting of the string "<code title="">Files</code>". (This value can be distinguished from the other values because it is not lowercase.)</li> <!-- <li><p>Sort the list...?</p></li> --> <li><p>The strings produced by these steps are those in the list <var title="">L</var>.</li> </ol><p>The <dfn id=dom-datatransfer-getdata title=dom-DataTransfer-getData><code>getData(<var title="">format</var>)</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, return the empty string and abort these steps.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is in the <a href=#concept-dnd-p title=concept-dnd-p>protected mode</a>, return the empty string and abort these steps.</li> <li><p>Let <var title="">format</var> be the first argument, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li><p>Let <var title="">convert-to-URL</var> be false.</li> <li><p>If <var title="">format</var> equals "<code title="">text</code>", change it to "<code title="">text/plain</code>".</li> <li><p>If <var title="">format</var> equals "<code title="">url</code>", change it to "<code title="">text/uri-list</code>" and set <var title="">convert-to-URL</var> to true.</li> <li><p>If there is no item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i> and whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to <var title="">format</var>, return the empty string and abort these steps.</li> <li><p>Let <var title="">result</var> be the data of the item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i> and whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to <var title="">format</var>.</li> <li><p>If <var title="">convert-to-URL</var> is true, then parse <var title="">result</var> as appropriate for <code title="">text/uri-list</code> data, and then set <var title="">result</var> to the first URL from the list, if any, or the empty string otherwise. <a href=#refsRFC2483>[RFC2483]</a></li> <li><p>Return <var title="">result</var>.</li> </ol><p>The <dfn id=dom-datatransfer-setdata title=dom-DataTransfer-setData><code>setData(<var title="">format</var>, <var title="">data</var>)</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, abort these steps. Nothing happens.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is not the <a href=#concept-dnd-rw title=concept-dnd-rw>read/write mode</a>, abort these steps. Nothing happens.</li> <li><p>Let <var title="">format</var> be the first argument, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li> <p>If <var title="">format</var> equals "<code title="">text</code>", change it to "<code title="">text/plain</code>".</p> <p>If <var title="">format</var> equals "<code title="">url</code>", change it to "<code title="">text/uri-list</code>".</p> </li> <li><p>Remove the item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i> and whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to <var title="">format</var>, if there is one.</li> <li><p>Add an item to the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i>, whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to <var title="">format</var>, and whose data is the string given by the method's second argument.</li> </ol><p>The <dfn id=dom-datatransfer-cleardata title=dom-DataTransfer-clearData><code>clearData()</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, abort these steps. Nothing happens.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is not the <a href=#concept-dnd-rw title=concept-dnd-rw>read/write mode</a>, abort these steps. Nothing happens.</li> <li><p>If the method was called with no arguments, remove each item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i>, and abort these steps.</li> <li><p>Let <var title="">format</var> be the first argument, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li> <p>If <var title="">format</var> equals "<code title="">text</code>", change it to "<code title="">text/plain</code>".</p> <p>If <var title="">format</var> equals "<code title="">url</code>", change it to "<code title="">text/uri-list</code>".</p> </li> <li><p>Remove the item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i> and whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to <var title="">format</var>, if there is one.</li> </ol><p class=note>The <code title=dom-DataTransfer-clearData><a href=#dom-datatransfer-cleardata>clearData()</a></code> method does not affect whether any files were included in the drag, so the <code title=dom-DataTransfer-types><a href=#dom-datatransfer-types>types</a></code> attribute's list might still not be empty after calling <code title=dom-DataTransfer-clearData><a href=#dom-datatransfer-cleardata>clearData()</a></code> (it would still contain the "<code title="">Files</code>" string if any files were included in the drag).</p> <p>The <dfn id=dom-datatransfer-files title=dom-DataTransfer-files><code>files</code></dfn> attribute must return a <a href=#live>live</a> <code><a href=#filelist>FileList</a></code> sequence consisting of <code><a href=#file>File</a></code> objects representing the files found by the following steps. The same object must be returned each time. Furthermore, for a given <code><a href=#filelist>FileList</a></code> object and a given underlying file, the same <code><a href=#file>File</a></code> object must be used each time.</p> <ol><li><p>Start with an empty list <var title="">L</var>.</li> <li><p>If the <code><a href=#datatransfer>DataTransfer</a></code> object is no longer associated with a <a href=#drag-data-store>drag data store</a>, the <code><a href=#filelist>FileList</a></code> is empty. Abort these steps; return the empty list <var title="">L</var>.</li> <li><p>If the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-mode title="drag data store mode">mode</a> is in the <a href=#concept-dnd-p title=concept-dnd-p>protected mode</a>, abort these steps; return the empty list <var title="">L</var>.</li> <li><p>For each item in the <a href=#drag-data-store-item-list>drag data store item list</a> <!-- in some order...? --> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i><a href=#file>File</a></i> <!-- DND-v3: (not <i>Blob</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 title="the drag data item type string">type</a>) to the list <var title="">L</var>.</li> <!-- <li><p>Sort the list...?</p></li> --> <li><p>The files found by these steps are those in the list <var title="">L</var>.</li> </ol><p class=note>This version of the API does not expose the types of the files during the drag.</p> </div> <h5 id=the-datatransferitemlist-interface><span class=secno>8.6.3.1 </span>The <code><a href=#datatransferitemlist>DataTransferItemList</a></code> interface</h5> <p>Each <code><a href=#datatransfer>DataTransfer</a></code> object is associated with a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object.</p> <pre class=idl>interface <dfn id=datatransferitemlist>DataTransferItemList</dfn> { readonly attribute unsigned long <a href=#dom-datatransferitemlist-length title=dom-DataTransferItemList-length>length</a>; <a href=#dom-datatransferitemlist-item title=dom-DataTransferItemList-item>getter</a> <a href=#datatransferitem>DataTransferItem</a> (unsigned long index); <a href=#dom-datatransferitemlist-removeitem title=dom-DataTransferItemList-removeItem>deleter</a> void (unsigned long index); void <a href=#dom-datatransferitemlist-clear title=dom-DataTransferItemList-clear>clear</a>(); <a href=#datatransferitem>DataTransferItem</a>? <a href=#dom-datatransferitemlist-add title=dom-DataTransferItemList-add>add</a>(DOMString data, DOMString type);<!-- DND-v3: <span>DataTransferItem</span>? <span title="dom-DataTransferItemList-add">add</span>(<span>Blob</span> data);--> <a href=#datatransferitem>DataTransferItem</a>? <a href=#dom-datatransferitemlist-add title=dom-DataTransferItemList-add>add</a>(<a href=#file>File</a> data);<!-- DND-v4: <span>DataTransferItem</span>? <span title="dom-DataTransferItemList-add">add</span>(any data, DOMString type);--><!-- DND-v5: <span>DataTransferItem</span>? <span title="dom-DataTransferItemList-add">add</span>(<span>DataTransferPromise</span> data);--> };</pre> <dl class=domintro><dt><var title="">items</var> . <code title=dom-DataTransferItemList-length><a href=#dom-datatransferitemlist-length>length</a></code></dt> <dd><p>Returns the number of items in the <a href=#drag-data-store>drag data store</a>.</dd> <dt><var title="">items</var>[<var title="">index</var>]</dt> <dd> <p>Returns the <code><a href=#datatransferitem>DataTransferItem</a></code> object representing the <var title="">index</var>th entry in the <a href=#drag-data-store>drag data store</a>.</p> </dd> <dt><code title="">delete</code> <var title="">items</var>[<var title="">index</var>]</dt> <dd> <p>Removes the <var title="">index</var>th entry in the <a href=#drag-data-store>drag data store</a>.</p> </dd> <dt><var title="">items</var> . <code title=dom-DataTransferItemList-clear><a href=#dom-datatransferitemlist-clear>clear</a></code>()</dt> <dd> <p>Removes all the entries in the <a href=#drag-data-store>drag data store</a>.</p> </dd> <dt><var title="">items</var> . <code title=dom-DataTransferItemList-add><a href=#dom-datatransferitemlist-add>add</a></code>(<var title="">data</var>)</dt> <dt><var title="">items</var> . <code title=dom-DataTransferItemList-add><a href=#dom-datatransferitemlist-add>add</a></code>(<var title="">data</var>, <var title="">type</var>)</dt> <dd> <p>Adds a new entry for the given data to the <a href=#drag-data-store>drag data store</a>. If the data is plain text <!-- DND-v4: or an object --> then a <var title="">type</var> string has to be provided also.</p> </dd> </dl><div class=impl> <p>While the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is associated with a <a href=#drag-data-store>drag data store</a>, the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object's <i>mode</i> is the same as the <a href=#drag-data-store-mode>drag data store mode</a>. When the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is <em>not</em> associated with a <a href=#drag-data-store>drag data store</a>, the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object's <i>mode</i> is the <i>disabled mode</i>. The <a href=#drag-data-store>drag data store</a> referenced in this section (which is used only when the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object is not in the <i>disabled mode</i>) is the <a href=#drag-data-store>drag data store</a> with which the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is associated.</p> <p>The <dfn id=dom-datatransferitemlist-length title=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>drag data store item list</a>.</p> <p>When a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object is not in the <i>disabled mode</i>, its <a href=#supported-property-indices>supported property indices</a> are the numbers in the range <span title="">0 .. <var title="">n</var>-1</span>, where <var title="">n</var> is the number of items in the <a href=#drag-data-store-item-list>drag data store item list</a>.</p> <p>To <dfn id=dom-datatransferitemlist-item title=dom-DataTransferItemList-item>determine the value of an indexed property</dfn> <var title="">i</var> of a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object, the user agent must return a <code><a href=#datatransferitem>DataTransferItem</a></code> object representing the <var title="">i</var>th item in the <a href=#drag-data-store>drag data store</a>. The same object must be returned each time a particular item is obtained from this <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object. The <code><a href=#datatransferitem>DataTransferItem</a></code> object must be associated with the same <code><a href=#datatransfer>DataTransfer</a></code> object as the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object when it is first created.</p> <p>To <dfn id=dom-datatransferitemlist-removeitem title=dom-DataTransferItemList-removeItem>delete an existing indexed property</dfn> <var title="">i</var> of a <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object, the user agent must run these steps:</p> <ol><li><p>If the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object is not in the <i title=concept-dnd-rw><a href=#concept-dnd-rw>read/write mode</a></i>, throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception and abort these steps.</li> <li><p>Remove the <var title="">i</var>th item from the <a href=#drag-data-store>drag data store</a>.</li> </ol><p>The <dfn id=dom-datatransferitemlist-clear title=dom-DataTransferItemList-clear><code>clear</code></dfn> method, if the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object is in the <i title=concept-dnd-rw><a href=#concept-dnd-rw>read/write mode</a></i>, must remove all the items from the <a href=#drag-data-store>drag data store</a>. Otherwise, it must do nothing.</p> <p>The <dfn id=dom-datatransferitemlist-add title=dom-DataTransferItemList-add><code>add()</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransferitemlist>DataTransferItemList</a></code> object is not in the <i title=concept-dnd-rw><a href=#concept-dnd-rw>read/write mode</a></i>, return null and abort these steps.</li> <li> <p>Jump to the appropriate set of steps from the following list:</p> <dl class=switch><dt>If the first argument to the method is a string</dt> <dd> <p>If there is already an item in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i> and whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to the value of the method's second argument, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, then throw a <code><a href=#notsupportederror>NotSupportedError</a></code> exception and abort these steps.</p> <p>Otherwise, add an item to the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i>Plain Unicode string</i>, whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is equal to the value of the method's second argument, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, and whose data is the string given by the method's first argument.</p> </dd> <!--DND-v3: <dt>If the first argument to the method is a <code>Blob</code></dt> <dd> <p>Add an item to the <span>drag data store item list</span> whose <span title="the drag data item kind">kind</span> is <i>Blob</i>, whose <span title="the drag data item type string">type string</span> is the <code title="dom-Blob-type">type</code> of the <code>Blob</code>, <span>converted to ASCII lowercase</span>, and whose data is the same as the <code>Blob</code>'s data.</p> </dd> --> <dt>If the first argument to the method is a <code><a href=#file>File</a></code></dt> <dd> <p>Add an item to the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">kind</a> is <i><a href=#file>File</a></i>, whose <a href=#the-drag-data-item-type-string title="the drag data item type string">type string</a> is the <code title=dom-Blob-type>type</code> of the <code><a href=#file>File</a></code>, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, and whose data is the same as the <code><a href=#file>File</a></code>'s data.</p> </dd> <!--DND-v4: (might want to prevent duplicates like for strings; see above) [make sure that the cloning happens before any side-effects can happen] <dt>Otherwise <dd> <p>Add an item to the <span>drag data store item list</span> whose <span title="the drag data item kind">kind</span> is <i>Object</i>, whose <span title="the drag data item type string">type string</span> is equal to the value of the method's second argument, <span>converted to ASCII lowercase</span>, and whose data is a <span>structured clone</span> of the method's first argument. If creating the clone throws an exception, then throw that exception and abort these steps.</p> </dd> --> </dl></li> <li><p><a href=#dom-datatransferitemlist-item title=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><a href=#datatransferitem>DataTransferItem</a></code> object).</li> </ol></div> <h5 id=the-datatransferitem-interface><span class=secno>8.6.3.2 </span>The <code><a href=#datatransferitem>DataTransferItem</a></code> interface</h5> <p>Each <code><a href=#datatransferitem>DataTransferItem</a></code> object is associated with a <code><a href=#datatransfer>DataTransfer</a></code> object.</p> <pre class=idl>interface <dfn id=datatransferitem>DataTransferItem</dfn> { readonly attribute DOMString <a href=#dom-datatransferitem-kind title=dom-DataTransferItem-kind>kind</a>; readonly attribute DOMString <a href=#dom-datatransferitem-type title=dom-DataTransferItem-type>type</a>; void <a href=#dom-datatransferitem-getasstring title=dom-DataTransferItem-getAsString>getAsString</a>(<a href=#functionstringcallback>FunctionStringCallback</a>? callback);<!-- DND-v3: <span>Blob</span> <span title="dom-DataTransferItem-getAsBlob">getAsBlob</span>();--> <a href=#file>File</a>? <a href=#dom-datatransferitem-getasfile title=dom-DataTransferItem-getAsFile>getAsFile</a>();<!-- DND-v4: void <span title="dom-DataTransferItem-getAsObject">getAsObject</span>(<span>FunctionObjectCallback</span> callback);--> }; [Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=functionstringcallback>FunctionStringCallback</dfn> { void <span title=dom-FunctionStringCallback-handleEvent>handleEvent</span>(DOMString data); };<!-- // DND-v4: [Callback=FunctionOnly, NoInterfaceObject] interface <dfn>FunctionObjectCallback</dfn> { void <span title="dom-FunctionObjectCallback-handleEvent">handleEvent</span>(DOMString data); };--></pre> <dl class=domintro><dt><var title="">item</var> . <code title=dom-DataTransferItem-kind><a href=#dom-datatransferitem-kind>kind</a></code></dt> <dd> <p>Returns <a href=#the-drag-data-item-kind>the drag data item kind</a>, one of: "string", <!-- DND-v3: "blob", --> "file"<!-- DND-v4: , "object" -->.</p> </dd> <dt><var title="">item</var> . <code title=dom-DataTransferItem-type><a href=#dom-datatransferitem-type>type</a></code></dt> <dd> <p>Returns <a href=#the-drag-data-item-type-string>the drag data item type string</a>.</p> </dd> <dt><var title="">item</var> . <code title=dom-DataTransferItem-getAsString><a href=#dom-datatransferitem-getasstring>getAsString</a></code>(<var title="">callback</var>)</dt> <dd> <p>Invokes the callback with the string data as the argument, if <a href=#the-drag-data-item-kind>the drag data item kind</a> is <i>Plain Unicode string</i>.</p> </dd> <!-- DND-v3: <dt><var title="">file</var> = <var title="">item</var> . <code title="dom-DataTransferItem-getAsBlob">getAsBlob</code>()</dt> <dd> <p>Returns a <code>Blob</code> object, if <span>the drag data item kind</span> is <i>Blob</i> or <i>File</i>.</p> </dd> --> <dt><var title="">file</var> = <var title="">item</var> . <code title=dom-DataTransferItem-getAsFile><a href=#dom-datatransferitem-getasfile>getAsFile</a></code>()</dt> <dd> <p>Returns a <code><a href=#file>File</a></code> object, if <a href=#the-drag-data-item-kind>the drag data item kind</a> is <i><a href=#file>File</a></i>.</p> </dd> <!-- DND-v4: <dt><var title="">file</var> = <var title="">item</var> . <code title="dom-DataTransferItem-getAsObject">getAsObject</code>()</dt> <dd> <p>Invokes the callback with the cloned object data as the argument, if <span>the drag data item kind</span> is <i>Plain Unicode string</i> or <i>Object</i>.</p> </dd> --> </dl><div class=impl> <p>While the <code><a href=#datatransferitem>DataTransferItem</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is associated with a <a href=#drag-data-store>drag data store</a> and that <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-item-list>drag data store item list</a> still contains the item that the <code><a href=#datatransferitem>DataTransferItem</a></code> object represents, the <code><a href=#datatransferitem>DataTransferItem</a></code> object's <i>mode</i> is the same as the <a href=#drag-data-store-mode>drag data store mode</a>. When the <code><a href=#datatransferitem>DataTransferItem</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is <em>not</em> associated with a <a href=#drag-data-store>drag data store</a>, or if the item that the <code><a href=#datatransferitem>DataTransferItem</a></code> object represents has been removed from the relevant <a href=#drag-data-store-item-list>drag data store item list</a>, the <code><a href=#datatransferitem>DataTransferItem</a></code> object's <i>mode</i> is the <i>disabled mode</i>. The <a href=#drag-data-store>drag data store</a> referenced in this section (which is used only when the <code><a href=#datatransferitem>DataTransferItem</a></code> object is not in the <i>disabled mode</i>) is the <a href=#drag-data-store>drag data store</a> with which the <code><a href=#datatransferitem>DataTransferItem</a></code> object's <code><a href=#datatransfer>DataTransfer</a></code> object is associated.</p> <p>The <dfn id=dom-datatransferitem-kind title=dom-DataTransferItem-kind><code>kind</code></dfn> attribute must return the empty string if the <code><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>the drag data item kind</a> of the item represented by the <code><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 title="">string</code>" <!-- DND-v3: <tr> <td> <i>Blob</i> <td> "<code title="">blob</code>"--> <tr><td> <i><a href=#file>File</a></i> <td> "<code title="">file</code>" <!-- DND-v4: <tr> <td> <i>Object</i> <td> "<code title="">object</code>"--> </table><p>The <dfn id=dom-datatransferitem-type title=dom-DataTransferItem-type><code>type</code></dfn> attribute must return the empty string if the <code><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>the drag data item type string</a> of the item represented by the <code><a href=#datatransferitem>DataTransferItem</a></code> object.</p> <p>The <dfn id=dom-datatransferitem-getasstring title=dom-DataTransferItem-getAsString><code>getAsString(<var title="">callback</var>)</code></dfn> method must run the following steps:</p> <ol><li><p>If the <var title="">callback</var> is null, abort these steps.</li> <li><p>If the <code><a href=#datatransferitem>DataTransferItem</a></code> object is not in the <i title=concept-dnd-rw><a href=#concept-dnd-rw>read/write mode</a></i> or the <i title=concept-dnd-ro><a href=#concept-dnd-ro>read-only mode</a></i>, abort these steps. The callback is never invoked.</li> <li><p>If <a href=#the-drag-data-item-kind>the drag data item kind</a> is not <i>Plain Unicode string</i>, abort these steps. The callback is never invoked.</li> <li><p>Otherwise, <a href=#queue-a-task>queue a task</a> to invoke <var title="">callback</var>, passing the actual data of the item represented by the <code><a href=#datatransferitem>DataTransferItem</a></code> object as the argument.</li> </ol><!--DND-v3: <p>The <dfn title="dom-DataTransferItem-getAsBlob"><code>getAsBlob()</code></dfn> method must run the following steps:</p> <ol> <li><p>If the <code>DataTransferItem</code> object is not in the <i title="concept-dnd-rw">read/write mode</i> or the <i title="concept-dnd-ro">read-only mode</i>, return null and abort these steps.</p></li> <li> --><!--DND-v4: <p>If <span>the drag data item kind</span> is <i>Object</i>, return null.</p></li> --><!--DND-v3: <p>If <span>the drag data item kind</span> is <i>File</i>, then return a new <code>File</code> object representing the actual data of the item represented by the <code>DataTransferItem</code> object.</p> <p>If <span>the drag data item kind</span> is <i>Unicode Data string</i>, then return a new <code>Blob</code> object representing the actual data of the item represented by the <code>DataTransferItem</code> object, with the <code title="dom-Blob-type">type</code> of the <code>Blob</code> being <span>the drag data item type string</span> and with the binary data of the <code>Blob</code> object being the Unicode string encoded as UTF-8. <a href="#refsRFC3629">[RFC3629]</a></p> <p>Otherwise, <span>the drag data item kind</span> is <i>Blob</i>; return a new <code>Blob</code> object representing the actual data of the item represented by the <code>DataTransferItem</code> object.</p> </li> </ol> --><p>The <dfn id=dom-datatransferitem-getasfile title=dom-DataTransferItem-getAsFile><code>getAsFile()</code></dfn> method must run the following steps:</p> <ol><li><p>If the <code><a href=#datatransferitem>DataTransferItem</a></code> object is not in the <i title=concept-dnd-rw><a href=#concept-dnd-rw>read/write mode</a></i> or the <i title=concept-dnd-ro><a href=#concept-dnd-ro>read-only mode</a></i>, return null and abort these steps.</li> <li><p>If <a href=#the-drag-data-item-kind>the drag data item kind</a> is not <i><a href=#file>File</a></i>, then return null and abort these steps.</li> <li><p>Return a new <code><a href=#file>File</a></code> object representing the actual data of the item represented by the <code><a href=#datatransferitem>DataTransferItem</a></code> object.</p> </ol><!--DND-v4: <p>The <dfn title="dom-DataTransferItem-getAsObject"><code>getAsObject(<var title="">callback</var>)</code></dfn> method must run the following steps:</p> <ol> <li><p>If the <code>DataTransferItem</code> object is not in the <i title="concept-dnd-rw">read/write mode</i> or the <i title="concept-dnd-ro">read-only mode</i>, return null and abort these steps.</p></li> <li> <p>Let <var title="">data</var> be the actual data of the item represented by the <code>DataTransferItem</code> object.</p> <p>If <span>the drag data item kind</span> is <i>Unicode Data string</i>, then <var title="">data</var> is a <code title="">DOMString</code> containing the actual data.</p> <p>If <span>the drag data item kind</span> is <i>Blob</i>, then <var title="">data</var> is a <code>Blob</code> representing the actual data.</p> <p>If <span>the drag data item kind</span> is <i>File</i>, then <var title="">data</var> is a <code>File</code> representing the actual data.</p> <p>If <span>the drag data item kind</span> is <i>Object</i>, then <var title="">data</var> is the object that is the actual data.</p> </li> <li><span>Queue a task</span> to invoke <var title="">callback</var>, passing a <span>structured clone</span> of <var title="">data</var> as the argument.</p></li> </ol> --></div> <h4 id=the-dragevent-interface><span class=secno>8.6.4 </span>The <code><a href=#dragevent>DragEvent</a></code> interface</h4> <p>The drag-and-drop processing model involves several events. They all use the <code><a href=#dragevent>DragEvent</a></code> interface.</p> <pre class=idl>[Constructor(DOMString type, optional <a href=#drageventinit>DragEventInit</a> eventInitDict)] interface <dfn id=dragevent>DragEvent</dfn> : <a href=#mouseevent>MouseEvent</a> { readonly attribute <a href=#datatransfer>DataTransfer</a>? <a href=#dom-dragevent-datatransfer title=dom-DragEvent-dataTransfer>dataTransfer</a>; }; dictionary <dfn id=drageventinit>DragEventInit</dfn> : <a href=#mouseeventinit>MouseEventInit</a> { <a href=#datatransfer>DataTransfer</a>? dataTransfer; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-DragEvent-dataTransfer><a href=#dom-dragevent-datatransfer>dataTransfer</a></code></dt> <dd> <p>Returns the <code><a href=#datatransfer>DataTransfer</a></code> object for the event.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-dragevent-datatransfer title=dom-DragEvent-dataTransfer><code>dataTransfer</code></dfn> attribute of the <code><a href=#dragevent>DragEvent</a></code> interface must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the context information for the event.</p> </div> <div class=impl> <p>When a user agent is required to <dfn id=fire-a-dnd-event>fire a DND event</dfn> named <var title="">e</var> at an element, using a particular <a href=#drag-data-store>drag data store</a>, the user agent must run the following steps:</p> <ol><li> <p>If <var title="">e</var> is <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code>, set the <a href=#drag-data-store-mode>drag data store mode</a> to the <a href=#concept-dnd-rw title=concept-dnd-rw>read/write mode</a>.</p> <p>If <var title="">e</var> is <code title=event-drop><a href=#event-drop>drop</a></code>, set the <a href=#drag-data-store-mode>drag data store mode</a> to the <a href=#concept-dnd-ro title=concept-dnd-ro>read-only mode</a>.</p> </li> <li><p>Let <var title="">dataTransfer</var> be a newly created <code><a href=#datatransfer>DataTransfer</a></code> object associated with the given <a href=#drag-data-store>drag data store</a>.</li> <li><p id=effectAllowed-initialization>Set the <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> attribute to the <a href=#drag-data-store>drag data store</a>'s <a href=#drag-data-store-allowed-effects-state>drag data store allowed effects state</a>.</li> <li> <p id=dropEffect-initialization>Set the <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> attribute to "<code title="">none</code>" if <var title="">e</var> is <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code>, <code title=event-drag><a href=#event-drag>drag</a></code>, or <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code>; to the value corresponding to the <a href=#current-drag-operation>current drag operation</a> if <var title="">e</var> is <code title=event-drop><a href=#event-drop>drop</a></code> or <code title=event-dragend><a href=#event-dragend>dragend</a></code>; and to a value based on the <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> attribute's value and to the drag-and-drop source, as given by the following table, otherwise (i.e. if <var title="">e</var> is <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> or <code title=event-dragover><a href=#event-dragover>dragover</a></code>):</p> <table><thead><tr><th><code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code></th> <th><code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code></th> </thead><tr><td>"<code title="">none</code>"</td> <td>"<code title="">none</code>"</td> <tr><td>"<code title="">copy</code>", "<code title="">copyLink</code>", "<code title="">copyMove</code>", "<code title="">all</code>"</td> <td>"<code title="">copy</code>"</td> <tr><td>"<code title="">link</code>", "<code title="">linkMove</code>"</td> <td>"<code title="">link</code>"</td> <tr><td>"<code title="">move</code>"</td> <td>"<code title="">move</code>"</td> <tr><td>"<code title="">uninitialized</code>" when what is being dragged is a selection from a text field</td> <td>"<code title="">move</code>"</td> <tr><td>"<code title="">uninitialized</code>" when what is being dragged is a selection</td> <td>"<code title="">copy</code>"</td> <tr><td>"<code title="">uninitialized</code>" when what is being dragged is an <code><a href=#the-a-element>a</a></code> element with an <code>href</code> attribute</td> <td>"<code title="">link</code>"</td> <tr><td>Any other case</td> <td>"<code title="">copy</code>"</td> </table></li> <li> <p>Create a <code><a href=#dragevent>DragEvent</a></code> object and initialize it to have the given name <var title="">e</var>, to bubble, to be cancelable unless <var title="">e</var> is <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code> or <code title=event-dragend><a href=#event-dragend>dragend</a></code>, and to have the <code title=dom-UIEvent-detail>detail</code> attribute initialized to zero, the mouse and key attributes initialized according to the state of the input devices as they would be for user interaction events, the <code title="">relatedTarget</code> attribute initialized to null, and the <code title=dom-DragEvent-dataTransfer><a href=#dom-dragevent-datatransfer>dataTransfer</a></code> attribute initialized to <var title="">dataTransfer</var>, the <code><a href=#datatransfer>DataTransfer</a></code> object created above.</p> <!-- interaction event spec point --> <p>If there is no relevant pointing device, the object must have its <code title="">screenX</code>, <code title="">screenY</code>, <code title="">clientX</code>, <code title="">clientY</code>, and <code title="">button</code> attributes set to 0.</p> </li> <li><p>Dispatch the newly created <code><a href=#dragevent>DragEvent</a></code> object at the specified target element.</li> <li><p>Set the <a href=#drag-data-store-allowed-effects-state>drag data store allowed effects state</a> to the current value of <var title="">dataTransfer</var>'s <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> attribute.</li> <li><p>Set the <a href=#drag-data-store-mode>drag data store mode</a> back to the <a href=#concept-dnd-p title=concept-dnd-p>protected mode</a> if it was changed in the first step.</li> <li><p>Break the association between <var title="">dataTransfer</var> and the <a href=#drag-data-store>drag data store</a>.</li> </ol></div> <div class=impl> <h4 id=drag-and-drop-processing-model><span class=secno>8.6.5 </span>Drag-and-drop processing model</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 occuring 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><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 title=dom-draggable><a href=#dom-draggable>draggable</a></code> set to true. If there is no such element, then nothing is being dragged; abort these steps, 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><a href=#the-img-element>img</a></code> elements and <code><a href=#the-a-element>a</a></code> elements with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute have their <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> attribute set to true by default.</p> </li> <li><p><a href=#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>drag data store</a>.</li> <li> <p>Establish which DOM node is the <dfn id=source-node>source node</dfn>, as follows:</p> <p>If it is a selection that is being dragged, then the <a href=#source-node>source node</a> is the text node that the user started the drag on (typically the text 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>source node</a> is the first text 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>source node</a> is the element that is being dragged.</p> <p>Otherwise, the <a href=#source-node>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>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>source node</a> during the course of the drag-and-drop operation.</p> </li> <li> <p>Determine the <dfn id=list-of-dragged-nodes>list of dragged nodes</dfn>, as follows:</p> <p>If it is a selection that is being dragged, then the <a href=#list-of-dragged-nodes>list of dragged nodes</a> contains, in <a href=#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>list of dragged nodes</a> contains only the <a href=#source-node>source node</a>, if any.</p> </li> <li> <p>If it is a selection that is being dragged, then add an item to the <a href=#drag-data-store-item-list>drag data store item list</a>, with its properties set as follows:</p> <dl><dt><a href=#the-drag-data-item-type-string>The drag data item type string</a> <dd>"<code>text/plain</code>"</dd> <dt><a href=#the-drag-data-item-kind>The drag data item kind</a> <dd><i>Plain Unicode string</i></dd> <dt>The actual data</dt> <dd>The text of the selection</dd> </dl><p>Otherwise, if any files are being dragged, then add one item per file to the <a href=#drag-data-store-item-list>drag data store item list</a>, with their properties set as follows:</p> <dl><dt><a href=#the-drag-data-item-type-string>The drag data item type string</a> <dd>The MIME type of the file, if known, or "<code>application/octet-stream</code>" otherwise.</dd> <dt><a href=#the-drag-data-item-kind>The drag data item kind</a> <dd><i><a href=#file>File</a></i></dd> <dt>The actual data</dt> <dd>The file's contents and name.</dd> </dl><p class=note>Dragging files can currently only happen from outside a <a href=#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>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=#mime-type title="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 title="the drag data item type string">drag data item type strings</a> must be <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</p> </li> <!-- DND-v2: text/html as an export format --> <!--MD--> <li> <p>If the <a href=#list-of-dragged-nodes>list of dragged nodes</a> is not empty, then <a href=#extracting-json title="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>drag data store item list</a>, with its properties set as follows:</p> <dl><dt><a href=#the-drag-data-item-type-string>The drag data item type string</a> <dd><code><a href=#application/microdata+json>application/microdata+json</a></code></dd> <dt><a href=#the-drag-data-item-kind>The drag data item kind</a> <dd><i>Plain Unicode string</i></dd> <dt>The actual data</dt> <dd>The resulting JSON string.</dd> </dl></li> <li> <p>Run the following substeps:</p> <ol><li><p>Let <var title="">urls</var> be an empty list of <a href=#absolute-url title="absolute URL">absolute URLs</a>.</li> <li> <p>For each <var title="">node</var> in the <a href=#list-of-dragged-nodes>list of dragged nodes</a>:</p> <dl><dt>If the node is an <code><a href=#the-a-element>a</a></code> element with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute</dt> <dd>Add to <var title="">urls</var> the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the element's <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> content attribute relative to the element.</dd> <dt>If the node is an <code><a href=#the-img-element>img</a></code> element with an <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute</dt> <dd>Add to <var title="">urls</var> the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the element's <code title=attr-img-src><a href=#attr-img-src>src</a></code> content attribute relative to the element.</dd> <!-- DND-v2: more --> </dl></li> <li><p>If <var title="">urls</var> is still empty, abort these substeps.</li> <li><p>Let <var title="">url string</var> be the result of concatenating the strings in <var title="">urls</var>, in the order they were added, separated by a U+000D CARRIAGE RETURN U+000A LINE FEED character pair (CRLF).</li> <li><p>Add one item to the <a href=#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>The drag data item type string</a> <dd><code>text/uri-list</code></dd> <dt><a href=#the-drag-data-item-kind>The drag data item kind</a> <dd><i>Plain Unicode string</i></dd> <dt>The actual data</dt> <dd><var title="">url string</var></dd> </dl></li> </ol></li> <li> <p>If it is an element that is being dragged, then set the <a href=#drag-data-store-elements-list>drag data store elements list</a> to contain just the <a href=#source-node>source node</a>.</p> <p>Otherwise, update the <a href=#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 drag began outside the user agent, then the platform conventions for determining the drag feedback should be used).</p> <p class=note>Script can use the <code title=dom-DataTransfer-addElement><a href=#dom-datatransfer-addelement>addElement()</a></code> method to add further elements to the list of what is being dragged. (This list is only used for rendering the drag feedback.)</p> </li> <li> <p><a href=#fire-a-dnd-event>Fire a DND event</a> named <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> at the <a href=#source-node>source node</a>.</p> <p>If the event is canceled, then the drag-and-drop operation should not occur; abort these steps.</p> <!-- only a should because the UA can always allow the user to drag without the page knowing --> <p class=note>Since events with no event listeners registered are, almost by definition, never canceled, drag-and-drop is always available to the user if the author does not specifically prevent it.</p> </li> <li> <p><a href=#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>drag data store bitmap</a>, if any. In this case, the <a href=#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 CSS pixels from the left side and from the top side of the image respectively. <a href=#refsCSS>[CSS]</a></li> <li>The elements in the <a href=#drag-data-store-elements-list>drag data store elements list</a>, if any.</li> <li>The <a href=#drag-data-store-default-feedback>drag data store default feedback</a>.</li> </ol></li> </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>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>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>current target element</a> changes when the <a href=#immediate-user-selection>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>current target element</a> and the <a href=#immediate-user-selection>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>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 "<code title="">none</code>", "<code title="">copy</code>", "<code title="">link</code>", and "<code title="">move</code>". Initially, it has the value "<code title="">none</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 title="initiate the drag-and-drop operation">initiated</a> and every 350ms (±200ms) thereafter for as long as the drag operation is ongoing, <a href=#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, abort these steps for this iteration (effectively "skipping missed frames" of the drag-and-drop operation).</p> </li> <li> <p><a href=#fire-a-dnd-event>Fire a DND event</a> named <code title=event-drag><a href=#event-drag>drag</a></code> event at the <a href=#source-node>source node</a>. If this event is canceled, the user agent must set the <a href=#current-drag-operation>current drag operation</a> to "<code title="">none</code>" (no drag operation).</p> </li> <li> <p>If the <code title=event-drag><a href=#event-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>immediate user selection</a> than during the last iteration (or if this is the first iteration), and if this <a href=#immediate-user-selection>immediate user selection</a> is not the same as the <a href=#current-target-element>current target element</a>, then update the <a href=#current-target-element>current target element</a> as follows:</p> <dl class=switch><dt>If the new <a href=#immediate-user-selection>immediate user selection</a> is null</dt> <dd><p>Set the <a href=#current-target-element>current target element</a> to null also.</dd> <dt>If the new <a href=#immediate-user-selection>immediate user selection</a> is in a non-DOM document or application</dt> <dd><p>Set the <a href=#current-target-element>current target element</a> to the <a href=#immediate-user-selection>immediate user selection</a>.</dd> <dt>Otherwise</dt> <dd> <p><a href=#fire-a-dnd-event>Fire a DND event</a> named <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> at the <a href=#immediate-user-selection>immediate user selection</a>.</p> <p>If the event is canceled, then set the <a href=#current-target-element>current target element</a> to the <a href=#immediate-user-selection>immediate user selection</a>.</p> <p>Otherwise, run the appropriate step from the following list:</p> <dl class=switch><dt>If the <a href=#current-target-element>current target element</a> is a text field (e.g. <code><a href=#the-textarea-element>textarea</a></code>, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state) or an <a href=#editing-host>editing host</a> or <a href=#editable>editable</a> element, and the <a href=#drag-data-store-item-list>drag data store item list</a> has an item with <a href=#the-drag-data-item-type-string>the drag data item type string</a> "<code>text/plain</code>" and <a href=#the-drag-data-item-kind>the drag data item kind</a> <i>Plain Unicode string</i></dt> <dd><p>Set the <a href=#current-target-element>current target element</a> to the <a href=#immediate-user-selection>immediate user selection</a> anyway.</dd> <dt>If the <a href=#current-target-element>current target element</a> is an element with a <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute that <a href=#concept-dropzone-match title=concept-dropzone-match>matches</a> the <a href=#drag-data-store>drag data store</a></dt> <dd><p>Set the <a href=#current-target-element>current target element</a> to the <a href=#immediate-user-selection>immediate user selection</a> anyway.</dd> <dt>If the <a href=#current-target-element>current target element</a> is <a href=#the-body-element-0>the body element</a></dt> <dd><p>Leave the <a href=#current-target-element>current target element</a> unchanged.</dd> <dt>Otherwise</dt> <dd> <p><a href=#fire-a-dnd-event>Fire a DND event</a> named <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> at <a href=#the-body-element-0>the body element</a>, if there is one, or at the <code><a href=#document>Document</a></code> object, if not. Then, and set the <a href=#current-target-element>current target element</a> to <a href=#the-body-element-0>the body element</a>, regardless of whether that event was canceled or not.</p> </dl></dd> </dl></li> <li> <p>If the previous step caused the <a href=#current-target-element>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>fire a DND event</a> named <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code> at the previous target element.</p> </li> <li> <p>If the <a href=#current-target-element>current target element</a> is a DOM element, then <a href=#fire-a-dnd-event>fire a DND event</a> named <code title=event-dragover><a href=#event-dragover>dragover</a></code> at this <a href=#current-target-element>current target element</a>.</p> <p>If the <code title=event-dragover><a href=#event-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>current target element</a> is a text field (e.g. <code><a href=#the-textarea-element>textarea</a></code>, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state) or an <a href=#editing-host>editing host</a> or <a href=#editable>editable</a> element, and the <a href=#drag-data-store-item-list>drag data store item list</a> has an item with <a href=#the-drag-data-item-type-string>the drag data item type string</a> "<code>text/plain</code>" and <a href=#the-drag-data-item-kind>the drag data item kind</a> <i>Plain Unicode string</i></dt> <dd><p>Set the <a href=#current-drag-operation>current drag operation</a> to either "<code title="">copy</code>" or "<code title="">move</code>", as appropriate given the platform conventions.</dd> <dt>If the <a href=#current-target-element>current target element</a> is an element with a <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute that <a href=#concept-dropzone-match title=concept-dropzone-match>matches</a> the <a href=#drag-data-store>drag data store</a> and <a href=#concept-dropzone-operation title=concept-dropzone-operation>specifies an operation</a></dt> <dd><p>Set the <a href=#current-drag-operation>current drag operation</a> to the operation <a href=#concept-dropzone-operation title=concept-dropzone-operation>specified</a> by the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute of the <a href=#current-target-element>current target element</a>.</p> <dt>If the <a href=#current-target-element>current target element</a> is an element with a <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute that <a href=#concept-dropzone-match title=concept-dropzone-match>matches</a> the <a href=#drag-data-store>drag data store</a> and does not <a href=#concept-dropzone-operation title=concept-dropzone-operation>specify an operation</a></dt> <dd><p>Set the <a href=#current-drag-operation>current drag operation</a> to "<code title="">copy</code>".</p> <dt>Otherwise</dt> <dd><p>Reset the <a href=#current-drag-operation>current drag operation</a> to "<code title="">none</code>".</dd> </dl><p>Otherwise (if the <code title=event-dragover><a href=#event-dragover>dragover</a></code> event <em>is</em> canceled), set the <a href=#current-drag-operation>current drag operation</a> based on the values of the <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> and <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> attributes of the <code><a href=#dragevent>DragEvent</a></code> object's <code title=dom-DragEvent-dataTransfer><a href=#dom-dragevent-datatransfer>dataTransfer</a></code> object as they stood after the event dispatch finished, as per the following table:</p> <table><thead><tr><th><code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code></th> <th><code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code></th> <th>Drag operation</th> </thead><tr><td>"<code title="">uninitialized</code>", "<code title="">copy</code>", "<code title="">copyLink</code>", "<code title="">copyMove</code>", or "<code title="">all</code>"</td> <td>"<code title="">copy</code>"</td> <td>"<code title="">copy</code>"</td> <tr><td>"<code title="">uninitialized</code>", "<code title="">link</code>", "<code title="">copyLink</code>", "<code title="">linkMove</code>", or "<code title="">all</code>"</td> <td>"<code title="">link</code>"</td> <td>"<code title="">link</code>"</td> <tr><td>"<code title="">uninitialized</code>", "<code title="">move</code>", "<code title="">copyMove</code>", "<code title="">linkMove</code>", or "<code title="">all</code>"</td> <td>"<code title="">move</code>"</td> <td>"<code title="">move</code>"</td> <tr><td colspan=2>Any other case</td> <td>"<code title="">none</code>"</td> </table></li> <li> <p>Otherwise, if the <a href=#current-target-element>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 <i><a href=#current-drag-operation>current drag operation</a></i> accordingly.</p> </li> <li> <p>Update the drag feedback (e.g. the mouse cursor) to match the <a href=#current-drag-operation>current drag operation</a>, as follows:</p> <table><thead><tr><th>Drag operation</th> <th>Feedback</th> </thead><tr><td>"<code title="">copy</code>"</td> <td>Data will be copied if dropped here.</td> <tr><td>"<code title="">link</code>"</td> <td>Data will be linked if dropped here.</td> <tr><td>"<code title="">move</code>"</td> <td>Data will be moved if dropped here.</td> <tr><td>"<code title="">none</code>"</td> <td>No operation allowed, dropping here will cancel the drag-and-drop operation.</td> </table></li> </ol></li> <li> <p>Otherwise, if the user ended the drag-and-drop operation (e.g. by releasing the mouse button in a mouse-driven drag-and-drop interface), or if the <code title=event-drag><a href=#event-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>current drag operation</a> is "<code title="">none</code>" (no drag operation), or, if the user ended the drag-and-drop operation by canceling it (e.g. by hitting the <kbd>Escape</kbd> key), or if the <a href=#current-target-element>current target element</a> is null, then the drag operation failed. Run these substeps:</p> <ol><li><p>Let <var title="">dropped</var> be false.</li> <li><p>If the <a href=#current-target-element>current target element</a> is a DOM element, <a href=#fire-a-dnd-event>fire a DND event</a> named <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code> at it; otherwise, if it is not null, use platform-specific conventions for drag cancellation.</p> </ol><p>Otherwise, the drag operation might be a success; run these substeps:</p> <ol><li><p>Let <var title="">dropped</var> be true.</li> <li><p>If the <a href=#current-target-element>current target element</a> is a DOM element, <a href=#fire-a-dnd-event>fire a DND event</a> named <code title=event-drop><a href=#event-drop>drop</a></code> at it; otherwise, use platform-specific conventions for indicating a drop.</li> <li> <p>If the event is canceled, set the <a href=#current-drag-operation>current drag operation</a> to the value of the <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> attribute of the <code><a href=#dragevent>DragEvent</a></code> object's <code title=dom-DragEvent-dataTransfer><a href=#dom-dragevent-datatransfer>dataTransfer</a></code> object as it stood after the event dispatch 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>current target element</a> is a text field (e.g. <code><a href=#the-textarea-element>textarea</a></code>, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state) or an <a href=#editing-host>editing host</a> or <a href=#editable>editable</a> element, and the <a href=#drag-data-store-item-list>drag data store item list</a> has an item with <a href=#the-drag-data-item-type-string>the drag data item type string</a> "<code>text/plain</code>" and <a href=#the-drag-data-item-kind>the drag data item kind</a> <i>Plain Unicode string</i></dt> <dd><p>Insert the actual data of the first item in the <a href=#drag-data-store-item-list>drag data store item list</a> to have <a href=#the-drag-data-item-type-string title="the drag data item type string">a drag data item type string</a> of "<code>text/plain</code>" and <a href=#the-drag-data-item-kind title="the drag data item kind">a drag data item kind</a> that is <i>Plain Unicode string</i> into the text field or <a href=#editing-host>editing host</a> or <a href=#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).</dd> <dt>Otherwise</dt> <dd><p>Reset the <a href=#current-drag-operation>current drag operation</a> to "<code title="">none</code>".</dd> </dl></li> </ol></li> <li> <p><a href=#fire-a-dnd-event>Fire a DND event</a> named <code title=event-dragend><a href=#event-dragend>dragend</a></code> at the <a href=#source-node>source node</a>.</p> </li> <li> <p>Run the appropriate steps from the following list as the default action of the <code title=event-dragend><a href=#event-dragend>dragend</a></code> event:</p> <dl class=switch><dt>If <var title="">dropped</var> is true, and the <a href=#current-target-element>current target element</a> is a text field (e.g. <code><a href=#the-textarea-element>textarea</a></code>, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state), and the <a href=#current-drag-operation>current drag operation</a> is "<code title="">move</code>", and the source of the drag-and-drop operation is a selection in the DOM</dt> <dd><p>The user agent should delete the range representing the dragged selection from the DOM.</dd> <dt>If <var title="">dropped</var> is true, and the <a href=#current-target-element>current target element</a> is a text field (e.g. <code><a href=#the-textarea-element>textarea</a></code>, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a> state), and the <a href=#current-drag-operation>current drag operation</a> is "<code title="">move</code>", and the source of the drag-and-drop operation is a selection in a text field</dt> <dd><p>The user agent should delete the dragged selection from the relevant text field.</dd> <dt>If <var title="">dropped</var> is false or if the <a href=#current-drag-operation>current drag operation</a> is "<code title="">none</code>"</dt> <dd><p>The drag was canceled. If the platform conventions dictate that this be represented to the user (e.g. by animating the dragged selection going back to the source of the drag-and-drop operation), then do so.</dd> <dt>Otherwise</dt> <dd><p>The event has no default action.</dd> </dl></li> </ol></li> </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 viewport 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><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> </div> <h4 id=dndevents><span class=secno>8.6.6 </span>Events summary</h4> <p><i>This section is non-normative.</i></p> <p>The following events are involved in the drag-and-drop model.</p> <table><thead><tr><th> Event Name </th> <th> Target </th> <!-- <th> Bubbles? </th> --> <th> Cancelable? </th> <th> <a href=#drag-data-store-mode>Drag data store mode</a> </th> <!-- <th> <code title="dom-DataTransfer-effectAllowed">effectAllowed</code> </th> --> <th> <code title=dom-DataTransfer-dropEffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> </th> <th> Default Action </th> <tbody><tr><td><dfn id=event-dragstart title=event-dragstart><code>dragstart</code></dfn></td> <td><a href=#source-node>Source node</a></td> <!-- <td>✓ Bubbles</td> --> <td>✓ Cancelable</td> <td><a href=#concept-dnd-rw title=concept-dnd-rw>Read/write mode</a> <!-- <td>"<code title="">uninitialized</code>"</td> --> <td>"<code title="">none</code>"</td> <td>Initiate the drag-and-drop operation</td> <tr><td><dfn id=event-drag title=event-drag><code>drag</code></dfn></td> <td><a href=#source-node>Source node</a></td> <!-- <td>✓ Bubbles</td> --> <td>✓ Cancelable</td> <td><a href=#concept-dnd-p title=concept-dnd-p>Protected mode</a> <!-- <td>Same as last event</td> --> <td>"<code title="">none</code>"</td> <td>Continue the drag-and-drop operation</td> <tr><td><dfn id=event-dragenter title=event-dragenter><code>dragenter</code></dfn></td> <td><a href=#immediate-user-selection>Immediate user selection</a> or <a href=#the-body-element-0>the body element</a></td> <!-- <td>✓ Bubbles</td> --> <td>✓ Cancelable</td> <td><a href=#concept-dnd-p title=concept-dnd-p>Protected mode</a> <!-- <td>Same as last event</td> --> <td><a href=#dropEffect-initialization>Based on <code>effectAllowed</code> value</a></td> <td>Reject <a href=#immediate-user-selection>immediate user selection</a> as potential <a href=#current-target-element title="current target element">target element</a></td> <tr><td><dfn id=event-dragleave title=event-dragleave><code>dragleave</code></dfn></td> <td><a href=#current-target-element title="current target element">Previous target element</a></td> <!-- <td>✓ Bubbles</td> --> <td>—</td> <td><a href=#concept-dnd-p title=concept-dnd-p>Protected mode</a> <!-- <td>Same as last event</td> --> <td>"<code title="">none</code>"</td> <td>None</td> <tr><td><dfn id=event-dragover title=event-dragover><code>dragover</code></dfn></td> <td><a href=#current-target-element>Current target element</a></td> <!-- <td>✓ Bubbles</td> --> <td>✓ Cancelable</td> <td><a href=#concept-dnd-p title=concept-dnd-p>Protected mode</a> <!-- <td>Same as last event</td> --> <td><a href=#dropEffect-initialization>Based on <code>effectAllowed</code> value</a></td> <td>Reset the <a href=#current-drag-operation>current drag operation</a> to "none"</td> <tr><td><dfn id=event-drop title=event-drop><code>drop</code></dfn></td> <td><a href=#current-target-element>Current target element</a></td> <!-- <td>✓ Bubbles</td> --> <td>✓ Cancelable</td> <td><a href=#concept-dnd-ro title=concept-dnd-ro>Read-only mode</a> <!-- <td>Same as last event</td> --> <td><a href=#current-drag-operation>Current drag operation</a></td> <td>Varies</td> <tr><td><dfn id=event-dragend title=event-dragend><code>dragend</code></dfn></td> <td><a href=#source-node>Source node</a></td> <!-- <td>✓ Bubbles</td> --> <td>—</td> <td><a href=#concept-dnd-p title=concept-dnd-p>Protected mode</a> <!-- <td>Same as last event</td> --> <td><a href=#current-drag-operation>Current drag operation</a></td> <td>Varies</td> </table><p>Not shown in the above table: all these events bubble, and the <code title=dom-DataTransfer-effectAllowed><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> attribute always has the value it had after the previous event was fired, defaulting to "<code title="">uninitialized</code>" in the <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> event.</p> <h4 id=the-draggable-attribute><span class=secno>8.6.7 </span>The <dfn title=attr-draggable><code>draggable</code></dfn> attribute</h4> <p>All <a href=#html-elements>HTML elements</a> may have the <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute set. The <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> attribute is an <a href=#enumerated-attribute>enumerated attribute</a>. It has three states. The first state is <i>true</i> and it has the keyword <code title="">true</code>. The second state is <i>false</i> and it has the keyword <code title="">false</code>. The third state is <i>auto</i>; it has no keywords but it is the <i>missing value default</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> <dl class=domintro><dt><var title="">element</var> . <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the element is draggable; otherwise, returns false.</p> <p>Can be set, to override the default and set the <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-draggable title=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 title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute is true become draggable as well.</p> <p>If an element's <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute has the state <i>true</i>, the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute must return true.</p> <p>Otherwise, if the element's <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute has the state <i>false</i>, the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute must return false.</p> <p>Otherwise, the element's <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute has the state <i>auto</i>. If the element is an <code><a href=#the-img-element>img</a></code> element, or, if the element is an <code><a href=#the-a-element>a</a></code> element with an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> content attribute, the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute must return true.</p> <p>Otherwise, the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> DOM must return false.</p> <p>If the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute is set to the value false, the <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute must be set to the literal value <code title="">false</code>. If the <code title=dom-draggable><a href=#dom-draggable>draggable</a></code> IDL attribute is set to the value true, the <code title=attr-draggable><a href=#the-draggable-attribute>draggable</a></code> content attribute must be set to the literal value <code title="">true</code>.</p> </div> <h4 id=the-dropzone-attribute><span class=secno>8.6.8 </span>The <dfn title=attr-dropzone><code>dropzone</code></dfn> attribute</h4> <p>All <a href=#html-elements>HTML elements</a> may have the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> content attribute set. When specified, its value must be an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of unique space-separated tokens</a> that are <a href=#ascii-case-insensitive>ASCII case-insensitive</a>. The allowed values are the following:</p> <dl><dt><dfn id=attr-dropzone-copy title=attr-dropzone-copy><code>copy</code></dfn></dt> <dd><p>Indicates that dropping an accepted item on the element will result in a copy of the dragged data.</p> <dt><dfn id=attr-dropzone-move title=attr-dropzone-move><code>move</code></dfn></dt> <dd><p>Indicates that dropping an accepted item on the element will result in the dragged data being moved to the new location.</p> <dt><dfn id=attr-dropzone-link title=attr-dropzone-link><code>link</code></dfn></dt> <dd><p>Indicates that dropping an accepted item on the element will result in a link to the original data.</p> <dt>Any keyword with three characters or more, beginning with the two characters U+0073 LATIN SMALL LETTER S and U+003A COLON or U+0053 LATIN CAPITAL LETTER S and U+003A COLON (i.e. an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">s:</code>")<dt> </dt><dd><p>Indicates that items with <a href=#the-drag-data-item-kind>the drag data item kind</a> <i>Plain Unicode string</i> and <a href=#the-drag-data-item-type-string>the drag data item type string</a> set to a value that matches the remainder of the keyword are accepted.</dd> <!--DND-v3: <dt>Any keyword with three characters or more, beginning with the two characters U+0062 LATIN SMALL LETTER B and U+003A COLON or U+0042 LATIN CAPITAL LETTER B and U+003A COLON (i.e. an <span>ASCII case-insensitive</span> match for the string "<code title="">b:</code>")<dt> <dd><p>Indicates that items with <span>the drag data item kind</span> <i>Blob</i>, <i>File</i>, or <i>Plain Unicode string</i> and <span>the drag data item type string</span> set to a value that matches the remainder of the keyword are accepted.</p></dd> --> <dt>Any keyword with three characters or more, beginning with the two characters U+0066 LATIN SMALL LETTER F and U+003A COLON or U+0046 LATIN CAPITAL LETTER F and U+003A COLON (i.e. an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">f:</code>")<dt> </dt><dd><p>Indicates that items with <a href=#the-drag-data-item-kind>the drag data item kind</a> <i><a href=#file>File</a></i> and <a href=#the-drag-data-item-type-string>the drag data item type string</a> set to a value that matches the remainder of the keyword are accepted.</dd> <!--DND-v4: <dt>Any keyword with three characters or more, beginning with the two characters U+006F LATIN SMALL LETTER O and U+003A COLON or U+004F LATIN CAPITAL LETTER O and U+003A COLON (i.e. an <span>ASCII case-insensitive</span> match for the string "<code title="">o:</code>")<dt> <dd><p>Indicates that items with <span>the drag data item type string</span> set to a value that matches the remainder of the keyword are accepted.</p></dd> --> </dl><p>The <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> content attribute's values must not have more than one of the three feedback values (<code title=attr-dropzone-copy><a href=#attr-dropzone-copy>copy</a></code>, <code title=attr-dropzone-move><a href=#attr-dropzone-move>move</a></code>, and <code title=attr-dropzone-link><a href=#attr-dropzone-link>link</a></code>) specified. If none are specified, the <code title=attr-dropzone-copy><a href=#attr-dropzone-copy>copy</a></code> value is implied.</p> <div class=impl> <p>A <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute <dfn id=concept-dropzone-match title=concept-dropzone-match>matches a drag data store</dfn> if the <a href=#dropzone-processing-steps><code title=attr-dropzone>dropzone</code> processing steps</a> result in a match.</p> <p>A <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute <dfn id=concept-dropzone-operation title=concept-dropzone-operation>specifies an operation</dfn> if the <a href=#dropzone-processing-steps><code title=attr-dropzone>dropzone</code> processing steps</a> result in a specified operation. The specified operation is as given by those steps.</p> <p>The <dfn id=dropzone-processing-steps><code title=attr-dropzone>dropzone</code> processing steps</dfn> are as follows. They either result in a match or not, and separate from this result either in a specified operation or not, as defined below.</p> <ol><li><p>Let <var title="">value</var> be the value of the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute.</li> <li><p>Let <var title="">keywords</var> be the result of <a href=#split-a-string-on-spaces title="split a string on spaces">splitting <var title="">value</var> on spaces</a>.</li> <li><p>Let <var title="">matched</var> be false.</li> <li><p>Let <var title="">operation</var> be unspecified.</li> <li> <p>For each value in <var title="">keywords</var>, if any, in the order that they were found in <var title="">value</var>, run the following steps.</p> <ol><li><p>Let <var title="">keyword</var> be the keyword.</li> <li> <p>If <var title="">keyword</var> is one of "<code title=attr-dropzone-copy><a href=#attr-dropzone-copy>copy</a></code>", "<code title=attr-dropzone-move><a href=#attr-dropzone-move>move</a></code>", or "<code title=attr-dropzone-link><a href=#attr-dropzone-link>link</a></code>", then: run the following substeps:</p> <ol><li><p>If <var title="">operation</var> is still unspecified, then let <var title="">operation</var> be the string given by <var title="">keyword</var>.</li> <li><p>Skip to the step labeled <i>end of keyword</i> below.</li> </ol></li> <li><p>If <var title="">keyword</var> is shorter than three characters in length, then skip to the step labeled <i>end of keyword</i> below.</li> <li><p>If the second character in <var title="">keyword</var> is not a U+003A COLON character (:), then skip to the step labeled <i>end of keyword</i> below.</li> <li><p>Let <var title="">kind code</var> be the first character in <var title="">keyword</var>, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li> <p>Jump to the appropriate step from the list below, based on the value of <var title="">kind code</var>:</p> <dl class=switch><dt>If <var title="">kind code</var> is a U+0073 LATIN SMALL LETTER S character</dt> <dd> <p>Let <var title="">kind<!--DND-v3:/DND-v4: s--></var> be <i>Plain Unicode string</i>.</p> </dd> <!--DND-v3: <dt>If <var title="">kind code</var> is a U+0062 LATIN SMALL LETTER B character</dt> <dd> <p>Let <var title="">kinds</var> be <i>Plain Unicode string</i>, <i>Blob</i>, and <i>File</i>.</p> </dd> --> <dt>If <var title="">kind code</var> is a U+0066 LATIN SMALL LETTER F character</dt> <dd> <p>Let <var title="">kind<!--DND-v3:/DND-v4: s--></var> be <i><a href=#file>File</a></i>.</p> </dd> <!--DND-v4: <dt>If <var title="">kind code</var> is a U+006F LATIN SMALL LETTER O character</dt> <dd> <p>Let <var title="">kinds</var> be <i>Plain Unicode string</i>, <i>Blob</i>, <i>File</i>, and <i>Object</i>.</p> </dd> --> <dt>Otherwise</dt> <dd> <p>Skip to the step labeled <i>end of keyword</i> below.</p> </dd> </dl></li> <li><p>Let <var title="">type</var> be the string consisting of all but the first two characters of <var title="">keyword</var>, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li><p>If there exist any items in the <a href=#drag-data-store-item-list>drag data store item list</a> whose <a href=#the-drag-data-item-kind title="the drag data item kind">drag data item kind</a> is <!--DND-v3:/DND-v4: one of--> the kind<!--DND-v3:/DND-v4: s--> given in <var title="">kind<!--DND-v3:/DND-v4: s--></var> and whose <span title="the drag data item type">drag data item type</span> is <var title="">type</var>, then let <var title="">matched</var> be true.</li> <li><p><i>End of keyword</i>: Go on to the next keyword, if any, or the next step in the overall algorithm, if there are no more.</li> </ol></li> <li> <p>The algorithm results in a match if <var title="">matched</var> is true, and does not otherwise.</p> <p>The algorithm results in a specified operation if <var title="">operation</var> is not unspecified. The specified operation, if one is specified, is the one given by <var title="">operation</var>.</p> </li> </ol><p>The <dfn id=dom-dropzone title=dom-dropzone><code>dropzone</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the content attribute of the same name.</p> </div> <div class=example> <p>In this example, a <code><a href=#the-div-element>div</a></code> element is made into a drop target for image files using the <code title=attr-dropzone><a href=#the-dropzone-attribute>dropzone</a></code> attribute. Images dropped into the target are then displayed.</p> <pre><div dropzone="copy f:image/png f:image/gif f:image/jpeg" ondrop="receive(event, this)"> <p>Drop an image here to have it displayed.</p> </div> <script> function receive(event, element) { var data = event.dataTransfer.items; for (var i = 0; i < data.length; i += 1) { if ((data[i].kind == 'file') && (data[i].type.match('^image/'))) { var img = new Image(); img.src = window.createObjectURL(data[i].getAsFile()); element.appendChild(img); } } } </script></pre> </div> <!-- <h4>Copy and paste</h4> <p>Copy-and-paste is a form of drag-and-drop: the "copy" part is equivalent to dragging content to another application (the "clipboard"), and the "paste" part is equivalent to dragging content <em>from</em> another application.</p> <p>Select-and-paste (a model used by mouse operations in the X Window System) is equivalent to a drag-and-drop operation where the source is the selection.</p> <div class="impl"> <h5>Copy to clipboard</h5> <p>When the user invokes a copy operation, the user agent must act as if the user had invoked a drag on the current selection. If the drag-and-drop operation initiates, then the user agent must act as if the user had indicated (as the <span>immediate user selection</span>) a hypothetical application representing the clipboard. Then, the user agent must act as if the user had ended the drag-and-drop operation without canceling it. If the drag-and-drop operation didn't get canceled, the user agent should then follow the relevant platform-specific conventions for copy operations (e.g. updating the clipboard).</p> <p>The events involved in this process are the <code title="event-dragstart">dragstart</code>, <code title="event-drag">drag</code>, and <code title="event-dragend">dragend</code> events.</p> <h5>Cut to clipboard</h5> <p>When the user invokes a cut operation, the user agent must act as if the user had invoked a copy operation (see the previous section), followed, if the copy was completed successfully, by <a href="#contenteditable-delete">a selection delete operation</a>.</p> <p>The events involved in this process are the <code title="event-dragstart">dragstart</code>, <code title="event-drag">drag</code>, and <code title="event-dragend">dragend</code> events.</p> <h5>Paste from clipboard</h5> <p>When the user invokes a clipboard paste operation, the user agent must act as if the user had invoked a drag on a hypothetical application representing the clipboard, setting the data associated with the drag as the content on the clipboard (in whatever formats are available).</p> <p>Then, the user agent must act as if the user had indicated (as the <span>immediate user selection</span>) the element with the keyboard focus, and then ended the drag-and-drop operation without canceling it.</p> <p>The events involved in this process are the <code title="event-dragenter">dragenter</code>, <code title="event-dragover">dragover</code>, <code title="event-dragleave">dragleave</code>, and <code title="event-drop">drop</code> events.</p> <h5>Paste from selection</h5> <p>When the user invokes a selection paste operation, the user agent must act as if the user had invoked a drag on the current selection, then indicated (as the <span>immediate user selection</span>) the element with the keyboard focus, and then ended the drag-and-drop operation without canceling it.</p> <p>All the drag-and-drop events can be involved in this process.</p> </div> --> <div class=impl> <h4 id=security-risks-in-the-drag-and-drop-model><span class=secno>8.6.9 </span>Security risks in the drag-and-drop model</h4> <p>User agents must not make the data added to the <code><a href=#datatransfer>DataTransfer</a></code> object during the <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> event available to scripts until the <code title=event-drop><a href=#event-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 title=event-drop><a href=#event-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 his 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> </div> <!--FIND--> <h3 id=text-search-apis><span class=secno>8.7 </span>Text search APIs</h3> <!-- window.find() --> <p class=critical>This legacy API is not very interoperably implemented, and has a number of design problems (such as having six boolean arguments in a row, giving the ability to expose a UA dialog, affecting the selection when successful, etc). We may just drop it instead. <a href=http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/thread.html#31457>Read more...</a></p> <!-- demo: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1076 --> <!-- bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=672395 https://bugs.webkit.org/show_bug.cgi?id=64761 --> <!-- notes: if first argument is '', gecko throws a dialog. webkit does not. aCaseSensitive, if true, matches case. Webkit: If false, even if the search string is the equivalent of cåt, it'll still match "cat". Gecko: some sort of unicode case-insensitive (aring matches Aring) search starts from the last place the user placed the invisible cursor once find() has selected text in a text field, it acts as if the cursor jumps back to the top of the page aWholeWord has no effect. Gecko: aWrapAround has no effect. WebKit: aWrapAround works by wrapping around at the bottom of the page (top if going backwards). Gecko: searches iframes if aSearchInFrames is set WebKit: doesn't search iframes; aSearchInFrames has no effect. Gecko: aShowDialog works Webkit: does not Gecko: doesn't work on display:none iframes. (works fine in webkit) WebKit: doesn't work before body.onload has fired or some such (works fine in gecko) --> <!-- boolean <span title="dom-find">find</span>(in optional DOMString aString, in optional boolean aCaseSensitive, in optional boolean aBackwards, in optional boolean aWrapAround, in optional aWholeWord, in optional aSearchInFrames, in optional aShowDialog); --> <p class=XXX><dfn id=dom-find title=dom-find>window.find()</dfn> goes here</p> <!--FIND--> <!--PEERCONNECTION--> <div data-component="other Hixie drafts (editor: Ian Hickson)"> <h2 id=video-conferencing-and-peer-to-peer-communication><span class=secno>9 </span>Video conferencing and peer-to-peer communication</h2> <h3 id=introduction-10><span class=secno>9.1 </span>Introduction</h3> <p><i>This section is non-normative.</i></p> <p>There are a number of facets to video-conferencing in HTML:</p> <ul><li>Getting a multimedia stream (video, audio, or both) from local devices (video cameras, microphones, Web cams) or from prerecorded files provided by the user.</li> <li>Recording such streams locally.</li> <li>Connecting to remote peers using NAT-traversal technologies such as ICE, STUN, and TURN.</li> <li>Sending the locally-produced streams to remote peers and receiving streams from remote peers.</li> <li>Displaying such streams (both the locally-produced ones and the remotely-obtained ones) locally using the <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code> elements.</li> <li>Sending arbitrary data to remote peers.</li> </ul><p>This section defines the APIs used for these features.</p> <h3 id=obtaining-local-multimedia-content><span class=secno>9.2 </span>Obtaining local multimedia content</h3> <pre class=idl>[NoInterfaceObject] interface <dfn id=navigatorusermedia>NavigatorUserMedia</dfn> { void <a href=#dom-navigator-getusermedia title=dom-navigator-getUserMedia>getUserMedia</a>(DOMString options, <a href=#navigatorusermediasuccesscallback>NavigatorUserMediaSuccessCallback</a>? successCallback, optional <a href=#navigatorusermediaerrorcallback>NavigatorUserMediaErrorCallback</a>? errorCallback); }; <a href=#navigator>Navigator</a> implements <a href=#navigatorusermedia>NavigatorUserMedia</a>; [Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=navigatorusermediasuccesscallback>NavigatorUserMediaSuccessCallback</dfn> { void <span title=dom-NavigatorUserMediaSuccessCallback-handleEvent>handleEvent</span>(<a href=#localmediastream>LocalMediaStream</a> stream); }; [NoInterfaceObject]<!-- this is based on PositionError in geolocation --> interface <dfn id=navigatorusermediaerror>NavigatorUserMediaError</dfn> { const unsigned short <a href=#dom-navigatorusermediaerror-permission_denied title=dom-NavigatorUserMediaError-PERMISSION_DENIED>PERMISSION_DENIED</a> = 1;<!-- const unsigned short <span title="dom-NavigatorUserMediaError-UNAVAILABLE">UNAVAILABLE</span> = 2; const unsigned short <span title="dom-NavigatorUserMediaError-TIMEOUT">TIMEOUT</span> = 3;--> readonly attribute unsigned short <a href=#dom-navigatorusermediaerror-code title=dom-NavigatorUserMediaError-code>code</a>;<!-- readonly attribute DOMString <span title="dom-NavigatorUserMediaError-message">message</span>;--> }; [Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=navigatorusermediaerrorcallback>NavigatorUserMediaErrorCallback</dfn> { void <span title=dom-NavigatorUserMediaSuccessCallback-handleEvent>handleEvent</span>(<a href=#navigatorusermediaerror>NavigatorUserMediaError</a> error); };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-navigator><a href=#dom-navigator>navigator</a></code> . <code title=dom-navigator-getUserMedia><a href=#dom-navigator-getusermedia>getUserMedia</a></code>(<var title="">options</var>, <var title="">successCallback</var> [, <var title="">errorCallback</var> ] )</dt> <dd> <p>Prompts the user for permission to use their Web cam or other video or audio input.</p> <p>The <var title="">options</var> argument is a string of comma-separated values, each of which is itself a space-separated list of tokens, the first token of which is from the following list:</p> <dl><dt>"<code title="">audio</code>"</dt> <dd>The provided media needs to include audio data.</dd> <dt>"<code title="">video</code>"</dt> <dd>The provided media needs to include video data. The token can be followed by the tokens "<code title="">user</code>" or "<code title="">environment</code>" to indicate the preferred cameras to use.</dd> </dl><p>If the user accepts, the <var title="">successCallback</var> is invoked, with a suitable <code><a href=#localmediastream>LocalMediaStream</a></code> object as its argument.</p> <p>If the user declines, the <var title="">errorCallback</var> (if any) is invoked.</p> </dd> <dt><var title="">error</var> . <code title=dom-NavigatorUserMediaError-code><a href=#dom-navigatorusermediaerror-code>code</a></code></dt> <dd> <p>Returns the current error's error code. At this time, this will always be 1, for which the constant <code title=dom-NavigatorUserMediaError-PERMISSION_DENIED><a href=#dom-navigatorusermediaerror-permission_denied>PERMISSION_DENIED</a></code> is defined.</p> </dd> </dl><div class=impl> <p>When the <dfn id=dom-navigator-getusermedia title=dom-navigator-getUserMedia><code>getUserMedia()</code></dfn> method is called, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">options</var> be the method's first argument.</li> <li><p>Let <var title="">successCallback</var> be the callback indicated by the method's second argument.</li> <li><p>Let <var title="">errorCallback</var> be the callback indicated by the method's third argument, if any, or null otherwise.</li> <li><p>If <var title="">successCallback</var> is null, abort these steps.</li> <!-- we could throw an exception instead (that's why the method doesn't return until later: so that we can add an exception here, or for /options/ below, without changing the algorithm) --> <li><p>Let <var title="">audio</var> be false.</li> <li><p>Let <var title="">video</var> be false.</li> <li><p>Let <var title="">camera preference</var> be the empty set.</li> <li><p><a href=#split-a-string-on-commas title="split a string on commas">Split <var title="">options</var> on commas</a> to obtain <var title="">list of options</var>.</li> <li> <p>For each string <var title="">option</var> in <var title="">list of options</var>, run the following substeps:</p> <ol><li><p><a href=#split-a-string-on-spaces title="split a string on spaces">Split <var title="">option</var> on spaces</a> to obtain <var title="">list of suboptions</var>.</li> <li><p>If the first token in <var title="">list of suboptions</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">audio</code>", let <var title="">audio</var> be true.</li> <li><p>If the first token in <var title="">list of suboptions</var> is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">video</code>", run these subsubsteps:</p> <ol><li><p>Let <var title="">video</var> be true.</li> <li><p>If <var title="">list of suboptions</var> contains a token that is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">user</code>", add any cameras that face towards the user to the <var title="">camera preference</var> set.</li> <li><p>If <var title="">list of suboptions</var> contains a token that is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">environment</code>", add any cameras that face away from the user to the <var title="">camera preference</var> set.</li> </ol></li> </ol></li> <!-- any error handling for /options/ should be done here (that's why the method doesn't return until the next step: so we can add exception throwing here) --> <li><p>If both <var title="">audio</var> and <var title="">video</var> are still false, then throw a <code><a href=#notsupportederror>NotSupportedError</a></code> exception and abort these steps.</li> <li><p>Return, and run the remaining steps asynchronously.</li> <li><p>Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, jump to the step labeled <i>failure</i> below.</li> <li> <p>Prompt the user in a user-agent-specific manner for permission to provide the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a> with a <code><a href=#localmediastream>LocalMediaStream</a></code> object representing a media stream.</p> <p>If <var title="">audio</var> is true, then the provided media should include an audio track. If <var title="">audio</var> is false, then the provided media must not include an audio track.</p> <p>If <var title="">video</var> is true, then the provided media should include a video track. If <var title="">video</var> is false, then the provided media must not include a video track.</p> <p>User agents are encouraged to default to using the user's primary or system default camera and/or microphone (as appropriate) to generate the media stream. User agents may allow users to use any media source, including pre-recorded media files.</p> <p>If <var title="">video</var> is true, then the user agent should encourage the user to provide a camera from the <var title="">camera preference</var> set.</p> <p>User agents may wish to offer the user more control over the provided media. For example, a user agent could offer to enable a camera light or flash, or to change settings such as the frame rate or shutter speed.</p> <p>If the user grants permission to use local recording devices, user agents are encouraged to include a prominent indicator that the devices are "hot" (i.e. an "on-air" or "recording" indicator).</p> <p>If the user denies permission, jump to the step labeled <i>failure</i> below. If the user never responds, this algorithm stalls on this step.</p> </li> <li><p>Let <var title="">stream</var> be the <code><a href=#localmediastream>LocalMediaStream</a></code> object for which the user granted permission.</li> <li><p><a href=#queue-a-task>Queue a task</a> to invoke <var title="">successCallback</var> with <var title="">stream</var> as its argument.</li> <li><p>Abort these steps.</li> <li><p><i>Failure</i>: If <var title="">errorCallback</var> is null, abort these steps.</li> <li><p>Let <var title="">error</var> be a new <code><a href=#navigatorusermediaerror>NavigatorUserMediaError</a></code> object whose <code title=dom-NavigatorUserMediaError-code><a href=#dom-navigatorusermediaerror-code>code</a></code> attribute has the numeric value 1 (<code title=dom-NavigatorUserMediaError-PERMISSION_DENIED><a href=#dom-navigatorusermediaerror-permission_denied>PERMISSION_DENIED</a></code>).</li> <li><p><a href=#queue-a-task>Queue a task</a> to invoke <var title="">errorCallback</var> with <var title="">error</var> as its argument.</li> </ol><p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#user-interaction-task-source>user interaction task source</a>.</p> <hr><p>The <dfn id=dom-navigatorusermediaerror-code title=dom-NavigatorUserMediaError-code><code>code</code></dfn> attribute of a <code><a href=#navigatorusermediaerror>NavigatorUserMediaError</a></code> object must return the code for the error, which must be <!--one of--> the following:</p> <dl><dt><dfn id=dom-navigatorusermediaerror-permission_denied title=dom-NavigatorUserMediaError-PERMISSION_DENIED><code>PERMISSION_DENIED</code></dfn> (numeric value 1)</dt> <dd>The user denied the page permission to use the user's media devices.</dd> </dl></div> <div class=example> <p>A voice chat feature in a game could attempt to get access to the user's microphone by calling the API as follows:</p> <pre><script> navigator.getUserMedia('audio', gotAudio); function gotAudio(stream) { // ... use 'stream' ... } </script></pre> </div> <div class=example> <p>A video-conferencing system would ask for both audio and video:</p> <pre><script> function beginCall() { navigator.getUserMedia('audio,video user', gotStream); } function gotStream(stream) { // ... use 'stream' ... } </script></pre> </div> <h3 id=stream-api><span class=secno>9.3 </span>Stream API</h3> <h4 id=introduction-11><span class=secno>9.3.1 </span>Introduction</h4> <p>The <code><a href=#mediastream>MediaStream</a></code> interface is used to represent streams of media data, typically (but not necessarily) of audio and/or video content, e.g. from a local camera or a remote site. The data from a <code><a href=#mediastream>MediaStream</a></code> object does not necessarily have a canonical binary form; for example, it could just be "the video currently coming from the user's video camera". This allows user agents to manipulate media streams in whatever fashion is most suitable on the user's platform.</p> <p>Each <code><a href=#mediastream>MediaStream</a></code> object can represent zero or more tracks, in particular audio and video tracks. Tracks can contain multiple channels of parallel data; for example a single audio track could have nine channels of audio data to represent a 7.2 surround sound audio track.</p> <p>Each track represented by a <code><a href=#mediastream>MediaStream</a></code> object has a corresponding <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> object.</p> <p>A <code><a href=#mediastream>MediaStream</a></code> object has an input and an output. The input depends on how the object was created: a <code><a href=#localmediastream>LocalMediaStream</a></code> object generated by a <code title=dom-navigator-getUserMedia><a href=#dom-navigator-getusermedia>getUserMedia()</a></code> call, for instance, might take its input from the user's local camera, while a <code><a href=#mediastream>MediaStream</a></code> created by a <code><a href=#peerconnection>PeerConnection</a></code> object will take as input the data received from a remote peer. The output of the object controls how the object is used, e.g. what is saved if the object is written to a file, what is displayed if the object is used in a <code><a href=#the-video-element>video</a></code> element, or indeed what is transmitted to a remote peer if the object is used with a <code><a href=#peerconnection>PeerConnection</a></code> object.</p> <p>Each track in a <code><a href=#mediastream>MediaStream</a></code> object can be disabled, meaning that it is muted in the object's output. All tracks are initially enabled.</p> <p id=finishedMute>A <code><a href=#mediastream>MediaStream</a></code> can be <a href=#concept-stream-finished title=concept-stream-finished>finished</a>, indicating that its inputs have forever stopped providing data. When a <code><a href=#mediastream>MediaStream</a></code> object is finished, all its tracks are muted regardless of whether they are enabled or disabled.</p> <p>The output of a <code><a href=#mediastream>MediaStream</a></code> object must correspond to the tracks in its input. Muted audio tracks must be replaced with silence. Muted video tracks must be replaced with blackness.</p> <p>A <code><a href=#mediastream>MediaStream</a></code> object's output can be "forked" by creating a new <code><a href=#mediastream>MediaStream</a></code> object from it using the <code title=dom-MediaStream><a href=#dom-mediastream>MediaStream()</a></code> constructor. The new <code><a href=#mediastream>MediaStream</a></code> object's input is the output of the object from which it was created, with any disabled tracks removed, and its output is therefore at most a subset of that "parent" object. (Merely muted tracks are not removed, so the tracks do not change when the parent is finished.) When such a fork's parent finishes, the fork is also said to have finished.</p> <p><img alt="" src=http://images.whatwg.org/media-stream-1.png></p><!-- no alt since it's all described in the previous paragraphs: this is just a summary --> <!-- c.clearRect(0, 0, 640, 480); c.save(); try { with (c) { save(); strokeStyle = '#AA0000'; lineWidth = 20; beginPath(); moveTo(50,98); lineTo(550, 98); stroke(); } mediaStream(c,50,10, true); } finally { c.restore(); } function cameraIcon(c,x,y) { with (c) { save(); try { translate(x,y); fillRect(-10,-10,20,20); beginPath(); moveTo(7,0); lineTo(20,-10); lineTo(20,10); fill(); font = '100 8px "Press Start 2P", sans-serif'; textAlign = 'center'; textBaseline = 'top'; fillText('Camera', 4, 15); } finally { restore(); } } } function mediaStream(c,x,y,vid) { with (c) { save(); translate(x-10,y-97); // cable fillStyle = 'black'; font = '100 10px "Press Start 2P", sans-serif'; textAlign = 'right'; fillText('Input', 95, 170); textAlign = 'left'; fillText('Output', 407, 170); // media stream fillStyle = '#EE8800'; strokeStyle = '#FFCC00'; lineWidth = 6; fillRect(100,100,300,170); strokeRect(100,100,300,170); fillStyle = 'black'; font = '900 12px "Press Start 2P", sans-serif'; textAlign = 'left'; fillText('MediaStream', 110, 123); // tracks textAlign = 'left'; strokeStyle = '#CC3300'; fillStyle = '#FFFF00'; lineWidth = 4; globalAlpha = vid ? 1 : 0.4; fillRect(120,140,100,110); strokeRect(120,140,100,110); globalAlpha = 1; fillRect(238,140,100,110); strokeRect(238,140,100,110); fillStyle = 'black'; font = '900 10px "Press Start 2P", sans-serif'; globalAlpha = vid ? 1 : 0.4; fillText('Track', 123, 155); fillText('(video)', 123, 170); globalAlpha = 1; fillText('Track', 241, 155); fillText('(stereo', 241, 170); fillText(' audio)', 241, 185); // channels strokeStyle = '#999999'; fillStyle = '#FFFFFF'; lineWidth = 2; fillRect(245,191,86,23); strokeRect(245,191,86,23); fillRect(245,220,86,23); strokeRect(245,220,86,23); fillStyle = 'black'; font = '100 8px "Press Start 2P", sans-serif'; textAlign = 'left'; textBaseline = 'alphabetic'; fillText('left', 249, 202); fillText('channel', 249, 211); fillText('right', 249, 231); fillText('channel', 249, 240); // track check marks fillStyle = 'black'; font = '900 35px "Lucida Grande", sans-serif'; textAlign = 'center'; textBaseline = 'middle'; fillText(vid ? '\u2713' : '\u2716', 220, 245); fillText('\u2713', 338, 245); restore(); } } --> <p>This can be used, for instance, in a video-conferencing scenario to display the local video from the user's camera and microphone in a local monitor, while only transmitting the audio to the remote peer (e.g. in response to the user using a "video mute" feature).</p> <p><img alt="" src=http://images.whatwg.org/media-stream-2.png></p><!-- again, no alt since it's all described in the previous paragraphs: this is just a summary --> <!-- c.clearRect(0, 0, 640, 480); c.save(); try { with (c) { save(); strokeStyle = '#AA0000'; lineWidth = 20; beginPath(); moveTo(50,98); lineTo(550, 98); lineTo(550, 210); lineTo(50, 210); lineTo(50, 320); lineTo(550, 320); lineTo(550,420); stroke(); beginPath(); moveTo(50,320); lineTo(50,420); stroke(); restore(); fillStyle = 'black'; font = '100 10px "Press Start 2P", sans-serif'; textAlign = 'center'; fillText('<video>', 50, 440); fillText('PeerConnection', 550, 440); font = '100 8px "Press Start 2P", sans-serif'; } cameraIcon(c,25,98) mediaStream(c,50,10, true); mediaStream(c,50,233, false); with (c) { font = '100 8px "Press Start 2P", sans-serif'; textAlign = 'left'; textBaseline = 'middle'; fillStyle = 'gray'; fillText('from', 4, 130); fillText('getUserMedia()', 4, 140); fillText('via URL.createObjectURL()', 4, 450); textAlign = 'center'; fillText('via addStream()', 550, 450); } } finally { c.restore(); } function cameraIcon(c,x,y) { with (c) { save(); try { translate(x,y); fillRect(-10,-10,20,20); beginPath(); moveTo(7,0); lineTo(20,-10); lineTo(20,10); fill(); font = '100 8px "Press Start 2P", sans-serif'; textAlign = 'center'; textBaseline = 'top'; fillText('Camera', 4, 15); } finally { restore(); } } } function mediaStream(c,x,y,vid) { with (c) { save(); translate(x-10,y-97); // cable fillStyle = 'black'; font = '100 10px "Press Start 2P", sans-serif'; textAlign = 'right'; fillText('Input', 95, 170); textAlign = 'left'; fillText('Output', 407, 170); // media stream fillStyle = '#EE8800'; strokeStyle = '#FFCC00'; lineWidth = 6; fillRect(100,100,300,170); strokeRect(100,100,300,170); fillStyle = 'black'; font = '900 12px "Press Start 2P", sans-serif'; textAlign = 'left'; fillText(!vid ? 'MediaStream' : 'LocalMediaStream', 110, 123); // tracks textAlign = 'left'; strokeStyle = '#CC3300'; fillStyle = '#FFFF00'; lineWidth = 4; globalAlpha = vid ? 1 : 0.4; fillRect(120,140,100,110); strokeRect(120,140,100,110); globalAlpha = 1; fillRect(238,140,100,110); strokeRect(238,140,100,110); fillStyle = 'black'; font = '900 10px "Press Start 2P", sans-serif'; globalAlpha = vid ? 1 : 0.4; fillText('Track', 123, 155); fillText('(video)', 123, 170); globalAlpha = 1; fillText('Track', 241, 155); fillText('(stereo', 241, 170); fillText(' audio)', 241, 185); // channels strokeStyle = '#999999'; fillStyle = '#FFFFFF'; lineWidth = 2; fillRect(245,191,86,23); strokeRect(245,191,86,23); fillRect(245,220,86,23); strokeRect(245,220,86,23); fillStyle = 'black'; font = '100 8px "Press Start 2P", sans-serif'; textAlign = 'left'; textBaseline = 'alphabetic'; fillText('left', 249, 202); fillText('channel', 249, 211); fillText('right', 249, 231); fillText('channel', 249, 240); // track check marks fillStyle = 'black'; font = '900 35px "Lucida Grande", sans-serif'; textAlign = 'center'; textBaseline = 'middle'; fillText(vid ? '\u2713' : '\u2716', 220, 245); fillText('\u2713', 338, 245); restore(); } } --> <p>When a track in a <code><a href=#mediastream>MediaStream</a></code> <var title="">parent</var> is disabled, any <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> objects corresponding to the tracks in any <code><a href=#mediastream>MediaStream</a></code> objects that were created from <var title="">parent</var> are disassociated from any track, and must not be reused for tracks again. If a disabled track in a <code><a href=#mediastream>MediaStream</a></code> <var title="">parent</var> is re-enabled, from the perspective of any <code><a href=#mediastream>MediaStream</a></code> objects that were created from <var title="">parent</var> it is a new track and thus new <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> objects must be created for the tracks that correspond to the re-enabled track.</p> <hr><p>The <code><a href=#localmediastream>LocalMediaStream</a></code> interface is used when the user agent is generating the stream's data (e.g. from a camera or streaming it from a local video file). It allows authors to control individual tracks during the generation of the content, e.g. to allow the user to temporarily disable a local camera during a video-conference chat.</p> <p>When a <code><a href=#localmediastream>LocalMediaStream</a></code> object is being generated from a local file (as opposed to a live audio/video source), the user agent should stream the data from the file in real time, not all at once. This reduces the ease with which pages can distinguish live video from pre-recorded video, which can help protect the user's privacy.</p> <h4 id=interface-definitions><span class=secno>9.3.2 </span>Interface definitions</h4> <!-- v2: support reading the bits from the stream directly, for use with streaming over WebSocket? Or do we rely on FileReader for that? sicking suggests defining a DataStream or BlobStream interface that you can get from a Stream to get to the underlying data; such an object would then be readable using the File API --> <pre class=idl>[<a href=#dom-mediastream title=dom-MediaStream>Constructor</a>(<a href=#mediastream>MediaStream</a> parentStream)] interface <dfn id=mediastream>MediaStream</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute DOMString <a href=#dom-mediastream-label title=dom-MediaStream-label>label</a>; readonly attribute <a href=#mediastreamtrack>MediaStreamTrack</a>[] <a href=#dom-mediastream-tracks title=dom-MediaStream-tracks>tracks</a>; <a href=#mediastreamrecorder>MediaStreamRecorder</a> <a href=#dom-mediastream-record title=dom-MediaStream-record>record</a>(); <!-- const unsigned short <span title="dom-MediaStream-LOADING">LOADING</span> = 0; --> const unsigned short <a href=#dom-mediastream-live title=dom-MediaStream-LIVE>LIVE</a> = 1; const unsigned short <a href=#dom-mediastream-ended title=dom-MediaStream-ENDED>ENDED</a> = 2; readonly attribute unsigned short <a href=#dom-mediastream-readystate title=dom-MediaStream-readyState>readyState</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-mediastream-onended title=handler-MediaStream-onended>onended</a>; }; interface <dfn id=localmediastream>LocalMediaStream</dfn> : <a href=#mediastream>MediaStream</a> { void <a href=#dom-mediastream-stop title=dom-MediaStream-stop>stop</a>(); }; interface <dfn id=mediastreamtrack>MediaStreamTrack</dfn> { readonly attribute DOMString <a href=#dom-mediastreamtrack-kind title=dom-MediaStreamTrack-kind>kind</a>; readonly attribute DOMString <a href=#dom-mediastreamtrack-label title=dom-MediaStreamTrack-label>label</a>; attribute boolean <a href=#dom-mediastreamtrack-enabled title=dom-MediaStreamTrack-enabled>enabled</a>; };</pre> <dl class=domintro><dt><var title="">stream</var> = new <code title=dom-MediaStream><a href=#dom-mediastream>MediaStream</a></code>( <var title="">parentStream</var> )</dt> <dd> <p>Creates a new <code><a href=#mediastream>MediaStream</a></code> object whose tracks are the enabled tracks of <var title="">parentStream</var>.</p> </dd> <dt><var title="">stream</var> . <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code></dt> <dd> <p>Returns a label that is unique to this stream, so that streams can be recognised after they are sent through the <code><a href=#peerconnection>PeerConnection</a></code> API.</p> </dd> <dt><var title="">recorder</var> = <var title="">stream</var> . <code title=dom-MediaStream-record><a href=#dom-mediastream-record>record</a></code>()</dt> <dd> <p>Begins recording the stream. The returned <code><a href=#mediastreamrecorder>MediaStreamRecorder</a></code> object provides access to the recorded data.</p> </dd> <dt><var title="">stream</var> . <code title=dom-MediaStream-stop><a href=#dom-mediastream-stop>stop</a></code>()</dt> <dd> <p>Permanently stops the generation of media data for the stream.</p> </dd> <dt><var title="">stream</var> . <code title=dom-MediaStream-tracks><a href=#dom-mediastream-tracks>tracks</a></code></dt> <dd> <p>Returns a <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> array representing the tracks that can be enabled and disabled.</p> </dd> <dt><var title="">track</var> = <var title="">stream</var> . <code title=dom-MediaStream-tracks><a href=#dom-mediastream-tracks>tracks</a></code>[<var title="">index</var>]</dt> <dd> <p>Returns the specified <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> object.</p> </dd> <dt><var title="">track</var> . <code title=dom-MediaStreamTrack-kind><a href=#dom-mediastreamtrack-kind>kind</a></code></dt> <dd> <p>Returns the string "<code title="">audio</code>" if the track is an audio track, and the string "<code title="">video</code>" if it is a video track.</p> </dd> <dt><var title="">track</var> . <code title=dom-MediaStreamTrack-label><a href=#dom-mediastreamtrack-label>label</a></code></dt> <dd> <p>Returns the label of the given track, if known, or the empty string otherwise.</p> </dd> <dt><var title="">track</var> . <code title=dom-MediaStreamTrack-enabled><a href=#dom-mediastreamtrack-enabled>enabled</a></code> [ = <var title="">value</var> ]</dt> <dd> <p>Returns true if the given track is active in the <code><a href=#mediastream>MediaStream</a></code>'s output, and false otherwise.</p> <p>Can be set, to change whether the track is enabled or not.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-mediastream title=dom-MediaStream><code>MediaStream(<var title="">parentStream</var>)</code></dfn> constructor must return a new <code><a href=#mediastream>MediaStream</a></code> object whose tracks at any moment in time are the enabled tracks of <var title="">parentStream</var> at that moment, and whose <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> is equal to the <var title="">parentStream</var>'s.</p> <p>The <dfn id=dom-mediastream-readystate title=dom-MediaStream-readyState><code>readyState</code></dfn> attribute represents the state of the stream. It must return the value to which the user agent last set it (as defined below). It can have the following values:</p> <dl><dt><dfn id=dom-mediastream-live title=dom-MediaStream-LIVE><code>LIVE</code></dfn> (numeric value 1)</dt> <dd>The stream is active (the user agent is making a best-effort attempt to receive or generate data in real time).</dd> <dt><dfn id=dom-mediastream-ended title=dom-MediaStream-ENDED><code>ENDED</code></dfn> (numeric value 2)</dt> <dd>The stream has finished (the user agent is no longer receiving or generating data, and will never receive or generate more data for this stream).</dd> </dl><p>When a <code><a href=#mediastream>MediaStream</a></code> object is created, its <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute must be set to <code title=dom-MediaStream-LIVE><a href=#dom-mediastream-live>LIVE</a></code> (1), unless it is being created using the <code title=dom-MediaStream><a href=#dom-mediastream>MediaStream()</a></code> constructor whose argument is a <code><a href=#mediastream>MediaStream</a></code> object whose <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute has the value <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2), in which case the <code><a href=#mediastream>MediaStream</a></code> object must be created with its <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute set to <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2).</p> <p>A <code><a href=#mediastream>MediaStream</a></code> object is said to <i>end</i> when the user agent learns that no more data will ever be forthcoming for this stream.</p> <p>When a <code><a href=#mediastream>MediaStream</a></code> object ends for any reason (e.g. because the user rescinds the permission for the page to use the local camera, or because the data comes from a finite file and the file's end has been reached and the user has not requested that it be looped, or because the stream comes from a remote peer and the remote peer has permanently stopped sending data, or because the <code><a href=#mediastream>MediaStream</a></code> was created from another <code><a href=#mediastream>MediaStream</a></code> and that stream has just itself ended), it is said to be <dfn id=concept-stream-finished title=concept-stream-finished>finished</dfn>. When this happens for any reason other than the <code title=dom-MediaStream-stop><a href=#dom-mediastream-stop>stop()</a></code> method being invoked, the user agent must <a href=#queue-a-task>queue a task</a> that runs the following steps:</p> <ol><li><p>If the object's <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute has the value <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2) already, then abort these steps. (The <code title=dom-MediaStream-stop><a href=#dom-mediastream-stop>stop()</a></code> method was probably called just before the stream stopped for other reasons, e.g. the user clicked an in-page stop button and then the user-agent-provided stop button.)</li> <li><p>Set the object's <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute to <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2).</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-MediaStream-ended><a href=#event-mediastream-ended>ended</a></code> at the object.</li> </ol><p>As soon as a <code><a href=#mediastream>MediaStream</a></code> object is <a href=#concept-stream-finished title=concept-stream-finished>finished</a>, the stream's tracks start outputting only silence and/or blackness, as appropriate, <a href=#finishedMute>as defined earlier</a>.</p> <p>If the end of the stream was reached due to a user request, the <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#user-interaction-task-source>user interaction task source</a>. Otherwise the <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#networking-task-source>networking task source</a>.</p> <hr><p>When a <code><a href=#localmediastream>LocalMediaStream</a></code> object's <dfn id=dom-mediastream-stop title=dom-MediaStream-stop><code>stop()</code></dfn> method is invoked, the user agent must <a href=#queue-a-task>queue a task</a> that runs the following steps:</p> <ol><li><p>If the object's <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute is in the <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2) state, then abort these steps.</li> <li><p>Permanently stop the generation of data for the stream. If the data is being generated from a live source (e.g. a microphone or camera), and no other stream is being generated from a live source, then the user agent should remove any active "on-air" indicator. If the data is being generated from a prerecorded source (e.g. a video file), any remaining content in the file is ignored. The stream is <a href=#concept-stream-finished title=concept-stream-finished>finished</a>. The stream's tracks start outputting only silence and/or blackness, as appropriate, <a href=#finishedMute>as defined earlier</a>.</li> <li><p>Set the object's <code title=dom-MediaStream-readyState><a href=#dom-mediastream-readystate>readyState</a></code> attribute to <code title=dom-MediaStream-ENDED><a href=#dom-mediastream-ended>ENDED</a></code> (2).</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-MediaStream-ended><a href=#event-mediastream-ended>ended</a></code> at the object.</li> </ol><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> queued for the <code title=dom-MediaStream-stop><a href=#dom-mediastream-stop>stop()</a></code> method is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <hr><p>When a <code><a href=#localmediastream>LocalMediaStream</a></code> object is created, the user agent must generate a globally unique identifier string, and must initialize the object's <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> attribute to that string. Such strings must only use characters in the ranges U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E, and must be 36 characters long.</p> <!-- UUIDs have 36 characters including hyphens; the ranges above comes from RFC4574 (the a=label: thing in SDP) --> <p>When a <code><a href=#mediastream>MediaStream</a></code> is created to represent a stream obtained from a remote peer, the <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> attribute is initialized from information provided by the remote source.</p> <!-- described below --> <p>When a <code><a href=#mediastream>MediaStream</a></code> is created from another using the <code title=dom-MediaStream><a href=#dom-mediastream>MediaStream()</a></code> constructor, the <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> attribute is initialized from the original.</p> <!-- described above --> <p>The <dfn id=dom-mediastream-label title=dom-MediaStream-label><code>label</code></dfn> attribute must return the value to which it was initialized when the object was created.</p> <p class=note>The label of a <code><a href=#mediastream>MediaStream</a></code> object is unique to the source of the stream, but that does not mean it is not possible to end up with duplicates. For example, when a <code><a href=#mediastream>MediaStream</a></code> object is created from another using the <code title=dom-MediaStream><a href=#dom-mediastream>MediaStream()</a></code> constructor, the fork has the same label as the original. Similarly, a locally generated stream could be sent from one user to a remote peer using <code><a href=#peerconnection>PeerConnection</a></code>, and then sent back to the original user in the same manner, in which case the original user will have multiple streams with the same label (the locally-generated one and the one received from the remote peer).</p> <hr><p>When the <dfn id=dom-mediastream-record title=dom-MediaStream-record><code>record()</code></dfn> method is invoked, the user agent must return a new <code><a href=#mediastreamrecorder>MediaStreamRecorder</a></code> object associated with the stream.</p> <hr><p>A <code><a href=#mediastream>MediaStream</a></code> can have multiple audio and video sources (e.g. because the user has multiple microphones, or because the real source of the stream is a <a href=#media-resource>media resource</a> with many media tracks). The stream represented by a <code><a href=#mediastream>MediaStream</a></code> thus has zero or more tracks.</p> <hr><p>The <dfn id=dom-mediastream-tracks title=dom-MediaStream-tracks><code>tracks</code></dfn> attribute must return a <a href=#platform-array-objects title="platform array objects">platform array object</a> for objects of type <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> that is <i>fixed length</i> and <i>read only</i>. The same object must be returned each time the attribute is accessed. <a href=#refsWEBIDL>[WEBIDL]</a></p> <p>The array must contain the <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> objects that correspond to the tracks of the stream. The relative order of all tracks in a user agent must be stable. All audio tracks must precede all video tracks. Tracks that come from a <a href=#media-resource>media resource</a> whose format defines an order must be in the order defined by the format; tracks that come from a <a href=#media-resource>media resource</a> whose format does not define an order must be in the relative order in which the tracks are declared in that <a href=#media-resource>media resource</a>. Within these constraints, the order is user-agent defined.</p> <!-- doesn't matter currently since I can't think of any way that you can get multiple tracks together. It would matter if we allowed a MediaStream() constructor that took an array of streams, though, or if getUserMedia() could return multiple audio or video tracks. --> <p>The <dfn id=dom-mediastreamtrack-kind title=dom-MediaStreamTrack-kind><code>MediaStreamTrack.kind</code></dfn> attribute must return the string "<code title="">audio</code>" if the object's corresponding track is or was an audio track, "<code title="">video</code>" if the corresponding track is or was a video track, and a user-agent defined string otherwise.</p> <p>User agents may label audio and video sources (e.g. "Internal microphone" or "External USB Webcam"). The <dfn id=dom-mediastreamtrack-label title=dom-MediaStreamTrack-label><code>MediaStreamTrack.label</code></dfn> attribute must return the label of the object's corresponding track, if any. If the corresponding track has or had no label, the attribute must instead return the empty string.</p> <p class=note>Thus the <code title=dom-MediaStreamTrack-kind><a href=#dom-mediastreamtrack-kind>kind</a></code> and <code title=dom-MediaStreamTrack-label><a href=#dom-mediastreamtrack-label>label</a></code> attributes do not change value, even if the <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> object is disassociated from its corresponding track.</p> <p>The <dfn id=dom-mediastreamtrack-enabled title=dom-MediaStreamTrack-enabled><code>MediaStreamTrack.enabled</code></dfn> attribute, on getting, must return the last value to which it was set. On setting, it must be set to the new value, and then, if the <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> object is still associated with a track, must enable the track if the new value is true, and disable it otherwise.</p> <p class=note>Thus, after a <code><a href=#mediastreamtrack>MediaStreamTrack</a></code> is disassociated from its track, its <code title=dom-MediaStreamTrack-enabled><a href=#dom-mediastreamtrack-enabled>enabled</a></code> attribute still changes value when set, it just doesn't do anything with that new value.</p> <hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#mediastream>MediaStream</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-mediastream-onended title=handler-MediaStream-onended><code>onended</code></dfn> <td> <code title=event-MediaStream-ended><a href=#event-mediastream-ended>ended</a></code> </table></div> <div class=example> <p>This sample code exposes a button. When clicked, the button is disabled and the user is prompted to offer a stream. The user can cause the button to be re-enabled by providing a stream (e.g. giving the page access to the local camera) and then disabling the stream (e.g. revoking that access).</p> <pre> <input type="button" value="Start" onclick="start()" id="startBtn"> <script> var startBtn = document.getElementById('startBtn'); function start() { navigator.getUserMedia('audio,video', gotStream); startBtn.disabled = true; } function gotStream(stream) { stream.onended = function () { startBtn.disabled = false; } } </script></pre> </div> <pre class=idl>interface <dfn id=mediastreamrecorder>MediaStreamRecorder</dfn> { void <a href=#dom-mediastreamrecorder-getrecordeddata title=dom-MediaStreamRecorder-getRecordedData>getRecordedData</a>(<a href=#blobcallback>BlobCallback</a>? callback); }; [Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=blobcallback>BlobCallback</dfn> { void <span title=dom-BlobCallback-handleEvent>handleEvent</span>(<a href=#blob>Blob</a> blob); };</pre> <dl class=domintro><dt><var title="">recorder</var> . <code title=dom-MediaStreamRecorder-getRecordedData><a href=#dom-mediastreamrecorder-getrecordeddata>getRecordedData</a></code>(<var title="">callback</var>)</dt> <dd> <p>Creates a <code><a href=#blob>Blob</a></code> of the recorded data, and invokes the provided callback with that <code><a href=#blob>Blob</a></code>.</p> </dd> </dl><div class=impl> <p>When the <dfn id=dom-mediastreamrecorder-getrecordeddata title=dom-MediaStreamRecorder-getRecordedData><code>getRecordedData()</code></dfn> method is called, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">callback</var> be the callback indicated by the method's first argument.</li> <li><p>If <var title="">callback</var> is null, abort these steps.</li> <!-- we could throw an exception instead (that's why the method doesn't return until later: so that we can add an exception here without changing the algorithm) --> <li><p>Let <var title="">data</var> be the data that was streamed by the <code><a href=#mediastream>MediaStream</a></code> object from which the <code><a href=#mediastreamrecorder>MediaStreamRecorder</a></code> was created since the creation of the <code><a href=#mediastreamrecorder>MediaStreamRecorder</a></code> object.</li> <li><p>Return, and run the remaining steps asynchronously.</li> <li><p>Generate a file that containing <var title="">data</var> in a format supported by the user agent for use in <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements.</li> <li><p>Let <var title="">blob</var> be a <code><a href=#blob>Blob</a></code> object representing the contents of the file generated in the previous step. <a href=#refsFILEAPI>[FILEAPI]</a></p> <li><p><a href=#queue-a-task>Queue a task</a> to invoke <var title="">callback</var> with <var title="">blob</var> as its argument.</li> </ol><p class=note>The <code title=dom-MediaStreamRecorder-getRecordedData><a href=#dom-mediastreamrecorder-getrecordeddata>getRecordedData()</a></code> method can be called multiple times on one <code><a href=#mediastreamrecorder>MediaStreamRecorder</a></code> object; each time, it will create a new file as if this was the first time the method was being called. In particular, the method does not stop or reset the recording when the method is called.</p> </div> <div class=example> <p>This example allows people to record a short audio message and upload it to the server. This example even shows rudimentary error handling.</p> <pre><input type="button" value="⚫" onclick="msgRecord()" id="recBtn"> <input type="button" value="◼" onclick="msgStop()" id="stopBtn" disabled> <p id="status">To start recording, press the ⚫ button.</p> <script> var recBtn = document.getElementById('recBtn'); var stopBtn = document.getElementById('stopBtn'); function report(s) { document.getElementById('status').textContent = s; } function msgRecord() { report('Attempting to access microphone...'); navigator.getUserMedia('audio', gotStream, noStream); recBtn.disabled = true; } var msgStream, msgStreamRecorder; function gotStream(stream) { report('Recording... To stop, press to ◼ button.'); msgStream = stream; msgStreamRecorder = stream.record(); stopBtn.disabled = false; stream.onended = function () { msgStop(); } } function msgStop() { report('Creating file...'); stopBtn.disabled = true; msgStream.onended = null; msgStream.stop(); msgStreamRecorder.getRecordedData(msgSave); } function msgSave(blob) { report('Uploading file...'); var x = new XMLHttpRequest(); x.open('POST', 'uploadMessage'); x.send(blob); x.onload = function () { report('Done! To record a new message, press the ⚫ button.'); recBtn.disabled = false; }; x.onerror = function () { report('Failed to upload message. To try recording a message again, press the ⚫ button.'); recBtn.disabled = false; }; } function noStream() { report('Could not obtain access to your microphone. To try again, press the ⚫ button.'); recBtn.disabled = false; } </script></pre> </div> <pre class=idl>partial interface <dfn id=dom-url title=dom-URL>URL</dfn> { static DOMString <a href=#dom-url-createobjecturl title=dom-URL-createObjectURL>createObjectURL</a>(<a href=#mediastream>MediaStream</a> stream); };</pre> <dl class=domintro><dt><var title="">window</var> . <code title=dom-URL><a href=#dom-url>URL</a></code> . <code title=dom-URL-createObjectURL><a href=#dom-url-createobjecturl>createObjectURL</a></code>(<var title="">stream</var>)</dt> <dd> <p>Mints a <a href=#blob-url>Blob URL</a> to refer to the given <code><a href=#mediastream>MediaStream</a></code>.</p> </dd> </dl><div class=impl> <p>When the <dfn id=dom-url-createobjecturl title=dom-URL-createObjectURL><code>createObjectURL()</code></dfn> method is called with a <code><a href=#mediastream>MediaStream</a></code> argument, the user agent must return a unique <a href=#blob-url>Blob URL</a> for the given <code><a href=#mediastream>MediaStream</a></code>. <a href=#refsFILEAPI>[FILEAPI]</a></p> <p>For audio and video streams, the data exposed on that stream must be in a format supported by the user agent for use in <code><a href=#the-audio-element>audio</a></code> and <code><a href=#the-video-element>video</a></code> elements.</p> <p class=bookkeeping>A <dfn id=blob-url>Blob URL</dfn> is the same as what the File API specification calls a <span>Blob URI</span>, except that anything in the definition of that feature that refers to <code><a href=#file>File</a></code> and <code><a href=#blob>Blob</a></code> objects is hereby extended to also apply to <code><a href=#mediastream>MediaStream</a></code> and <code><a href=#localmediastream>LocalMediaStream</a></code> objects.</p> </div> <div class=example> <p>This example allows people to take photos of themselves from the local video camera.</p> <pre><article> <style scoped> video { transform: scaleX(-1); } p { text-align: center; } </style> <h1>Snapshot Kiosk</h1> <section id="splash"> <p id="errorMessage">Loading...</p> </section> <section id="app" hidden> <p><video id="monitor" autoplay></video> <canvas id="photo"></canvas> <p><input type=button value="&#x1F4F7;" onclick="snapshot()"> </section> <script> navigator.getUserMedia('video user', gotStream, noStream); var video = document.getElementById('monitor'); var canvas = document.getElementById('photo'); function gotStream(stream) { video.src = URL.createObjectURL(stream); video.onerror = function () { stream.stop(); }; stream.onended = noStream; video.onloadedmetadata = function () { canvas.width = video.videoWidth; canvas.height = video.videoHeight; document.getElementById('splash').hidden = true; document.getElementById('app').hidden = false; }; } function noStream() { document.getElementById('errorMessage').textContent = 'No camera available.'; } function snapshot() { canvas.getContext('2d').drawImage(video, 0, 0); } </script> </article></pre> </div> <h3 id=peer-to-peer-connections><span class=secno>9.4 </span>Peer-to-peer connections</h3> <h4 id=introduction-12><span class=secno>9.4.1 </span>Introduction</h4> <p><i>This section is non-normative.</i></p> <p>To send audio, video, or data to another peer, the <code><a href=#peerconnection>PeerConnection</a></code> interface can be used.</p> <p>This interface uses the ICE, SDP, STUN, and TURN technologies to perform NAT traversal and codec negotiation. This is entirely abstracted from the interface, so as to make the API as simple as possible to use.</p> <p>In order to bootstrap a peer-to-peer connection, a page has to first have an indirect communications channel, known as the <i>signaling channel</i>, via which messages can be exchanged with the other peer. Typically, this will take the form of <code>XMLHttpRequest</code>-based or <code><a href=#websocket>WebSocket</a></code>-based communication through the server: messages are sent to the server with a session identifier, and the server then routes them to the other peer using the same session. The precise details of this signaling channel are left up to the page author.</p> <p>Once a signaling channel has been established, one peer is arbitrarily picked as the initiator of the peer-to-peer connection. Typically, this would be the peer whose user initiated the call (in the telephonic sense).</p> <p>This initiating peer creates a <code><a href=#peerconnection>PeerConnection</a></code> object, passing it a configuration string and a signaling callback. The configuration string is how the user agent is informed of STUN and TURN servers, and is described in more detail in the next section. The signaling callback is a function that takes one argument, a string, which it then sends on the signaling channel.</p> <p>After creating the <code><a href=#peerconnection>PeerConnection</a></code> object, the script can use the <code title=dom-PeerConnection-addStream><a href=#dom-peerconnection-addstream>addStream()</a></code> method to add any audio or video streams to be sent.</p> <p>Once the script that created the <code><a href=#peerconnection>PeerConnection</a></code> object has finished, the user agent will invoke the callback with an initial offer, containing any audio or video streams. The precise format of the string sent to the callback is not important for the purposes of the page author; it is simply an opaque string to be sent to the other peer over the signaling channel established earlier.</p> <p>When the other peer, the receiving peer, receives this initial offer, it similarly creates a <code><a href=#peerconnection>PeerConnection</a></code> object with a configuration string and signaling callback, and then calls the <code title=dom-PeerConnection-processSignalingMessage><a href=#dom-peerconnection-processsignalingmessage>processSignalingMessage()</a></code> method with, as its argument, the initial offer received from the initiating peer. It can also use the <code title=dom-PeerConnection-addStream><a href=#dom-peerconnection-addstream>addStream()</a></code> method to add any audio or video streams to be sent back.</p> <p>Once the script that created the receiving peer's <code><a href=#peerconnection>PeerConnection</a></code> object has finished, the receiving peer's user agent invokes its callback to send a response. Again, the author treats this as an opaque string to be sent back to the initating peer over the signaling channel.</p> <p>Messages can be sent back and forth an arbitrary number of times over the signaling channel as the user agents negotiate codecs, as streams get added or removed, etc.</p> <p>Finally when the connection is to be ended the <code title=dom-PeerConnection-close><a href=#dom-peerconnection-close>close()</a></code> method is invoked on the <code><a href=#peerconnection>PeerConnection</a></code> objects.</p> <h4 id=interface-definitions-0><span class=secno>9.4.2 </span>Interface definitions</h4> <pre class=idl>[<a href=#dom-peerconnection title=dom-PeerConnection>Constructor</a>(DOMString serverConfiguration, <a href=#signalingcallback>SignalingCallback</a> signalingCallback)] interface <dfn id=peerconnection>PeerConnection</dfn> : <a href=#eventtarget>EventTarget</a> { void <a href=#dom-peerconnection-processsignalingmessage title=dom-PeerConnection-processSignalingMessage>processSignalingMessage</a>(DOMString message); const unsigned short <a href=#dom-peerconnection-new title=dom-PeerConnection-NEW>NEW</a> = 0; const unsigned short <a href=#dom-peerconnection-negotiating title=dom-PeerConnection-NEGOTIATING>NEGOTIATING</a> = 1; const unsigned short <a href=#dom-peerconnection-active title=dom-PeerConnection-ACTIVE>ACTIVE</a> = 2; const unsigned short <a href=#dom-peerconnection-closed title=dom-PeerConnection-CLOSED>CLOSED</a> = 3; readonly attribute unsigned short <a href=#dom-peerconnection-readystate title=dom-PeerConnection-readyState>readyState</a>; void <a href=#dom-peerconnection-send title=dom-PeerConnection-send>send</a>(DOMString text); <!-- v2: binary --> void <a href=#dom-peerconnection-addstream title=dom-PeerConnection-addStream>addStream</a>(<a href=#mediastream>MediaStream</a> stream); void <a href=#dom-peerconnection-removestream title=dom-PeerConnection-removeStream>removeStream</a>(<a href=#mediastream>MediaStream</a> stream); readonly attribute <a href=#mediastream>MediaStream</a>[] <a href=#dom-peerconnection-localstreams title=dom-PeerConnection-localStreams>localStreams</a>; readonly attribute <a href=#mediastream>MediaStream</a>[] <a href=#dom-peerconnection-remotestreams title=dom-PeerConnection-remoteStreams>remoteStreams</a>; void <a href=#dom-peerconnection-close title=dom-PeerConnection-close>close</a>(); // <span class=XXX>connection quality information</span> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-peerconnection-onconnecting title=handler-PeerConnection-onconnecting>onconnecting</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-peerconnection-onopen title=handler-PeerConnection-onopen>onopen</a>;<!-- [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-PeerConnection-onerror">onerror</span>; [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-PeerConnection-onclose">onclose</span>;--> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-peerconnection-onmessage title=handler-PeerConnection-onmessage>onmessage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-peerconnection-onaddstream title=handler-PeerConnection-onaddstream>onaddstream</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-peerconnection-onremovestream title=handler-PeerConnection-onremovestream>onremovestream</a>; }; [Callback=FunctionOnly, NoInterfaceObject] interface <dfn id=signalingcallback>SignalingCallback</dfn> { void <span title=dom-SignalingCallback-handleEvent>handleEvent</span>(DOMString message, <a href=#peerconnection>PeerConnection</a> source); };</pre> <p>A <code><a href=#peerconnection>PeerConnection</a></code> allows two users to communicate directly, browser-to-browser. Communications are coordinated via a signaling channel provided by script in the page via the server, e.g. using <code>XMLHttpRequest</code>.</p> <dl class=domintro><dt><var title="">connection</var> = new <code title=dom-PeerConnection><a href=#dom-peerconnection>PeerConnection</a></code>(<var title="">serverConfiguration</var>, <var title="">signalingCallback</var>)</dt> <dd> <p>Creates a <code><a href=#peerconnection>PeerConnection</a></code> object.</p> <p>The <var title="">serverConfiguration</var> string gives the address of a STUN or TURN server to use to establish the connection. <a href=#refsSTUN>[STUN]</a> <a href=#refsTURN>[TURN]</a></p> <p>The allowed formats for this string are:</p> <dl><dt>"<code title=""><var title="">TYPE</var> 203.0.113.2:3478</code>" <dd> <p>Indicates a specific IP address and port for the server.</p> </dd> <dt>"<code title=""><var title="">TYPE</var> relay.example.net:3478</code>" <dd> <p>Indicates a specific host and port for the server; the user agent will look up the IP address in DNS.</p> </dd> <dt>"<code title=""><var title="">TYPE</var> example.net</code>" <dd> <p>Indicates a specific domain for the server; the user agent will look up the IP address and port in DNS.</p> </dd> </dl><p>The "<code title=""><var title="">TYPE</var></code>" is one of:</p> <dl><dt><code title="">STUN</code></dt> <dd>Indicates a STUN server <dt><code title="">STUNS</code></dt> <dd>Indicates a STUN server that is to be contacted using a TLS session. <dt><code title="">TURN</code></dt> <dd>Indicates a TURN server <dt><code title="">TURNS</code></dt> <dd>Indicates a TURN server that is to be contacted using a TLS session. </dl><p>The <var title="">signalingCallback</var> argument is a method that will be invoked when the user agent needs to send a message to the other host over the signaling channel. When the callback is invoked, convey its first argument (a string) to the other peer using whatever method is being used by the Web application to relay signaling messages. (Messages returned from the other peer are provided back to the user agent using the <code title=dom-PeerConnection-processSignalingMessage><a href=#dom-peerconnection-processsignalingmessage>processSignalingMessage()</a></code> method.)</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-readyState><a href=#dom-peerconnection-readystate>readyState</a></code></dt> <dd> <p>Returns the current readiness state for the connection, represented by a number from the following list:</p> <dl><dt> <code><a href=#peerconnection>PeerConnection</a></code> . <code title=dom-PeerConnection-NEW><a href=#dom-peerconnection-new>NEW</a></code> (0)</dt> <dd>The object was just created, and no networking has yet occurred.</dd> <dt> <code><a href=#peerconnection>PeerConnection</a></code> . <code title=dom-PeerConnection-NEGOTIATING><a href=#dom-peerconnection-negotiating>NEGOTIATING</a></code> (1)</dt> <dd>The user agent is attempting to establish a connection.</dd> <dt> <code><a href=#peerconnection>PeerConnection</a></code> . <code title=dom-PeerConnection-ACTIVE><a href=#dom-peerconnection-active>ACTIVE</a></code> (2)</dt> <dd>The connection is as good as its going to get.</dd> <dt> <code><a href=#peerconnection>PeerConnection</a></code> . <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3)</dt> <dd>The connection is closed.</dd> </dl></dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-processSignalingMessage><a href=#dom-peerconnection-processsignalingmessage>processSignalingMessage</a></code>(<var title="">message</var>)</dt> <dd> <p>When a message is relayed from the remote peer over the signaling channel is received by the Web application, pass it to the user agent by calling the <code title=dom-PeerConnection-processSignalingMessage><a href=#dom-peerconnection-processsignalingmessage>processSignalingMessage()</a></code> method.</p> <p>The order of messages is important. Passing messages to the user agent in a different order than they were generated by the remote peer's user agent can prevent a successful connection from being established or degrade the connection's quality if one is established.</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-send><a href=#dom-peerconnection-send>send</a></code>(<var title="">text</var>)</dt> <dd> <!-- v2: binary --> <p>Attempts to send the given text to the remote peer. This uses UDP, which is inherently unreliable; there is no guarantee that every message will be received.</p> <p>When a message sent in this manner from the other peer is received, a <code title=event-MediaStream-message><a href=#event-mediastream-message>message</a></code> event is fired at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> <p>The maximum length of <var title="">text</var> is 504 bytes after encoding the string as UTF-8; attempting to send a payload greater than 504 bytes results in an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception.</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-addStream><a href=#dom-peerconnection-addstream>addStream</a></code>(<var title="">stream</var>)</dt> <dd> <p>Attempts to starting sending the given stream to the remote peer.</p> <p>When the other peer starts sending a stream in this manner, an <code title=event-MediaStream-addstream><a href=#event-mediastream-addstream>addstream</a></code> event is fired at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-removeStream><a href=#dom-peerconnection-removestream>removeStream</a></code>(<var title="">stream</var>)</dt> <dd> <p>Stops sending the given stream to the remote peer.</p> <p>When the other peer stops sending a stream in this manner, a <code title=event-MediaStream-removestream><a href=#event-mediastream-removestream>removestream</a></code> event is fired at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code></dt> <dd> <p>Returns a live array containing the streams that the user agent is currently attempting to transmit to the remote peer (those that were added with <code title=dom-PeerConnection-addStream><a href=#dom-peerconnection-addstream>addStream()</a></code>).</p> </dd> <dt><var title="">connection</var> . <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code></dt> <dd> <p>Returns a live array containing the streams that the user agent is currently receiving from the remote peer.</p> <p>This array is updated when <code title=event-MediaStream-addstream><a href=#event-mediastream-addstream>addstream</a></code> and <code title=event-MediaStream-removestream><a href=#event-mediastream-removestream>removestream</a></code> events are fired.</p> </dd> </dl><div class=impl> <p>A <code><a href=#peerconnection>PeerConnection</a></code> object has an associated <dfn id=peerconnection-signaling-callback><code>PeerConnection</code> signaling callback</dfn>, a <dfn id=peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</dfn>, a <dfn id=peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</dfn>, a <dfn id=peerconnection-readiness-state><code>PeerConnection</code> readiness state</dfn> and an <dfn id=ice-started-flag>ICE started flag</dfn>. These are initialized when the object is created.</p> <p>The <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> can have the following values:</p> <dl><dt><dfn id=dom-peerconnection-new title=dom-PeerConnection-NEW><code>NEW</code></dfn> (numeric value 0)</dt> <dd>The object was just created and its ICE Agent has not yet been started.</dd> <dt><dfn id=dom-peerconnection-negotiating title=dom-PeerConnection-NEGOTIATING><code>NEGOTIATING</code></dfn> (numeric value 1)</dt> <dd>The ICE Agent is actively preforming ICE processing.</dd> <dt><dfn id=dom-peerconnection-active title=dom-PeerConnection-ACTIVE><code>ACTIVE</code></dfn> (numeric value 2)</dt> <dd>The ICE Agent has concluded ICE processing. If any media streams were successfully negotiated, any relevant media is streaming.</dd> <dt><dfn id=dom-peerconnection-closed title=dom-PeerConnection-CLOSED><code>CLOSED</code></dfn> (numeric value 3)</dt> <dd>The <code title=dom-PeerConnection-close><a href=#dom-peerconnection-close>close()</a></code> method has been invoked.</dd> </dl><p>When the <dfn id=dom-peerconnection title=dom-PeerConnection><code>PeerConnection()</code></dfn> constructor is invoked, the user agent must run the following steps. This algorithm has a <a href=#synchronous-section>synchronous section</a> (which is triggered as part of the <a href=#event-loop>event loop</a> algorithm). Steps in the <a href=#synchronous-section>synchronous section</a> are marked with ⌛.</p> <ol><li><p>Let <var title="">serverConfiguration</var> be the constructor's first argument.</li> <li><p>Let <var title="">signalingCallback</var> be the constructor's second argument.</li> <li><p>Let <var title="">connection</var> be a newly created <code><a href=#peerconnection>PeerConnection</a></code> object.</li> <li><p>Create an ICE Agent and let <var title="">connection</var>'s <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> be that ICE Agent. <a href=#refsICE>[ICE]</a></li> <li><p>If <var title="">serverConfiguration</var> contains a U+000A LINE FEED (LF) character or a U+000D CARRIAGE RETURN (CR) character (or both), remove all characters from <var title="">serverConfiguration</var> after the first such character.</li> <li><p><a href=#split-a-string-on-spaces title="split a string on spaces">Split <var title="">serverConfiguration</var> on spaces</a> to obtain <var title="">configuration components</var>.</li> <li> <p>If <var title="">configuration components</var> has two or more components, and the first component is a <a href=#case-sensitive>case-sensitive</a> match for one of the following strings:</p> <ul class=brief><li>"<code title="">STUN</code>" <li>"<code title="">STUNS</code>" <li>"<code title="">TURN</code>" <li>"<code title="">TURNS</code>" </ul><p>...then run the following substeps:</p> <ol><li><p>Let <var title="">server type</var> be STUN if the first component of <var title="">configuration components</var> is "<code title="">STUN</code>" or "<code title="">STUNS</code>", and TURN otherwise (the first component of <var title="">configuration components</var> is "<code title="">TURN</code>" or "<code title="">TURNS</code>").</p> <li><p>Let <var title="">secure</var> be true if the first component of <var title="">configuration components</var> is "<code title="">STUNS</code>" or "<code title="">TURNS</code>", and false otherwise.</p> <li><p>Let <var title="">host</var> be the contents of the second component of <var title="">configuration components</var> up to the character before the first U+003A COLON character (:), if any, or the entire string otherwise.</li> <li><p>Let <var title="">port</var> be the contents of the second component of <var title="">configuration components</var> from the character after the first U+003A COLON character (:) up to the end, if any, or the empty string otherwise.</li> <li> <p>Configure the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a>'s STUN or TURN server as follows:</p> <ul><li>If <var title="">server type</var> is STUN, the server is a STUN server. Otherwise, <var title="">server type</var> is TURN and the server is a TURN server.</li> <li>If <var title="">secure</var> is true, the server is to be contacted using TLS-over-TCP, otherwise, it is to be contacted using UDP.</li> <li>The IP address, host name, or domain name of the server is <var title="">host</var>.</li> <li>The port to use is <var title="">port</var>. If this is the empty string, then only a domain name is configured (and the ICE Agent will use DNS SRV requests to determine the IP address and port).</li> <li>The long-term username for the STUN or TURN server is the <a href=#ascii-serialization-of-an-origin title="ASCII serialization of an origin">ASCII serialization</a> of the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a>; the long-term password is the empty string.</li> </ul><p>If the given IP address, host name, domain name, or port are invalid, then the user agent must act as if no STUN or TURN server is configured.</p> </li> </ol></li> <li><p>Let the <var title="">connection</var>'s <a href=#peerconnection-signaling-callback><code>PeerConnection</code> signaling callback</a> be <var title="">signalingCallback</var>.</li> <li><p>Set <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> to <code title=dom-PeerConnection-NEW><a href=#dom-peerconnection-new>NEW</a></code> (0).</li> <li><p>Set <var title="">connection</var>'s <a href=#ice-started-flag>ICE started flag</a> to false.</li> <li><p>Let <var title="">connection</var>'s <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a> be a new <a href=#data-udp-media-stream>data UDP media stream</a>.</li> <li><p>Let <var title="">connection</var>'s <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> attribute be an empty read-only <code><a href=#mediastream>MediaStream</a></code> array. <a href=#refsWEBIDL>[WEBIDL]</a></li> <li><p>Let <var title="">connection</var>'s <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> attribute be an empty read-only <code><a href=#mediastream>MediaStream</a></code> array. <a href=#refsWEBIDL>[WEBIDL]</a></li> <li><p>Return <var title="">connection</var>, but continue these steps asynchronously.</li> <li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous section</a> consists of the remaining steps of this algorithm. (Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked with ⌛.)</li> <li><p>⌛ If <var title="">connection</var>'s <a href=#ice-started-flag>ICE started flag</a> is still false, start the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> and send the initial offer. The initial offer must include a media description for the <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a>, marked as "sendrecv", and for all the streams in <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> (marked as "sendonly"). <a href=#refsICE>[ICE]</a> <a href=#refsSDPOFFERANSWER>[SDPOFFERANSWER]</a></li> <li><p>⌛ Let <var title="">connection</var>'s <a href=#ice-started-flag>ICE started flag</a> be true.</li> <li><p>⌛ If <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is still <code title=dom-PeerConnection-NEW><a href=#dom-peerconnection-new>NEW</a></code> (0), then <a href=#queue-a-task>queue a task</a> that sets it to <code title=dom-PeerConnection-NEGOTIATING><a href=#dom-peerconnection-negotiating>NEGOTIATING</a></code> (1) and then <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-MediaStream-connecting><a href=#event-mediastream-connecting>connecting</a></code> at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> </ol><p>When a <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> is required to send SDP offers or answers, the user agent must follow these steps:</p> <ol><li><p>Let <var title="">sdp</var> be the SDP offer or answer to be sent. <a href=#refsSDPOFFERANSWER>[SDPOFFERANSWER]</a></li> <li><p>Let <var title="">message</var> be the concatenation of the string "<code title="">SDP</code>", a U+000A LINE FEED (LF) character, and <var title="">sdp</var>, in that order.</li> <li><p><a href=#queue-a-task>Queue a task</a> to invoke that <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a>'s <a href=#peerconnection-signaling-callback><code>PeerConnection</code> signaling callback</a> with <var title="">message</var> as its first argument and the <code><a href=#peerconnection>PeerConnection</a></code> as its second argument.</li> </ol><p>All streams represented by <code><a href=#mediastream>MediaStream</a></code> objects must be marked as "sendonly" by the peer that initially adds the stream to the session. The <code><a href=#peerconnection>PeerConnection</a></code> API does not support bidirectional ("sendrecv") audio or video media streams. <a href=#refsSDPOFFERANSWER>[SDPOFFERANSWER]</a></p> <p>User agents may negotiate any codec and any resolution, bitrate, or other quality metric. User agents are encouraged to initially negotiate for the native resolution of the stream. For streams that are then rendered (using a <code><a href=#the-video-element>video</a></code> element), user agents are encouraged to renegotiate for a resolution that matches the rendered display size.</p> <p class=note>Starting with the native resolution means that if the Web application notifies its peer of the native resolution as it starts sending data, and the peer prepares its <code><a href=#the-video-element>video</a></code> element accordingly, there will be no need for a renegotiation once the stream is flowing.</p> <p>All SDP media descriptions for streams represented by <code><a href=#mediastream>MediaStream</a></code> objects must include a label attribute ("<code title="">a=label:</code>") whose value is the value of the <code><a href=#mediastream>MediaStream</a></code> object's <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> attribute. <a href=#refsSDP>[SDP]</a> <a href=#refsSDPLABEL>[SDPLABEL]</a></p> <p><a href=#peerconnection-ice-agent title="PeerConnection ICE Agent"><code>PeerConnection</code> ICE Agents</a> must not generate any candidates for media streams whose media descriptions do not have a label attribute ("<code title="">a=label:</code>"). <a href=#refsICE>[ICE]</a> <a href=#refsSDP>[SDP]</a> <a href=#refsSDPLABEL>[SDPLABEL]</a></p> <p>When a user agent starts receiving media for a component and a candidate was provided for that component by a <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a>, the user agent must follow these steps:</p> <ol><li><p>Let <var title="">connection</var> be the <code><a href=#peerconnection>PeerConnection</a></code> whose ICE Agent is expecting this media.</li> <li><p>If there is already a <code><a href=#mediastream>MediaStream</a></code> object for the media stream to which this component belongs, then associate the component with that media stream and abort these steps. (Some media streams have multiple components; this API does not expose the role of these individual components in ICE.)</li> <li><p>Create a <code><a href=#mediastream>MediaStream</a></code> object to represent the media stream. Set its <code title=dom-MediaStream-label><a href=#dom-mediastream-label>label</a></code> attribute to the value of the SDP Label attribute for that component's media stream.</li> <li> <p><a href=#queue-a-task>Queue a task</a> to run the following substeps:</p> <ol><li><p>If the <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), abort these steps.</li> <!-- close() was probably called just before this task ran --> <li><p>Add the newly created <code><a href=#mediastream>MediaStream</a></code> object to the end of <var title="">connection</var>'s <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> array.</li> <li><p><a href=#fire-a-stream-event>Fire a stream event</a> named <code title=event-MediaStream-addstream><a href=#event-mediastream-addstream>addstream</a></code> with the newly created <code><a href=#mediastream>MediaStream</a></code> object at the <var title="">connection</var> object.</li> </ol></li> </ol><p>When a <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> finds that a stream from the remote peer has been removed (its port has been set to zero in a media description sent on the signaling channel), the user agent must follow these steps:</p> <ol><li><p>Let <var title="">connection</var> be the <code><a href=#peerconnection>PeerConnection</a></code> whose <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> has determined that a stream is being removed.</li> <li><p>Let <var title="">stream</var> be the <code><a href=#mediastream>MediaStream</a></code> object that represents the media stream being removed, if any. If there isn't one, then abort these steps.</li> <li> <p>By definition, <var title="">stream</var> is now <a href=#concept-stream-finished title=concept-stream-finished>finished</a>.</p> <p class=note>A <a href=#concept-task title=concept-task>task</a> is thus <a href=#queue-a-task title="queue a task">queued</a> to update <var title="">stream</var> and fire an event.</p> </li> <li> <p><a href=#queue-a-task>Queue a task</a> to run the following substeps:</p> <ol><li><p>If the <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), abort these steps.</li> <!-- close() was probably called just before this task ran --> <li><p>Remove <var title="">stream</var> from <var title="">connection</var>'s <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> array.</li> <li><p><a href=#fire-a-stream-event>Fire a stream event</a> named <code title=event-MediaStream-removestream><a href=#event-mediastream-removestream>removestream</a></code> with <var title="">stream</var> at the <var title="">connection</var> object.</li> </ol></li> </ol><p>When the <dfn id=dom-peerconnection-processsignalingmessage title=dom-PeerConnection-processSignalingMessage><code title="">processSignalingMessage()</code></dfn> method is invoked, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">message</var> be the method's argument.</li> <li><p>Let <var title="">connection</var> be the <code><a href=#peerconnection>PeerConnection</a></code> object on which the method was invoked.</li> <li><p>If <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li> <p>If the first four characters of <var title="">message</var> are not "<code title="">SDP</code>" followed by a U+000A LINE FEED (LF) character, then abort these steps. (This indicates an error in the signaling channel implementation. User agents may report such errors to their developer consoles to aid debugging.)</p> <p class=note>Future extensions to the <code><a href=#peerconnection>PeerConnection</a></code> interface might use other prefix values to implement additional features.</p> </li> <li><p>Let <var title="">sdp</var> be the string consisting of all but the first four characters of <var title="">message</var>.</li> <li><p>If <var title="">connection</var>'s <a href=#ice-started-flag>ICE started flag</a> is true, then pass <var title="">sdp</var> to the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> as a subsequent offer or answer, to be interpreted as appropriate given the current state of the ICE Agent, and abort these steps. <a href=#refsICE>[ICE]</a></li> <li> <p>The <a href=#ice-started-flag>ICE started flag</a> is false. Start the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> and pass it <var title="">sdp</var> as the initial offer from the other peer; the ICE Agent will then (asynchronously) construct the initial answer and transmit it as described above.</p> <p>If there is a <a href=#remotely-initiated-data-udp-media-stream>remotely-initiated data UDP media stream</a> in the initial offer, and it has an encryption key advertised in its media description that is 16 bytes long, then that is the <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a>.</p> <p>After the initial answer has been sent, the ICE Agent must add all the streams in <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> to the session, as described above. <a href=#refsICE>[ICE]</a></p> </li> <li><p>Let <var title="">connection</var>'s <a href=#ice-started-flag>ICE started flag</a> be true.</li> <li><p><a href=#queue-a-task>Queue a task</a> that sets <var title="">connection</var>'s <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> to <code title=dom-PeerConnection-NEGOTIATING><a href=#dom-peerconnection-negotiating>NEGOTIATING</a></code> (1) and then <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-MediaStream-connecting><a href=#event-mediastream-connecting>connecting</a></code> at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> </ol><p>When a <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> completes ICE processing (even if there are no active streams), the user agent must <a href=#queue-a-task>queue a task</a> that sets the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> to <code title=dom-PeerConnection-ACTIVE><a href=#dom-peerconnection-active>ACTIVE</a></code> (2) and then <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-MediaStream-open><a href=#event-mediastream-open>open</a></code> at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> <p>When a <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> restarts ICE processing for any reason (e.g. because a peer is adding or removing a stream), the user agent must <a href=#queue-a-task>queue a task</a> that sets the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> to <code title=dom-PeerConnection-NEGOTIATING><a href=#dom-peerconnection-negotiating>NEGOTIATING</a></code> (1) and then <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-MediaStream-connecting><a href=#event-mediastream-connecting>connecting</a></code> at the <code><a href=#peerconnection>PeerConnection</a></code> object.</p> <p>The <dfn id=dom-peerconnection-readystate title=dom-PeerConnection-readyState><code title="">readyState</code></dfn> attribute must return the numeric value of the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a>.</p> <p>When the <dfn id=dom-peerconnection-send title=dom-PeerConnection-send><code title="">send()</code></dfn> method is invoked, the user agent must run the following steps:</p> <ol><!-- v2: binary --><li><p>Let <var title="">message</var> be the method's first argument.</li> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>Let <var title="">data</var> be <var title="">message</var> encoded as UTF-8. <a href=#refsRFC3629>[RFC3629]</a></li> <li><p>If <var title="">data</var> is longer than 504 bytes, throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these steps.</li> <!-- IPv4: 576 (min IPv4 MTU size) - 20 (IP header) - 8 (UDP header) - 44 (UDP data media stream overhead) = 504 --> <!-- IPv6: 1280 (min IPv6 MTU size) - 40 (IP header) - 8 (UDP header) - 44 (UDP data media stream overhead) = 1188 --> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a> is not an <a href=#active-data-udp-media-stream>active data UDP media stream</a>, abort these steps. No message is sent.</li> <li><p>If the user agent is rate-limiting packets sent using this API, and sending the data packet at this time would exceed the limit, then abort these steps. User agents may report this to the user, e.g. in a development console.</li> <li><p><a href=#transmit-a-data-packet-to-a-peer>Transmit a data packet to a peer</a> using the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a> with <var title="">data</var> as the message.</li> </ol><p>When the <dfn id=dom-peerconnection-addstream title=dom-PeerConnection-addStream><code title="">addStream()</code></dfn> method is invoked, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">stream</var> be the method's argument.</li> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>If <var title="">stream</var> is already in the <code><a href=#peerconnection>PeerConnection</a></code> object's <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> object, then abort these steps.</li> <li><p>Add <var title="">stream</var> to the end of the <code><a href=#peerconnection>PeerConnection</a></code> object's <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> object.</li> <li><p>Return from the method.</li> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#ice-started-flag>ICE started flag</a> is false, then abort these steps.</li> <li><p>Have the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> add a media stream for <var title="">stream</var> the next time the user agent <a href=#provide-a-stable-state title="provide a stable state">provides a stable state</a>. Any other pending stream additions and removals must be processed at the same time. <a href=#refsICE>[ICE]</a></li> <!-- section 9.1.1.3 --> </ol><p>When the <dfn id=dom-peerconnection-removestream title=dom-PeerConnection-removeStream><code title="">removeStream()</code></dfn> method is invoked, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">stream</var> be the method's argument.</li> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>If <var title="">stream</var> is not in the <code><a href=#peerconnection>PeerConnection</a></code> object's <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> object, then abort these steps.</li> <li><p>Remove <var title="">stream</var> from the <code><a href=#peerconnection>PeerConnection</a></code> object's <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> object.</li> <li><p>Return from the method.</li> <li><p>If the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#ice-started-flag>ICE started flag</a> is false, then abort these steps.</li> <li><p>Have the <code><a href=#peerconnection>PeerConnection</a></code>'s <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> remove the media stream for <var title="">stream</var> the next time the user agent <a href=#provide-a-stable-state title="provide a stable state">provides a stable state</a>. Any other pending stream additions and removals must be processed at the same time. <a href=#refsICE>[ICE]</a></li> <!-- section 9.1.1.2 --> </ol><p>The <dfn id=dom-peerconnection-localstreams title=dom-PeerConnection-localStreams><code>localStreams</code></dfn> and <dfn id=dom-peerconnection-remotestreams title=dom-PeerConnection-remoteStreams><code>remoteStreams</code></dfn> attributes must return the read-only <code><a href=#mediastream>MediaStream</a></code> arrays that the attributes were respectively set to when the <code><a href=#peerconnection>PeerConnection</a></code>'s constructor ran.</p> <p>When the <dfn id=dom-peerconnection-close title=dom-PeerConnection-close><code title="">close()</code></dfn> method is invoked, the user agent must run the following steps:</p> <ol><li><p>If the <code><a href=#peerconnection>PeerConnection</a></code> object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> is <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3), throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</li> <li><p>Destroy the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a>, abruptly ending any active ICE processing and any active streaming, and releasing any relevant resources (e.g. TURN permissions).</li> <li><p>Set the object's <a href=#peerconnection-readiness-state><code>PeerConnection</code> readiness state</a> to <code title=dom-PeerConnection-CLOSED><a href=#dom-peerconnection-closed>CLOSED</a></code> (3).</li> <!-- <li><p><span>Queue a task</span> to <span>fire a simple event</span> named <code title="event-MediaStream-close">close</code> at the <code>PeerConnection</code> object.</p></li> --> </ol><p class=note>The <code title=dom-PeerConnection-localStreams><a href=#dom-peerconnection-localstreams>localStreams</a></code> and <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> objects remain in the state they were in when the object was closed.</p> <hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#peerconnection>PeerConnection</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-peerconnection-onconnecting title=handler-PeerConnection-onconnecting><code>onconnecting</code></dfn> <td> <code title=event-MediaStream-connecting><a href=#event-mediastream-connecting>connecting</a></code> <tr><td><dfn id=handler-peerconnection-onopen title=handler-PeerConnection-onopen><code>onopen</code></dfn> <td> <code title=event-MediaStream-open><a href=#event-mediastream-open>open</a></code> <!-- <tr><td><dfn title="handler-PeerConnection-onerror"><code>onerror</code></dfn> <td> <code title="event-MediaStream-error">error</code>--> <!-- <tr><td><dfn title="handler-PeerConnection-onclose"><code>onclose</code></dfn> <td> <code title="event-MediaStream-close">close</code>--> <tr><td><dfn id=handler-peerconnection-onmessage title=handler-PeerConnection-onmessage><code>onmessage</code></dfn> <td> <code title=event-MediaStream-message><a href=#event-mediastream-message>message</a></code> <tr><td><dfn id=handler-peerconnection-onaddstream title=handler-PeerConnection-onaddstream><code>onaddstream</code></dfn> <td> <code title=event-MediaStream-addstream><a href=#event-mediastream-addstream>addstream</a></code> <tr><td><dfn id=handler-peerconnection-onremovestream title=handler-PeerConnection-onremovestream><code>onremovestream</code></dfn> <td> <code title=event-MediaStream-removestream><a href=#event-mediastream-removestream>removestream</a></code> </table><hr><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> listed in this section is the <a href=#networking-task-source>networking task source</a>.</p> </div> <div class=example> <p>When two peers decide they are going to set up a connection to each other, they both go through these steps. The STUN/TURN server configuration describes a server they can use to get things like their public IP address or to set up NAT traversal. They also have to send data for the signaling channel to each other using the same out-of-band mechanism they used to establish that they were going to communicate in the first place.</p> <pre>// the first argument describes the STUN/TURN server configuration var local = new PeerConnection('TURNS example.net', sendSignalingChannel); local.signalingChannel(...); // if we have a message from the other side, pass it along here // (aLocalStream is some LocalMediaStream object) local.addStream(aLocalStream); // start sending video function sendSignalingChannel(message) { ... // send message to the other side via the signaling channel } function receiveSignalingChannel (message) { // call this whenever we get a message on the signaling channel local.signalingChannel(message); } local.onaddstream = function (event) { // (videoElement is some <video> element) videoElement.src = URL.createObjectURL(event.stream); };</pre> </div> <p class=warning>To prevent network sniffing from allowing a fourth party to establish a connection to a peer using the information sent out-of-band to the other peer and thus spoofing the client, the configuration information should always be transmitted using an encrypted connection.</p> <div class=impl> <h3 id=the-data-stream><span class=secno>9.5 </span>The data stream</h3> <p>All <code><a href=#peerconnection>PeerConnection</a></code> connections include a <dfn id=data-udp-media-stream>data UDP media stream</dfn>, which is used to send data packets peer-to-peer, for instance game control packets. This data channel is unreliable (packets are not guaranteed to be delivered), and packets received out of order are discarded.</p> <p>SDP media descriptions for <a href=#data-udp-media-stream title="data UDP media stream">data UDP media streams</a> must use the "<code title="">application</code>" media type, the "<code title="">udp</code>" transport protocol, and the "<code><a href=#application/html-peer-connection-data>application/html-peer-connection-data</a></code>" media format description. <a href=#refsSDP>[SDP]</a></p> <p>All SDP media descriptions for <a href=#data-udp-media-stream title="data UDP media stream">data UDP media streams</a> must include a label attribute ("<code title="">a=label:</code>") whose value is the string "<code title="">data</code>". <a href=#refsSDP>[SDP]</a> <a href=#refsSDPLABEL>[SDPLABEL]</a></p> <p>All SDP media descriptions for <a href=#data-udp-media-stream title="data UDP media stream">data UDP media streams</a> must also include a key field ("<code title="">k=</code>"), with the value being a base64-encoded representation of 16 cryptographically random bytes determined on a per-ICE-Agent basis. <a href=#refsSDP>[SDP]</a></p> <p><a href=#peerconnection-ice-agent title="PeerConnection ICE Agent"><code>PeerConnection</code> ICE Agents</a> must attempt to establish a connection for their <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a> with the initial offer/answer exchange, and must maintain that UDP media stream for the ICE Agents' whole lifetime.</p> <p>Each <a href=#peerconnection-data-udp-media-stream><code>PeerConnection</code> data UDP media stream</a> has a <dfn id=sending-sequence-number>sending sequence number</dfn>, which must initially be set to one (1), and a <dfn id=most-recently-received-sequence-number>most recently received sequence number</dfn>, much must initially be zero (0). <p>A <a href=#data-udp-media-stream>data UDP media stream</a> is an <dfn id=active-data-udp-media-stream>active data UDP media stream</dfn> if the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> has selected a destination for it. A <a href=#data-udp-media-stream>data UDP media stream</a> can change active status many times during the lifetime of its <code><a href=#peerconnection>PeerConnection</a></code> object (e.g. any time the network topology changes and the ICE Agent performs an ICE Restart). <a href=#refsICE>[ICE]</a></p> <p>Bytes transmitted on a <a href=#data-udp-media-stream>data UDP media stream</a> are masked so as to prevent cross-protocol attacks (<a href=#data-udp-media-stream>data UDP media stream</a> always appear to contain random noise to other protocols). For the purposes of masking, the <dfn id=data-udp-media-stream-masking-salt>data UDP media stream masking salt</dfn> is defined to be the following 16 bytes, described here as hexadecimal numbers: DB 68 B5 FD 17 0E 15 77 56 AF 7A 3A 1A 57 75 02</p> <!-- obtained thusly: head -c 16 /dev/urandom | hexdump -C --> <p>Bytes transmitted on a <a href=#data-udp-media-stream>data UDP media stream</a> are also hashed so as to prevent forgery attacks (an attacker cannot change the data without knowing the key negotiated via the signaling channel). For the purposes of this hashing, the <dfn id=data-udp-media-stream-hashing-salt>data UDP media stream hashing salt</dfn> is defined to be the following 16 bytes, described here as hexadecimal numbers: 4E 2F 96 AB 0A 39 92 A2 56 94 91 F5 7E 58 2E FA</p> <!-- obtained thusly: head -c 16 /dev/urandom | hexdump -C --> <p>When the user agent is to <dfn id=transmit-a-data-packet-to-a-peer>transmit a data packet to a peer</dfn> using a <a href=#data-udp-media-stream>data UDP media stream</a> and with a byte string payload <var title="">raw message</var>, the user agent must run the following steps:</p> <ol><li><p>Let <var title="">nonce</var> be 16 cryptographically random bytes.</li> <li><p>Let <var title="">ice-key</var> be the 16 bytes given as the encryption key for the <a href=#data-udp-media-stream>data UDP media stream</a> in its media description, as defined above.</li> <li><p>Let <var title="">sending sequence number</var> be the current <a href=#sending-sequence-number>sending sequence number</a>.</li> <li><p>Increment the <a href=#sending-sequence-number>sending sequence number</a> by one (1).</li> <li><p>Let <var title="">mask-key</var> be the first 16 bytes of the HMAC-SHA1 of the 16 <a href=#data-udp-media-stream-masking-salt>data UDP media stream masking salt</a> bytes keyed with the 16 <var title="">ice-key</var> bytes. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">typed raw message</var> be the concatenation of the <var title="">sequence number</var> as a big-endian 64 bit integer, three 0x00 bytes, a 0x01 byte, and <var title="">raw message</var>.</li> <li><p>Let <var title="">masked message</var> be the result of encrypting <var title="">typed raw message</var> using AES-128-CTR keyed with <var title="">mask-key</var> and using the 16 <var title="">nonce</var> bytes as the initial counter value. <a href=#refsAES128CTR>[AES128CTR]</a></li> <li><p>Let <var title="">masked message with nonce</var> be the concatenation of <var title="">nonce</var> and <var title="">masked message</var>.</li> <li><p>Let <var title="">hash-key</var> be the first 16 bytes of the HMAC-SHA1 of the 16 <a href=#data-udp-media-stream-hashing-salt>data UDP media stream hashing salt</a> bytes keyed with the 16 <var title="">ice-key</var> bytes. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">hash</var> be the first 16 bytes of the HMAC-SHA1 of <var title="">masked message with nonce</var> keyed with the 16 <var title="">hash-key</var> bytes. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">hashed masked message with nonce</var> be the concatenation of <var title="">hash</var> and <var title="">masked message with nonce</var>.</li> <li><p>Send <var title="">hashed masked message with nonce</var> in a UDP packet to the destination that the relevant <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> has selected a destination for the <a href=#data-udp-media-stream>data UDP media stream</a>.</li> </ol><p>When a packet that is part of a <a href=#data-udp-media-stream>data UDP media stream</a> is received, the user agent must run the following steps:</p> <ol><!-- v2: binary --><li><p>Let <var title="">hashed masked message with nonce</var> be the UDP packet's data.</li> <li><p>If <var title="">hashed masked message with nonce</var> is shorter than 32 bytes, then abort these steps.</li> <li><p>Let <var title="">ice-key</var> be the 16 bytes given as the encryption key for the <a href=#data-udp-media-stream>data UDP media stream</a> in the media description for this media stream. <a href=#refsSDP>[SDP]</a></li> <li><p>Let <var title="">hash-key</var> be the first 16 bytes of the HMAC-SHA1 of the 16 <a href=#data-udp-media-stream-hashing-salt>data UDP media stream hashing salt</a> bytes keyed with the 16 <var title="">ice-key</var> bytes. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">hash</var> be the first 16 bytes of the <var title="">hashed masked message with nonce</var>.</li> <li><p>Let <var title="">masked message with nonce</var> be all but the first 16 bytes of <var title="">hashed masked message with nonce</var>.</li> <li><p>If <var title="">hash</var> does not equal the first 16 bytes of the HMAC-SHA1 of <var title="">masked message with nonce</var> keyed with the 16 <var title="">hash-key</var> bytes, abort these steps. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">nonce</var> be the first 16 bytes of the <var title="">masked message with nonce</var>.</li> <li><p>Let <var title="">masked message</var> be all but the first 16 bytes of <var title="">masked message with nonce</var>.</li> <li><p>Let <var title="">mask-key</var> be the first 16 bytes of the HMAC-SHA1 of the 16 <a href=#data-udp-media-stream-masking-salt>data UDP media stream masking salt</a> bytes keyed with the 16 <var title="">ice-key</var> bytes. <a href=#refsHMAC>[HMAC]</a> <a href=#refsSHA1>[SHA1]</a></li> <li><p>Let <var title="">typed raw message</var> be the result of decrypting <var title="">masked message</var> using AES-128-CTR keyed with <var title="">mask-key</var> and using the 16 <var title="">nonce</var> bytes as the initial counter value. <a href=#refsAES128CTR>[AES128CTR]</a></li> <li><p>Let <var title="">sequence number</var> be the result of interpreting the first eight bytes of <var title="">typed raw message</var> as a 64 bit big-endian integer.</li> <li><p>If <var title="">sequence number</var> is less than the <a href=#most-recently-received-sequence-number>most recently received sequence number</a> then abort these steps.</li> <li><p>Let the <a href=#most-recently-received-sequence-number>most recently received sequence number</a> be <var title="">sequence number</var>.</li> <li><p>If the ninth, tenth, eleventh, and twelfth bytes of <var title="">typed raw message</var> are not 0x00, 0x00, 0x00, and 0x01 respectively, then abort these steps.</li> <li><p>Let <var title="">raw message</var> be the byte string consisting of all but the first twelve bytes of <var title="">typed raw message</var>.</li> <li><p>Let <var title="">message</var> be <var title="">raw message</var> <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>.</li> <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not cancelable, has no default action, and has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute initialized to <var title="">message</var>, and <a href=#queue-a-task>queue a task</a> to dispatch the event at the <code><a href=#peerconnection>PeerConnection</a></code> object responsible for this side of the <a href=#data-udp-media-stream>data UDP media stream</a>.</li> </ol><p class=note>Though described above as being computed for each packet, the <var title="">ice-key</var>, <var title="">hash-key</var>, and <var title="">mask-key</var> values can be precomputed as soon as the <a href=#peerconnection-ice-agent><code>PeerConnection</code> ICE Agent</a> is started.</p> <div class=note> <p>The format of a packet sent over a <a href=#data-udp-media-stream>data UDP media stream</a>, as generated and parsed by the algorithms above, is as follows. The total overhead per packet is thus 44 bytes, of which four are intended for future extensions.</p> <pre> /'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''. +--------------+ +---------------+ +-ENCRYPTED------------------------------------------------------------+ : | 16 byte hash | | 16 byte nonce | | [ 8 bytes of sequence number ] [ 4 bytes of frame type ] [ data... ] | : +--------------+ +---------------+ +----------------------------------------------------------------------+ : \...........................................................................................' </pre> </div> <p>A <dfn id=remotely-initiated-data-udp-media-stream>remotely-initiated data UDP media stream</dfn> is the first "sendrecv" media stream in the initial offer whose media is "<code title="">application</code>", whose transport protocol is "<code title="">udp</code>", whose media format description is "<code><a href=#application/html-peer-connection-data>application/html-peer-connection-data</a></code>", and whose label attribute ("<code title="">a=label:</code>") has the value "<code title="">data</code>".</p> <p>The <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#networking-task-source>networking task source</a>.</p> </div> <h4 id=security-considerations><span class=secno>9.5.1 </span>Security considerations</h4> <p>The <a href=#data-udp-media-stream>data UDP media stream</a> packet format is designed to protect against several obvious attacks. The data is made to appear pseudo-random, so that it cannot be used in a cross-protocol attack, even if somehow the stream were to be directed at an unsuspecting remote host. The data is hashed in such a way that it cannot be modified in transit. That data is encrypted so that it cannot be read in transit.</p> <p>These security mechanisms rely in part on a key that is negotiated over the signalling channel; as such, the security is only as strong as the security of the signaling channel. Authors are encouraged to use TLS to protect the signalling channel and the page(s) hosting the application, and are encouraged to secure the host used to relay the signalling channel.</p> <div class=impl> <p>To avoid network traffic congestion and other denial of service attacks based on traffic volume, user agents should apply rate-limiting to <a href=#data-udp-media-stream title="data UDP media stream">data UDP media streams</a>.</p> </div> <h3 id=garbage-collection-0><span class=secno>9.6 </span>Garbage collection</h3> <p>A <code><a href=#window>Window</a></code> object <dfn id=concept-peerconnection-owner title=concept-PeerConnection-owner>has a strong reference</dfn> to any <code><a href=#peerconnection>PeerConnection</a></code> objects created from the constructor whose global object is that <code><a href=#window>Window</a></code> object.</p> <!-- we could be less strict here, e.g. dropping the reference when there's no way for an event to be fired because there's no event handlers registered and there's no way for the remote peer to notice anything because no media is streaming; or e.g. dropping the reference when the object reaches the CLOSED state. But as dropping the reference in those cases is black-box indistinguishable from keeping the reference, I haven't bothered to work out the exact rules. If you do change this, see the /unloading document cleanup steps/. --> <h3 id=event-definitions-1><span class=secno>9.7 </span>Event definitions</h3> <p>The <code title=event-MediaStream-addstream><a href=#event-mediastream-addstream>addstream</a></code> and <code title=event-MediaStream-removestream><a href=#event-mediastream-removestream>removestream</a></code> events use the <code><a href=#mediastreamevent>MediaStreamEvent</a></code> interface:</p> <div class=impl> <p>The <dfn id=dom-mediastreamevent-stream title=dom-MediaStreamEvent-stream><code>stream</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the <code><a href=#mediastream>MediaStream</a></code> object associated with the event.</p> <p><dfn id=fire-a-stream-event title="fire a stream event">Firing a stream event named <var title="">e</var></dfn> with a <code><a href=#mediastream>MediaStream</a></code> <var title="">stream</var> means that an event with the name <var title="">e</var>, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the <code><a href=#mediastreamevent>MediaStreamEvent</a></code> interface with the <code title=dom-MediaStreamEvent-stream><a href=#dom-mediastreamevent-stream>stream</a></code> attribute initialized to <var title="">stream</var>, must be created and dispatched at the given target.</p> </div> <h3 id=mediastreamevents><span class=secno>9.8 </span>Event Summary</h3> <p><i>This section is non-normative.</i></p> <p>The following event fires on <code><a href=#mediastream>MediaStream</a></code> objects:</p> <table><thead><tr><th>Event name <th>Interface <th>Fired when... <tbody><tr><td><dfn id=event-mediastream-ended title=event-MediaStream-ended><code>ended</code></dfn> <td><code><a href=#event>Event</a></code> <td>The <code><a href=#mediastream>MediaStream</a></code> object will no longer stream any data, either because the user revoked the permissions, or because the source device has been ejected, or because the remote peer stopped sending data, or because the <code title=dom-MediaStream-stop><a href=#dom-mediastream-stop>stop()</a></code> method was invoked. </table><p>The following events fire on <code><a href=#peerconnection>PeerConnection</a></code> objects:</p> <table><thead><tr><th>Event name <th>Interface <th>Fired when... <tbody><tr><td><dfn id=event-mediastream-connecting title=event-MediaStream-connecting><code>connecting</code></dfn> <td><code><a href=#event>Event</a></code> <td>The ICE Agent has begun negotiating with the peer. This can happen multiple times during the lifetime of the <code><a href=#peerconnection>PeerConnection</a></code> object. <tr><td><dfn id=event-mediastream-open title=event-MediaStream-open><code>open</code></dfn> <td><code><a href=#event>Event</a></code> <td>The ICE Agent has finished negotiating with the peer. <!-- <tr> <td><dfn title="event-MediaStream-error"><code>error</code></dfn> <td><code>Event</code> <td> <tr> <td><dfn title="event-MediaStream-close"><code>close</code></dfn> <td><code>Event</code> <td>The <code title="dom-PeerConnection-close">close()</code> method was called. --> <tr><td><dfn id=event-mediastream-message title=event-MediaStream-message><code>message</code></dfn> <td><code><a href=#messageevent>MessageEvent</a></code> <td>A <a href=#data-udp-media-stream>data UDP media stream</a> message was received. <tr><td><dfn id=event-mediastream-addstream title=event-MediaStream-addstream><code>addstream</code></dfn> <td><code><a href=#mediastreamevent>MediaStreamEvent</a></code> <td>A new stream has been added to the <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> array. <tr><td><dfn id=event-mediastream-removestream title=event-MediaStream-removestream><code>removestream</code></dfn> <td><code><a href=#mediastreamevent>MediaStreamEvent</a></code> <td>A stream has been removed from the <code title=dom-PeerConnection-remoteStreams><a href=#dom-peerconnection-remotestreams>remoteStreams</a></code> array. </table></div> <!--PEERCONNECTION--> <div data-component="Web Workers (editor: Ian Hickson)"> <h2 id=workers><span class=secno>10 </span>Web workers</h2> <h3 id=introduction-13><span class=secno>10.1 </span>Introduction</h3> <h4 id=scope-0><span class=secno>10.1.1 </span>Scope</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-4><span class=secno>10.1.2 </span>Examples</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</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><!DOCTYPE HTML> <html> <head> <title>Worker example: One-core computation</title> </head> <body> <p>The highest prime number discovered so far is: <output id="result"></output></p> <script> var worker = new Worker('worker.js'); worker.onmessage = function (event) { document.getElementById('result').textContent = event.data; }; </script> </body> </html></pre> <p>The <code title=dom-Worker><a href=#dom-worker>Worker()</a></code> constructor call creates a worker and returns a <code><a href=#worker>Worker</a></code> object representing that worker, which is used to communicate with the worker. That object's <code title=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>var n = 1; search: while (true) { n += 1; for (var i = 2; i <= Math.sqrt(n); i += 1) if (n % i == 0) continue search; // found a prime! postMessage(n); }</pre> <p>The bulk of this code is simply an unoptimized search for a prime number. The <code title=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=http://www.whatwg.org/demos/workers/primes/page.html>View this example online</a>.</p> <h5 id=a-worker-for-updating-a-client-side-database><span class=secno>10.1.2.2 </span>A worker for updating a client-side database</h5> <p><i>This section is non-normative.</i></p> <p>In this example, the main document spawns a worker whose only task is to listen for notifications from the server, and, when appropriate, either add or remove data from the client-side database.</p> <p>Since no communication occurs between the worker and the main page, the main page can start the worker by just doing:</p> <pre><script> new Worker('worker.js'); </script></pre> <p>The worker itself is as follows:</p> <pre>var server = new WebSocket('ws://whatwg.org/database'); var database = openDatabase('demobase', '1.0', 'Demo Database', 10240); server.onmessage = function (event) { // data is in the format "command key value" var data = event.data.split(' '); switch (data[0]) { case '+': database.transaction(function(tx) { tx.executeSql('INSERT INTO pairs (key, value) VALUES (?, ?)', data[1], data[2]); }); case '-': database.transaction(function(tx) { tx.executeSql('DELETE FROM pairs WHERE key=? AND value=?', data[1], data[2]); }); } };</pre> <p>This connects to the server using the <code><a href=#websocket>WebSocket</a></code> mechanism and opens the local database (which, we presume, has been created earlier). The worker then just listens for messages from the server and acts on them as appropriate, forever (or until the main page is closed).</p> <p><a href=http://www.whatwg.org/demos/workers/database-updater/page.html>View this example online</a>. (This example will not actually function, since the server does not actually exist and the database is not created by this sample code.)</p> <h5 id=worker-used-for-background-i/o><span class=secno>10.1.2.3 </span>Worker used for background I/O</h5> <p><i>This section is non-normative.</i></p> <p>In this example, the main document uses two workers, one for fetching stock updates for at regular intervals, and one for fetching performing search queries that the user requests.</p> <p>The main page is as follows:</p> <pre><!DOCTYPE HTML> <html> <head> <title>Worker example: Stock ticker</title> <script> // TICKER var symbol = 'GOOG'; // default symbol to watch var ticker = new Worker('ticker.js'); // SEARCHER var searcher = new Worker('searcher.js'); function search(query) { searcher.postMessage(query); } // SYMBOL SELECTION UI function select(newSymbol) { symbol = newSymbol; ticker.postMessage(symbol); } </script> </head> <body onload="search('')"> <p><output id="symbol"></output> <output id="value"></output></p> <script> ticker.onmessage = function (event) { var data = event.data.split(' '); document.getElementById('symbol').textContent = data[0]; document.getElementById('value').textContent = data[1]; }; ticker.postMessage(symbol); </script> <p><label>Search: <input type="text" autofocus oninput="search(this.value)"></label></p> <ul id="results"></ul> <script> searcher.onmessage = function (event) { var data = event.data.split(' '); var results = document.getElementById('results'); while (results.hasChildNodes()) // clear previous results results.removeChild(results.firstChild); for (var i = 0; i < data.length; i += 1) { // add a list item with a button for each result var li = document.createElement('li'); var button = document.createElement('button'); button.value = data[i]; button.type = 'button'; button.onclick = function () { select(this.value); }; button.textContent = data[i]; li.appendChild(button); results.appendChild(li); } }; </script> <p>(The data in this example is not real. Try searching for "Google" or "Apple".)</p> </body> </html></pre> <p>The two workers use a common library for performing the actual network calls. This library is as follows:</p> <pre>function get(url) { try { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.send(); return xhr.responseText; } catch (e) { return ''; // turn all errors into empty results } }</pre> <p>The stock updater worker is as follows:</p> <pre>importScripts('io.js'); var timer; var symbol; function update() { postMessage(symbol + ' ' + get('stock.cgi?' + symbol)); timer = setTimeout(update, 10000); } onmessage = function (event) { if (timer) clearTimeout(timer); symbol = event.data; update(); };</pre> <p>The search query worker is as follows:</p> <pre>importScripts('io.js'); onmessage = function (event) { postMessage(get('search.cgi?' + event.data)); };</pre> <p><a href=http://www.whatwg.org/demos/workers/stocks/page.html>View this example online</a>.</p> <h5 id=shared-workers-introduction><span class=secno>10.1.2.4 </span>Shared workers introduction</h5> <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><!DOCTYPE HTML> <title>Shared workers: demo 1</title> <pre id="log">Log:</pre> <script> var worker = new SharedWorker('test.js'); var log = document.getElementById('log'); worker.port.onmessage = function(e) { // note: not worker.onmessage! log.textContent += '\n' + e.data; } </script> </pre> <p>Here is the JavaScript worker:</p> <pre>onconnect = function(e) { var port = e.ports[0]; port.postMessage('Hello World!'); } </pre> <p><a href=http://www.whatwg.org/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 title="">addEventListener()</code> instead of an <a href=#event-handler-idl-attributes title="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><!DOCTYPE HTML> <title>Shared workers: demo 2</title> <pre id="log">Log:</pre> <script> var worker = new SharedWorker('test.js'); var log = document.getElementById('log'); worker.port.addEventListener('message', function(e) { log.textContent += '\n' + e.data; }, false); worker.port.start(); // note: need this when using addEventListener worker.port.postMessage('ping'); </script> </pre> <p>Here is the JavaScript worker:</p> <pre>onconnect = function(e) { var port = e.ports[0]; port.postMessage('Hello World!'); port.onmessage = function(e) { port.postMessage('pong'); // not e.ports[0].postMessage! // e.target.postMessage('pong'); would work also } } </pre> <p><a href=http://www.whatwg.org/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><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>top-level browsing context</a>.</p> <p>Here is the outer HTML page:</p> <pre><!DOCTYPE HTML> <title>Shared workers: demo 3</title> <pre id="log">Log:</pre> <script> var worker = new SharedWorker('test.js'); var log = document.getElementById('log'); worker.port.addEventListener('message', function(e) { log.textContent += '\n' + e.data; }, false); worker.port.start(); worker.port.postMessage('ping'); </script> <iframe src="inner.html"></iframe> </pre> <p>Here is the inner HTML page:</p> <pre><!DOCTYPE HTML> <title>Shared workers: demo 3 inner frame</title> <pre id=log>Inner log:</pre> <script> var worker = new SharedWorker('test.js'); var log = document.getElementById('log'); worker.port.onmessage = function(e) { log.textContent += '\n' + e.data; } </script> </pre> <p>Here is the JavaScript worker:</p> <pre>var count = 0; onconnect = function(e) { count += 1; var port = e.ports[0]; port.postMessage('Hello World! You are connection #' + count); port.onmessage = function(e) { port.postMessage('pong'); } } </pre> <p><a href=http://www.whatwg.org/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.5 </span>Shared state using a shared worker</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><!DOCTYPE HTML> <html> <head> <title>Workers example: Multiviewer</title> <script> function openViewer() { window.open('viewer.html'); } </script> </head> <body> <p><button type=button onclick="openViewer()">Open a new viewer</button></p> <p>Each viewer opens in a new window. You can have as many viewers as you like, they all view the same data.</p> </body> </html></pre> <p>The viewer is more involved:</p> <pre><!DOCTYPE HTML> <html> <head> <title>Workers example: Multiviewer viewer</title> <script> var worker = new SharedWorker('worker.js', 'core'); // CONFIGURATION function configure(event) { if (event.data.substr(0, 4) != 'cfg ') return; var name = event.data.substr(4).split(' ', 1); // update display to mention our name is name document.getElementsByTagName('h1')[0].textContent += ' ' + name; // no longer need this listener worker.port.removeEventListener('message', configure, false); } worker.port.addEventListener('message', configure, false); // MAP function paintMap(event) { if (event.data.substr(0, 4) != 'map ') return; var data = event.data.substr(4).split(','); // display tiles data[0] .. data[8] var canvas = document.getElementById('map'); var context = canvas.getContext('2d'); for (var y = 0; y < 3; y += 1) { for (var x = 0; x < 3; x += 1) { var tile = data[y * 3 + x]; if (tile == '0') context.fillStyle = 'green'; else context.fillStyle = 'maroon'; fillRect(x * 50, y * 50, 50, 50); } } } worker.port.addEventListener('message', paintMap, false); // PUBLIC CHAT function updatePublicChat(event) { if (event.data.substr(0, 4) != 'txt ') return; var name = event.data.substr(4).split(' ', 1); var message = event.data.substr(4 + length(name) + 1); // display "<name> message" in public chat var dialog = document.getElementById('public'); var dt = document.createElement('dt'); dt.textContent = name; dialog.appendChild(dt); var dd = document.createElement('dd'); dd.textContent = message; dialog.appendChild(dd); } worker.port.addEventListener('message', updatePublicChat, false); // PRIVATE CHAT function startPrivateChat(event) { if (event.data.substr(0, 4) != 'msg ') return; var name = event.data.substr(4).split(' ', 1); var port = event.ports[0]; // display a private chat UI var ul = document.getElementById('private'); var li = document.createElement('li'); var h3 = document.createElement('h3'); h3.textContent = 'Private chat with ' + name; li.appendChild(h3); var dialog = document.createElement('dialog'); var addMessage = function(name, message) { var dt = document.createElement('dt'); dt.textContent = name; dialog.appendChild(dt); var dd = document.createElement('dd'); dd.textContent = message; dialog.appendChild(dd); }; port.onmessage = function (event) { addMessage(name, event.data); }; li.appendChild(dialog); var form = document.createElement('form'); var p = document.createElement('p'); var input = document.createElement('input'); input.size = 50; p.appendChild(input); p.appendChild(document.createTextNode(' ')); var button = document.createElement('button'); button.textContent = 'Post'; p.appendChild(button); form.onsubmit = function () { port.postMessage(input.value); addMessage('me', input.value); input.value = ''; return false; }; form.appendChild(p); li.appendChild(form); } worker.port.addEventListener('message', startPrivateChat, false); worker.port.start(); </script> </head> <body> <h1>Viewer</h1> <h2>Map</h2> <p><canvas id="map" height=150 width=150></canvas></p> <p> <button type=button onclick="worker.port.postMessage('mov left')">Left</button> <button type=button onclick="worker.port.postMessage('mov up')">Up</button> <button type=button onclick="worker.port.postMessage('mov down')">Down</button> <button type=button onclick="worker.port.postMessage('mov right')">Right</button> <button type=button onclick="worker.port.postMessage('set 0')">Set 0</button> <button type=button onclick="worker.port.postMessage('set 1')">Set 1</button> </p> <h2>Public Chat</h2> <dialog id="public"></dialog> <form onsubmit="worker.port.postMessage('txt ' + message.value); message.value = ''; return false;"> <p> <input type="text" name="message" size="50"> <button>Post</button> </p> </form> <h2>Private Chat</h2> <ul id="private"></ul> </body> </html> </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 title="">configure()</code> method in this example.</p> <p>Finally, the worker:</p> <pre> var nextName = 0; function getNextName() { // this could use more friendly names // but for now just return a number return nextName++; } var map = [ [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 0, 1], ]; function wrapX(x) { if (x < 0) return wrapX(x + map[0].length); if (x >= map[0].length) return wrapX(x - map[0].length); return x; } function wrapY(y) { if (y < 0) return wrapY(y + map.length); if (y >= map[0].length) return wrapY(y - map.length); return y; } function sendMapData(callback) { var data = ''; for (var y = viewer.y-1; y <= viewer.y+1; y += 1) { for (var x = viewer.x-1; x <= viewer.x+1; x += 1) { if (data != '') data += ','; data += map[y][x]; } } callback('map ' + data); } var viewers = {}; onconnect = function (event) { event.ports[0]._name = getNextName(); event.ports[0]._data = { port: event.port, x: 0, y: 0, }; viewers[event.ports[0]._name] = event.port._data; event.ports[0].postMessage('cfg ' + name); event.ports[0].onmessage = getMessage; sendMapData(event.ports[0].postMessage); }; function getMessage(event) { switch (event.data.substr(0, 4)) { case 'mov ': var direction = event.data.substr(4); var dx = 0; var dy = 0; switch (direction) { case 'up': dy = -1; break; case 'down': dy = 1; break; case 'left': dx = -1; break; case 'right': dx = 1; break; } event.target._data.x = wrapX(event.target._data.x + dx); event.target._data.y = wrapY(event.target._data.y + dy); sendMapData(event.target.postMessage); break; case 'set ': var value = event.data.substr(4); map[event.target._data.y][event.target._data.x] = value; for (var viewer in viewers) sendMapData(viewers[viewer].port.postMessage); break; case 'txt ': var name = event.target._name; var message = event.data.substr(4); for (var viewer in viewers) viewers[viewer].port.postMessage('txt ' + name + ' ' + message); break; case 'msg ': var party1 = event._data; var party2 = viewers[event.data.substr(4).split(' ', 1)]; if (party2) { var channel = new MessageChannel(); party1.port.postMessage('msg ' + party2.name, [channel.port1]); party2.port.postMessage('msg ' + party1.name, [channel.port2]); } break; } }</pre> <p><strong>Connecting to multiple pages</strong>. The script uses the <code title=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=http://www.whatwg.org/demos/workers/multiviewer/page.html>View this example online</a>.</p> <h5 id=delegation><span class=secno>10.1.2.6 </span>Delegation</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><!DOCTYPE HTML> <html> <head> <title>Worker example: Multicore computation</title> </head> <body> <p>Result: <output id="result"></output></p> <script> var worker = new Worker('worker.js'); worker.onmessage = function (event) { document.getElementById('result').textContent = event.data; }; </script> </body> </html></pre> <p>The worker itself is as follows:</p> <pre>// settings var num_workers = 10; var items_per_worker = 1000000; // start the workers var result = 0; var pending_workers = num_workers; for (var i = 0; i < num_workers; i += 1) { var worker = new Worker('core.js'); worker.postMessage(i * items_per_worker); worker.postMessage((i+1) * items_per_worker); worker.onmessage = storeResult; } // handle the results function storeResult(event) { result += 1*event.data; pending_workers -= 1; if (pending_workers <= 0) postMessage(result); // finished! }</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>var start; onmessage = getStart; function getStart(event) { start = 1*event.data; onmessage = getEnd; } var end; function getEnd(event) { end = 1*event.data; onmessage = null; work(); } function work() { var result = 0; for (var i = start; i < end; i += 1) { // perform some complex calculation here result += 1; } postMessage(result); close(); }</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=http://www.whatwg.org/demos/workers/multicore/page.html>View this example online</a>.</p> <!--(this uses startConversation, which is currently commented out) <h5>Providing libraries</h5> <!- -END dev-html- -><p><i>This section is non-normative.</i></p><!- -START dev-html- -> <p>Suppose that a cryptography library is made available that provides three tasks:</p> <dl> <dt>Generate a public/private key pair</dt> <dd>Takes a port, on which it will send two messages, first the public key and then the private key.</dd> <dt>Given a plaintext and a public key, return the corresponding cyphertext</dt> <dd>Takes a port, to which any number of messages can be sent, the first giving the public key, and the remainder giving the plaintext, each of which is encrypted and then sent on that same channel as the cyphertext. The user can close the port when it is done encrypting content.</dd> <dt>Given a cyphertext and a private key, return the corresponding plaintext</dt> <dd>Takes a port, to which any number of messages can be sent, the first giving the private key, and the remainder giving the cyphertext, each of which is decrypted and then sent on that same channel as the plaintext. The user can close the port when it is done decrypting content.</dd> </dl> <p>The library itself is as follows:</p> <pre>function handleMessage(e) { if (e.data == "genkeys") genkeys(e.ports[0]); else if (e.data == "encrypt") encrypt(e.ports[0]); else if (e.data == "decrypt") decrypt(e.ports[0]); } function genkeys(p) { var keys = _generateKeyPair(); p.postMessage(keys[0]); p.postMessage(keys[1]); } function encrypt(p) { var key, state = 0; p.onmessage = function (e) { if (state == 0) { key = e.data; state = 1; } else { p.postMessage(_encrypt(key, e.data)); } }; } function decrypt(p) { var key, state = 0; p.onmessage = function (e) { if (state == 0) { key = e.data; state = 1; } else { p.postMessage(_decrypt(key, e.data)); } }; } // support being used as a shared worker as well as a dedicated worker if ('onmessage' in this) // dedicated worker onmessage = handleMessage; else // shared worker onconnect = function (e) { e.port.onmessage = handleMessage; } // the "crypto" functions: function _generateKeyPair() { return [Math.random(), Math.random()]; } function _encrypt(k, s) { return 'encrypted-' + k + ' ' + s; } function _decrypt(k, s) { return s.substr(s.indexOf(' ')+1); }</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><!DOCTYPE HTML> <html> <head> <title>Worker example: Crypto library</title> <script> var cryptoLib = new Worker('libcrypto-v1.js'); // or could use 'libcrypto-v2.js' function getKeys() { var state = 0; cryptoLib.startConversation("genkeys").onmessage = function (e) { if (state == 0) document.getElementById('public').value = e.data; else if (state == 1) document.getElementById('private').value = e.data; state += 1; }; } function enc() { var port = cryptoLib.startConversation("encrypt"); port.postMessage(document.getElementById('public').value); port.postMessage(document.getElementById('input').value); port.onmessage = function (e) { document.getElementById('input').value = e.data; port.close(); }; } function dec() { var port = cryptoLib.startConversation("decrypt"); port.postMessage(document.getElementById('private').value); port.postMessage(document.getElementById('input').value); port.onmessage = function (e) { document.getElementById('input').value = e.data; port.close(); }; } </script> <style> textarea { display: block; } </style> </head> <body onload="getKeys()"> <fieldset> <legend>Keys</legend> <p><label>Public Key: <textarea id="public"></textarea></label></p> <p><label>Private Key: <textarea id="private"></textarea></label></p> </fieldset> <p><label>Input: <textarea id="input"></textarea></label></p> <p><button onclick="enc()">Encrypt</button> <button onclick="dec()">Decrypt</button></p> </body> </html></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>function handleMessage(e) { if (e.data == "genkeys") genkeys(e.ports[0]); else if (e.data == "encrypt") encrypt(e.ports[0]); else if (e.data == "decrypt") decrypt(e.ports[0]); } function genkeys(p) { var generator = new Worker('libcrypto-v2-generator.js'); generator.postMessage('', [p]); } function encrypt(p) { p.onmessage = function (e) { var key = e.data; var encryptor = new Worker('libcrypto-v2-encryptor.js'); encryptor.postMessage(key, [p]); }; } function encrypt(p) { p.onmessage = function (e) { var key = e.data; var decryptor = new Worker('libcrypto-v2-decryptor.js'); decryptor.postMessage(key, [p]); }; } // support being used as a shared worker as well as a dedicated worker if ('onmessage' in this) // dedicated worker onmessage = handleMessage; else // shared worker onconnect = function (e) { e.ports[0].onmessage = handleMessage }; </pre> <p>The little subworkers would then be as follows.</p> <p>For generating key pairs:</p> <pre>onmessage = function (e) { var k = _generateKeyPair(); e.ports[0].postMessage(k[0]); e.ports[0].postMessage(k[1]); close(); } function _generateKeyPair() { return [Math.random(), Math.random()]; }</pre> <p>For encrypting:</p> <pre>onmessage = function (e) { var key = e.data; e.ports[0].onmessage = function (e) { var s = e.data; postMessage(_encrypt(key, s)); } } function _encrypt(k, s) { return 'encrypted-' + k + ' ' + s; }</pre> <p>For decrypting:</p> <pre>onmessage = function (e) { var key = e.data; e.ports[0].onmessage = function (e) { var s = e.data; postMessage(_decrypt(key, s)); } } function _decrypt(k, s) { return s.substr(s.indexOf(' ')+1); }</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="http://www.whatwg.org/demos/workers/crypto/page.html">View this example online</a>.</p> (end startConversation block) (beware nested comments)--> <h4 id=tutorials><span class=secno>10.1.3 </span>Tutorials</h4> <h5 id=creating-a-dedicated-worker><span class=secno>10.1.3.1 </span>Creating a dedicated worker</h5> <p><i>This section is non-normative.</i></p> <p>Creating a worker requires a URL to a JavaScript file. The <code title=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>var worker = new Worker('helper.js');</pre> <h5 id=communicating-with-a-dedicated-worker><span class=secno>10.1.3.2 </span>Communicating with a dedicated worker</h5> <p><i>This section is non-normative.</i></p> <p>Dedicated workers use <code><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 title=handler-worker-onmessage><a href=#handler-worker-onmessage>onmessage</a></code> <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL attribute</a> on the <code><a href=#worker>Worker</a></code> object:</p> <pre>worker.onmessage = function (event) { ... };</pre> <p>You can also use the <code title=dom-EventTarget-addEventListener>addEventListener()</code> method.</p> <p class=note>The implicit <code><a href=#messageport>MessagePort</a></code> used by dedicated workers has its <a href=#port-message-queue>port message queue</a> implicitly enabled when it is created, so there is no equivanet to the <code><a href=#messageport>MessagePort</a></code> interface's <code title=dom-MessagePort-start><a href=#dom-messageport-start>start()</a></code> method on the <code><a href=#worker>Worker</a></code> interface.</p> <p>To <em>send</em> data to a worker, use the <code title=dom-Worker-postMessage><a href=#dom-worker-postmessage>postMessage()</a></code> method. Structured data can be sent over this communication channel. To send <code><a href=#arraybuffer>ArrayBuffer</a></code> objects efficiently (by transferring them rather than cloning them), list them in an array in the second argument.</p> <pre>worker.postMessage({ operation: 'find-edges', input: buffer, // an ArrayBuffer object threshold: 0.6, }, [buffer]);</pre> <p>To receive a message inside the worker, the <code title=handler-DedicatedWorkerGlobalScope-onmessage><a href=#handler-dedicatedworkerglobalscope-onmessage>onmessage</a></code> <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL attribute</a> is used.</p> <pre>onmessage = function (event) { ... };</pre> <p>You can again also use the <code title=dom-EventTarget-addEventListener>addEventListener()</code> method.</p> <p>In either case, the data is provided in the event object's <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute.</p> <p>To send messages back, you again use <code title=dom-DedicatedWorkerGlobalScope-postMessage><a href=#dom-dedicatedworkerglobalscope-postmessage>postMessage()</a></code>. It supports the structured data in the same manner.</p> <pre>postMessage(event.data.input, [event.data.input]); // transfer the buffer back</pre> <h5 id=shared-workers><span class=secno>10.1.3.3 </span>Shared workers</h5> <p><i>This section is non-normative.</i></p> <p>Shared workers are identified in one of two ways: either by the URL of the script used to create it, or by explicit name. When created by name, the URL used by the first page to create the worker with that name is the URL of the script that will be used for that worker. This allows multiple applications on a domain to all use a single shared worker to provide a common service, without the applications having to keep track of a common URL for the script used to provide the service.</p> <p class=note>In either case, shared workers are scoped by <a href=#origin>origin</a>. Two different sites using the same names will not collide.</p> <p>Creating shared workers is done using the <code title=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>var worker = new SharedWorker('service.js');</pre> <p>Communicating with shared workers is done with explicit <code><a href=#messageport>MessagePort</a></code> objects. The object returned by the <code title=dom-SharedWorker><a href=#dom-sharedworker>SharedWorker()</a></code> constructor holds a reference to the port on its <code title=dom-SharedWorker-port><a href=#dom-sharedworker-port>port</a></code> attribute.</p> <pre>worker.port.onmessage = function (event) { ... }; worker.port.postMessage('some message'); worker.port.postMessage({ foo: 'structured', bar: ['data', 'also', 'possible']});</pre> <p>Inside the shared worker, new clients of the worker are announced using the <code title=event-connect>connect</code> event. The port for the new client is given by the event object's <code title=dom-messageevent-ports><a href=#dom-messageevent-ports>ports</a></code> array as its first (and only) value.</p> <pre>onconnect = function (event) { var newPort = event.ports[0]; // set up a listener newPort.onmessage = function (event) { ... }; // send a message back to the port newPort.postMessage('ready!'); // can also send structured data, of course };</pre> <h3 id=infrastructure-0><span class=secno>10.2 </span>Infrastructure</h3> <p>There are two kinds of workers; dedicated workers, and shared workers. Dedicated workers, once created, and 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=#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</h4> <p>The global scope is the "inside" of a worker.</p> <h5 id=the-workerglobalscope-abstract-interface><span class=secno>10.2.1.1 </span>The <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> abstract interface</h5> <pre class=idl>interface <dfn id=workerglobalscope>WorkerGlobalScope</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute <a href=#workerglobalscope>WorkerGlobalScope</a> <a href=#dom-workerglobalscope-self title=dom-WorkerGlobalScope-self>self</a>; readonly attribute <a href=#workerlocation>WorkerLocation</a> <a href=#dom-workerglobalscope-location title=dom-WorkerGlobalScope-location>location</a>; void <a href=#dom-workerglobalscope-close title=dom-WorkerGlobalScope-close>close</a>(); <!-- v2-onclose [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-WorkerGlobalScope-onclose">onclose</span>; --> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-onerror title=handler-WorkerGlobalScope-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-onoffline title=handler-WorkerGlobalScope-onoffline>onoffline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-ononline title=handler-WorkerGlobalScope-ononline>ononline</a>; }; <a href=#workerglobalscope>WorkerGlobalScope</a> implements <a href=#workerutils>WorkerUtils</a>;</pre> <p>The <dfn id=dom-workerglobalscope-self title=dom-WorkerGlobalScope-self><code>self</code></dfn> attribute must return the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object itself.</p> <p>The <dfn id=dom-workerglobalscope-location title=dom-WorkerGlobalScope-location><code>location</code></dfn> attribute must return the <code><a href=#workerlocation>WorkerLocation</a></code> object created for the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object when the worker was created. It represents the <a href=#absolute-url>absolute URL</a> of the script that was used to initialize the worker, after any redirects.</p> <hr><p>When a script invokes the <dfn id=dom-workerglobalscope-close title=dom-WorkerGlobalScope-close><code>close()</code></dfn> method on a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, the user agent must run the following steps (atomically):</p> <ol><li><p>Discard any <a href=#concept-task title=concept-task>tasks</a> that have been added to the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a>.</p> <!-- v2-onclose <li><p><span>Queue a task</span> to <span>fire a simple event</span> named <code title="event-close">close</code> at the <code>WorkerGlobalScope</code> object.</p></li> --> <li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to true. (This prevents any further tasks from being queued.)</li> </ol><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by objects implementing the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><!-- v2-onclose <tr><td><dfn title="handler-WorkerGlobalScope-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> --><tr><td><dfn id=handler-workerglobalscope-onerror title=handler-WorkerGlobalScope-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> <tr><td><dfn id=handler-workerglobalscope-onoffline title=handler-WorkerGlobalScope-onoffline><code>onoffline</code></dfn> <td> <code title=event-offline><a href=#event-offline>offline</a></code> <!-- new --> <tr><td><dfn id=handler-workerglobalscope-ononline title=handler-WorkerGlobalScope-ononline><code>ononline</code></dfn> <td> <code title=event-online><a href=#event-online>online</a></code> <!-- new --> </table><hr><p>The <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> interface must not exist if the interface's <span>relevant namespace object</span> is a <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p> <h5 id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface><span class=secno>10.2.1.2 </span>Dedicated workers and the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> interface</h5> <pre class=idl>[Supplemental, NoInterfaceObject] interface <dfn id=dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</dfn> : <a href=#workerglobalscope>WorkerGlobalScope</a> { void <a href=#dom-dedicatedworkerglobalscope-postmessage title=dom-DedicatedWorkerGlobalScope-postMessage>postMessage</a>(any message, optional sequence<<a href=#transferable>Transferable</a>> transfer);<!-- <span>MessagePort</span> <span title="dom-DedicatedWorkerGlobalScope-startConversation">startConversation</span>(any message);--> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-dedicatedworkerglobalscope-onmessage title=handler-DedicatedWorkerGlobalScope-onmessage>onmessage</a>; };</pre> <p><code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects act as if they had an implicit <code><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><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p> <p>All messages received by that port must immediately be retargeted at the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p> <p>The <dfn id=dom-dedicatedworkerglobalscope-postmessage title=dom-DedicatedWorkerGlobalScope-postMessage><code>postMessage()</code></dfn><!-- and <dfn title="dom-DedicatedWorkerGlobalScope-startConversation"><code>startConversation()</code></dfn>--> method<!--s (startConversation)--> on <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects must act as if, when invoked, it<!--/they (startConversation)--> immediately invoked the method of the same name on the port, with the same arguments, and returned the same return value.</p> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by objects implementing the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-dedicatedworkerglobalscope-onmessage title=handler-DedicatedWorkerGlobalScope-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> </table><p>For the purposes of the <a href=#application-cache>application cache</a> networking model, a dedicated worker is an extension of the <a href=#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><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> interface</h5> <pre class=idl>[Supplemental, NoInterfaceObject] interface <dfn id=sharedworkerglobalscope>SharedWorkerGlobalScope</dfn> : <a href=#workerglobalscope>WorkerGlobalScope</a> { readonly attribute DOMString <a href=#dom-sharedworkerglobalscope-name title=dom-SharedWorkerGlobalScope-name>name</a>; readonly attribute <a href=#applicationcache>ApplicationCache</a> <a href=#dom-sharedworkerglobalscope-applicationcache title=dom-SharedWorkerGlobalScope-applicationCache>applicationCache</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-sharedworkerglobalscope-onconnect title=handler-SharedWorkerGlobalScope-onconnect>onconnect</a>; };</pre> <p>Shared workers receive message ports through <code title=event-WorkerGlobalScope-connect>connect</code> events on their global object for each connection.</p> <p>The <dfn id=dom-sharedworkerglobalscope-name title=dom-SharedWorkerGlobalScope-name><code>name</code></dfn> attribute must return the value it was assigned when the <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object was created by the "<a href=#run-a-worker>run a worker</a>" algorithm. Its value represents the name that can be used to obtain a reference to the worker using the <code><a href=#sharedworker>SharedWorker</a></code> constructor.</p> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by objects implementing the <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-sharedworkerglobalscope-onconnect title=handler-SharedWorkerGlobalScope-onconnect><code>onconnect</code></dfn> <td> <code title=event-connect>connect</code> </table><p>For the purposes of the <a href=#application-cache>application cache</a> networking model, a shared worker is its own <a href=#cache-host>cache host</a>. The <a href=#run-a-worker>run a worker</a> algorithm takes care of associating the worker with an <a href=#application-cache>application cache</a>.</p> <p class=note>The <code title=dom-SharedWorkerGlobalScope-applicationCache><a href=#dom-sharedworkerglobalscope-applicationcache>applicationCache</a></code> attribute returns the <code><a href=#applicationcache>ApplicationCache</a></code> object for the worker.</p><!-- normative conf criteria is in the appcache section --> <h4 id=origins-of-workers><span class=secno>10.2.2 </span>Origins of workers</h4> <p>Both the <a href=#origin>origin</a> and <a href=#effective-script-origin>effective script origin</a> of scripts running in workers are the <a href=#origin>origin</a> of the <a href=#absolute-url>absolute URL</a> given in that the worker's <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute represents.</p> <h4 id=the-event-loop><span class=secno>10.2.3 </span>The event loop</h4> <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object has an <a href=#event-loop>event loop</a> distinct from those defined for <a href=#unit-of-related-similar-origin-browsing-contexts title="unit of related similar-origin browsing contexts">units of related similar-origin browsing contexts</a>. This <a href=#event-loop>event loop</a> has no associated <a href=#browsing-context>browsing context</a>, and its <a href=#task-queue title="task queue">task queues</a> only have events, callbacks, and networking activity as <a href=#concept-task title=concept-task>tasks</a>. The processing model of these <a href=#event-loop title="event loop">event loops</a> is defined below in the <a href=#run-a-worker>run a worker</a> algorithm.</p> <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object also has a <dfn id=dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</dfn> flag, which must initially be false, but which can get set to true by the algorithms in the processing model section below.</p> <p>Once the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set to true, the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a> must discard any further <a href=#concept-task title=concept-task>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 title=dom-WorkerGlobalScope-closing>closing</a> flag is true, timers stop firing, notifications for all pending asynchronous operations are dropped, etc.</p> <h4 id="the-worker's-lifetime"><span class=secno>10.2.4 </span>The worker's lifetime</h4> <p>Workers communicate with other workers and with <a href=#browsing-context title="browsing context">browsing contexts</a> through <a href=#channel-messaging title="channel messaging">message channels</a> and their <code><a href=#messageport>MessagePort</a></code> objects.</p> <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> <var title="">worker global scope</var> has a list of <dfn id="the-worker's-ports">the worker's ports</dfn>, which consists of all the <code><a href=#messageport>MessagePort</a></code> objects that are entangled with another port and that have one (but only one) port owned by <var title="">worker global scope</var>. This list includes <!--all the <code>MessagePort</code> objects that are in events pending in the <span>event loop</span>, as well as (commented out because in practice it makes no difference either way as far as I can tell, and it would be hard to strictly implement since these ports might not yet be across the thread boundary)--> the implicit <code><a href=#messageport>MessagePort</a></code> in the case of <a href=#dedicatedworkerglobalscope title=DedicatedWorkerGlobalScope>dedicated workers</a>.</p> <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> also has a list of <dfn id="the-worker's-workers">the worker's workers</dfn>. Initially this list is empty; it is populated when the worker creates or obtains further workers.</p> <p>Finally, each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> also has a list of <dfn id="the-worker's-documents">the worker's <code>Document</code>s</dfn>. Initially this list is empty; it is populated when the worker is created.</p> <p>Whenever a <code><a href=#document>Document</a></code> <var title="">d</var> is <dfn id="add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">added to the worker's <code>Document</code>s</dfn>, the user agent must, for each worker in the list of <a href="#the-worker's-workers">the worker's workers</a> whose list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> does not contain <var title="">d</var>, <a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">add <var title="">d</var> to <var title="">q</var>'s <code>WorkerGlobalScope</code> owner's list of <span>the worker's <code>Document</code>s</span></a>.</p> <!-- suggestions welcome on making this sentence into understandable English --> <p>Whenever a <code><a href=#document>Document</a></code> object is <a href=#discard-a-document title="discard a Document">discarded</a>, it must be removed from the list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> of each worker whose list contains that <code><a href=#document>Document</a></code>.</p> <p>Given a <a href="#script's-global-object">script's global object</a> <var title="">o</var> when creating or obtaining a worker, the <dfn id=list-of-relevant-document-objects-to-add>list of relevant <code>Document</code> objects to add</dfn> depends on the type of <var title="">o</var>. If <var title="">o</var> is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object (i.e. if we are creating a nested worker), then the relevant <code><a href=#document>Document</a></code>s are the <code><a href=#document>Document</a></code>s that are in <var title="">o</var>'s own list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a>. Otherwise, <var title="">o</var> is a <code><a href=#window>Window</a></code> object, and the relevant <code><a href=#document>Document</a></code> is just the <code><a href=#document>Document</a></code> that is the <a href=#active-document>active document</a> of the <code><a href=#window>Window</a></code> object <var title="">o</var>.</p> <hr><p>A worker is said to be a <dfn id=permissible-worker>permissible worker</dfn> if its list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> is not empty.</p> <p>A worker is said to be a <dfn id=protected-worker>protected worker</dfn> if it is a <a href=#permissible-worker>permissible worker</a> and either it has outstanding timers, database transactions, or network connections, or its list of <a href="#the-worker's-ports">the worker's ports</a> is not empty, or its <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> is actually a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object (i.e. the worker is a shared worker).</p> <p>A worker is said to be an <dfn id=active-needed-worker>active needed worker</dfn> if any of the <code><a href=#document>Document</a></code> objects in <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> are <a href=#fully-active>fully active</a>.</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>active needed worker</a> but it is a <a href=#permissible-worker>permissible worker</a>.</p> <h4 id=processing-model-4><span class=secno>10.2.5 </span>Processing model</h4> <p>When a user agent is to <dfn id=run-a-worker>run a worker</dfn> for a script with <a href=#url>URL</a> <var title="">url</var>, a <a href=#browsing-context>browsing context</a> <var title="">owner browsing context</var>, a <code><a href=#document>Document</a></code> <var title="">owner document</var>, an <a href=#origin>origin</a> <var title="">owner origin</var>, and with global scope <var title="">worker global scope</var>, it must run the following steps:</p> <ol><li> <p>Create a separate parallel execution environment (i.e. a separate thread or process or equivalent construct), and run the rest of these steps asynchronously in that context.</p> </li> <li><p>If <var title="">worker global scope</var> is actually a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object (i.e. the worker is a shared worker), and there are any <a href=#relevant-application-cache title="relevant application cache">relevant application caches</a> that are identified by a manifest URL with the <a href=#same-origin>same origin</a> as <var title="">url</var> and that have <var title="">url</var> as one of their entries, <em>not</em> excluding entries marked as <a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>, then associate the <var title="">worker global scope</var> with the <a href=#concept-appcache-selection title=concept-appcache-selection>most appropriate application cache</a> of those that match.</li> <li> <p>Attempt to <a href=#fetch>fetch</a> the resource identified by <var title="">url</var>, from the <var title="">owner origin</var>, with the <i>synchronous flag</i> set and the <i>force same-origin flag</i> set.</p> <!-- not http-origin privacy sensitive (looking forward to CORS) --> <p>If the attempt fails, then for each <code><a href=#worker>Worker</a></code> or <code><a href=#sharedworker>SharedWorker</a></code> object associated with <var title="">worker global scope</var>, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at that object. Abort these steps.</p> <p>If the attempt succeeds, then let <var title="">source</var> be the script resource <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>. </p> <p>Let <var title="">language</var> be JavaScript.</p> <p class=note>As with <code><a href=#the-script-element>script</a></code> elements, the MIME type of the script is ignored. Unlike with <code><a href=#the-script-element>script</a></code> elements, there is no way to override the type. It's always assumed to be JavaScript.</p> </li> <li> <p>A new <a href=#concept-script title=concept-script>script</a> is now created, as follows.</p> <p>Create a new <a href=#script-execution-environment>script execution environment</a> set up as appropriate for the scripting language <var title="">language</var>.</p> <p>Parse/compile/initialize <var title="">source</var> using that <a href=#script-execution-environment>script execution environment</a>, as appropriate for <var title="">language</var>, and thus obtain a <a href=#list-of-code-entry-points>list of code entry-points</a>; set the <i><a href=#initial-code-entry-point>initial code entry-point</a></i> to the entry-point for any executable code to be immediately run.</p> <p>Set the <a href="#script's-global-object">script's global object</a> to <var title="">worker global scope</var>.</p> <p>Set the <a href="#script's-browsing-context">script's browsing context</a> to <var title="">owner browsing context</var>.</p> <p>Set the <a href="#script's-document">script's document</a> to <var title="">owner document</var>.</p> <p>Set the <a href="#script's-url-character-encoding">script's URL character encoding</a> to UTF-8. (This is just used for encoding non-ASCII characters in the query component of URLs.)</p> <p>Set the <a href="#script's-base-url">script's base URL</a> to <var title="">url</var>.</p> </li> <li> <p><strong>Closing orphan workers</strong>: Start monitoring the worker such that no sooner than it stops being either a <a href=#protected-worker>protected worker</a> or a <a href=#suspendable-worker>suspendable worker</a>, and no later than it stops being a <a href=#permissible-worker>permissible worker</a>, <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set to true<!-- v2-onclose and <span title="queue a task">a task is queued</span> to <span>fire a simple event</span> named <code title="event-close">close</code> at <var title="">worker global scope</var>-->.</p> </li> <li> <p><strong>Suspending workers</strong>: Start monitoring the worker, such that whenever <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is false and the worker is a <a href=#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 title=dom-WorkerGlobalScope-closing>closing</a> flag switches to true or the worker stops being a <a href=#suspendable-worker>suspendable worker</a>.</p> </li> <li> <p><a href=#jump-to-a-code-entry-point title="jump to a code entry-point">Jump</a> to the <a href=#concept-script title=concept-script>script</a>'s <i><a href=#initial-code-entry-point>initial code entry-point</a></i>, and let that run until it either returns, fails to catch an exception, or gets prematurely aborted by the "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms defined below.</p> <!-- v2-onclose <p class="note">If the script gets aborted by the "<span>kill a worker</span>" algorithm, then that same algorithm will cause there to only be a single <span title="concept-task">task</span> in the <span>event loop</span> at the next step, namely the task for the <code title="message-close">close</code> event. The "<span>terminate a worker</span>" algorithm removes all the events.</p> --> </li> <li><p>If <var title="">worker global scope</var> is actually a <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object (i.e. the worker is a dedicated worker), then enable the <a href=#port-message-queue>port message queue</a> of the worker's implicit port.</li> <li> <p><i title="">Event loop</i>: Wait until either there is a <a href=#concept-task title=concept-task>task</a> in one of the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a> or <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set to true.</p> </li> <li> <p>Run the oldest task on one of the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a>, if any. The user agent may pick any <a href=#task-queue>task queue</a>.</p> <p class=note>The handling of events or the execution of callbacks might get prematurely aborted by the "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms defined below.</p> </li> <li> <p>If the <a href=#storage-mutex>storage mutex</a> is now owned by the worker's <a href=#event-loop>event loop</a>, release it so that it is once again free.</p> </li> <li> <p>Remove the task just run in the earlier step, if any, from its <a href=#task-queue>task queue</a>.</p> </li> <li> <p>If there are any more events in the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a> or if <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set to false, then jump back to the step above labeled <i><a href=#event-loop>event loop</a></i>.</p> </li> <li> <p>Empty the <var title="">worker global scope</var>'s <a href=#list-of-active-timeouts>list of active timeouts</a> and its <a href=#list-of-active-intervals>list of active intervals</a>.</p> </li> <li> <p>Disentangle all the ports in the list of <a href="#the-worker's-ports">the worker's ports</a>.</p> </li> <!-- v2-onclose <li> <p>For each <code>Worker</code> or <code>SharedWorker</code> object associated with <var title="">worker global scope</var>, <span>queue a task</span> to <span>fire a simple event</span> named <code title="event-close">close</code> at that object.</p> </li> --> </ol><hr><p>When a user agent is to <dfn id=kill-a-worker>kill a worker</dfn> it must run the following steps in parallel with the worker's main loop (the "<a href=#run-a-worker>run a worker</a>" processing model defined above):</p> <ol><!-- v2-onclose <li><p>If the worker's <code>WorkerGlobalScope</code> object's <span title="dom-WorkerGlobalScope-closing">closing</span> flag is false, <span>queue a task</span> to <span>fire a simple event</span> named <code title="event-close">close</code> at the worker's <code>WorkerGlobalScope</code> object.</p></li> --><li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to true.</li> <!-- v2-onclose <li><p>Wait a user-agent-defined amount of time. If the "<span>run a worker</span>" processing model defined above immediately starts running event listeners registered for the <code title="event-close">close</code> event, this time should not be zero — the idea is that the <code title="event-close">close</code> event can be used to clean up when shutting down unexpectedly.</p></li> --> <li><p>If there are any <a href=#concept-task title=concept-task>tasks</a> queued in the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a><!-- v2-onclose other than the <code title="event-close">close</code> event that this algorithm just added-->, discard them without processing them.</li> <!-- v2-onclose <li><p>If the <code title="event-close">close</code> event that this algorithm just queued hasn't yet been dispatched, then abort the script currently running in the worker.</p></li> --> <li><p>Wait a user-agent-defined amount of time.</li> <li><p>Abort the script currently running in the worker<!-- v2-onclose (if any script is running, then it will be a handler for the <code title="event-close">close</code> event)-->.</li> </ol><p>User agents may invoke the "<a href=#kill-a-worker>kill a worker</a>" processing model on a worker at any time, e.g. in response to user requests, in response to CPU quota management, or when a worker stops being an <a href=#active-needed-worker>active needed worker</a> if the worker continues executing even after its <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag was set to true.</p> <hr><p>When a user agent is to <dfn id=terminate-a-worker>terminate a worker</dfn> it must run the following steps in parallel with the worker's main loop (the "<a href=#run-a-worker>run a worker</a>" processing model defined above):</p> <ol><li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to true.</li> <li><p>If there are any <a href=#concept-task title=concept-task>tasks</a> queued in the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task queues</a>, discard them without processing them.</li> <li><p>Abort the script currently running in the worker.</li> <li><p>If the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object is actually a <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object (i.e. the worker is a dedicated worker), then empty the <a href=#port-message-queue>port message queue</a> of the port that the worker's implicit port is entangled with.</li> </ol><hr><p>The <a href=#task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <h4 id=runtime-script-errors-0><span class=secno>10.2.6 </span>Runtime script errors</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>report the error</a> using the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <code title=handler-WorkerGlobalScope-onerror><a href=#handler-workerglobalscope-onerror>onerror</a></code> attribute. </p> <p>For shared workers, if the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> afterwards, or if the error occurred while handling a previous script error, the error may be reported to the user. </p> <p>For dedicated workers, if the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> afterwards, or if the error occurred while handling a previous script error, the user agent must <a href=#queue-a-task>queue a task</a> to fire an event that uses the <code><a href=#errorevent>ErrorEvent</a></code> interface, with the name <code title=event-error>error</code>, that doesn't bubble and is cancelable, with its <code title=dom-ErrorEvent-message><a href=#dom-errorevent-message>message</a></code>, <code title=dom-ErrorEvent-filename><a href=#dom-errorevent-filename>filename</a></code>, and <code title=dom-ErrorEvent-lineno><a href=#dom-errorevent-lineno>lineno</a></code> attributes initialized appropriately, at the <code><a href=#worker>Worker</a></code> object associated with the worker. If the event is not canceled, the user agent must act as if the uncaught runtime script error had occurred in the global scope that the <code><a href=#worker>Worker</a></code> object is in, thus repeating the entire runtime script error reporting process one level up.</p> <p>If the implicit port connecting the worker to its <code><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><a href=#worker>Worker</a></code> object had no <code title=event-error>error</code> event handler and as if that worker's <code title=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 proagate up to the chain of dedicated workers up to the original <code><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>task source</a> for the task mentioned above is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <hr><pre class=idl>[Constructor(DOMString type, optional <a href=#erroreventinit>ErrorEventInit</a> eventInitDict)] interface <dfn id=errorevent>ErrorEvent</dfn> : <a href=#event>Event</a> { readonly attribute DOMString <a href=#dom-errorevent-message title=dom-ErrorEvent-message>message</a>; readonly attribute DOMString <a href=#dom-errorevent-filename title=dom-ErrorEvent-filename>filename</a>; readonly attribute unsigned long <a href=#dom-errorevent-lineno title=dom-ErrorEvent-lineno>lineno</a>; }; dictionary <dfn id=erroreventinit>ErrorEventInit</dfn> : <a href=#eventinit>EventInit</a> { DOMString message; DOMString filename; unsigned long lineno; };</pre> <p>The <dfn id=dom-errorevent-message title=dom-ErrorEvent-message><code>message</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the error message.</p> <p>The <dfn id=dom-errorevent-filename title=dom-ErrorEvent-filename><code>filename</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the <a href=#absolute-url>absolute URL</a> of the script in which the error originally occurred.</p> <p>The <dfn id=dom-errorevent-lineno title=dom-ErrorEvent-lineno><code>lineno</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to zero. It represents the line number where the error occurred in the script.</p> <h4 id=creating-workers><span class=secno>10.2.7 </span>Creating workers</h4> <h5 id=the-abstractworker-abstract-interface><span class=secno>10.2.7.1 </span>The <code><a href=#abstractworker>AbstractWorker</a></code> abstract interface</h5> <pre class=idl>[Supplemental, NoInterfaceObject] interface <dfn id=abstractworker>AbstractWorker</dfn> : <a href=#eventtarget>EventTarget</a> { [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-abstractworker-onerror title=handler-AbstractWorker-onerror>onerror</a>; <!-- v2-onclose [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-AbstractWorker-onclose">onclose</span>; --> };</pre> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by objects implementing the <code><a href=#abstractworker>AbstractWorker</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-abstractworker-onerror title=handler-AbstractWorker-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> <!-- v2-onclose <tr><td><dfn title="handler-AbstractWorker-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> --> </table><h5 id=dedicated-workers-and-the-worker-interface><span class=secno>10.2.7.2 </span>Dedicated workers and the <code><a href=#worker>Worker</a></code> interface</h5> <pre class=idl>[<a href=#dom-worker title=dom-Worker>Constructor</a>(DOMString scriptURL)] interface <dfn id=worker>Worker</dfn> : <a href=#abstractworker>AbstractWorker</a> { void <a href=#dom-worker-terminate title=dom-Worker-terminate>terminate</a>(); void <a href=#dom-worker-postmessage title=dom-Worker-postMessage>postMessage</a>(any message, optional sequence<<a href=#transferable>Transferable</a>> transfer);<!-- <span>MessagePort</span> <span title="dom-Worker-startConversation">startConversation</span>(any message);--> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-worker-onmessage title=handler-Worker-onmessage>onmessage</a>; };</pre> <p>The <dfn id=dom-worker-terminate title=dom-Worker-terminate><code>terminate()</code></dfn> method, when invoked, must cause the "<a href=#terminate-a-worker>terminate a worker</a>" algorithm to be run on the worker with with the object is associated.</p> <p><code><a href=#worker>Worker</a></code> objects act as if they had an implicit <code><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><a href=#worker>Worker</a></code> object.</p> <p>All messages received by that port must immediately be retargeted at the <code><a href=#worker>Worker</a></code> object.</p> <p>The <dfn id=dom-worker-postmessage title=dom-Worker-postMessage><code>postMessage()</code></dfn><!-- and <dfn title="dom-Worker-startConversation"><code>startConversation()</code></dfn>--> method<!--s (startConversation)--> on <code><a href=#worker>Worker</a></code> objects must act as if, when invoked, it<!--/they (startConversation)--> immediately invoked the method of the same name on the port, with the same arguments, and returned the same return value.</p> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by objects implementing the <code><a href=#worker>Worker</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-worker-onmessage title=handler-Worker-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> </table><hr><p>When the <dfn id=dom-worker title=dom-Worker><code>Worker(<var title="">scriptURL</var>)</code></dfn> constructor is invoked, the user agent must run the following steps:</p> <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">scriptURL</var> argument relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>, when the method is invoked.</li> <li><p>If this fails, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</li> <li> <p>If the <a href=#origin>origin</a> of the resulting <a href=#absolute-url>absolute URL</a> is not the <a href=#same-origin title="same origin">same</a> as the origin of the <a href=#entry-script>entry script</a>, then throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p class=note>Thus, scripts must be external files with the same scheme as the original page: you can't load a script from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> or <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>, and an <code>https:</code> page couldn't start workers using scripts with <code>http:</code> URLs.</p> </li> <li><p>Create a new <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object. Let <var title="">worker global scope</var> be this new object.</li> <li><p>Create a new <code><a href=#worker>Worker</a></code> object, associated with <var title="">worker global scope</var>. Let <var title="">worker</var> be this new object.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor. Let this be the <var title="">outside port</var>.</li> <li><p>Associate the <var title="">outside port</var> with <var title="">worker</var>.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by <var title="">worker global scope</var>. Let <var title="">inside port</var> be this new object.</li> <li><p>Associate <var title="">inside port</var> with <var title="">worker global scope</var>.</li> <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var> and <var title="">inside port</var>.</li> <li><p>Return <var title="">worker</var>, and run the following steps asynchronously.</li> <!-- (this is done by the "run a worker" algorithm) <li><p>Enable <var title="">inside port</var>'s <span>port message queue</span>.</p></li> --> <li><p>Enable <var title="">outside port</var>'s <a href=#port-message-queue>port message queue</a>.</li> <li> <p>Let <var title="">docs</var> be the <a href=#list-of-relevant-document-objects-to-add>list of relevant <code>Document</code> objects to add</a> given the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor.</p> </li> <li> <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to <var title="">worker global scope</var>'s list of <span>the worker's <code>Document</code>s</span></a> the <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p> </li> <li> <p>If the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object (i.e. we are creating a nested worker), add <var title="">worker global scope</var> to the list of <a href="#the-worker's-workers">the worker's workers</a> of the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that is the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor.</p> </li> <li> <p><a href=#run-a-worker>Run a worker</a> for the resulting <a href=#absolute-url>absolute URL</a>, with the <a href="#script's-browsing-context">script's browsing context</a> of the script that invoked the method as the <var title="">owner browsing context</var>, with the <a href="#script's-document">script's document</a> of the script that invoked the method as the <var title="">owner document</var>, with the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a> as the <var title="">owner origin</var>, and with <var title="">worker global scope</var> as the global scope.</p> </li> </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global object</a> is either a <code><a href=#window>Window</a></code> object or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p> <h5 id=shared-workers-and-the-sharedworker-interface><span class=secno>10.2.7.3 </span>Shared workers and the <code><a href=#sharedworker>SharedWorker</a></code> interface</h5> <pre class=idl>[<a href=#dom-sharedworker title=dom-SharedWorker>Constructor</a>(DOMString scriptURL, optional DOMString name)] interface <dfn id=sharedworker>SharedWorker</dfn> : <a href=#abstractworker>AbstractWorker</a> { readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-sharedworker-port title=dom-SharedWorker-port>port</a>; };</pre> <p>The <dfn id=dom-sharedworker-port title=dom-SharedWorker-port><code>port</code></dfn> attribute must return the value it was assigned by the object's constructor. It represents the <code><a href=#messageport>MessagePort</a></code> for communicating with the shared worker.</p> <p>When the <dfn id=dom-sharedworker title=dom-SharedWorker><code>SharedWorker(<var title="">scriptURL</var>, <var title="">name</var>)</code></dfn> constructor is invoked, the user agent must run the following steps:</p> <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">scriptURL</var> argument.</li> <li><p>If this fails, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</li> <li><p>Otherwise, let <var title="">scriptURL</var> be the resulting <a href=#absolute-url>absolute URL</a>.</li> <li><p>Let <var title="">name</var> be the value of the second argument, or the empty string if the second argument was omitted.</li> <li> <p>If the <a href=#origin>origin</a> of <var title="">scriptURL</var> is not the <a href=#same-origin title="same origin">same</a> as the origin of the <a href=#entry-script>entry script</a>, then throw a <code><a href=#securityerror>SecurityError</a></code> exception.</p> <p class=note>Thus, scripts must be external files with the same scheme as the original page: you can't load a script from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> or <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>, and an <code>https:</code> page couldn't start workers using scripts with <code>http:</code> URLs.</p> </li> <li> <p>Let <var title="">docs</var> be the <a href=#list-of-relevant-document-objects-to-add>list of relevant <code>Document</code> objects to add</a> given the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor.</p> </li> <li> <p>Execute the following substeps atomically:</p> <ol><li><p>Create a new <code><a href=#sharedworker>SharedWorker</a></code> object, which will shortly be associated with a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object. Let this <code><a href=#sharedworker>SharedWorker</a></code> object be <var title="">worker</var>.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by the <a href="#script's-global-object" title="script's global object">global object</a> of the script that invoked the method. Let this be the <var title="">outside port</var>.</li> <li><p>Assign <var title="">outside port</var> to the <code title=dom-SharedWorker-port><a href=#dom-sharedworker-port>port</a></code> attribute of <var title="">worker</var>.</li> <li><p>Let <var title="">worker global scope</var> be null.</li> <li> <p>If <var title="">name</var> is not the empty string and there exists a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object whose <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is false, whose <code title=dom-WorkerGlobalScope-name>name</code> attribute is exactly equal to <var title="">name</var>, and whose <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute represents an <a href=#absolute-url>absolute URL</a> with the <a href=#same-origin>same origin</a> as <var title="">scriptURL</var>, then let <var title="">worker global scope</var> be that <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object.</p> <p>Otherwise, if <var title="">name</var> is the empty string and there exists a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object whose <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is false, whose <code title=dom-WorkerGlobalScope-name>name</code> attribute is the empty string, and whose <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute represents an <a href=#absolute-url>absolute URL</a> that is exactly equal to <var title="">scriptURL</var>, then let <var title="">worker global scope</var> be that <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object.</p> </li> <li> <p>If <var title="">worker global scope</var> is not null, but the user agent has been configured to disallow communication between the <a href=#concept-script title=concept-script>script</a> that invoked the constructor and the worker represented by the <var title="">worker global scope</var>, then set <var title="">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>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> <li> <p>If <var title="">worker global scope</var> is not null, then run these steps:</p> <ol><li><p>If <var title="">worker global scope</var>'s <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute represents an <a href=#absolute-url>absolute URL</a> that is not exactly equal to <var title="">scriptURL</var>, then throw a <code><a href=#urlmismatcherror>URLMismatchError</a></code> exception and abort all these steps.</li> <li><p>Associate <var title="">worker</var> with <var title="">worker global scope</var>.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by <var title="">worker global scope</var>. Let this be the <var title="">inside port</var>.</li> <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var> and <var title="">inside port</var>.</li> <li><p>Return <var title="">worker</var> and perform the next step asynchronously.</li> <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the name <code title=event-connect>connect</code>, which does not bubble, is not cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value is initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array containing only the newly created port, and <a href=#queue-a-task>queue a task</a> to dispatch the event at <var title="">worker global scope</var>.</li> <li> <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to <var title="">worker global scope</var>'s list of <span>the worker's <code>Document</code>s</span></a> the <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p> </li> <li> <p>If the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, add <var title="">worker global scope</var> to the list of <a href="#the-worker's-workers">the worker's workers</a> of the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that is the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor.</p> </li> <li><p>Abort all these steps.</li> </ol></li> <li><p>Create a new <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object. Let <var title="">worker global scope</var> be this new object.</li> <li><p>Associate <var title="">worker</var> with <var title="">worker global scope</var>.</li> <li><p>Set the <code title=dom-SharedWorkerGlobalScope-name><a href=#dom-sharedworkerglobalscope-name>name</a></code> attribute of <var title="">worker global scope</var> to <var title="">name</var>.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by <var title="">worker global scope</var>. Let <var title="">inside port</var> be this new object.</li> <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var> and <var title="">inside port</var>.</li> </ol></li> <li><p>Return <var title="">worker</var> and perform the remaining steps asynchronously.</li> <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the name <code title=event-connect>connect</code>, which does not bubble, is not cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value is initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array containing only the newly created port, and <a href=#queue-a-task>queue a task</a> to dispatch the event at <var title="">worker global scope</var>.</li> <li> <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to <var title="">worker global scope</var>'s list of <span>the worker's <code>Document</code>s</span></a> the <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p> </li> <li> <p>If the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, add <var title="">worker global scope</var> to the list of <a href="#the-worker's-workers">the worker's workers</a> of the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that is the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the constructor.</p> </li> <li> <p><a href=#run-a-worker>Run a worker</a> for <var title="">scriptURL</var>, with the <a href="#script's-browsing-context">script's browsing context</a> of the script that invoked the method as the <var title="">owner browsing context</var>, with the <a href="#script's-document">script's document</a> of the script that invoked the method as the <var title="">owner document</var>, with the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a> as the <var title="">owner origin</var>, and with <var title="">worker global scope</var> as the global scope.</p> </li> </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global object</a> is either a <code><a href=#window>Window</a></code> object or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p> <p>The <a href=#task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <h3 id=apis-available-to-workers><span class=secno>10.3 </span>APIs available to workers</h3> <pre class=idl>[NoInterfaceObject] interface <dfn id=workerutils>WorkerUtils</dfn> { void <a href=#dom-workerglobalscope-importscripts title=dom-WorkerGlobalScope-importScripts>importScripts</a>(DOMString... urls); readonly attribute <a href=#workernavigator>WorkerNavigator</a> <a href=#dom-worker-navigator title=dom-worker-navigator>navigator</a>; }; <a href=#workerutils>WorkerUtils</a> implements <a href=#windowtimers>WindowTimers</a>; <a href=#workerutils>WorkerUtils</a> implements <a href=#windowbase64>WindowBase64</a>;</pre> <p>The DOM APIs (<code><a href=#node>Node</a></code> objects, <code><a href=#document>Document</a></code> objects, etc) are not available to workers in this version of this specification.</p> <h4 id=importing-scripts-and-libraries><span class=secno>10.3.1 </span>Importing scripts and libraries</h4> <p>When a script invokes the <dfn id=dom-workerglobalscope-importscripts title=dom-WorkerGlobalScope-importScripts><code>importScripts(<var title="">urls</var>)</code></dfn> method on a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, the user agent must run the following steps:</p> <ol><li><p>If there are no arguments, return without doing anything. Abort these steps.</li> <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> each argument.</li> <li><p>If any fail, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</li> <!-- <li><p>If any of the resulting <span title="absolute URL">absolute URLs</span> have an <span>origin</span> that is not the <span title="same origin">same</span> as the origin of the script that invoked the method, then throw a <code>SecurityError</code> exception.</p></li> --> <li> <p>Attempt to <a href=#fetch>fetch</a> each resource identified by the resulting <a href=#absolute-url title="absolute URL">absolute URLs</a>, from the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a>, with the <i>synchronous flag</i> set.</p> <!-- not http-origin privacy sensitive --> </li> <li> <p>For each argument in turn, in the order given, starting with the first one, run these substeps:</p> <ol><li> <p>Wait for the fetching attempt for the corresponding resource to complete.</p> <p>If the fetching attempt failed, throw a <code><a href=#networkerror>NetworkError</a></code> exception and abort all these steps.</p> <p>If the attempt succeeds, then let <var title="">source</var> be the script resource <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>. </p> <p>Let <var title="">language</var> be JavaScript.</p> <p class=note>As with the worker's script, the script here is always assumed to be JavaScript, regardless of the MIME type.</p> </li> <li> <p><a href=#create-a-script>Create a script</a>, using <var title="">source</var> as the script source and <var title="">language</var> as the scripting language, using the same global object, browsing context, URL character encoding, base URL, and script group as the <a href=#concept-script title=concept-script>script</a> that was created by the worker's <a href=#run-a-worker>run a worker</a> algorithm.</p> <p>Let the newly created <a href=#concept-script title=concept-script>script</a> run until it either returns, fails to parse, fails to catch an exception, or gets prematurely aborted by the "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms defined above.</p> <p>If it failed to parse, then throw an ECMAScript <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort all these steps. <a href=#refsECMA262>[ECMA262]</a></p> <p>If an exception was raised or if the script was prematurely aborted, then abort all these steps, letting the exception or aborting continue to be processed by the script that called the <code title=dom-WorkerGlobalScope-importScripts><a href=#dom-workerglobalscope-importscripts>importScripts()</a></code> method.</p> <p>If the "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms abort the script then abort all these steps.</p> </li> </ol></li> </ol><h4 id=the-workernavigator-object><span class=secno>10.3.2 </span>The <code><a href=#workernavigator>WorkerNavigator</a></code> object</h4> <p>The <dfn id=dom-worker-navigator title=dom-worker-navigator><code>navigator</code></dfn> attribute of the <code><a href=#workerutils>WorkerUtils</a></code> interface must return an instance of the <code><a href=#workernavigator>WorkerNavigator</a></code> interface, which represents the identity and state of the user agent (the client):</p> <pre class=idl>interface <dfn id=workernavigator>WorkerNavigator</dfn> {}; <a href=#workernavigator>WorkerNavigator</a> implements <a href=#navigatorid>NavigatorID</a>; <a href=#workernavigator>WorkerNavigator</a> implements <a href=#navigatoronline>NavigatorOnLine</a>;</pre> <p>Objects implementing the <code><a href=#workernavigator>WorkerNavigator</a></code> interface also implement the <code><a href=#navigatorid>NavigatorID</a></code> and <code><a href=#navigatoronline>NavigatorOnLine</a></code> interfaces. </p> <p>This <code><a href=#workernavigator>WorkerNavigator</a></code> interface must not exist if the interface's <span>relevant namespace object</span> is a <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p> <h4 id=interface-objects-and-constructors><span class=secno>10.3.3 </span>Interface objects and constructors</h4> <p>There must be no interface objects and constructors available in the global scope of scripts whose <a href="#script's-global-object">script's global object</a> is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object except for the following:</p> <ul><li><p><code>XMLHttpRequest</code> and all interface objects and constructors defined by the XMLHttpRequest specifications, except that the <span>document response entity body</span> must always be null. The <span><code>XMLHttpRequest</code> base URL</span> is the <a href="#script's-base-url">script's base URL</a>; the <span><code>XMLHttpRequest</code> origin</span> is the script's <a href=#origin>origin</a>. <a href=#refsXHR>[XHR]</a></li> <li><p>The interface objects and constructors defined by this specification.</li> <li><p>Constructors defined by specifications that explicitly say that they should be visible when the <a href="#script's-global-object">script's global object</a> is a <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>, a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>, or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface; the interfaces of any objects with such constructors; and the interfaces of any objects made accessible through APIs exposed by those constructors or made accessible through interfaces to be implemented by any objects that are themselves accessible to scripts whose <a href="#script's-global-object">script's global object</a> implements the <code><a href=#workerutils>WorkerUtils</a></code> interface.</li> </ul><p class=note>These requirements do not override the requirements defined by the Web IDL specification, in particular concerning the visibility of interfaces annotated with the <code title="">[NoInterfaceObject]</code> extended attribute.</p> <h4 id=worker-locations><span class=secno>10.3.4 </span>Worker locations</h4> <pre class=idl>interface <dfn id=workerlocation>WorkerLocation</dfn> { // <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a> stringifier readonly attribute DOMString <a href=#dom-workerlocation-href title=dom-WorkerLocation-href>href</a>; readonly attribute DOMString <a href=#dom-workerlocation-protocol title=dom-WorkerLocation-protocol>protocol</a>; readonly attribute DOMString <a href=#dom-workerlocation-host title=dom-WorkerLocation-host>host</a>; readonly attribute DOMString <a href=#dom-workerlocation-hostname title=dom-WorkerLocation-hostname>hostname</a>; readonly attribute DOMString <a href=#dom-workerlocation-port title=dom-WorkerLocation-port>port</a>; readonly attribute DOMString <a href=#dom-workerlocation-pathname title=dom-WorkerLocation-pathname>pathname</a>; readonly attribute DOMString <a href=#dom-workerlocation-search title=dom-WorkerLocation-search>search</a>; readonly attribute DOMString <a href=#dom-workerlocation-hash title=dom-WorkerLocation-hash>hash</a>; };</pre> <p>A <code><a href=#workerlocation>WorkerLocation</a></code> object represents an <a href=#absolute-url>absolute URL</a> set at its creation.</p> <p>The <dfn id=dom-workerlocation-href title=dom-WorkerLocation-href><code>href</code></dfn> attribute must return the <a href=#absolute-url>absolute URL</a> that the object represents.</p> <p>The <code><a href=#workerlocation>WorkerLocation</a></code> interface also has the complement of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, <dfn id=dom-workerlocation-protocol title=dom-WorkerLocation-protocol><code>protocol</code></dfn>, <dfn id=dom-workerlocation-host title=dom-WorkerLocation-host><code>host</code></dfn>, <dfn id=dom-workerlocation-port title=dom-WorkerLocation-port><code>port</code></dfn>, <dfn id=dom-workerlocation-hostname title=dom-WorkerLocation-hostname><code>hostname</code></dfn>, <dfn id=dom-workerlocation-pathname title=dom-WorkerLocation-pathname><code>pathname</code></dfn>, <dfn id=dom-workerlocation-search title=dom-WorkerLocation-search><code>search</code></dfn>, and <dfn id=dom-workerlocation-hash title=dom-WorkerLocation-hash><code>hash</code></dfn>. These must follow the rules given for <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, with the <a href=#concept-uda-input title=concept-uda-input>input</a> being the <a href=#absolute-url>absolute URL</a> that the object represents (same as the <code title=dom-WorkerLocation-href><a href=#dom-workerlocation-href>href</a></code> attribute), and the <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> being a no-op, since the attributes are defined to be readonly. </p> <p>The <code><a href=#workerlocation>WorkerLocation</a></code> interface must not exist if the interface's <span>relevant namespace object</span> is a <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p> </div><!--data-component--> <!--POSTMSG--> <h2 id=comms><span class=secno>11 </span>Communication</h2> <div data-component="Web Messaging (editor: Ian Hickson)"> <h3 id=event-definitions-2><span class=secno>11.1 </span>Event definitions</h3> <p>Messages in <a href=#server-sent-events>server-sent events</a>, <a href=#network>Web sockets</a>, <a href=#web-messaging>cross-document messaging</a>, and <a href=#channel-messaging>channel messaging</a> use the <dfn id=event-message title=event-message><code>message</code></dfn> event. </p> <p>The following interface is defined for this event:</p> <pre class=idl>[Constructor(DOMString type, optional <a href=#messageeventinit>MessageEventInit</a> eventInitDict)] interface <dfn id=messageevent>MessageEvent</dfn> : <a href=#event>Event</a> { readonly attribute any <a href=#dom-messageevent-data title=dom-MessageEvent-data>data</a>; readonly attribute DOMString <a href=#dom-messageevent-origin title=dom-MessageEvent-origin>origin</a>; readonly attribute DOMString <a href=#dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId>lastEventId</a>; readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>; readonly attribute <a href=#messageport>MessagePort</a>[]? <a href=#dom-messageevent-ports title=dom-MessageEvent-ports>ports</a>; }; dictionary <dfn id=messageeventinit>MessageEventInit</dfn> : <a href=#eventinit>EventInit</a> { any data; DOMString origin; DOMString lastEventId; <a href=#windowproxy>WindowProxy</a>? source; <a href=#messageport>MessagePort</a>[]? ports; };</pre> <dl class=domintro><dt><var title="">event</var> . <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code></dt> <dd> <p>Returns the data of the message.</p> </dd> <dt><var title="">event</var> . <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code></dt> <dd> <p>Returns the origin of the message, for <a href=#server-sent-events>server-sent events</a> and <a href=#web-messaging>cross-document messaging</a>.</p> </dd> <dt><var title="">event</var> . <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code></dt> <dd> <p>Returns the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a>, for <a href=#server-sent-events>server-sent events</a>.</p> </dd> <dt><var title="">event</var> . <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code></dt> <dd> <p>Returns the <code><a href=#windowproxy>WindowProxy</a></code> of the source window, for <a href=#web-messaging>cross-document messaging</a>.</p> </dd> <dt><var title="">event</var> . <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code></dt> <dd> <p>Returns the <code><a href=#messageport>MessagePort</a></code> array sent with the message, for <a href=#web-messaging>cross-document messaging</a> and <a href=#channel-messaging>channel messaging</a>.</p> </dd> </dl><div class=impl> <p>The <dfn id=dom-messageevent-data title=dom-MessageEvent-data><code>data</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the message being sent.</p> <p>The <dfn id=dom-messageevent-origin title=dom-MessageEvent-origin><code>origin</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents, in <a href=#server-sent-events>server-sent events</a> and <a href=#web-messaging>cross-document messaging</a>, the <a href=#origin>origin</a> of the document that sent the message (typically the scheme, hostname, and port of the document, but not its path or fragment identifier).</p> <p>The <dfn id=dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId><code>lastEventId</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents, in <a href=#server-sent-events>server-sent events</a>, the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a> of the event source.</p> <p>The <dfn id=dom-messageevent-source title=dom-MessageEvent-source><code>source</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents, in <a href=#web-messaging>cross-document messaging</a>, the <code><a href=#windowproxy>WindowProxy</a></code> of the <a href=#browsing-context>browsing context</a> of the <code><a href=#window>Window</a></code> object from which the message came.</p> <p>The <dfn id=dom-messageevent-ports title=dom-MessageEvent-ports><code>ports</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null<!-- a <span title="dfn-read-only-array">read only</span> empty array-->. It represents, in <a href=#web-messaging>cross-document messaging</a> and <a href=#channel-messaging>channel messaging</a> the <code><a href=#messageport>MessagePort</a></code> array being sent, if any.</p> </div> </div><!--data-component--> <!--POSTMSG--> <h3 id=server-sent-events><span class=secno>11.2 </span><dfn>Server-sent events</dfn></h3> <div data-component="Server-Sent Events (editor: Ian Hickson)"> <h4 id=server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</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><a href=#eventsource>EventSource</a></code> interface.</p> <p>Using this API consists of creating an <code><a href=#eventsource>EventSource</a></code> object and registering an event listener.</p> <pre>var source = new EventSource('updates.cgi'); source.onmessage = function (event) { alert(event.data); };</pre> <p>On the server-side, the script ("<code title="">updates.cgi</code>" in this case) sends messages in the following form, with the <code><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 title="">addHandler</code> and <code title="">removeHandler</code> are functions that take one argument, the event):</p> <pre>var source = new EventSource('updates.cgi'); source.addEventListener('add', addHandler, false); source.addEventListener('remove', removeHandler, false);</pre> <p>The default event type is "message".</p> <hr><p>Event streams 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>XMLHttpRequest</code> or an <code><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 implementor 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>11.2.2 </span>The <code><a href=#eventsource>EventSource</a></code> interface</h4> <pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url, optional <a href=#eventsourceinit>EventSourceInit</a> eventSourceInitDict)] interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute DOMString <a href=#dom-eventsource-url title=dom-EventSource-url>url</a>; readonly attribute boolean <a href=#dom-eventsource-withcredentials title=dom-EventSource-withCredentials>withCredentials</a>; // ready state const unsigned short <a href=#dom-eventsource-connecting title=dom-EventSource-CONNECTING>CONNECTING</a> = 0; const unsigned short <a href=#dom-eventsource-open title=dom-EventSource-OPEN>OPEN</a> = 1; const unsigned short <a href=#dom-eventsource-closed title=dom-EventSource-CLOSED>CLOSED</a> = 2; readonly attribute unsigned short <a href=#dom-eventsource-readystate title=dom-EventSource-readyState>readyState</a>; // networking [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onopen title=handler-EventSource-onopen>onopen</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onmessage title=handler-EventSource-onmessage>onmessage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onerror title=handler-EventSource-onerror>onerror</a>; void <a href=#dom-eventsource-close title=dom-EventSource-close>close</a>(); }; dictionary <dfn id=eventsourceinit>EventSourceInit</dfn> { boolean <dfn id=dom-eventsourceinit-withcredentials title=dom-EventSourceInit-withCredentials>withCredentials</dfn> = false; };</pre> <p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource()</code></dfn> constructor takes one or two arguments. The first specifies the <a href=#url>URL</a> to which to connect. The second specifies the settings, if any, in the form of an <code><a href=#eventsourceinit>EventSourceInit</a></code> dictionary. When the <code>EventSource()</code> constructor is invoked, the UA must run these steps:</p> <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <a href=#url>URL</a> specified in the first argument, relative to the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>. </li> <li><p>If the previous step failed, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</li> <li><p>Create a new <code><a href=#eventsource>EventSource</a></code> object.</li> <li><p>Let <var title="">CORS mode</var> be <a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a>.</li> <li><p>If the second argument is present, and the <code title=dom-EventSourceInit-withCredentials><a href=#dom-eventsourceinit-withcredentials>withCredentials</a></code> dictionary member has the value true, then set <var title="">CORS mode</var> to <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</a> and initialize the new <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-withCredentials><a href=#dom-eventsource-withcredentials>withCredentials</a></code> attribute to true.</li> <li><p>Return the new <code><a href=#eventsource>EventSource</a></code> object, and continue these steps in the background (without blocking scripts).</li> <li> <p>Do a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the resulting <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being <var title="">CORS mode</var>, and the <i title="">origin</i> being the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a><!--, and the <i>default origin behaviour</i> set to <i>fail</i> (though it has no effect in the "Use Credentials" mode)-->, and process the resource obtained in this fashion, if any, as described below.</p> <p class=note>The definition of the <a href=#fetch title=fetch>fetching</a> algorithm (which is used by CORS) is such that if the browser is already fetching the resource identified by the given <a href=#absolute-url>absolute URL</a>, that connection can be reused, instead of a new connection being established. All messages received up to this point are dispatched immediately, in this case.</p> </li> </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global object</a> is either a <code><a href=#window>Window</a></code> object or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p> <hr><p>The <dfn id=dom-eventsource-url title=dom-EventSource-url><code>url</code></dfn> attribute must return the <a href=#absolute-url>absolute URL</a> that resulted from <a href=#resolve-a-url title="resolve a url">resolving</a> the value that was passed to the constructor.</p> <!-- not the result of redirects, since that would introduce race conditions --> <p>The <dfn id=dom-eventsource-withcredentials title=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 title=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 title=dom-EventSource-CONNECTING><code>CONNECTING</code></dfn> (numeric value 0)</dt> <dd>The connection has not yet been established, or it was closed and the user agent is reconnecting.</dd> <dt><dfn id=dom-eventsource-open title=dom-EventSource-OPEN><code>OPEN</code></dfn> (numeric value 1)</dt> <dd>The user agent has an open connection and is dispatching events as it receives them.</dd> <dt><dfn id=dom-eventsource-closed title=dom-EventSource-CLOSED><code>CLOSED</code></dfn> (numeric value 2)</dt> <dd>The connection is not open, and the user agent is not trying to reconnect. Either there was a fatal error or the <code title=dom-EventSource-close><a href=#dom-eventsource-close>close()</a></code> method was invoked.</dd> </dl><p>When the object is created its <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> must be set to <code title=dom-EventSource-CONNECTING><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 title=dom-EventSource-close><code>close()</code></dfn> method must abort any instances of the <a href=#fetch>fetch</a> algorithm started for this <code><a href=#eventsource>EventSource</a></code> object, and must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p> <!-- this also causes all the message events to stop firing, even if they were queued before close() was called --> <p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#eventsource>EventSource</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-eventsource-onopen title=handler-EventSource-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code> <tr><td><dfn id=handler-eventsource-onmessage title=handler-EventSource-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> <tr><td><dfn id=handler-eventsource-onerror title=handler-EventSource-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> </table><hr><p>In addition to the above, each <code><a href=#eventsource>EventSource</a></code> object has the following associated with it:</p> <ul><li>A <dfn id=concept-event-stream-reconnection-time title=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> <li>A <dfn id=concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</dfn>. This must initially be the empty string.</li> </ul><p>These values are not currently exposed on the interface.</p> <h4 id=processing-model-5><span class=secno>11.2.3 </span>Processing model</h4> <p>The resource indicated in the argument to the <code title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor is <a href=#fetch title=fetch>fetched</a> when the constructor is run.</p> <p>For HTTP connections, the <code title="">Accept</code> header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be <code><a href=#text/event-stream>text/event-stream</a></code>, as described below).</p> <p>If the event source's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a> is not the empty string, then a <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code> HTTP header must be included with the request, whose value is the value of the event source's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a>, encoded as UTF-8.</p> <p>User agents should use the <code>Cache-Control: no-cache</code> header in requests to bypass any caches for requests of event sources. (This header is not a <a href=#custom-request-headers title="custom request headers">custom request header</a>, so the user agent will still use the CORS <a href=#simple-cross-origin-request>simple cross-origin request</a> mechanism.) User agents should ignore HTTP cache headers in the response, never caching event sources.</p> <hr><p>As data is received, the <a href=#concept-task title=concept-task>tasks</a> queued by the <a href=#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>Content-Type</a> header specifying the type <code><a href=#text/event-stream>text/event-stream</a></code>, either with no parameters or with a single parameter with the name "<code title="">charset</code>" whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">utf-8</code>", 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 href=#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>announce the connection</a>.</p> <p>The <a href=#concept-task title=concept-task>task</a> that the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a> for such a resource (with the correct <a href=#mime-type>MIME type</a>) has completed must cause the user agent to asynchronously <a href=#reestablish-the-connection>reestablish the connection</a>. This applies whether the connection is closed gracefully or unexpectedly. It doesn't apply for the error conditions listed below.</p> <p>HTTP 200 OK responses that have a <a href=#content-type>Content-Type</a> specifying an unsupported type (including the <code><a href=#text/event-stream>text/event-stream</a></code> type with unsupported parameters or parameters with unsupported values), or that have no <a href=#content-type>Content-Type</a> at all, must cause the user agent to <a href=#fail-the-connection>fail the connection</a>.</p> <!-- about:blank is defined as having no MIME type; javascript: as having the type text/html --> <p>HTTP 305 Use Proxy, HTTP 401 Unauthorized, and 407 Proxy Authentication Required should be treated transparently as for any other subresource.</p> <p>HTTP 301 Moved Permanently, HTTP 302 Found, 303 See Other, and 307 Temporary Redirect responses are handled by the <a href=#fetch title=fetch>fetching</a> and CORS algorithms. In the case of 301 redirects, the user agent must also remember the new URL so that subsequent requests for this resource for this <code><a href=#eventsource>EventSource</a></code> object start with the URL given for the last 301 seen for requests for this object.</p> <p>Any other HTTP response code not listed here, and any network error that prevents the HTTP connection from being established in the first place (e.g. DNS errors), must cause the user agent to <a href=#fail-the-connection>fail the connection</a>.</p> <!-- including: HTTP 201 Created, HTTP 202 Accepted, HTTP 203 Non-Authoritative Information, HTTP 204 No Content, HTTP 205 Reset Content, HTTP 206 Partial Content, HTTP 300 Multiple Choices, HTTP 304 Not Modified, HTTP 400 Bad Request, 403 Forbidden, 404 Not Found, 405 Method Not Allowed, 406 Not Acceptable, 408 Request Timeout, 409 Conflict, 410 Gone, 411 Length Required, 412 Precondition Failed, 413 Request Entity Too Large, 414 Request-URI Too Long, 415 Unsupported Media Type, 416 Requested Range Not Satisfiable, 417 Expectation Failed, 500 Internal Server Error, 501 Not Implemented, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout, and 505 HTTP Version Not Supported responses --> <!-- mailto: is defined as equivalent to HTTP 204 --> <p>For non-HTTP protocols, UAs should act in equivalent ways.</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>queue a task</a> which, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is set to a value other than <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, sets the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code> and <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-open>open</code> at the <code><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 asynchronously, not as part of a <a href=#concept-task title=concept-task>task</a>. (The tasks that it queues, of course, are run like normal tasks and not asynchronously.)</p> <ol><li> <p><a href=#queue-a-task>Queue a task</a> to run the following steps:</p> <ol><li><p>If the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is set to <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, abort the task.</li> <li><p>Set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>.</li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#eventsource>EventSource</a></code> object.</li> </ol></li> <li><p>Wait a delay equal to the reconnection time of the event source.</li> <li><p>Wait until the aforementioned task has run, if it has not yet run.</li> <li> <p><a href=#queue-a-task>Queue a task</a> to run the following steps:</p> <ol><li><p>If the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is not set to <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>, abort these steps.</li> <li><p>Perform a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the <a href=#absolute-url>absolute URL</a> of the event source resource, with the <i>mode</i> being <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use Credentials</a>, and the <i title="">origin</i> being the same as the <a href=#origin>origin</a> used in the original request triggered by the <code title=dom-EventSource><a href=#dom-eventsource>EventSource()</a></code> constructor<!--, and the <i>default origin behaviour</i> set to <i>fail</i> (though it has no effect in the "Use Credentials" mode)-->, and process the resource obtained in this fashion, if any, as described earlier in this section.</li> </ol></li> </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>queue a task</a> which, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is set to a value other than <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, sets the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code> and <a href=#fire-a-simple-event title="fire a simple event">fires a simple event</a> named <code title=event-error>error</code> at the <code><a href=#eventsource>EventSource</a></code> object. <strong>Once the user agent has <a href=#fail-the-connection title="fail the connection">failed the connection</a>, it does <em>not</em> attempt to reconnect!</strong></p> <hr><p>The <a href=#task-source>task source</a> for any <a href=#concept-task title=concept-task>tasks</a> that are <a href=#queue-a-task title="queue a task">queued</a> by <code><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>11.2.4 </span>Parsing an event stream</h4> <p>This event stream format's <a href=#mime-type>MIME type</a> is <code><a href=#text/event-stream>text/event-stream</a></code>.</p> <p>The event stream format is as described by the <code title="">stream</code> production of the following ABNF, the character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p> <pre>stream = [ bom ] *event event = *( comment / field ) end-of-line comment = colon *any-char end-of-line field = 1*name-char [ colon [ space ] *any-char ] end-of-line end-of-line = ( cr lf / cr / lf ) ; characters lf = %x000A ; U+000A LINE FEED (LF) cr = %x000D ; U+000D CARRIAGE RETURN (CR) space = %x0020 ; U+0020 SPACE colon = %x003A ; U+003A COLON (:) bom = %xFEFF ; U+FEFF BYTE ORDER MARK name-char = %x0000-0009 / %x000B-000C / %x000E-0039 / %x003B-10FFFF ; a <a href=#unicode-character>Unicode character</a> other than U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), or U+003A COLON (:) any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF ; a <a href=#unicode-character>Unicode character</a> other than U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)</pre> <p>Event streams in this format must always be encoded as UTF-8. <a href=#refsRFC3629>[RFC3629]</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>11.2.5 </span>Interpreting an event stream</h4> <p>Streams must be <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>. </p> <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.</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, a single U+000D CARRIAGE RETURN (CR) character not followed by a U+000A LINE FEED (LF) character, and the end of the file being the four ways in which a line can end.</p> <p>When a stream is parsed, a <var title="">data</var> buffer, an <var title="">event name</var> buffer, and a <var title="">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)</dt> <dd><p><a href=#dispatchMessage>Dispatch the event</a>, as defined below.</dd> <dt>If the line starts with a U+003A COLON character (:)</dt> <dd><p>Ignore the line.</dd> <dt>If the line contains a U+003A COLON character (:)</dt> <dd> <p>Collect the characters on the line before the first U+003A COLON character (:), and let <var title="">field</var> be that string.</p> <p>Collect the characters on the line after the first U+003A COLON character (:), and let <var title="">value</var> be that string. If <var title="">value</var> starts with a U+0020 SPACE character, remove it from <var title="">value</var>.</p> <p><a href=#processField>Process the field</a> using the steps described below, using <var title="">field</var> as the field name and <var title="">value</var> as the field value.</p> </dd> <dt>Otherwise, the string is not empty but does not contain a U+003A COLON character (:)</dt> <dd> <p><a href=#processField>Process the field</a> using the steps described below, using the whole line as the field name, and the empty string as the field value.</p> </dd> </dl><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 title="">process the field</dfn> given a field name and a field value depend on the field name, as given in the following list. Field names must be compared literally, with no case folding performed.</p> <dl class=switch><dt>If the field name is "event"</dt> <dd><p>Set the <var title="">event name</var> buffer to field value.</dd> <dt>If the field name is "data"</dt> <dd><p>Append the field value to the <var title="">data</var> buffer, then append a single U+000A LINE FEED (LF) character to the <var title="">data</var> buffer.</dd> <dt>If the field name is "id"</dt> <dd><p>Set the <var title="">last event ID</var> buffer to the field value.</dd> <dt>If the field name is "retry"</dt> <dd><p>If the field value consists of only characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then interpret the field value as an integer in base ten, and set the event stream's <a href=#concept-event-stream-reconnection-time title=concept-event-stream-reconnection-time>reconnection time</a> to that integer. Otherwise, ignore the field.</dd> <!-- v2 feature request from Per-Erik Brodin: > > > Finally, it could be useful to be able to reset the reconnection > > > time to the user agent default value by sending the retry field only > > > and leave out the value similar to how you reset the last event id. > > > > What's the use case? > > Take the stock ticker as an example. When the stock market closes the > server logic knows that there won't be any new events for a number of > hours and so it can send the corresponding reconnection time and close > the connection. If the client is still running by the time the market > opens, it will reconnect, and the server can now reset the reconnection > time to a time that is convenient for the user agent (which is the user > agent default value, unknown to the server). --> <!-- v2 feature request from John Fallows - http://www.w3.org/mid/c5b3a7130810271238h11e40a4fybfcd5983ed5dc08d@mail.gmail.com <dt>If the field name is "reconnect"</dt> <dd><p>If the field value is the empty string, then: <a href="#dispatchMessage">dispatch the event</a> as defined below, and then drop the connection and immediately reconnect as if the <span title="concept-event-stream-reconnection-time">reconnection time</span> was zero for this one time.</p></dd> --> <dt>Otherwise</dt> <dd><p>The field is ignored.</dd> </dl><p id=dispatchMessage>When the user agent is required to <dfn title="">dispatch the event</dfn>, then the user agent must act as follows: <ol><li><p>Set the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a> of the event source to value of the <var title="">last event ID</var> buffer. The buffer does not get reset, so the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>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> <li><p>If the <var title="">data</var> buffer is an empty string, set the <var title="">data</var> buffer and the <var title="">event name</var> buffer to the empty string and abort these steps.</li> <li><p>If the <var title="">data</var> buffer's last character is a U+000A LINE FEED (LF) character, then remove the last character from the <var title="">data</var> buffer.</li> <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not cancelable, and has no default action. The <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute must be initialized to the value of the <var title="">data</var> buffer, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute must be initialized to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an origin">Unicode serialization</a> of the <a href=#origin>origin</a> of the event stream's URL, and the <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code> attribute must be initialized to the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID string</a> of the event source.</li> <li><p>If the <var title="">event name</var> buffer has a value other than the empty string, change the <a href=#concept-event-type title=concept-event-type>type</a> of the newly created event to equal the value of the <var title="">event name</var> buffer.</li> <li><p>Set the <var title="">data</var> buffer and the <var title="">event name</var> buffer to the empty string.</li> <li><p><a href=#queue-a-task>Queue a task</a> which, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is set to a value other than <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, dispatches the newly created event at the <code><a href=#eventsource>EventSource</a></code> object.</li> <!-- so calling close() drops the messages immediately. The connection dying doesn't interfere with already-sent messages since it sets us to CLOSED via a task, not synchronously --> </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 title=concept-event-stream-last-event-id>last event ID string</a>, then the event's <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code> field will be set to the value of whatever the last seen "id" field was.</p> <div 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 title=event-message><a href=#event-message>message</a></code> with the interface <code><a href=#messageevent>MessageEvent</a></code> to be dispatched on the <code><a href=#eventsource>EventSource</a></code> object. The event's <code title=dom-MessageEvent-data><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>var stocks = new EventSource("http://stocks.example.com/ticker.php"); stocks.onmessage = function (event) { var data = event.data.split('\n'); updateStocks(data[0], data[1], data[2]); };</pre> <p>...where <code title="">updateStocks()</code> is a function defined as:</p> <pre>function updateStocks(symbol, delta, value) { ... }</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 title=http-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 title=http-last-event-id><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=notes><span class=secno>11.2.6 </span>Notes</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. Where possible, chunking should be disabled for serving event streams unless the rate of messages is high enough for this not to matter.</p> <!-- v2 can we get a better solution? --> <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><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><a href=#eventsource>EventSource</a></code> functionality on a per-page basis, or by sharing a single <code><a href=#eventsource>EventSource</a></code> object using a <a href=#sharedworkerglobalscope title=SharedWorkerGlobalScope>shared worker</a>. </p> <h4 id=eventsource-push><span class=secno>11.2.7 </span>Connectionless push and other features</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 title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor.</li> <li>The server sends occasional messages.</li> <li>In between two messages, the browser detects that it is idle except for the network activity involved in keeping the TCP connection alive, and decides to switch to sleep mode to save power.</li> <li>The browser disconnects from the server.</li> <li>The browser contacts a service on the network, and requests that that service, a "push proxy", maintain the connection instead.</li> <li>The "push proxy" service contacts the remote HTTP server and requests the resource specified by the author in the <code title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor (possibly including a <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code> HTTP header, etc).</li> <li>The browser allows the mobile device to go to sleep.</li> <li>The server sends another message.</li> <li>The "push proxy" service uses a technology such as OMA push to convey the event to the mobile device, which wakes only enough to process the event and then returns to sleep.</li> </ol></div> <p>This can reduce the total data usage, and can therefore result in considerable power savings.</p> <p>As well as implementing the existing API and <code><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>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-1><span class=secno>11.2.8 </span>Garbage collection</h4> <p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>, and the object has one or more event listeners registered for <code title=event-open>open</code>, <code title=event-message><a href=#event-message>message</a></code> or <code title=event-error>error</code> events, there must be a strong reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code> object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was invoked from to the <code><a href=#eventsource>EventSource</a></code> object itself.</p> <p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is <code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code>, and the object has one or more event listeners registered for <code title=event-message><a href=#event-message>message</a></code> or <code title=event-error>error</code> events, there must be a strong reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code> object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was invoked from to the <code><a href=#eventsource>EventSource</a></code> object itself.</p> <p>While there is a task queued by an <code><a href=#eventsource>EventSource</a></code> object on the <a href=#remote-event-task-source>remote event task source</a>, there must be a strong reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code> object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was invoked from to that <code><a href=#eventsource>EventSource</a></code> object.</p> <p>If a user agent is to <dfn id=concept-eventsource-forcibly-close title=concept-EventSource-forcibly-close>forcibly close</dfn> an <code><a href=#eventsource>EventSource</a></code> object (this happens when a <code><a href=#document>Document</a></code> object goes away permanently), the user agent must abort any instances of the <a href=#fetch>fetch</a> algorithm started for this <code><a href=#eventsource>EventSource</a></code> object, and must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p> <!-- same as calling close() --> <p>If an <code><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=#fetch title=fetch>fetch</a> algorithm opened by this <code><a href=#eventsource>EventSource</a></code>.</p> <!-- no need to throw tasks away or anything; for it to get garbage collected, there can't be anything that would be able to receive those events --> <p class=note>It's possible for one active network connection to be shared by multiple <code><a href=#eventsource>EventSource</a></code> objects and their <a href=#fetch>fetch</a> algorithms, which is why the above is phrased in terms of aborting the <a href=#fetch>fetch</a> algorithm and not the actual underlying download.</p> <h4 id=iana-considerations><span class=secno>11.2.9 </span>IANA considerations</h4> <h5 id=text/event-stream><span class=secno>11.2.9.1 </span><dfn><code>text/event-stream</code></dfn></h5> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type text/event-stream --> <dl><dt>Type name:</dt> <dd>text</dd> <dt>Subtype name:</dt> <dd>event-stream</dd> <dt>Required parameters:</dt> <dd>No parameters</dd> <dt>Optional parameters:</dt> <dd> <dl><dt><code title="">charset</code></dt> <dd> <p>The <code title="">charset</code> parameter may be provided. The parameter's value must be "<code title="">utf-8</code>". This parameter serves no purpose; it is only allowed for compatibility with legacy servers.</p> </dd> </dl></dd> <dt>Encoding considerations:</dt> <dd>8bit (always UTF-8)</dd> <dt>Security considerations:</dt> <dd> <p>An event stream from an origin distinct from the origin of the content consuming the event stream can result in information leakage. To avoid this, user agents are required to apply CORS semantics. <a href=#refsCORS>[CORS]</a></p> <p>Event streams can overwhelm a user agent; a user agent is expected to apply suitable restrictions to avoid depleting local resources because of an overabundance of information from an event stream.</p> <p>Servers can be overwhelmed if a situation develops in which the server is causing clients to reconnect rapidly. Servers should use a 5xx status code to indicate capacity problems, as this will prevent conforming clients from reconnecting automatically.</p> </dd> <dt>Interoperability considerations:</dt> <dd> Rules for processing both conforming and non-conforming content are defined in this specification. </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers and tools using Web services. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>No sequence of bytes can uniquely identify an event stream.</dd> <dt>File extension(s):</dt> <dd>No specific file extensions are recommended for this type.</dd> <dt>Macintosh file type code(s):</dt> <dd>No specific Macintosh file type codes are recommended for this type.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>This format is only expected to be used by dynamic open-ended streams served using HTTP or a similar protocol. Finite resources are not expected to be labeled with this type.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers have no meaning with <code><a href=#text/event-stream>text/event-stream</a></code> resources.</p> <h5 id=last-event-id><span class=secno>11.2.9.2 </span><dfn title=http-last-event-id><code>Last-Event-ID</code></dfn></h5> <p>This section describes a header field for registration in the Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p> <dl><dt>Header field name</dt> <dd>Last-Event-ID</dd> <dt>Applicable protocol</dt> <dd>http</dd> <dt>Status</dt> <dd>standard</dd> <dt>Author/Change controller</dt> <dd>W3C</dd> <dt>Specification document(s)</dt> <dd> This document is the relevant specification. </dd> <dt>Related information</dt> <dd>None.</dd> </dl></div><!--data-component--> <h3 id=network><span class=secno>11.3 </span><dfn>Web sockets</dfn></h3> <div data-component="WebSocket API (editor: Ian Hickson)"> <h4 id=network-intro><span class=secno>11.3.1 </span>Introduction</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><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>11.3.2 </span>The <code><a href=#websocket>WebSocket</a></code> interface</h4> <pre class=idl>[<a href=#dom-websocket title=dom-WebSocket>Constructor</a>(DOMString url, optional DOMString protocols), <a href=#dom-websocket title=dom-WebSocket>Constructor</a>(DOMString url, optional DOMString[] protocols)] interface <dfn id=websocket>WebSocket</dfn> : <a href=#eventtarget>EventTarget</a> { readonly attribute DOMString <a href=#dom-websocket-url title=dom-WebSocket-url>url</a>; // ready state const unsigned short <a href=#dom-websocket-connecting title=dom-WebSocket-CONNECTING>CONNECTING</a> = 0; const unsigned short <a href=#dom-websocket-open title=dom-WebSocket-OPEN>OPEN</a> = 1; const unsigned short <a href=#dom-websocket-closing title=dom-WebSocket-CLOSING>CLOSING</a> = 2; const unsigned short <a href=#dom-websocket-closed title=dom-WebSocket-CLOSED>CLOSED</a> = 3; readonly attribute unsigned short <a href=#dom-websocket-readystate title=dom-WebSocket-readyState>readyState</a>; readonly attribute unsigned long <a href=#dom-websocket-bufferedamount title=dom-WebSocket-bufferedAmount>bufferedAmount</a>; // networking [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onopen title=handler-WebSocket-onopen>onopen</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onerror title=handler-WebSocket-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>; readonly attribute DOMString <a href=#dom-websocket-extensions title=dom-WebSocket-extensions>extensions</a>; readonly attribute DOMString <a href=#dom-websocket-protocol title=dom-WebSocket-protocol>protocol</a>; void <a href=#dom-websocket-close title=dom-WebSocket-close>close</a>([Clamp] optional unsigned short code, optional DOMString reason); // messaging [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onmessage title=handler-WebSocket-onmessage>onmessage</a>; attribute DOMString <a href=#dom-websocket-binarytype title=dom-WebSocket-binaryType>binaryType</a>; void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(DOMString data); void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(<a href=#arraybuffer>ArrayBuffer</a> data); void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(<a href=#blob>Blob</a> data); };</pre> <p>The <dfn id=dom-websocket title=dom-WebSocket><code>WebSocket(<var title="">url</var>, <var title="">protocols</var>)</code></dfn> constructor takes one or two arguments. The first argument, <var title="">url</var>, specifies the <a href=#url>URL</a> to which to connect. The second, <var title="">protocols</var>, if present, 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 must all be strings that match the requirements for elements that comprise the value of <code title=http-sec-websocket-protocol>Sec-WebSocket-Protocol</code> header fields as defined by the WebSocket protocol specification. <a href=#refsWSP>[WSP]</a></p> <p>When the <code>WebSocket()</code> constructor is invoked, the UA must run these steps:</p> <ol><li><p><i><a href="#parse-a-websocket-url's-components">Parse a WebSocket URL's components</a></i> from the <var title="">url</var> argument, to obtain <var title="">host</var>, <var title="">port</var>, <var title="">resource name</var>, and <var title="">secure</var>. If this fails, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps. <a href=#refsWSP>[WSP]</a></li> <li><p>If <var title="">secure</var> is false but the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a> has a scheme component that is itself a secure protocol, e.g. HTTPS, then throw a <code><a href=#securityerror>SecurityError</a></code> exception.</li> <li> <p>If <var title="">port</var> is a port to which the user agent is configured to block access, then throw a <code><a href=#securityerror>SecurityError</a></code> exception. (User agents typically block access to well-known ports like SMTP.)</p> <!-- e.g. http://www.mozilla.org/projects/netlib/PortBanning.html --> <p>Access to ports 80 and 443 should not be blocked, including the unlikely cases when <var title="">secure</var> is false but <var title="">port</var> is 443 or <var title="">secure</var> is true but <var title="">port</var> is 80.</p> <!-- paragraph requested by zcorpan --> </li> <li> <p>If <var title="">protocols</var> is absent, let <var title="">protocols</var> be an empty array.</p> <p>Otherwise, if <var title="">protocols</var> is present and a string, let <var title="">protocols</var> instead be an array consisting of just that string.</p> </li> <li><p>If any of the values in <var title="">protocols</var> occur more than once or otherwise fail to match the requirements for elements that comprise the value of <code title=http-sec-websocket-protocol>Sec-WebSocket-Protocol</code> header fields as defined by the WebSocket protocol specification, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps. <a href=#refsWSP>[WSP]</a></li> <li><p>Let <var title="">origin</var> be the <a href=#ascii-serialization-of-an-origin title="ASCII serialization of an origin">ASCII serialization</a> of the <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a>, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <li><p>Return a new <code><a href=#websocket>WebSocket</a></code> object, and continue these steps in the background (without blocking scripts).</li> <li> <p><i><a href=#establish-a-websocket-connection>Establish a WebSocket connection</a></i> given the set (<var title="">host</var>, <var title="">port</var>, <var title="">resource name</var>, <var title="">secure</var>), along with the <var title="">protocols</var> list, an empty list for the extensions, and <var title="">origin</var>. The <i><a href=#headers-to-send-appropriate-cookies>headers to send appropriate cookies</a></i> must be a <code title=http-Cookie>Cookie</code> header whose value is the <i><a href=#cookie-string>cookie-string</a></i> computed from the user's cookie store and the URL <var title="">url</var>; for these purposes this is <em>not</em> a "non-HTTP" API. <a href=#refsWSP>[WSP]</a> <a href=#refsCOOKIES>[COOKIES]</a></p> <p>When the user agent <i title="validate the server's response"><a href="#validate-the-server's-response">validates the server's response</a></i> during the "<i><a href=#establish-a-websocket-connection>establish a WebSocket connection</a></i>" algorithm, if the status code received from the server is not 101 (e.g. it is a redirect), the user agent must <i><a href=#fail-the-websocket-connection>fail the websocket connection</a></i>.</p> <p class=warning>Following HTTP procedures here could introduce serious security problems in a Web browser context. For example, consider a host with a WebSocket server at one path and an open HTTP redirector at another. Suddenly, any script that can be given a particular WebSocket URL can be tricked into communicating to (and potentially sharing secrets with) any host on the Internet, even if the script checks that the URL has the right hostname.</p> <!-- http://www.ietf.org/mail-archive/web/hybi/current/msg06951.html --> <p class=note>If the <i><a href=#establish-a-websocket-connection>establish a WebSocket connection</a></i> algorithm fails, it triggers the <i><a href=#fail-the-websocket-connection>fail the WebSocket connection</a></i> algorithm, which then invokes the <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> algorithm, which then establishes that <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, which fires the <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p> </li> </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global object</a> is either a <code><a href=#window>Window</a></code> object or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p> <hr><p>The <dfn id=dom-websocket-url title=dom-WebSocket-url><code>url</code></dfn> attribute must return the result of <a href=#resolve-a-url title="resolve a url">resolving</a> the <a href=#url>URL</a> that was passed to the constructor. (It doesn't matter what it is resolved relative to, since we already know it is an <a href=#absolute-url>absolute URL</a>.)</p> <p>The <dfn id=dom-websocket-readystate title=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 title=dom-WebSocket-CONNECTING><code>CONNECTING</code></dfn> (numeric value 0)</dt> <dd>The connection has not yet been established.</dd> <dt><dfn id=dom-websocket-open title=dom-WebSocket-OPEN><code>OPEN</code></dfn> (numeric value 1)</dt> <dd><i><a href=#the-websocket-connection-is-established>The WebSocket connection is established</a></i> and communication is possible.</dd> <dt><dfn id=dom-websocket-closing title=dom-WebSocket-CLOSING><code>CLOSING</code></dfn> (numeric value 2)</dt> <dd>The connection is going through the closing handshake.</dd> <dt><dfn id=dom-websocket-closed title=dom-WebSocket-CLOSED><code>CLOSED</code></dfn> (numeric value 3)</dt> <dd>The connection has been closed or could not be opened.</dd> </dl><p>When the object is created its <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> must be set to <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code> (0).</p> <p>The <dfn id=dom-websocket-extensions title=dom-WebSocket-extensions><code>extensions</code></dfn> attribute must initially return the empty string. After <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, its value might change, as defined below.</p> <p class=note>The <code title=dom-WebSocket-extensions><a href=#dom-websocket-extensions>extensions</a></code> attribute returns the extensions selected by the server, if any. (Currently this will only ever be the empty string.)</p> <p>The <dfn id=dom-websocket-protocol title=dom-WebSocket-protocol><code>protocol</code></dfn> attribute must initially return the empty string. After <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, its value might change, as defined below.</p> <p class=note>The <code title=dom-WebSocket-protocol><a href=#dom-websocket-protocol>protocol</a></code> attribute 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> <p>The <dfn id=dom-websocket-close title=dom-WebSocket-close><code>close()</code></dfn> method must run the following steps:</p> <ol><li><p>If the method's first argument is present but is not an integer equal to 1000 or in the range 3000 to 4999, throw an <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these steps.</li> <li><p>If the method's second argument has any unpaired surrogates, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps.</li> <li><p>If the method's second argument is present, then let <var title="">reason</var> be the result of encoding that argument as UTF-8. If <var title="">reason</var> is longer than 123 bytes, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps. <a href=#refsRFC3629>[RFC3629]</a></li> <li><p>Run the first matching steps from the following list:</p> <dl class=switch><dt>If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute is in the <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) or <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (3) state</dt> <dd> <p>Do nothing.</p> <p class=note>The connection is already closing or is already closed. If it has not already, a <code title=event-close>close</code> event will eventually fire <a href=#closeWebSocket>as described below</a>.</p> </dd> <dt>If the WebSocket connection is not yet <i title="the WebSocket connection is established"><a href=#the-websocket-connection-is-established>established</a></i> <a href=#refsWSP>[WSP]</a></dt> <dd> <p><i><a href=#fail-the-websocket-connection>Fail the WebSocket connection</a></i> and set the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). <a href=#refsWSP>[WSP]</a></p> <p class=note>The <i><a href=#fail-the-websocket-connection>fail the WebSocket connection</a></i> algorithm invokes the <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> algorithm, which then establishes that <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, which fires the <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p> </dd> <dt>If the WebSocket closing handshake has not yet been <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>started</a></i> <a href=#refsWSP>[WSP]</a></dt> <dd> <p><i><a href=#start-the-websocket-closing-handshake>Start the WebSocket closing handshake</a></i> and set the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). <a href=#refsWSP>[WSP]</a></p> <p>If the first argument is present, then the status code<!--CLOSE CODE--> to use in the WebSocket Close message must be the integer given by the first argument. <a href=#refsWSP>[WSP]</a></p> <p>If the second argument is also present, then <var title="">reason</var> must be provided in the Close message after the status code<!--CLOSE CODE-->. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></p> <p class=note>The <i><a href=#start-the-websocket-closing-handshake>start the WebSocket closing handshake</a></i> algorithm eventually invokes the <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> algorithm, which then establishes that <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, which fires the <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p> </dd> <dt>Otherwise</dt> <dd> <p>Set the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2).</p> <p class=note><i><a href=#the-websocket-closing-handshake-is-started>The WebSocket closing handshake is started</a></i>, and will eventually invoke the <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> algorithm, which will establish that <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, and thus the <code title=event-close>close</code> event will fire, <a href=#closeWebSocket>as described below</a>.</p> </dd> </dl></li> </ol><hr><p>The <dfn id=dom-websocket-bufferedamount title=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 title=dom-WebSocket-send><a href=#dom-websocket-send>send()</a></code> but that, as of the last time the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</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 asynchronously with script execution.) This does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware. If the connection is closed, this attribute's value will only increase with each call to the <code title=dom-WebSocket-send><a href=#dom-websocket-send>send()</a></code> method (the number does not reset to zero once the connection closes).</p> <div class=example> <p>In this simple example, the <code title=dom-WebSocket-bufferedAmount><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>var socket = new WebSocket('ws://game.example.com:12010/updates'); socket.onopen = function () { setInterval(function() { if (socket.bufferedAmount == 0) socket.send(getUpdateData()); }, 50); };</pre> <p>The <code title=dom-WebSocket-bufferedAmount><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><a href=#websocket>WebSocket</a></code> object is created, its <dfn id=dom-websocket-binarytype title=dom-WebSocket-binaryType><code>binaryType</code></dfn> IDL attribute must be set to the string "<code title="">blob</code>". On getting, it must return the last value it was set to. On setting, if the new value is either the string "<code title="">blob</code>" or the string "<code title="">arraybuffer</code>", then set the IDL attribute to this new value. Otherwise, throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p> <p class=note>This attribute allows authors to control how binary data is exposed to scripts. By setting the attribute to "<code title="">blob</code>", binary data is returned in <code><a href=#blob>Blob</a></code> form; by setting it to "<code title="">arraybuffer</code>", it is returned in <code><a href=#arraybuffer>ArrayBuffer</a></code> form. User agents can use this as a hint for how to handle incoming binary data: if the attribute is set to "<code title="">blob</code>", it is safe to spool it to disk, and if it is set to "<code title="">arraybuffer</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 as fired the event for it.</p> <p>The <dfn id=dom-websocket-send title=dom-WebSocket-send><code>send(<var title="">data</var>)</code></dfn> method transmits data using the connection. If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute is <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code>, it must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. Otherwise, the user agent must run the appropriate set of steps from the following list:</p> <dl><dt>If the argument is a string</dt> <dd> <p>If the <var title="">data</var> argument has any unpaired surrogates, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception. If <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and the string has no unpaired surrogates, and <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake has not yet started</a></i>, then the user agent must <i>send a WebSocket Message</i> comprised of <var title="">data</var> 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 <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</a>. Any invokation of this method with a string argument that does not throw an exception must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the number of bytes needed to express the argument as UTF-8. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></p> </dd> <dt>If the argument is a <code><a href=#blob>Blob</a></code> object</dt> <dd> <p>If <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake has not yet started</a></i>, then the user agent must <i>send a WebSocket Message</i> comprised of <var title="">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 <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</a>. The data to be sent is the raw data represented by the <code><a href=#blob>Blob</a></code> object. <!-- that sentence is meant to invoke "This interface represents immutable raw data." --> Any invokation of this method with a <code><a href=#blob>Blob</a></code> argument that does not throw an exception must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the size of the <code><a href=#blob>Blob</a></code> object's raw data, in bytes. <!-- that sentence is meant to invoke the same as Blob.size --> <a href=#refsWSP>[WSP]</a> <a href=#refsFILEAPI>[FILEAPI]</a></p> </dd> <dt>If the argument is an <code><a href=#arraybuffer>ArrayBuffer</a></code> object</dt> <dd> <p>If <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake has not yet started</a></i>, then the user agent must <i>send a WebSocket Message</i> comprised of <var title="">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 <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</a>. The data to be sent is the data stored in the buffer described by the <code><a href=#arraybuffer>ArrayBuffer</a></code> object. <!-- that sentence is meant to invoke "The ArrayBuffer type describes a buffer used to store data for the array buffer views." at the top of the Typed Array spec --> Any invokation of this method with an <code><a href=#arraybuffer>ArrayBuffer</a></code> argument that does not throw an exception must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the length of the <code><a href=#arraybuffer>ArrayBuffer</a></code> in bytes. <!-- that sentence is meant to invoke the same as ArrayBuffer.byteLength --> <a href=#refsWSP>[WSP]</a> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p> </dd> </dl><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#websocket>WebSocket</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-websocket-onopen title=handler-WebSocket-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code> <tr><td><dfn id=handler-websocket-onmessage title=handler-WebSocket-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> <tr><td><dfn id=handler-websocket-onerror title=handler-WebSocket-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code> <tr><td><dfn id=handler-websocket-onclose title=handler-WebSocket-onclose><code>onclose</code></dfn> <td> <code title=event-close>close</code> </table><h4 id=feedback-from-the-protocol><span class=secno>11.3.3 </span>Feedback from the protocol</h4> <p>When <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, the user agent must <a href=#queue-a-task>queue a task</a> to run these steps:</p> <ol><li><p>Change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1).</li> <li><p>Change the <code title=dom-WebSocket-extensions><a href=#dom-websocket-extensions>extensions</a></code> attribute's value to the <i><a href=#extensions-in-use>extensions in use</a></i>, if is not the null value. <a href=#refsWSP>[WSP]</a></li> <li><p>Change the <code title=dom-WebSocket-protocol><a href=#dom-websocket-protocol>protocol</a></code> attribute's value to the <i><a href=#subprotocol-in-use>subprotocol in use</a></i>, if is not the null value. <a href=#refsWSP>[WSP]</a></li> <li><p>Act as if the user agent had <a href=#receives-a-set-cookie-string title="receives a set-cookie-string">received a set-cookie-string</a> consisting of the <i><a href="#cookies-set-during-the-server's-opening-handshake">cookies set during the server's opening handshake</a></i>, for the URL <var title="">url</var> given to the <code title=dom-WebSocket><a href=#dom-websocket>WebSocket()</a></code> constructor. <a href=#refsCOOKIES>[COOKIES]</a> <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></li> <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-open>open</code> at the <code><a href=#websocket>WebSocket</a></code> object.</p> </ol><hr><p>When <i><a href=#a-websocket-message-has-been-received>a WebSocket message has been received</a></i> with type <var title="">type</var> and data <var title="">data</var>, the user agent must <a href=#queue-a-task>queue a task</a> to follow these steps: <a href=#refsWSP>[WSP]</a></p> <ol><li> <p>If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value is not <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1), then abort these steps.</p> </li> <li> <p>Let <var title="">event</var> be an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not cancelable, and has no default action. </p> </li> <li><p>Initialize <var title="">event</var>'s <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an origin">Unicode serialization</a> of the <a href=#origin>origin</a> of the <a href=#url>URL</a> that was passed to the <code><a href=#websocket>WebSocket</a></code> object's constructor.</li> <li> <p>If <var title="">type</var> indicates that the data is Text, then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to <var title="">data</var>. <p>If <var title="">type</var> indicates that the data is Binary, and <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> is set to "<code title="">blob</code>", then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to a new <code><a href=#blob>Blob</a></code> object that represents <var title="">data</var> as its raw data. <a href=#refsFILEAPI>[FILEAPI]</a></p> <p>If <var title="">type</var> indicates that the data is Binary, and <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> is set to "<code title="">arraybuffer</code>", then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to a new read-only <code><a href=#arraybuffer>ArrayBuffer</a></code> object whose contents are <var title="">data</var>. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p> </li> <li> <p>Dispatch <var title="">event</var> at the <code><a href=#websocket>WebSocket</a></code> object.</p> </li> </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 title="task queue">task queues</a> while they prepare the buffers if not. For example, if the <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> attribute was set to "<code title="">blob</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 title=concept-task>task</a> for this particular message the script switched <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> to "<code title="">arraybuffer</code>", the user agent would want to page the data back to RAM before running this <a href=#concept-task title=concept-task>task</a> so as to avoid stalling the main thread while it created the <code><a href=#arraybuffer>ArrayBuffer</a></code> object.</p> <hr><p>When <i><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</a></i>, the user agent must <a href=#queue-a-task>queue a task</a> to change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). (If the <code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called, the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value will already be set to <code title=dom-WebSocket-CLOSING><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><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, possibly <i title="">cleanly</i>, the user agent must <a href=#queue-a-task>queue a task</a> to run the following substeps:</p> <ol><li><p>Change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (3).</li> <li><p>If the user agent was required to <i><a href=#fail-the-websocket-connection>fail the websocket connection</a></i> or <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i> <dfn id=concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</dfn>, <a href=#fire-a-simple-event>fire a simple event</a> named <code title="">error</code> at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li> <li><p>Create an event that uses the <code><a href=#closeevent>CloseEvent</a></code> interface, with the event name <code title=event-close>close</code>, which does not bubble, is not cancelable, has no default action, whose <code title=dom-CloseEvent-wasClean><a href=#dom-closeevent-wasclean>wasClean</a></code> attribute is initialized to true if the connection closed <i title="">cleanly</i> and false otherwise, whose <code title=dom-CloseEvent-code><a href=#dom-closeevent-code>code</a></code> attribute is initialized to <i><a href=#the-websocket-connection-close-code>the WebSocket connection close code</a></i>, and whose <code title=dom-CloseEvent-reason><a href=#dom-closeevent-reason>reason</a></code> attribute is initialized to <i><a href=#the-websocket-connection-close-reason>the WebSocket connection close reason</a></i> <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>, and dispatch the event at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li> </ol><p>The <a href=#task-source>task source</a> for all <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a task">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>11.3.4 </span>Ping and Pong frames</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 send solicit pongs whenever appropriate for the server's needs.</p> <h4 id=parsing-websocket-urls><span class=secno>11.3.5 </span>Parsing WebSocket URLs</h4> <p>The steps to <dfn id="parse-a-websocket-url's-components">parse a WebSocket URL's components</dfn> from a string <var title="">url</var> are as follows. These steps return either a <var title="">host</var>, a <var title="">port</var>, a <var title="">resource name</var>, and a <var title="">secure</var> flag, or they fail.</p> <ol><li><p>If the <var title="">url</var> string is not an <a href=#absolute-url>absolute URL</a>, then fail this algorithm.</li> <li> <p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">url</var> string, with the <span>URL character encoding</span> set to UTF-8. <a href=#refsRFC3629>[RFC3629]</a></p> <!-- the URL character encoding is used to escape the query component --> <p class=note>It doesn't matter what it is resolved relative to, since we already know it is an <a href=#absolute-url>absolute URL</a> at this point.</p> </li> <li><p>If <var title="">url</var> does not have a <a href=#url-scheme title=url-scheme><scheme></a> component whose value, when <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is either "<code title="">ws</code>" or "<code title="">wss</code>", then fail this algorithm.</li> <li><p>If <var title="">url</var> has a <a href=#url-fragment title=url-fragment><fragment></a> component, then fail this algorithm.</li> <li><p>If the <a href=#url-scheme title=url-scheme><scheme></a> component of <var title="">url</var> is "<code title="">ws</code>", set <var title="">secure</var> to false; otherwise, the <a href=#url-scheme title=url-scheme><scheme></a> component is "<code title="">wss</code>", set <var title="">secure</var> to true.</li> <li><p>Let <var title="">host</var> be the value of the <a href=#url-host title=url-host><host></a> component of <var title="">url</var>, <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li> <!-- at this point this is Punycode-encoded already --> <li><p>If <var title="">url</var> has a <a href=#url-port title=url-port><port></a> component, then let <var title="">port</var> be that component's value; otherwise, there is no explicit <var title="">port</var>.</li> <li><p>If there is no explicit <var title="">port</var>, then: if <var title="">secure</var> is false, let <var title="">port</var> be 80, otherwise let <var title="">port</var> be 443.</li> <li><p>Let <var title="">resource name</var> be the value of the <a href=#url-path title=url-path><path></a> component (which might be empty) of <var title="">url</var>.</li> <!-- at this point this is UTF-8 encoded and %-escaped --> <li><p>If <var title="">resource name</var> is the empty string, set it to a single character U+002F SOLIDUS (/).</li> <li><p>If <var title="">url</var> has a <a href=#url-query title=url-query><query></a> component, then append a single U+003F QUESTION MARK character (?) to <var title="">resource name</var>, followed by the value of the <a href=#url-query title=url-query><query></a> component.</li> <!-- at this point this is UTF-8 encoded and %-escaped --> <li><p>Return <var title="">host</var>, <var title="">port</var>, <var title="">resource name</var>, and <var title="">secure</var>.</li> </ol><h4 id=event-definitions-3><span class=secno>11.3.6 </span>Event definitions</h4> <pre class=idl>[Constructor(DOMString type, optional <a href=#closeeventinit>CloseEventInit</a> eventInitDict)] interface <dfn id=closeevent>CloseEvent</dfn> : <a href=#event>Event</a> { readonly attribute boolean <a href=#dom-closeevent-wasclean title=dom-CloseEvent-wasClean>wasClean</a>; readonly attribute unsigned short <a href=#dom-closeevent-code title=dom-CloseEvent-code>code</a>; readonly attribute DOMString <span title=dom-WebSocket-reason>reason</span>; }; dictionary <dfn id=closeeventinit>CloseEventInit</dfn> : <a href=#eventinit>EventInit</a> { boolean wasClean; unsigned short code; DOMString reason; };</pre> <p>The <dfn id=dom-closeevent-wasclean title=dom-CloseEvent-wasClean><code>wasClean</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to false. It represents whether the connection closed cleanly or not.</p> <p>The <dfn id=dom-closeevent-code title=dom-CloseEvent-code><code>code</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to zero. It represents the WebSocket connection close code provided by the server.</p> <p>The <dfn id=dom-closeevent-reason title=dom-CloseEvent-reason><code>reason</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to empty string. It represents the WebSocket connection close reason provided by the server.</p> <h4 id=garbage-collection-2><span class=secno>11.3.7 </span>Garbage collection</h4> <p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value was set to <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code> (0) as of the last time the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a> must not be garbage collected if there are any event listeners registered for <code title=event-open>open</code> events, <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code> events, or <code title=event-close>close</code> events.</p> <p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value was set to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1) as of the last time the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a> must not be garbage collected if there are any event listeners registered for <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code>, or <code title=event-close>close</code> events.</p> <p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value was set to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) as of the last time the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a> must not be garbage collected if there are any event listeners registered for <code title=event-error>error</code> or <code title=event-close>close</code> events.</p> <p>A <code><a href=#websocket>WebSocket</a></code> object with <i title="the WebSocket connection is established"><a href=#the-websocket-connection-is-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><a href=#websocket>WebSocket</a></code> object is garbage collected while its connection is still open, the user agent must <i><a href=#start-the-websocket-closing-handshake>start the WebSocket closing handshake</a></i>, with no status code<!--CLOSE 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><a href=#websocket>WebSocket</a></code> object (this happens when a <code><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 title="the WebSocket connection is established"><a href=#the-websocket-connection-is-established>established</a></i> <a href=#refsWSP>[WSP]</a></dt> <dd> <p><i><a href=#fail-the-websocket-connection>Fail the WebSocket connection</a></i>. <a href=#refsWSP>[WSP]</a></p> </dd> <dt>If the WebSocket closing handshake has not yet been <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>started</a></i> <a href=#refsWSP>[WSP]</a></dt> <dd> <p><i><a href=#start-the-websocket-closing-handshake>Start the WebSocket closing handshake</a></i>, with the status code<!--CLOSE CODE--> to use in the WebSocket Close message being 1001. <a href=#refsWSP>[WSP]</a></p> </dd> <dt>Otherwise</dt> <dd> <p>Do nothing.</p> </dd> </dl></div><!--data-component--> <!--POSTMSG--> <div data-component="Web Messaging (editor: Ian Hickson)"> <h3 id=web-messaging><span class=secno>11.4 </span><dfn id=crossDocumentMessages>Cross-document messaging</dfn></h3> <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> <div class=impl> <p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> in <a href=#web-messaging>cross-document messaging</a> is the <dfn id=posted-message-task-source>posted message task source</dfn>.</p> </div> <h4 id=introduction-14><span class=secno>11.4.1 </span>Introduction</h4> <p><i>This section is non-normative.</i></p> <div class=example> <p>For example, if document A contains an <code><a href=#the-iframe-element>iframe</a></code> element that contains document B, and script in document A calls <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage()</a></code> on the <code><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><a href=#window>Window</a></code> of document A. The script in document A might look like:</p> <pre>var o = document.getElementsByTagName('iframe')[0]; o.contentWindow.postMessage('Hello world', 'http://b.example.org/');</pre> <p>To register an event handler for incoming events, the script would use <code title="">addEventListener()</code> (or similar mechanisms). For example, the script in document B might look like:</p> <pre>window.addEventListener('message', receiver, false); function receiver(e) { if (e.origin == 'http://example.com') { if (e.data == 'Hello world') { e.source.postMessage('Hello', e.origin); } else { alert(e.data); } } }</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>11.4.2 </span>Security</h4> <div class=impl> <h5 id=authors><span class=secno>11.4.2.1 </span>Authors</h5> </div> <p class=warning id=security-4>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 title=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 title=dom-MessageEvent-origin><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 title=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 title="">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 multplied 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> <div class=impl> <h5 id=user-agents><span class=secno>11.4.2.2 </span>User agents</h5> <p>The integrity of this API is based on the inability for scripts of one <a href=#origin>origin</a> to post arbitrary events (using <code title="">dispatchEvent()</code> or otherwise) to objects in other origins (those that are not the <a href=#same-origin title="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=#origin title=origin>origins</a>, to protect naïve sites from denial-of-service attacks.</p> </div> <h4 id=posting-messages><span class=secno>11.4.3 </span>Posting messages</h4> <dl class=domintro><dt><var title="">window</var> . <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage</a></code>(<var title="">message</var>, <var title="">targetOrigin</var> [, <var title="">transfer</var> ])</dt> <dd> <p>Posts a message to the given window. Objects listed in <var title="">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 title="">*</code>". To restrict the message to same-origin targets only, without needing to explicitly state the origin, set the target origin to "<code title="">/</code>".</p> <p>Throws a <code><a href=#datacloneerror>DataCloneError</a></code> if <var title="">transfer</var> array contains duplicate objects or if <var title="">message</var> could not be cloned.</p> </dd> </dl><p class=note>When posting a message to a <code><a href=#window>Window</a></code> of a <a href=#browsing-context>browsing context</a> that has just been navigated to a new <code><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>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><a href=#window>Window</a></code> of newly created child <code><a href=#the-iframe-element>iframe</a></code>, authors are advised to have the child <code><a href=#document>Document</a></code> post a message to their parent announcing their readiness to receive messages, and for the parent to wait for this message before beginning posting messages.</p> <div class=impl> <p>When a script invokes the <dfn id=dom-window-postmessage title=dom-window-postMessage><code>postMessage(<var title="">message</var>, <var title="">targetOrigin</var>, <var title="">transfer</var>)</code></dfn> method (with two or three arguments) on a <code><a href=#window>Window</a></code> object, the user agent must follow these steps:</p> <ol><!-- a lot of this is similar or identical to port.postMessage --><li> <p>If the value of the <var title="">targetOrigin</var> argument is neither a single U+002A ASTERISK character (*), a single U+002F SOLIDUS character (/), nor an <a href=#absolute-url>absolute URL</a>, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort the overall set of steps.</p> </li> <li> <p>Let <var title="">new ports</var> be an empty array.</p> </li> <li> <p>Let <var title="">transfer map</var> be an empty association list of <code><a href=#transferable>Transferable</a></code> objects to placeholder objects.</p> </li> <li> <p>If the method was invoked with a third argument <var title="">transfer</var>, run these substeps:</p> <ol><li> <p>If any object is listed in <var title="">transfer</var> more than once, or any of the <code><a href=#transferable>Transferable</a></code> objects listed in <var title="">transfer</var> are marked as <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neutered</a>, then throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort these steps.</p> </li> <li> <p>For each object <var title="">x</var> in <var title="">transfer</var> in turn, add a mapping from <var title="">x</var> to a new unique placeholder object created for <var title="">x</var> to <var title="">transfer map</var>, and if <var title="">x</var> is a <code><a href=#messageport>MessagePort</a></code> object, also append the placeholder object to the <var title="">new ports</var> array.</p> </li> </ol></li> <li> <p>Let <var title="">message clone</var> be the result of obtaining a <a href=#structured-clone>structured clone</a> of the <var title="">message</var> argument, with <var title="">transfer map</var> as the <i>transfer map</i>. If this throws an exception, then throw that exception and abort these steps.</p> </li> <li> <p>If the method was invoked with a third argument <var title="">transfer</var>, run these substeps:</p> <ol><li> <p>Let <var title="">new owner</var> be the <code><a href=#window>Window</a></code> object on which the method was invoked.</p> </li> <li> <p>For each object <var title="">x</var> in <var title="">transfer</var> in turn, obtain a new object <var title="">y</var> by <a href=#transfer-a-transferable-object title="transfer a Transferable object">transferring</a> the object <var title="">x</var> to <var title="">new owner</var>, and replace the placeholder object that was created for the object <var title="">x</var> by the new object <var title="">y</var> wherever the placeholder exists (i.e. in <var title="">message clone</var> and in <var title="">new ports</var>).</p> </li> </ol></li> <li> <p>Make <var title="">new ports</var> into a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array.</p> </li> <li> <p>Return from the <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage()</a></code> method, but asynchronously continue running these steps.</p> </li> <li> <p>If the <var title="">targetOrigin</var> argument is a single literal U+002F SOLIDUS character (/), and the <code><a href=#document>Document</a></code> of the <code><a href=#window>Window</a></code> object on which the method was invoked does not have the <a href=#same-origin>same origin</a> as the <a href=#entry-script>entry script</a>'s <a href="#script's-document" title="script's document">document</a>, then abort these steps silently.</p> <p>Otherwise, if the <var title="">targetOrigin</var> argument is an <a href=#absolute-url>absolute URL</a>, and the <code><a href=#document>Document</a></code> of the <code><a href=#window>Window</a></code> object on which the method was invoked does not have the <a href=#same-origin>same origin</a> as <var title="">targetOrigin</var>, then abort these steps silently.</p> <p>Otherwise, the <var title="">targetOrigin</var> argument is a single literal U+002A ASTERISK character (*), and no origin check is made.</p> </li> <li> <p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not cancelable, and has no default action. The <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute must be initialized to the value of <var title="">message clone</var>, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute must be initialized to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an origin">Unicode serialization</a> of the <a href=#origin>origin</a> of the script that invoked the method, the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be initialized to the <a href="#script's-global-object">script's global object</a>'s <code><a href=#windowproxy>WindowProxy</a></code> object, and the <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute must be initialized to the <var title="">new ports</var> array. </p> <!-- invariant: the global object is always a Window if the script can see this method --> </li> <li> <p><a href=#queue-a-task>Queue a task</a> to dispatch the event created in the previous step at the <code><a href=#window>Window</a></code> object on which the method was invoked. The <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#posted-message-task-source>posted message task source</a>.</p> </li> </ol></div> <h3 id=channel-messaging><span class=secno>11.5 </span><dfn>Channel messaging</dfn></h3> <h4 id=introduction-15><span class=secno>11.5.1 </span>Introduction</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 title="browsing context">browsing contexts</a>) to communicate directly, authors can use <a href=#channel-messaging>channel messaging</a>.</p> <p>Communication channels in this mechanisms 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 asynchronous, and delivered as DOM events.</p> <p>To create a connection (two "entangled" ports), the <code title="">MessageChannel()</code> constructor is called:</p> <pre>var channel = new MessageChannel();</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 title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage()</a></code>:</p> <pre>otherWindow.postMessage('hello', 'http://example.com', [channel.port2]);</pre> <p>To send messages, the <code title=dom-MessagePort-postMessage><a href=#dom-messageport-postmessage>postMessage()</a></code> method on the port is used:</p> <pre>channel.port1.postMessage('hello');</pre> <p>To receive messages, one listens to <code title=event-message><a href=#event-message>message</a></code> events:</p> <pre>channel.port1.onmessage = handleMessage; function handleMessage(event) { // message is in event.data // ... }</pre> <h5 id=ports-as-the-basis-of-an-object-capability-model-on-the-web><span class=secno>11.5.1.1 </span>Ports as the basis of an object-capability model on the Web</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 title="">provider</var> as the only mechanism by which another origin <var title="">consumer</var> can effect change in or obtain information from <var title="">provider</var>.</p> <p>For example, consider a situation in which a social Web site embeds in one <code><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><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><a href=#the-iframe-element>iframe</a></code> cannot access anything inside the first <code><a href=#the-iframe-element>iframe</a></code>; together they can only:</p> <ul class=brief><li><a href=#navigate>Navigate</a> the <code><a href=#the-iframe-element>iframe</a></code> to a new <a href=#url>URL</a>, such as the same <a href=#url>URL</a> but with a different fragment identifier, causing the <code><a href=#window>Window</a></code> in the <code><a href=#the-iframe-element>iframe</a></code> to receive a <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code> event.</li> <li>Resize the <code><a href=#the-iframe-element>iframe</a></code>, causing the <code><a href=#window>Window</a></code> in the <code><a href=#the-iframe-element>iframe</a></code> to receive a <code title=event-resize>resize</code> event.</li> <!-- anything else? --> <li>Send a <code title=event-message><a href=#event-message>message</a></code> event to the <code><a href=#window>Window</a></code> in the <code><a href=#the-iframe-element>iframe</a></code> using the <code title=dom-window-postMessage><a href=#dom-window-postmessage>window.postMessage()</a></code> API.</li> </ul><p>The contacts provider can use these methods, most particularly the third one, to provide an API that can be accessed by other origins to manipulate the user's address book. For example, it could respond to a message "<code title="">add-contact Guillaume Tell <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><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><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>11.5.1.2 </span>Ports as the basis of abstracting out service implementations</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>XMLHttpRequest</code> objects in the service's <code><a href=#the-iframe-element>iframe</a></code>, an evolution of the service might instead want to use a <a href=#sharedworker title=SharedWorker>shared worker</a> with a single <code><a href=#websocket>WebSocket</a></code> connection.</p> <p>If the initial design used <code><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>XMLHttpRequest</code>s-in-each-<code><a href=#the-iframe-element>iframe</a></code> model to the shared-<code><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>11.5.2 </span>Message channels</h4> <pre class=idl>[<a href=#dom-messagechannel title=dom-MessageChannel>Constructor</a>] interface <dfn id=messagechannel>MessageChannel</dfn> { readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-channel-port1 title=dom-channel-port1>port1</a>; readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-channel-port2 title=dom-channel-port2>port2</a>; };</pre> <dl class=domintro><dt><var title="">channel</var> = new <code title=dom-MessageChannel><a href=#dom-messagechannel>MessageChannel</a></code>()</dt> <dd> <p>Returns a new <code><a href=#messagechannel>MessageChannel</a></code> object with two new <code><a href=#messageport>MessagePort</a></code> objects.</p> </dd> <dt><var title="">channel</var> . <code title=dom-MessageChannel-port1>port1</code></dt> <dd> <p>Returns the first <code><a href=#messageport>MessagePort</a></code> object.</p> </dd> <dt><var title="">channel</var> . <code title=dom-MessageChannel-port2>port2</code></dt> <dd> <p>Returns the second <code><a href=#messageport>MessagePort</a></code> object.</p> </dd> </dl><div class=impl> <p>When the <dfn id=dom-messagechannel title=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>Create a new <code>MessagePort</code> object</a> owned by the <a href="#script's-global-object">script's global object</a>, and let <var title="">port1</var> be that object.</li> <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by the <a href="#script's-global-object">script's global object</a>, and let <var title="">port2</var> be that object.</li> <li><p><a href=#entangle>Entangle</a> the <var title="">port1</var> and <var title="">port2</var> objects.</li> <li><p>Instantiate a new <code><a href=#messagechannel>MessageChannel</a></code> object, and let <var title="">channel</var> be that object.</li> <li><p>Let the <code title=dom-channel-port1><a href=#dom-channel-port1>port1</a></code> attribute of the <var title="">channel</var> object be <var title="">port1</var>.</p> <li><p>Let the <code title=dom-channel-port2><a href=#dom-channel-port2>port2</a></code> attribute of the <var title="">channel</var> object be <var title="">port2</var>.</p> <li><p>Return <var title="">channel</var>.</li> </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global object</a> is either a <code><a href=#window>Window</a></code> object or an object implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p> <p>The <dfn id=dom-channel-port1 title=dom-channel-port1><code>port1</code></dfn> and <dfn id=dom-channel-port2 title=dom-channel-port2><code>port2</code></dfn> attributes must return the values they were assigned when the <code><a href=#messagechannel>MessageChannel</a></code> object was created.</p> </div> <h4 id=message-ports><span class=secno>11.5.3 </span>Message ports</h4> <p>Each channel has two message ports. Data sent through one port is received by the other port, and vice versa.</p> <pre class=idl>interface <dfn id=messageport>MessagePort</dfn> : <a href=#eventtarget>EventTarget</a> { <!-- v2-onclose readonly attribute boolean <span title="dom-MessagePort-active">active</span>; --> void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(any message, optional sequence<<a href=#transferable>Transferable</a>> transfer);<!-- <span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(any message);--> void <a href=#dom-messageport-start title=dom-MessagePort-start>start</a>(); void <a href=#dom-messageport-close title=dom-MessagePort-close>close</a>(); // event handlers [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-messageport-onmessage title=handler-MessagePort-onmessage>onmessage</a>; }; <a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre> <dl class=domintro><!-- v2-onclose <dt><var title="">port</var> . <code title="dom-MessagePort-active">active</code></dt> <dd> <p>Returns true if the port is still active; otherwise, returns false.</p> </dd> --><dt><var title="">port</var> . <code title=dom-MessagePort-postMessage><a href=#dom-messageport-postmessage>postMessage</a></code>(<var title="">message</var> [, <var title="">transfer</var>] )</dt> <dd> <p>Posts a message through the channel. Objects listed in <var title="">transfer</var> are transferred, not just cloned, meaning that they are no longer usable on the sending side.</p> <p>Throws a <code><a href=#datacloneerror>DataCloneError</a></code> if <var title="">transfer</var> array contains duplicate objects or the source or target ports, or if <var title="">message</var> could not be cloned.</p> </dd> <dt><var title="">port</var> . <code title=dom-MessagePort-start><a href=#dom-messageport-start>start</a></code>()</dt> <dd> <p>Begins dispatching messages received on the port.</p> </dd> <dt><var title="">port</var> . <code title=dom-MessagePort-close><a href=#dom-messageport-close>close</a></code>()</dt> <dd> <p>Disconnects the port, so that it is no longer active.</p> </dd> </dl><div class=impl> <p>Each <code><a href=#messageport>MessagePort</a></code> object can be entangled with another (a symmetric relationship). Each <code><a href=#messageport>MessagePort</a></code> object also has a <a href=#task-source>task source</a> called the <dfn id=port-message-queue>port message queue</dfn>, initial empty. A <a href=#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).</p> <p>When the user agent is to <dfn id=create-a-new-messageport-object>create a new <code>MessagePort</code> object</dfn> owned by a <a href="#script's-global-object">script's global object</a> object <var title="">owner</var>, it must instantiate a new <code><a href=#messageport>MessagePort</a></code> object, and let its owner be <var title="">owner</var>.</p> <p>When the user agent is to <dfn id=entangle>entangle</dfn> two <code><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><a href=#messagechannel>MessageChannel</a></code> object, then that <code><a href=#messagechannel>MessageChannel</a></code> object no longer represents an actual channel: the two ports in that object are no longer entangled.</p> </li> <li><p>Associate the two ports to be entangled, so that they form the two parts of a new channel. (There is no <code><a href=#messagechannel>MessageChannel</a></code> object that represents this channel.)</li> </ol><p>When the user agent is to <dfn id=clone-a-port>clone a port</dfn> <var title="">original port</var>, with the clone being owned by <var title="">owner</var>, it must run the following steps, which return a new <code><a href=#messageport>MessagePort</a></code> object. These steps must be run atomically.</p> <ol><li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> owned by <var title="">owner</var>, and let <var title="">new port</var> be that object.</li> <li><p>Move all the events in the <a href=#port-message-queue>port message queue</a> of <var title="">original port</var> to the <a href=#port-message-queue>port message queue</a> of <var title="">new port</var>, if any, leaving the <var title="">new port</var>'s <a href=#port-message-queue>port message queue</a> in its initial disabled state.</li> <li> <p>If the <var title="">original port</var> is entangled with another port, then run these substeps:</p> <ol><li><p>Let the <var title="">remote port</var> be the port with which the <var title="">original port</var> is entangled.</li> <li><p><a href=#entangle>Entangle</a> the <var title="">remote port</var> and <var title="">new port</var> objects. The <var title="">original port</var> object will be disentangled by this process.</li> </ol></li> <li><p>Return <var title="">new port</var>. It is the clone.</li> </ol><p id=transferMessagePort>To <a href=#transfer-a-transferable-object title="transfer a Transferable object">transfer</a> a <code><a href=#messageport>MessagePort</a></code> object <var title="">old</var> to a new owner <var title="">owner</var>, a user agent must <a href=#clone-a-port title="clone a port">clone</a> the <var title="">old</var> object with the clone being owned by <var title="">owner</var>, thus obtaining <var title="">new</var>, must <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neuter</a> the <var title="">old</var> port, and must finally return <var title="">new</var>.</p> <hr><!-- v2-onclose <p>The <dfn title="dom-MessagePort-active"><code>active</code></dfn> attribute must return true if the port is entangled, and false otherwise.</p> <hr> --><p>The <dfn id=dom-messageport-postmessage title=dom-MessagePort-postMessage><code>postMessage()</code></dfn> method, when called on a port <var title="">source port</var>, must cause the user agent to run the following steps:</p> <ol><!-- a lot of this is similar or identical to window.postMessage --><li><p>Let <var title="">target port</var> be the port with which <var title="">source port</var> is entangled, if any.</li> <li> <p>Let <var title="">new ports</var> be an empty array.</p> </li> <li> <p>Let <var title="">transfer map</var> be an empty association list of <code><a href=#transferable>Transferable</a></code> objects to placeholder objects.</p> </li> <li> <p>If the method was invoked with a second argument <var title="">transfer</var>, run these substeps:</p> <ol><li> <p>If any object is listed in <var title="">transfer</var> more than once, or any of the <code><a href=#transferable>Transferable</a></code> objects listed in <var title="">transfer</var> are marked as <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neutered</a>, then throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort these steps.</p> </li> <li> <p>If any of the objects in <var title="">transfer</var> are either the <var title="">source port</var> or the <var title="">target port</var> (if any), then throw a <code><a href=#datacloneerror>DataCloneError</a></code> exception and abort these steps.</p> </li> <li> <p>For each object <var title="">x</var> in <var title="">transfer</var> in turn, add a mapping from <var title="">x</var> to a new unique placeholder object created for <var title="">x</var> to <var title="">transfer map</var>, and if <var title="">x</var> is a <code><a href=#messageport>MessagePort</a></code> object, also append the placeholder object to the <var title="">new ports</var> array.</p> </li> </ol></li> <li> <p>Let <var title="">message clone</var> be the result of obtaining a <a href=#structured-clone>structured clone</a> of the <var title="">message</var> argument, with <var title="">transfer map</var> as the <i>transfer map</i>. If this throws an exception, then throw that exception and abort these steps.</p> </li> <li> <p>If the method was invoked with a second argument <var title="">transfer</var>, run these substeps:</p> <ol><li> <p>Let <var title="">new owner</var> be the owner of <var title="">target port</var>, if there is a <var title="">target port</var>, or else some arbitrary owner. (This <var title="">new owner</var> is used when transfering objects below. If there is no <var title="">target port</var>, the <code><a href=#transferable>Transferable</a></code> objects given in the second argument, if any, are still <a href=#transfer-a-transferable-object title="transfer a Transferable object">transfered</a>, but since they are then discarded, it doesn't matter where they are transfered to.)</p> </li> <li> <p>For each object <var title="">x</var> in <var title="">transfer</var> in turn, obtain a new object <var title="">y</var> by <a href=#transfer-a-transferable-object title="transfer a Transferable object">transferring</a> the object <var title="">x</var> to <var title="">new owner</var>, and replace the placeholder object that was created for the object <var title="">x</var> by the new object <var title="">y</var> wherever the placeholder exists (i.e. in <var title="">message clone</var> and in <var title="">new ports</var>).</p> </li> </ol></li> <li> <p>Make <var title="">new ports</var> into a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array.</p> </li> <li><p>If there is no <var title="">target port</var> (i.e. if <var title="">source port</var> is not entangled), then abort these steps.</li> <!-- we don't throw an exception if there is no target port because this can happen at a moment's notice. we don't return false because if the port is _about_ to be closed, the message might not be listened for anyway. we don't do this before the steps above because otherwise you can tell the difference (in whether the ports have become useless, or in when the structured clone algorithm runs scripts --> <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not cancelable, and has no default action. </li> <li><p>Let the <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute of the event be initialized to the value of <var title="">message clone</var>.</li> <li><p>Let the <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute of the event be initialized to the <var title="">new ports</var> array.</li> <li><p>Add the event to the <a href=#port-message-queue>port message queue</a> of <var title="">target port</var>.</li> </ol><!-- <hr> <p>The <dfn title="dom-MessagePort-startConversation"><code>startConversation(<var title="">message</var>)</code></dfn> method is a convenience method that simplifies create a new <code>MessageChannel</code> and invoking <code title="dom-MessagePort-postMessage">postMessage()</code> with one of the new ports. When invoked on a port <var title="">source port</var>, it must run the following steps:</p> <ol> <li><p>Let <var title="">message</var> be the method's first argument.</p></li> <li><p><span>Create a new <code>MessagePort</code> object</span> owned by the <span>script's global object</span>, and let <var title="">port1</var> be that object.</p></li> <li><p>If the <var title="">source port</var> is not entangled with another port, then return <var title="">port1</var> and abort these steps.</p></li> <!- - we don't throw an exception because this can happen moment's notice. we don't return null because then we'd end up with null derefs. better to just let the likely next postMessage call fall on the floor. - -> <li><p>Let <var title="">target port</var> be the port with which <var title="">source port</var> is entangled.</p></li> <li><p><span>Create a new <code>MessagePort</code> object</span> owned by the owner of the <var title="">target port</var>, and let <var title="">port2</var> be that object.</p></li> <li><p><span>Entangle</span> the <var title="">port1</var> and <var title="">port2</var> objects.</p></li> <li><p>Create an event that uses the <code>MessageEvent</code> interface, with the name <code title="event-message">message</code>, which does not bubble, is not cancelable, and has no default action. </p></li> <li><p>Let the <code title="dom-MessageEvent-data">data</code> attribute of the event be initialized to the value of <var title="">message</var>, the method's first argument.</p></li> <li><p>Let the <code title="dom-MessageEvent-ports">ports</code> attribute of the event be initialized to a <span title="dfn-read-only-array">read only</span> array containing only <var title="">port2</var>.</p></li> <li><p>Return <var title="">port1</var> from the method, but continue with these steps.</p></li> <li><p>Add the event to the <span>port message queue</span> of <var title="">target port</var>.</p></li> </ol> --><hr><p>The <dfn id=dom-messageport-start title=dom-MessagePort-start><code>start()</code></dfn> method must enable its port's <a href=#port-message-queue>port message queue</a>, if it is not already enabled.</p> <p>When a port's <a href=#port-message-queue>port message queue</a> is enabled, the <a href=#event-loop>event loop</a> must use it as one of its <a href=#task-source title="task source">task sources</a>.</p> <p class=note>If the <code><a href=#document>Document</a></code> of the port's event listeners' <a href="#script's-global-object" title="script's global object">global object</a> is not <a href=#fully-active>fully active</a>, then the messages are lost.</p> <!-- because of the jump-to-entry-point algorithm first step --> <hr><p>The <dfn id=dom-messageport-close title=dom-MessagePort-close><code>close()</code></dfn> method, when called on a port <var title="">local port</var> that is entangled with another port, must cause the user agents to disentangle the two ports. If the method is called on a port that is not entangled, then the method must do nothing.</p> <hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as IDL attributes, by all objects implementing the <code><a href=#messageport>MessagePort</a></code> interface:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-messageport-onmessage title=handler-MessagePort-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code> </table><p>The first time a <code><a href=#messageport>MessagePort</a></code> object's <code title=handler-MessagePort-onmessage><a href=#handler-messageport-onmessage>onmessage</a></code> IDL attribute is set, the port's <a href=#port-message-queue>port message queue</a> must be enabled, as if the <code title=dom-MessagePort-start><a href=#dom-messageport-start>start()</a></code> method had been called.</p> </div> <h5 id=ports-and-garbage-collection><span class=secno>11.5.3.1 </span>Ports and garbage collection</h5> <div class=impl> <p>When a <code><a href=#messageport>MessagePort</a></code> object <var title="">o</var> is entangled, user agents must either act as if <var title="">o</var>'s entangled <code><a href=#messageport>MessagePort</a></code> object has a strong reference to <var title="">o</var>, or as if <var title="">o</var>'s owner has a strong reference to <var title="">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><a href=#messageport>MessagePort</a></code> object must not be garbage collected while there exists a message in a <a href=#task-queue>task queue</a> that is to be dispatched on that <code><a href=#messageport>MessagePort</a></code> object, or while the <code><a href=#messageport>MessagePort</a></code> object's <a href=#port-message-queue>port message queue</a> is open and there exists a <code title=event-message><a href=#event-message>message</a></code> event in that queue.</p> <!-- we might not need to explicitly say the first part if DOM Events is fixed to say that events on a task queue prevent GC --> <!-- ports in the ports attribute of a MessageEvent that isn't dispatched yet are safe because the MessageEvent is safe --> </div> <p class=note>Authors are strongly encouraged to explicitly close <code><a href=#messageport>MessagePort</a></code> objects to disentangle them, so that their resources can be recollected. Creating many <code><a href=#messageport>MessagePort</a></code> objects and discarding them without closing them can lead to high memory usage.</p> </div><!--data-component--> <!--POSTMSG--> <div data-component="Web Storage (editor: Ian Hickson)"> <h2 id=webstorage><span class=secno>12 </span>Web storage</h2> <h3 id=introduction-16><span class=secno>12.1 </span>Introduction</h3> <p><i>This section is non-normative.</i></p> <p>This specification introduces two related mechanisms, similar to HTTP session cookies, for storing structured data 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 title=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> <!-- we're not using xrefs here because this is just an intro --> <div class=example> <p>For example, a page could have a checkbox that the user ticks to indicate that he wants insurance:</p> <pre><label> <input type="checkbox" onchange="sessionStorage.insurance = checked ? 'true' : ''"> I want insurance on this trip. </label></pre> <p>A later page could then check, from script, whether the user had checked the checkbox or not:</p> <pre>if (sessionStorage.insurance) { ... }</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> <!-- sessionStorage.flightDeparture = 'OSL'; sessionStorage.flightArrival = 'NYC'; for (var i in forms[0].elements) sessionStorage["data_" + i.name] = i.value; // if we add storage of non-strings if (!sessionStorage[documents]) sessionStorage[documents] = {}; sessionStorage[documents][filename] = <document/>; --> <p>The second storage mechanism is designed for storage that spans multiple windows, and lasts beyond the current session. In particular, Web applications may 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 title=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><p> You have viewed this page <span id="count">an untold number of</span> time(s). </p> <script> if (!localStorage.pageLoadCount) localStorage.pageLoadCount = 0; localStorage.pageLoadCount = parseInt(localStorage.pageLoadCount) + 1; document.getElementById('count').textContent = localStorage.pageLoadCount; </script></pre> </div> <p>Each site has its own separate storage area.</p> <h3 id=storage><span class=secno>12.2 </span>The API</h3> <h4 id=the-storage-interface><span class=secno>12.2.1 </span>The <code><a href=#storage-0>Storage</a></code> interface</h4> <pre class=idl>interface <dfn id=storage-0>Storage</dfn> { readonly attribute unsigned long <a href=#dom-storage-length title=dom-Storage-length>length</a>; DOMString? <a href=#dom-storage-key title=dom-Storage-key>key</a>(unsigned long index); getter DOMString <a href=#dom-storage-getitem title=dom-Storage-getItem>getItem</a>(DOMString key); setter creator void <a href=#dom-storage-setitem title=dom-Storage-setItem>setItem</a>(DOMString key, DOMString value); deleter void <a href=#dom-storage-removeitem title=dom-Storage-removeItem>removeItem</a>(DOMString key); void <a href=#dom-storage-clear title=dom-Storage-clear>clear</a>(); };</pre> <!-- v2 ideas: a getInfo() method that returns an object that tells you: - when the key was added - when the key was last modified - which page was the last to modify the key [-Mihai Sucan] support non-string values --> <p>Each <code><a href=#storage-0>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><a href=#storage-0>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 title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> and <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes. Multiple separate objects implementing the <code><a href=#storage-0>Storage</a></code> interface can all be associated with the same list of key/value pairs simultaneously.</p> <p>The <dfn id=dom-storage-length title=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 title=dom-Storage-key><code>key(<var title="">n</var>)</code></dfn> method must return the name of the <var title="">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 title=dom-Storage-setItem>adding</a> or <a href=#dom-storage-removeitem title=dom-Storage-removeItem>removing</a> a key may change the order of the keys, but merely changing the value of an existing key must not.) <!--The order of keys may differ between instances of the <code>Storage</code> interface accessing the same list. [removed for now for clarity, but if people ask, put it back. this is part of the spec.]--> If <var title="">n</var> is <!--less than zero or [can't, unsigned]--> greater than or equal to the number of key/value pairs in the object, then this method must return null.</p> <p>The <a href=#supported-property-names>supported property names</a> on a <code><a href=#storage-0>Storage</a></code> object are the keys of each key/value pair currently present in the list associated with the object.</p> <p>The <dfn id=dom-storage-getitem title=dom-Storage-getItem><code>getItem(<var title="">key</var>)</code></dfn> method must return the current value associated with the given <var title="">key</var>. If the given <var title="">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 title=dom-Storage-setItem><code>setItem(<var title="">key</var>, <var title="">value</var>)</code></dfn> method must first check if a key/value pair with the given <var title="">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 title="">key</var> and with its value set to <var title="">value</var>.</p> <p>If the given <var title="">key</var> <em>does</em> exist in the list, then it must have its value updated to <var title="">value</var>.</p> <p>If it couldn't set the new value, the method must throw an <code><a href=#quotaexceedederror>QuotaExceededError</a></code> exception. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)</p> <p>The <dfn id=dom-storage-removeitem title=dom-Storage-removeItem><code>removeItem(<var title="">key</var>)</code></dfn> method must cause the key/value pair with the given <var title="">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 title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code> and <code title=dom-Storage-removeItem><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 title=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 title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are invoked, events are fired on other <code><a href=#document>Document</a></code> objects that can access the newly stored or removed data, as defined in the sections on the <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> and <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes.</p> <!-- not normative, see the sections below for the normative statement --> <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>12.2.2 </span>The <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute</h4> <pre class=idl>[NoInterfaceObject] interface <dfn id=windowsessionstorage>WindowSessionStorage</dfn> { readonly attribute <a href=#storage-0>Storage</a> <a href=#dom-sessionstorage title=dom-sessionStorage>sessionStorage</a>; }; <a href=#window>Window</a> implements <a href=#windowsessionstorage>WindowSessionStorage</a>;</pre> <p>The <dfn id=dom-sessionstorage title=dom-sessionStorage><code>sessionStorage</code></dfn> attribute represents the set of storage areas specific to the current <a href=#top-level-browsing-context>top-level browsing context</a>.</p> <p>Each <a href=#top-level-browsing-context>top-level browsing context</a> has a unique set of session storage areas, one for each <a href=#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 may support resuming sessions after a restart.</p> <p>When a new <code><a href=#document>Document</a></code> is created in a <a href=#browsing-context>browsing context</a> which has a <a href=#top-level-browsing-context>top-level browsing context</a>, the user agent must check to see if that <a href=#top-level-browsing-context>top-level browsing context</a> has a session storage area for that document's <a href=#origin>origin</a>. If it does, then that is the <code><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=#origin>origin</a> must be created, and then <em>that</em> is the <code><a href=#document>Document</a></code>'s assigned session storage area. A <code><a href=#document>Document</a></code>'s assigned storage area does not change during the lifetime of a <code><a href=#document>Document</a></code>, even in the case of a <a href=#nested-browsing-context>nested browsing context</a> (e.g. in an <code><a href=#the-iframe-element>iframe</a></code>) being moved to another <a href=#parent-browsing-context>parent browsing context</a>.</p> <p>The <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute must return a <code><a href=#storage-0>Storage</a></code> object associated with the <code><a href=#document>Document</a></code>'s assigned session storage area, if any, or null if there isn't one. Each <code><a href=#document>Document</a></code> object must have a separate object for its <code><a href=#window>Window</a></code>'s <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute.</p> <p>When a new <a href=#top-level-browsing-context>top-level browsing context</a> is created by cloning an existing <a href=#browsing-context>browsing context</a>, the new browsing context must start with the same session storage areas as the original, but the two sets must from that point on be considered separate, not affecting each other in any way.</p> <p>When a new <a href=#top-level-browsing-context>top-level browsing context</a> is created by a <a href=#concept-script title=concept-script>script</a> in an existing <a href=#browsing-context>browsing context</a>, or by the user following a link in an existing browsing context, or in some other way related to a specific <code><a href=#document>Document</a></code>, then the session storage area of the <a href=#origin>origin</a> of that <code><a href=#document>Document</a></code> must be copied into the new browsing context when it is created. From that point on, however, the two session storage areas must be considered separate, not affecting each other in any way.</p> <p id=sessionStorageEvent>When the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a <code><a href=#storage-0>Storage</a></code> object <var title="">x</var> that is associated with a session storage area, if the methods did something, then in every <code><a href=#document>Document</a></code> object whose <code><a href=#window>Window</a></code> object's <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute's <code><a href=#storage-0>Storage</a></code> object is associated with the same storage area, other than <var title="">x</var>, a <code title=event-storage><a href=#event-storage>storage</a></code> event must be fired, as <a href=#event-storage title=event-storage>described below</a>.</p> <h4 id=the-localstorage-attribute><span class=secno>12.2.3 </span>The <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute</h4> <pre class=idl>[NoInterfaceObject] interface <dfn id=windowlocalstorage>WindowLocalStorage</dfn> { readonly attribute <a href=#storage-0>Storage</a> <a href=#dom-localstorage title=dom-localStorage>localStorage</a>; }; <a href=#window>Window</a> implements <a href=#windowlocalstorage>WindowLocalStorage</a>;</pre> <p>The <dfn id=dom-localstorage title=dom-localStorage><code>localStorage</code></dfn> object provides a <code><a href=#storage-0>Storage</a></code> object for an <a href=#origin>origin</a>.</p> <p>User agents must have a set of local storage areas, one for each <a href=#origin>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 title=dom-localStorage><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-initialization-steps><code>Storage</code> object initialization steps</dfn>:</p> <!-- these steps are named because marcos uses them from another spec --> <ol><li><p>The user agent may throw a <code><a href=#securityerror>SecurityError</a></code> exception instead of returning a <code><a href=#storage-0>Storage</a></code> object if the request violates a policy decision (e.g. if the user agent is configured to not allow the page to persist data).</li> <li><p>If the <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a> is not a scheme/host/port tuple, then throw a <code><a href=#securityerror>SecurityError</a></code> exception and abort these steps.</li> <li><p>Check to see if the user agent has allocated a local storage area for the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of the <code><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=#origin>origin</a>.</li> <li><p>Return the <code><a href=#storage-0>Storage</a></code> object associated with that origin's local storage area. Each <code><a href=#document>Document</a></code> object must have a separate object for its <code><a href=#window>Window</a></code>'s <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute.</p> </ol><p id=localStorageEvent>When the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a <code><a href=#storage-0>Storage</a></code> object <var title="">x</var> that is associated with a local storage area, if the methods did something, then in every <code><a href=#document>Document</a></code> object whose <code><a href=#window>Window</a></code> object's <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute's <code><a href=#storage-0>Storage</a></code> object is associated with the same storage area, other than <var title="">x</var>, a <code title=event-storage><a href=#event-storage>storage</a></code> event must be fired, as <a href=#event-storage title=event-storage>described below</a>.</p> <p id=localStorageMutex>Whenever the properties of a <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute's <code><a href=#storage-0>Storage</a></code> object are to be examined, returned, set, or deleted, whether as part of a direct property access, when checking for the presence of a property, during property enumeration, when determining the number of properties present, or as part of the execution of any of the methods or attributes defined on the <code><a href=#storage-0>Storage</a></code> interface, the user agent must first <a href=#obtain-the-storage-mutex>obtain the storage mutex</a>.</p> <h5 id=security-localStorage><span class=secno>12.2.3.1 </span>Security</h5> <p>User agents must throw a <code><a href=#securityerror>SecurityError</a></code> exception whenever any of the members of a <code><a href=#storage-0>Storage</a></code> object originally returned by the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute are accessed by scripts whose <a href=#effective-script-origin>effective script origin</a> is not the <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of the <code><a href=#window>Window</a></code> object on which the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute was accessed.</p> <p class=note>This means <code><a href=#storage-0>Storage</a></code> objects are neutered when the <code title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute is used.</p> <h4 id=the-storage-event><span class=secno>12.2.4 </span>The <code title=event-storage><a href=#event-storage>storage</a></code> event</h4> <p>The <dfn id=event-storage title=event-storage><code>storage</code></dfn> event is fired when a storage area changes, as described in the previous two sections (<a href=#sessionStorageEvent>for session storage</a>, <a href=#localStorageEvent>for local storage</a>).</p> <p>When this happens, the user agent must <a href=#queue-a-task>queue a task</a> to fire an event with the name <code><a href=#storage-0>storage</a></code>, which does not bubble and is not cancelable, and which uses the <code><a href=#storageevent>StorageEvent</a></code> interface, at each <code><a href=#window>Window</a></code> object whose <code><a href=#document>Document</a></code> object has a <code><a href=#storage-0>Storage</a></code> object that is affected.</p> <p class=note>This includes <code><a href=#document>Document</a></code> objects that are not <a href=#fully-active>fully active</a>, but events fired on those are ignored by the <a href=#event-loop>event loop</a> until the <code><a href=#document>Document</a></code> becomes <a href=#fully-active>fully active</a> again.</p> <p>The <a href=#task-source>task source</a> for this task is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p>If the event is being fired due to an invocation of the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code> or <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code> methods, the event must have its <code title=dom-StorageEvent-key><a href=#dom-storageevent-key>key</a></code> attribute initialized to the name of the key in question, its <code title=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 title=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 title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> method, the event must have its <code title=dom-StorageEvent-key><a href=#dom-storageevent-key>key</a></code>, <code title=dom-StorageEvent-oldValue><a href=#dom-storageevent-oldvalue>oldValue</a></code>, and <code title=dom-StorageEvent-newValue><a href=#dom-storageevent-newvalue>newValue</a></code> attributes initialized to null.</p> <p>In addition, the event must have its <code title=dom-StorageEvent-url><a href=#dom-storageevent-url>url</a></code> attribute initialized to <a href="#the-document's-address" title="the document's address">the address of the document</a> whose <code><a href=#storage-0>Storage</a></code> object was affected; and its <code title=dom-StorageEvent-storageArea><a href=#dom-storageevent-storagearea>storageArea</a></code> attribute initialized to the <code><a href=#storage-0>Storage</a></code> object from the <code><a href=#window>Window</a></code> object of the target <code><a href=#document>Document</a></code> that represents the same kind of <code><a href=#storage-0>Storage</a></code> area as was affected (i.e. session or local).</p> <h5 id=event-definition-0><span class=secno>12.2.4.1 </span>Event definition</h5> <pre class=idl>[Constructor(DOMString type, optional <a href=#storageeventinit>StorageEventInit</a> eventInitDict)] interface <dfn id=storageevent>StorageEvent</dfn> : <a href=#event>Event</a> { readonly attribute DOMString <a href=#dom-storageevent-key title=dom-StorageEvent-key>key</a>; readonly attribute DOMString? <a href=#dom-storageevent-oldvalue title=dom-StorageEvent-oldValue>oldValue</a>; readonly attribute DOMString? <a href=#dom-storageevent-newvalue title=dom-StorageEvent-newValue>newValue</a>; readonly attribute DOMString <a href=#dom-storageevent-url title=dom-StorageEvent-url>url</a>; readonly attribute <a href=#storage-0>Storage</a>? <a href=#dom-storageevent-storagearea title=dom-StorageEvent-storageArea>storageArea</a>; }; dictionary <dfn id=storageeventinit>StorageEventInit</dfn> : <a href=#eventinit>EventInit</a> { DOMString key; DOMString? oldValue; DOMString? newValue; DOMString url; <a href=#storage-0>Storage</a>? storageArea; };</pre> <p>The <dfn id=dom-storageevent-key title=dom-StorageEvent-key><code>key</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the key being changed.</p> <p>The <dfn id=dom-storageevent-oldvalue title=dom-StorageEvent-oldValue><code>oldValue</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the old value of the key being changed.</p> <p>The <dfn id=dom-storageevent-newvalue title=dom-StorageEvent-newValue><code>newValue</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the new value of the key being changed.</p> <p>The <dfn id=dom-storageevent-url title=dom-StorageEvent-url><code>url</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to the empty string. It represents the address of the document whose key changed.</p> <p>The <dfn id=dom-storageevent-storagearea title=dom-StorageEvent-storageArea><code>storageArea</code></dfn> attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the <code><a href=#storage-0>Storage</a></code> object that was affected.</p> <h4 id=threads><span class=secno>12.2.5 </span>Threads</h4> <p>Because of <a href=#localStorageMutex>the use</a> of the <a href=#storage-mutex>storage mutex</a>, multiple browsing contexts will be able to access the local storage areas simultaneously in such a manner that scripts cannot detect any concurrent script execution.</p> <p>Thus, the <code title=dom-Storage-length><a href=#dom-storage-length>length</a></code> attribute of a <code><a href=#storage-0>Storage</a></code> object, and the value of the various properties of that object, cannot change while a script is executing, other than in a way that is predictable by the script itself.</p> <h3 id=disk-space-0><span class=secno>12.3 </span>Disk space</h3> <p>User agents should limit the total amount of space allowed for storage areas.</p> <p>User agents should guard against sites storing data under the origins 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>If the storage area space limit is reached during a <code title="dom-Storage-setItem">setItem()</code> call, the method will throw an exception.</p>--> <p>A mostly arbitrary limit of five megabytes per <a href=#origin>origin</a> is recommended. Implementation feedback is welcome and will be used to update this suggestion in the future.</p> <h3 id=privacy><span class=secno>12.4 </span>Privacy</h3> <h4 id=user-tracking><span class=secno>12.4.1 </span>User tracking</h4> <p>A third-party advertiser (or any entity capable of getting content distributed to multiple sites) could use a unique identifier stored in its local storage area to track a user across multiple sessions, building a profile of the user's interests to allow for highly targeted advertising. In conjunction with a site that is aware of the user's real identity (for example an e-commerce site that requires authenticated credentials), this could allow oppressive groups to target individuals with greater accuracy than in a world with purely anonymous Web usage.</p> <p>There are a number of techniques that can be used to mitigate the risk of user tracking:</p> <dl><dt>Blocking third-party storage</dt> <dd> <p>User agents may restrict access to the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> objects to scripts originating at the domain of the top-level document of the <a href=#browsing-context>browsing context</a>, for instance denying access to the API for pages from other domains running in <code><a href=#the-iframe-element>iframe</a></code>s.</p> </dd> <dt>Expiring stored data</dt> <dd> <p>User agents may, if so 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 title="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 he authenticates 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> <!--v2 consider adding an explicit way for sites to state when data should expire, as in localStorage.expireData(365); --> </dd> <dt>Treating persistent storage as cookies</dt> <dd> <p>If users attempt to protect their privacy by clearing cookies without also clearing data stored in the local storage area, sites can defeat those attempts by using the two features as redundant backup for each other. User agents should present the interfaces for clearing these in a way that helps users to understand this possibility and enables them to delete data in all persistent storage features simultaneously. <a href=#refsCOOKIES>[COOKIES]</a></p> </dd> <dt>Site-specific white-listing of access to local storage areas</dt> <dd> <p>User agents may allow sites to access session storage areas in an unrestricted manner, but require the user to authorize access to local storage areas.</p> </dd> <dt>Origin-tracking of stored data</dt> <dd> <p>User agents may record the <a href=#origin title=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 blacklist ("delete this data and prevent this domain from ever storing data again"), the user can restrict the use of persistent storage to sites that he trusts.</p> </dd> <dt>Shared blacklists</dt> <dd> <p>User agents may allow users to share their persistent storage domain blacklists.</p> <p>This would allow communities to act together to protect their privacy.</p> </dd> </dl><p>While these suggestions prevent trivial use of this API for user tracking, they do not block it altogether. Within a single domain, a site can continue to track the user during a session, and can then pass all this information to the third party along with any identifying information (names, credit card numbers, addresses) obtained by the site. If a third party cooperates with multiple sites to obtain such information, a profile can still be created.</p> <p>However, user tracking is to some extent possible even with no cooperation from the user agent whatsoever, for instance by using session identifiers in URLs, a technique already commonly used for innocuous purposes but easily repurposed for user tracking (even retroactively). This information can then be shared with other sites, using using visitors' IP addresses and other user-specific data (e.g. user-agent headers and configuration settings) to combine separate sessions into coherent user profiles.</p> <h4 id=sensitivity-of-data><span class=secno>12.4.2 </span>Sensitivity of data</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>12.5 </span>Security</h3> <h4 id=dns-spoofing-attacks><span class=secno>12.5.1 </span>DNS spoofing attacks</h4> <p>Because of the potential for DNS spoofing attacks, one cannot guarantee that a host claiming to be in a certain domain really is from that domain. To mitigate this, pages can use TLS. Pages using TLS can be sure that only the user, software working on behalf of the user, and other pages using TLS that have certificates identifying them as being from the same domain, can access their storage areas.</p> <h4 id=cross-directory-attacks><span class=secno>12.5.2 </span>Cross-directory attacks</h4> <p>Different authors sharing one host name, for example users hosting content on <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 recommended to avoid using these features, as it would be trivial for other authors to read the data and overwrite it.</p> <p class=note>Even if a path-restriction feature was made available, the usual DOM scripting security model would make it trivial to bypass this protection and access the data from any path.</p> <h4 id=implementation-risks><span class=secno>12.5.3 </span>Implementation risks</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=#origin>origin</a> model described in this specification is important for user security.</p> </div><!--data-component--> <h2 id=syntax><span class=secno>13 </span><dfn>The HTML syntax</dfn></h2> <p class=note>This section only describes the rules for resources labeled with an <a href=#html-mime-type>HTML MIME type</a>. Rules for XML resources are discussed in the section below entitled "<a href=#the-xhtml-syntax>The XHTML syntax</a>".</p> <h3 id=writing><span class=secno>13.1 </span>Writing HTML documents</h3> <div class=impl> <p><i>This section only applies to documents, authoring tools, and markup generators. In particular, it does not apply to conformance checkers; conformance checkers must use the requirements given in the next section ("parsing HTML documents").</i></p> </div> <p>Documents must consist of the following parts, in the given order:</p> <ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li> <li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> <li>A <a href=#syntax-doctype title=syntax-doctype>DOCTYPE</a>. <li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> <li>The root element, in the form of an <code><a href=#the-html-element>html</a></code> <a href=#syntax-elements title=syntax-elements>element</a>.</li> <li>Any number of <a href=#syntax-comments title=syntax-comments>comments</a> and <a href=#space-character title="space character">space characters</a>.</li> </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 title="character encoding declaration">character encoding declarations</a> are to be serialized, as discussed in the section on that topic.</p> <div class=note> <p>Space characters before the root <code><a href=#the-html-element>html</a></code> element, and space characters at the start of the <code><a href=#the-html-element>html</a></code> element and before the <code><a href=#the-head-element>head</a></code> element, will be dropped when the document is parsed; space characters <em>after</em> the root <code><a href=#the-html-element>html</a></code> element will be parsed as if they were at the end of the <code><a href=#the-body-element>body</a></code> element. Thus, space characters around the root element do not round-trip.</p> <p>It is suggested that newlines be inserted after the DOCTYPE, after any comments that are before the root element, after the <code><a href=#the-html-element>html</a></code> element's start tag (if it is not <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>), and after any comments that are inside the <code><a href=#the-html-element>html</a></code> element but before the <code><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 characters in the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL LETTER Z). For convenience, in this section this is just referred to as "case-insensitive".</p> <h4 id=the-doctype><span class=secno>13.1.1 </span>The DOCTYPE</h4> <p>A <dfn id=syntax-doctype title=syntax-doctype>DOCTYPE</dfn> is a <!-- mostly useless but nonetheless --> 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 href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=""><!DOCTYPE</code>".</li> <li>One or more <a href=#space-character title="space character">space characters</a>.</li> <li>A string that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">html</code>".</li> <li>Optionally, a <a href=#doctype-legacy-string>DOCTYPE legacy string</a> or an <a href=#obsolete-permitted-doctype-string>obsolete permitted DOCTYPE string</a> (defined below).</li> <li>Zero or more <a href=#space-character title="space character">space characters</a>.</li> <li>A U+003E GREATER-THAN SIGN character (>).</li> </ol><p class=note>In other words, <code><!DOCTYPE html></code>, case-insensitively.</p> <hr><p>For the purposes of HTML generators that cannot output HTML markup with the short DOCTYPE "<code title=""><!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 href=#space-character title="space character">space characters</a>.</li> <li>A string that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">SYSTEM</code>".</li> <li>One or more <a href=#space-character title="space character">space characters</a>.</li> <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li> <li>The literal string "<code><a href=#about:legacy-compat>about:legacy-compat</a></code>".</li> <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>quote mark</i>).</li> </ol><p class=note>In other words, <code><!DOCTYPE html SYSTEM "about:legacy-compat"></code> or <code><!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>DOCTYPE legacy string</a> should not be used unless the document is generated from a system that cannot output the shorter string.</p> <hr><!-- see the parser section before changing this bit --><p>To help authors transition from HTML4 and XHTML1, an <dfn id=obsolete-permitted-doctype-string>obsolete permitted DOCTYPE string</dfn> can be inserted into the DOCTYPE (in the position defined above). This string must consist of:</p> <ol class=brief><li>One or more <a href=#space-character title="space character">space characters</a>.</li> <li>A string that is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">PUBLIC</code>".</li> <li>One or more <a href=#space-character title="space character">space characters</a>.</li> <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>first quote mark</i>).</li> <li>The string from one of the cells in the first column of the table below. The row to which this cell belongs is the <i>selected row</i>.</li> <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>first quote mark</i>).</li> <li>If the cell in the second column of the <i>selected row</i> is not blank, one or more <a href=#space-character title="space character">space characters</a>.</li> <li>If the cell in the second column of the <i>selected row</i> is not blank, a U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>third quote mark</i>).</li> <li>If the cell in the second column of the <i>selected row</i> is not blank, the string from the cell in the second column of the <i>selected row</i>.</li> <li>If the cell in the second column of the <i>selected row</i> is not blank, a matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>third quote mark</i>).</li> </ol><table><caption> Allowed values for public and system identifiers in an <a href=#obsolete-permitted-doctype-string>obsolete permitted DOCTYPE string</a>. </caption> <thead><tr><th> Public identifier <th> System identifier <tbody><tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code> <td> <tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code> <td> <code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code> <tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code> <td> <tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code> <td> <code title="">http://www.w3.org/TR/html4/strict.dtd</code> <tr><td> <code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code> <td> <code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code> <tr><td> <code title="">-//W3C//DTD XHTML 1.1//EN</code> <td> <code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code> </table><p>A <a href=#syntax-doctype title=syntax-doctype>DOCTYPE</a> containing an <a href=#obsolete-permitted-doctype-string>obsolete permitted DOCTYPE string</a> is an <dfn id=obsolete-permitted-doctype>obsolete permitted DOCTYPE</dfn>. Authors should not use <a href=#obsolete-permitted-doctype title="obsolete permitted DOCTYPE">obsolete permitted DOCTYPEs</a>, as they are unnecessarily long.</p> <h4 id=elements-0><span class=secno>13.1.2 </span>Elements</h4> <p>There are five different kinds of <dfn id=syntax-elements title=syntax-elements>elements</dfn>: <a href=#void-elements>void elements</a>, <a href=#raw-text-elements>raw text elements</a>, <a href=#rcdata-elements>RCDATA elements</a>, <a href=#foreign-elements>foreign elements</a>, and <a href=#normal-elements>normal elements</a>.</p> <dl><dt><dfn id=void-elements>Void elements</dfn></dt> <dd><code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#the-br-element>br</a></code>, <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code>, <code><a href=#the-wbr-element>wbr</a></code></dd> <!-- see also other places that say VOIDLIST --> <dt><dfn id=raw-text-elements>Raw text elements</dfn></dt> <dd><code><a href=#the-script-element>script</a></code>, <code><a href=#the-style-element>style</a></code></dd> <!-- iframe and noscript don't count as raw text for syntax purposes --> <dt><dfn id=rcdata-elements>RCDATA elements</dfn></dt> <dd><code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-title-element>title</a></code></dd> <dt><dfn id=foreign-elements>Foreign elements</dfn></dt> <dd>Elements from the <a href=#mathml-namespace>MathML namespace</a> and the <a href=#svg-namespace>SVG namespace</a>.</dd> <dt><dfn id=normal-elements>Normal elements</dfn></dt> <dd>All other allowed <a href=#html-elements>HTML elements</a> are normal elements.</dd> </dl><p><dfn id=syntax-tags title=syntax-tags>Tags</dfn> are used to delimit the start and end of elements in the markup. <a href=#raw-text-elements title="raw text elements">Raw text</a>, <a href=#rcdata-elements title="RCDATA elements">RCDATA</a>, and <a href=#normal-elements title="normal elements">normal</a> elements have a <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> to indicate where they begin, and an <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> to indicate where they end. The start and end tags of certain <a href=#normal-elements>normal elements</a> can be <a href=#syntax-tag-omission title=syntax-tag-omission>omitted</a>, as described later. Those that cannot be omitted must not be omitted. <a href=#void-elements>Void elements</a> only have a start tag; end tags must not be specified for <a href=#void-elements>void elements</a>. <a href=#foreign-elements>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 contents of the element must be placed between just after the start tag (which <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied, in certain cases</a>) and just before the end tag (which again, <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied in certain cases</a>). The exact allowed contents of each individual element depend on the content model 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>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><a href=#raw-text-elements>Raw text elements</a> can have <a href=#syntax-text title=syntax-text>text</a>, though it has <a href=#cdata-rcdata-restrictions>restrictions</a> described below.</p> <p><a href=#rcdata-elements>RCDATA elements</a> can have <a href=#syntax-text title=syntax-text>text</a> and <a href=#syntax-charref title=syntax-charref>character references</a>, but the text must not contain an <a href=#syntax-ambiguous-ampersand title=syntax-ambiguous-ampersand>ambiguous ampersand</a>. There are also <a href=#cdata-rcdata-restrictions>further restrictions</a> described below.</p> <p><a href=#foreign-elements>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>Foreign elements</a> whose start tag is <em>not</em> marked as self-closing can have <a href=#syntax-text title=syntax-text>text</a>, <a href=#syntax-charref title=syntax-charref>character references</a>, <a href=#syntax-cdata title=syntax-cdata>CDATA sections</a>, other <a href=#syntax-elements title=syntax-elements>elements</a>, and <a href=#syntax-comments title=syntax-comments>comments</a>, but the text must not contain the character U+003C LESS-THAN SIGN (<) or an <a href=#syntax-ambiguous-ampersand title=syntax-ambiguous-ampersand>ambiguous ampersand</a>.</p> <div class=note> <p>The HTML syntax does not support namespace declarations, even in <a href=#foreign-elements>foreign elements</a>.</p> <p>For instance, consider the following HTML fragment:</p> <pre><p> <svg> <metadata> <!-- this is invalid --> <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/> </metadata> </svg> </p></pre> <p>The innermost element, <code title="">cdr:license</code>, is actually in the SVG namespace, as the "<code title="">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 title="">cdr:license</code>" in the SVG namespace.</p> </div> <p><a href=#normal-elements>Normal elements</a> can have <a href=#syntax-text title=syntax-text>text</a>, <a href=#syntax-charref title=syntax-charref>character references</a>, other <a href=#syntax-elements title=syntax-elements>elements</a>, and <a href=#syntax-comments title=syntax-comments>comments</a>, but the text must not contain the character U+003C LESS-THAN SIGN (<) or an <a href=#syntax-ambiguous-ampersand title=syntax-ambiguous-ampersand>ambiguous ampersand</a>. Some <a href=#normal-elements>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 title=syntax-tag-name>tag name</dfn>, giving the element's name. HTML elements all have names that only use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z. In the HTML syntax, tag names, even those for <a href=#foreign-elements>foreign elements</a>, may be written with any mix of lower- and uppercase letters that, when converted to all-lowercase, matches the element's tag name; tag names are case-insensitive.</p> <h5 id=start-tags><span class=secno>13.1.2.1 </span>Start tags</h5> <p><dfn id=syntax-start-tag title=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 (<).</li> <li>The next few characters of a start tag must be the element's <a href=#syntax-tag-name title=syntax-tag-name>tag name</a>.</li> <li>If there are to be any attributes in the next step, there must first be one or more <a href=#space-character title="space character">space characters</a>.</li> <li>Then, the start tag may have a number of attributes, the <a href=#syntax-attributes title=syntax-attributes>syntax for which</a> is described below. Attributes must be separated from each other by one or more <a href=#space-character title="space character">space characters</a>.</li> <li>After the attributes, or after the <a href=#syntax-tag-name title=syntax-tag-name>tag name</a> if there are no attributes, there may be one or more <a href=#space-character title="space character">space characters</a>. (Some attributes are required to be followed by a space. See the <a href=#syntax-attributes title=syntax-attributes>attributes section</a> below.)</li> <li>Then, if the element is one of the <a href=#void-elements>void elements</a>, or if the element is a <a href=#foreign-elements title="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>void elements</a>, but on <a href=#foreign-elements>foreign elements</a> it marks the start tag as self-closing.</li> <li>Finally, start tags must be closed by a U+003E GREATER-THAN SIGN character (>).</li> </ol><h5 id=end-tags><span class=secno>13.1.2.2 </span>End tags</h5> <p><dfn id=syntax-end-tag title=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 (<).</li> <li>The second character of an end tag must be a U+002F SOLIDUS character (/).</li> <li>The next few characters of an end tag must be the element's <a href=#syntax-tag-name title=syntax-tag-name>tag name</a>.</li> <li>After the tag name, there may be one or more <a href=#space-character title="space character">space characters</a>.</li> <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN character (>).</li> </ol><h5 id=attributes-0><span class=secno>13.1.2.3 </span>Attributes</h5> <p><dfn id=syntax-attributes title=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 title=syntax-attribute-name>Attribute names</dfn> must consist of one or more characters other than the <a href=#space-character title="space character">space characters</a>, U+0000 NULL, U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters, the control characters, and any characters that are not defined by Unicode. In the HTML syntax, attribute names, even those for <a href=#foreign-elements>foreign elements</a>, may be written with any mix of lower- and uppercase letters that are an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the attribute's name.</p> <p><dfn id=syntax-attribute-value title=syntax-attribute-value>Attribute values</dfn> are a mixture of <a href=#syntax-text title=syntax-text>text</a> and <a href=#syntax-charref title=syntax-charref>character references</a>, except with the additional restriction that the text cannot contain an <a href=#syntax-ambiguous-ampersand title=syntax-ambiguous-ampersand>ambiguous ampersand</a>.</p> <p>Attributes can be specified in four different ways:</p> <dl><dt>Empty attribute syntax</dt> <dd> <p>Just the <a href=#syntax-attribute-name title=syntax-attribute-name>attribute name</a>. The value is implicitly the empty string.</p> <div class=example> <p>In the following example, the <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> attribute is given with the empty attribute syntax:</p> <pre><input <em>disabled</em>></pre> </div> <p>If an attribute using the empty attribute syntax is to be followed by another attribute, then there must be a <a href=#space-character>space character</a> separating the two.</p> </dd> <dt id=unquoted>Unquoted attribute value syntax</dt> <dd> <p>The <a href=#syntax-attribute-name title=syntax-attribute-name>attribute name</a>, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by a single U+003D EQUALS SIGN character, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by the <a href=#syntax-attribute-value title=syntax-attribute-value>attribute value</a>, which, in addition to the requirements given above for attribute values, must not contain any literal <a href=#space-character title="space character">space characters</a>, any U+0022 QUOTATION MARK characters ("), U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN characters (=), U+003C LESS-THAN SIGN characters (<), U+003E GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT characters (`), and must not be the empty string.</p> <!-- The ` character is in this list on a temporary basis, waiting for IE to fix its parsing bug whereby it treats ` as an attribute value delimiter. Otherwise, escaping software that tries to be clever and not use quotes when it doesn't need to could be tricked by an attacker. Posit a site that allows the user to input text that is used verbatim in two attributes, such that the user can set the first attribute's value to: ` ...and the second to: ` onload='...payload...' end=x ...with the assumption that the site is going to not quote the first one, and quote the second one with double quotes: <body title=` class="` onload='...payload...' end=x"> In IE, this is treated as: <body title=' class="' onload='...payload...' end='x"'> --> <div class=example> <p>In the following example, the <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute is given with the unquoted attribute value syntax:</p> <pre><input <em>value=yes</em>></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 title=syntax-start-tag>start tag</a> syntax above, then there must be a <a href=#space-character>space character</a> separating the two.</p> </dd> <dt>Single-quoted attribute value syntax</dt> <dd> <p>The <a href=#syntax-attribute-name title=syntax-attribute-name>attribute name</a>, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by a single U+003D EQUALS SIGN character, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by a single U+0027 APOSTROPHE character ('), followed by the <a href=#syntax-attribute-value title=syntax-attribute-value>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 title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is given with the single-quoted attribute value syntax:</p> <pre><input <em>type='checkbox'</em>></pre> </div> <p>If an attribute using the single-quoted attribute syntax is to be followed by another attribute, then there must be a <a href=#space-character>space character</a> separating the two.</p> </dd> <dt>Double-quoted attribute value syntax</dt> <dd> <p>The <a href=#syntax-attribute-name title=syntax-attribute-name>attribute name</a>, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by a single U+003D EQUALS SIGN character, followed by zero or more <a href=#space-character title="space character">space characters</a>, followed by a single U+0022 QUOTATION MARK character ("), followed by the <a href=#syntax-attribute-value title=syntax-attribute-value>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 title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute is given with the double-quoted attribute value syntax:</p> <pre><input <em>name="be evil"</em>></pre> </div> <p>If an attribute using the double-quoted attribute syntax is to be followed by another attribute, then there must be a <a href=#space-character>space character</a> separating the two.</p> </dd> </dl><p>There must never be two or more attributes on the same start tag whose names are an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for each other.</p> <hr><p>When a <a href=#foreign-elements title="foreign elements">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 title="">actuate</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:actuate</code> <tr><td> <code title="">arcrole</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:arcrole</code> <tr><td> <code title="">href</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:href</code> <tr><td> <code title="">role</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:role</code> <tr><td> <code title="">show</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:show</code> <tr><td> <code title="">title</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:title</code> <tr><td> <code title="">type</code> <td> <a href=#xlink-namespace>XLink namespace</a> <td> <code title="">xlink:type</code> <tr><td> <code title="">base</code> <td> <a href=#xml-namespace>XML namespace</a> <!-- attr-xml-base --> <td> <code title="">xml:base</code> <tr><td> <code title="">lang</code> <td> <a href=#xml-namespace>XML namespace</a> <td> <code title="">xml:lang</code> <tr><td> <code title="">space</code> <td> <a href=#xml-namespace>XML namespace</a> <td> <code title="">xml:space</code> <tr><td> <code title="">xmlns</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a> <td> <code title="">xmlns</code> <tr><td> <code title="">xlink</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a> <td> <code title="">xmlns:xlink</code> </table><p>No other namespaced attribute can be expressed in <a href=#syntax>the HTML syntax</a>.</p> <h5 id=optional-tags><span class=secno>13.1.2.4 </span>Optional tags</h5> <p>Certain tags can be <dfn id=syntax-tag-omission title=syntax-tag-omission>omitted</dfn>.</p> <p class=note>Omitting an element's <a href=#syntax-start-tag title=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><a href=#the-html-element>html</a></code> element, even if the string <code title=""><html></code> doesn't appear anywhere in the markup.</p> <!-- <html> --> <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the first thing inside the <code><a href=#the-html-element>html</a></code> element is not a <a href=#syntax-comments title=syntax-comments>comment</a>.</p> <!-- </html> --> <p>An <code><a href=#the-html-element>html</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-html-element>html</a></code> element is not immediately followed by a <a href=#syntax-comments title=syntax-comments>comment</a>.</p> <!-- <head> --> <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the element is empty, or if the first thing inside the <code><a href=#the-head-element>head</a></code> element is an element.</p> <!-- </head> --> <p>A <code><a href=#the-head-element>head</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-head-element>head</a></code> element is not immediately followed by a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>.</p> <!-- <body> --> <p>A <code><a href=#the-body-element>body</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the element is empty, or if the first thing inside the <code><a href=#the-body-element>body</a></code> element is not a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>, except if the first thing inside the <code><a href=#the-body-element>body</a></code> element is a <code><a href=#the-script-element>script</a></code> or <code><a href=#the-style-element>style</a></code> element. <!-- Note that even if the </head> end tag is present, the parser makes <style> and <script> elements between </head> and <body> end up in the <head> instead of implying the <body> --></p> <!-- </body> --> <p>A <code><a href=#the-body-element>body</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-body-element>body</a></code> element is not immediately followed by a <a href=#syntax-comments title=syntax-comments>comment</a>.</p> <!-- </li> --> <p>An <code><a href=#the-li-element>li</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-li-element>li</a></code> element is immediately followed by another <code><a href=#the-li-element>li</a></code> element or if there is no more content in the parent element.</p> <!-- </dt> --> <p>A <code><a href=#the-dt-element>dt</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-dt-element>dt</a></code> element is immediately followed by another <code><a href=#the-dt-element>dt</a></code> element or a <code><a href=#the-dd-element>dd</a></code> element.</p> <!-- </dd> --> <p>A <code><a href=#the-dd-element>dd</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-dd-element>dd</a></code> element is immediately followed by another <code><a href=#the-dd-element>dd</a></code> element or a <code><a href=#the-dt-element>dt</a></code> element, or if there is no more content in the parent element.</p> <!-- </p> --> <p>A <code><a href=#the-p-element>p</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-p-element>p</a></code> element is immediately followed by an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-article-element>article</a></code>, <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#dir>dir</a></code>, <code><a href=#the-div-element>div</a></code>, <code><a href=#the-dl-element>dl</a></code>, <code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-header-element>header</a></code>, <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-menu-element>menu</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#the-section-element>section</a></code>, <code><a href=#the-table-element>table</a></code>, or <code><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 not an <code><a href=#the-a-element>a</a></code> element.</p> <!-- </rt> --> <p>An <code><a href=#the-rt-element>rt</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-rt-element>rt</a></code> element is immediately followed by an <code><a href=#the-rt-element>rt</a></code> or <code><a href=#the-rp-element>rp</a></code> element, or if there is no more content in the parent element.</p> <!-- </rp> --> <p>An <code><a href=#the-rp-element>rp</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-rp-element>rp</a></code> element is immediately followed by an <code><a href=#the-rt-element>rt</a></code> or <code><a href=#the-rp-element>rp</a></code> element, or if there is no more content in the parent element.</p> <!-- </optgroup> (the text assumes <optgroup> can only be inside a <select>; commented out text below can handle the non-<select> case if we ever allow it) --> <p>An <code><a href=#the-optgroup-element>optgroup</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-optgroup-element>optgroup</a></code> element <!--has an ancestor <code>select</code> element and--> is immediately followed by another <code><a href=#the-optgroup-element>optgroup</a></code> element, or if <!--all of the elements that are ancestors of the <code>optgroup</code> element, up to and including the first ancestor element that is not an <code>optgroup</code> element, have no more content--> there is no more content in the parent element.</p> <!-- so e.g. the max number of </optgroup>s are omitted here: <select><optgroup></select> <p id=x><optgroup></optgroup>x</p> <p id=x><optgroup><optgroup></optgroup></optgroup>x</p> <p><optgroup id=x><optgroup></optgroup>x</p> <p><optgroup><optgroup id=x>x</p> --> <!-- </option> --> <p>An <code><a href=#the-option-element>option</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-option-element>option</a></code> element is immediately followed by another <code><a href=#the-option-element>option</a></code> element, or if it is immediately followed by an <code><a href=#the-optgroup-element>optgroup</a></code> element, or if there is no more content in the parent element.</p> <!-- <colgroup> --> <p>A <code><a href=#the-colgroup-element>colgroup</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the first thing inside the <code><a href=#the-colgroup-element>colgroup</a></code> element is a <code><a href=#the-col-element>col</a></code> element, and if the element is not immediately preceded by another <code><a href=#the-colgroup-element>colgroup</a></code> element whose <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> has been omitted. (It can't be omitted if the element is empty.)</p> <!-- </colgroup> --> <p>A <code><a href=#the-colgroup-element>colgroup</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-colgroup-element>colgroup</a></code> element is not immediately followed by a <a href=#space-character>space character</a> or a <a href=#syntax-comments title=syntax-comments>comment</a>.</p> <!-- </thead> --> <p>A <code><a href=#the-thead-element>thead</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-thead-element>thead</a></code> element is immediately followed by a <code><a href=#the-tbody-element>tbody</a></code> or <code><a href=#the-tfoot-element>tfoot</a></code> element.</p> <!-- <tbody> --> <p>A <code><a href=#the-tbody-element>tbody</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> may be omitted if the first thing inside the <code><a href=#the-tbody-element>tbody</a></code> element is a <code><a href=#the-tr-element>tr</a></code> element, and if the element is not immediately preceded by a <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tfoot-element>tfoot</a></code> element whose <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> has been omitted. (It can't be omitted if the element is empty.)</p> <!-- </tbody> --> <p>A <code><a href=#the-tbody-element>tbody</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-tbody-element>tbody</a></code> element is immediately followed by a <code><a href=#the-tbody-element>tbody</a></code> or <code><a href=#the-tfoot-element>tfoot</a></code> element, or if there is no more content in the parent element.</p> <!-- </tfoot> --> <p>A <code><a href=#the-tfoot-element>tfoot</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-tfoot-element>tfoot</a></code> element is immediately followed by a <code><a href=#the-tbody-element>tbody</a></code> element, or if there is no more content in the parent element.</p> <!-- </tr> --> <p>A <code><a href=#the-tr-element>tr</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-tr-element>tr</a></code> element is immediately followed by another <code><a href=#the-tr-element>tr</a></code> element, or if there is no more content in the parent element.</p> <!-- </td> --> <p>A <code><a href=#the-td-element>td</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-td-element>td</a></code> element is immediately followed by a <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element, or if there is no more content in the parent element.</p> <!-- </th> --> <p>A <code><a href=#the-th-element>th</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> may be omitted if the <code><a href=#the-th-element>th</a></code> element is immediately followed by a <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element, or if there is no more content in the parent element.</p> <p><strong>However</strong>, a <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> must never be omitted if it has any attributes.</p> <h5 id=element-restrictions><span class=secno>13.1.2.5 </span>Restrictions on content models</h5> <p>For historical reasons, certain elements have extra restrictions beyond even the restrictions given by their content model.</p> <p>A <code><a href=#the-table-element>table</a></code> element must not contain <code><a href=#the-tr-element>tr</a></code> elements, even though these elements are technically allowed inside <code><a href=#the-table-element>table</a></code> elements according to the content models described in this specification. (If a <code><a href=#the-tr-element>tr</a></code> element is put inside a <code><a href=#the-table-element>table</a></code> in the markup, it will in fact imply a <code><a href=#the-tbody-element>tbody</a></code> start tag before it.)</p> <p>A single <a href=#syntax-newlines title=syntax-newlines>newline</a> may be placed immediately after the <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> of <code><a href=#the-pre-element>pre</a></code> and <code><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 title=syntax-newlines>newline</a> <em>must</em> be included if the element's contents themselves start with a <a href=#syntax-newlines title=syntax-newlines>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><a href=#the-pre-element>pre</a></code> blocks are equivalent:</p> <pre><pre>Hello</pre></pre> <pre><pre><br>Hello</pre></pre> </div> <h5 id=cdata-rcdata-restrictions><span class=secno>13.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5> <p>The text in <a href=#raw-text-elements title="raw text elements">raw text</a> and <a href=#rcdata-elements>RCDATA elements</a> must not contain any occurrences of the string "<code title=""></</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-1><span class=secno>13.1.3 </span>Text</h4> <p><dfn id=syntax-text title=syntax-text>Text</dfn> is allowed inside elements, attribute values, and comments. Text must consist of <a href=#unicode-character title="Unicode character">Unicode characters</a>. Text must not contain U+0000 characters. Text must not contain permanently undefined Unicode characters (noncharacters). Text must not contain control characters other than <a href=#space-character title="space character">space characters</a>. Extra constraints are placed on what is and what is not allowed in text based on where the text is to be put, as described in the other sections.</p> <h5 id=newlines><span class=secno>13.1.3.1 </span>Newlines</h5> <p><dfn id=syntax-newlines title=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 title=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 title=syntax-newlines>newline</a>.</p> <h4 id=character-references><span class=secno>13.1.4 </span>Character references</h4> <p>In certain cases described in other sections, <a href=#syntax-text title=syntax-text>text</a> may be mixed with <dfn id=syntax-charref title=syntax-charref>character references</dfn>. These can be used to escape characters that couldn't otherwise legally be included in <a href=#syntax-text title=syntax-text>text</a>.</p> <p>Character references must start with a U+0026 AMPERSAND character (&). Following this, there are three possible kinds of character references:</p> <dl><dt>Named character references</dt> <dd>The ampersand must be followed by one of the names given in the <a href=#named-character-references>named character references</a> section, using the same case. <span class=impl>The name must be one that is terminated by a U+003B SEMICOLON character (;).</span></dd> <dt>Decimal numeric character reference</dt> <dd>The ampersand must be followed by a U+0023 NUMBER SIGN character (#), followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten integer that corresponds to a Unicode code point that is allowed according to the definition below. The digits must then be followed by a U+003B SEMICOLON character (;).</dd> <dt>Hexadecimal numeric character reference</dt> <dd>The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, representing a base-sixteen integer that corresponds to a Unicode code point that is allowed according to the definition below. The digits must then be followed by a U+003B SEMICOLON character (;).</dd> </dl><p>The numeric character reference forms described above are allowed to reference any Unicode code point other than U+0000, U+000D, permanently undefined Unicode characters (noncharacters), and control characters other than <a href=#space-character title="space character">space characters</a>.</p> <p>An <dfn id=syntax-ambiguous-ampersand title=syntax-ambiguous-ampersand>ambiguous ampersand</dfn> is a U+0026 AMPERSAND character (&) that is followed by one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, 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>named character references</a> section.</p> <h4 id=cdata-sections><span class=secno>13.1.5 </span>CDATA sections</h4> <p><dfn id=syntax-cdata title=syntax-cdata>CDATA sections</dfn> must consist of the following components, in this order:</p> <ol><li>The string "<code title=""><![CDATA[</code>".</li> <li>Optionally, <a href=#syntax-text title=syntax-text>text</a>, with the additional restriction that the text must not contain the string "<code title="">]]></code>".</li> <li>The string "<code title="">]]></code>".</li> </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 an <code>ms</code> element:</p> <pre><p>You can add a string to a number, but this stringifies the number:</p> <math> <ms><![CDATA[x<y]]></ms> <mo>+</mo> <mn>3</mn> <mo>=</mo> <ms><![CDATA[x<y3]]></ms> </math></pre> </div> <h4 id=comments><span class=secno>13.1.6 </span>Comments</h4> <p><dfn id=syntax-comments title=syntax-comments>Comments</dfn> must start with the four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may have <a href=#syntax-text title=syntax-text>text</a>, with the additional restriction that the text must not start with a single U+003E GREATER-THAN SIGN character (>), nor start with a U+002D HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN (>) character, nor contain two consecutive U+002D HYPHEN-MINUS characters (<code title="">--</code>), nor end with a U+002D HYPHEN-MINUS character (-). Finally, the comment must be ended by the three character sequence U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p> <div class=impl> <h3 id=parsing><span class=secno>13.2 </span>Parsing HTML documents</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>The XHTML syntax</a>".</p> <p>User agents must use the parsing rules described in this section to generate the DOM trees from <code><a href=#text/html>text/html</a></code> resources. Together, these rules define what is referred to as the <dfn id=html-parser>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>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 <dfn id=parse-error title="parse error">parse errors</dfn>. The error handling for parse errors is well-defined: user agents must either act as described below when encountering such problems, or must abort processing at the first error that they encounter for which they do not wish to apply the rules described below.</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. Conformance checkers are not required to recover from parse errors.</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>For the purposes of conformance checkers, if a resource is determined to be in <a href=#syntax>the HTML syntax</a>, then it is an <a href=#html-documents title="HTML documents">HTML document</a>.</p> </div> <div class=impl> <h4 id=overview-of-the-parsing-model><span class=secno>13.2.1 </span>Overview of the parsing model</h4> <p class=overview><object data=images/parsing-model-overview.svg height=450 width=345><img alt="" height=450 src=http://images.whatwg.org/parsing-model-overview.png width=345></object></p> <p>The input to the HTML parsing process consists of a stream of Unicode code points, which is passed through a <a href=#tokenization>tokenization</a> stage followed by a <a href=#tree-construction>tree construction</a> stage. The output is a <code><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><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 title="dynamic markup insertion">it can also come from script</a> running in the user agent, e.g. using the <code title=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>... <script> document.write('<p>'); </script> ...</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> </div> <div class=impl> <h4 id=the-input-stream><span class=secno>13.2.2 </span>The <dfn>input stream</dfn></h4> <p>The stream of Unicode 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 <em>character encoding</em>, which the user agent must use to decode the bytes into characters.</p> <p class=note>For XML documents, the algorithm user agents must 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> <h5 id=determining-the-character-encoding><span class=secno>13.2.2.1 </span>Determining the character encoding</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 an 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 (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 title=Content-Type>Content-Type metadata</a> of the document) and all the bytes available so far, and returns an encoding and a <dfn id=concept-encoding-confidence title=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>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 an encoding at all, then the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> is <i>irrelevant</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 title=concept-encoding-confidence>confidence</a> <i>certain</i> and abort these steps.</li> <li><p>If the transport layer specifies an encoding, and it is supported, return that encoding with the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> <i>certain</i>, and abort these steps.</li> <li> <p>The user agent may wait for more bytes of the resource to be available, either in this step or at any later step in this algorithm. For instance, a user agent might wait 500ms or 1024 bytes, whichever came first. In general preparsing the source to find the encoding improves performance, as it reduces the need to throw away the data structures used when parsing upon finding the encoding information. However, if the user agent delays too long to obtain data to determine the encoding, then the cost of the delay could outweigh any performance improvements from the preparse.</p> <p class=note>The authoring conformance requirements for character encoding declarations limit them to only appearing <a href=#charset1024>in the first 1024 bytes</a>. User agents are therefore encouraged to use the preparse algorithm below (part of these steps) on the first 1024 bytes, but not to stall beyond that.</p> </li> <li><p>For each of the rows in the following table, starting with the first one and going down, if there are as many or more bytes available than the number of bytes in the first column, and the first bytes of the file match the bytes given in the first column, then return the encoding given in the cell in the second column of that row, with the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> <i>certain</i>, and abort these steps:</p> <!-- this table is present in several forms in this file; keep them in sync --> <table><thead><tr><th>Bytes in Hexadecimal <th>Encoding <tbody><!-- nobody uses this <tr> <td>00 00 FE FF <td>UTF-32BE <tr> <td>FF FE 00 00 <td>UTF-32LE --><tr><td>FE FF <td>Big-endian UTF-16 <tr><td>FF FE <td>Little-endian UTF-16 <tr><td>EF BB BF <td>UTF-8 <!-- nobody uses this <tr> <td>DD 73 66 73 <td>UTF-EBCDIC --> </table><p class=note>This step looks for Unicode Byte Order Marks (BOMs).</li> <li><p>Otherwise, the user agent will have to search for explicit character encoding information in the file itself. This should proceed as follows: <p>Let <var title="">position</var> be a pointer to a byte in the input stream, initially pointing at the first byte. If at any point during these substeps the user agent either runs out of bytes or decides that scanning further bytes would not be efficient, then skip to the next step of the overall character encoding detection algorithm. User agents may decide that scanning <em>any</em> bytes is not efficient, in which case these substeps are entirely skipped.</p> <p>Now, repeat the following "two" steps until the algorithm aborts (either because user agent aborts, as described above, or because a character encoding is found):</p> <ol><li><p>If <var title="">position</var> points to:</p> <dl class=switch><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt> <dd> <p>Advance the <var title="">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 the those in the '<!--' sequence.)</p> </dd> <dt>A sequence of bytes starting with: 0x3C, 0x4D or 0x6D, 0x45 or 0x65, 0x54 or 0x74, 0x41 or 0x61, and one of 0x09, 0x0A, 0x0C, 0x0D, 0x20, 0x2F (case-insensitive ASCII '<meta' followed by a space or slash)</dt> <dd> <ol><li><p>Advance the <var title="">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> <li><p>Let <var title="">attribute list</var> be an empty list of strings.</li> <!-- so long as we only care about http-equiv, content, and charset, this can be a 3-bit bitfield --> <li><p>Let <var title="">got pragma</var> be false.</li> <li><p>Let <var title="">need pragma</var> be null.</li> <li><p>Let <var title="">charset</var> be the null value (which, for the purposes of this algorithm, is distinct from an unrecognised encoding or the empty string).</li> <li><p><i>Attributes</i>: <a href=#concept-get-attributes-when-sniffing title=concept-get-attributes-when-sniffing>Get an attribute</a> and its value. If no attribute was sniffed, then jump to the <i>processing</i> step below.</li> <li><p>If the attribute's name is already in <var title="">attribute list</var>, then return to the step labeled <i>attributes</i>.</p> <li><p>Add the attribute's name to <var title="">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 title="">http-equiv</code>"</dt> <dd><p>If the attribute's value is "<code title="">content-type</code>", then set <var title="">got pragma</var> to true.</dd> <dt>If the attribute's name is "<code title="">content</code>"</dt> <dd><p>Apply the <a href=#algorithm-for-extracting-an-encoding-from-a-meta-element>algorithm for extracting an encoding from a <code>meta</code> element</a>, giving the attribute's value as the string to parse. If an encoding is returned, and if <var title="">charset</var> is still set to null, let <var title="">charset</var> be the encoding returned, and set <var title="">need pragma</var> to true.</dd> <dt>If the attribute's name is "<code title="">charset</code>"</dt> <dd><p>Let <var title="">charset</var> be the encoding corresponding to the attribute's value, and set <var title="">need pragma</var> to false.</dd> </dl></li> <li><p>Return to the step labeled <i>attributes</i>.</li> <li><p><i>Processing</i>: If <var title="">need pragma</var> is null, then jump to the second step of the overall "two step" algorithm.</li> <li><p>If <var title="">need pragma</var> is true but <var title="">got pragma</var> is false, then jump to the second step of the overall "two step" algorithm.</li> <li><p>If <var title="">charset</var> is <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, change the value of <var title="">charset</var> to UTF-8.</li> <li><p>If <var title="">charset</var> is not a supported character encoding, then jump to the second step of the overall "two step" algorithm.</li> <li><p>Return the encoding given by <var title="">charset</var>, with <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> <i>tentative</i>, and abort all these steps.</li> </ol></dd> <dt>A sequence of bytes starting with a 0x3C byte (ASCII <), optionally a 0x2F byte (ASCII /), and finally a byte in the range 0x41-0x5A or 0x61-0x7A (an ASCII letter)</dt> <dd> <ol><li><p>Advance the <var title="">position</var> pointer so that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII >) byte.</li> <li><p>Repeatedly <a href=#concept-get-attributes-when-sniffing title=concept-get-attributes-when-sniffing>get an attribute</a> until no further attributes can be found, then jump to the second step in the overall "two step" algorithm.</li> </ol></dd> <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt> <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt> <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt> <dd> <p>Advance the <var title="">position</var> pointer so that it points at the first 0x3E byte (ASCII >) that comes after the 0x3C byte that was found.</p> </dd> <dt>Any other byte</dt> <dd> <p>Do nothing with that byte.</p> </dd> </dl></li> <li>Move <var title="">position</var> so it points at the next byte in the input stream, and return to the first step of this "two step" algorithm.</li> </ol><p>When the above "two step" algorithm says to <dfn id=concept-get-attributes-when-sniffing title=concept-get-attributes-when-sniffing>get an attribute</dfn>, it means doing this:</p> <ol><li><p>If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this substep.</li> <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII >), then abort the "get an attribute" algorithm. There isn't one.</li> <li><p>Otherwise, the byte at <var title="">position</var> is the start of the attribute name. Let <var title="">attribute name</var> and <var title="">attribute value</var> be the empty string.</li> <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p> <dl class=switch><dt>If it is 0x3D (ASCII =), and the <var title="">attribute name</var> is longer than the empty string</dt> <dd>Advance <var title="">position</var> to the next byte and jump to the step below labeled <i>value</i>.</dd> <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt> <dd>Jump to the step below labeled <i>spaces</i>.</dd> <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt> <dd>Abort the "get an attribute" algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty string.</dd> <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII Z)</dt> <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute name</var> (where <var title="">b</var> is the value of the byte at <var title="">position</var>). (This converts the input to lowercase.)</dd> <dt>Anything else</dt> <dd>Append the Unicode character with the same code point as the value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how bytes outside the ASCII range are handled here, since only ASCII characters can contribute to the detection of a character encoding.)</dd> </dl></li> <li><p>Advance <var title="">position</var> to the next byte and return to the previous step.</li> <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance <var title="">position</var> to the next byte, then, repeat this step.</li> <li><p>If the byte at <var title="">position</var> is <em>not</em> 0x3D (ASCII =), abort the "get an attribute" algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty string.</li> <li><p>Advance <var title="">position</var> past the 0x3D (ASCII =) byte.</li> <li><p><i>Value</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance <var title="">position</var> to the next byte, then, repeat this step.</li> <li><p>Process the byte at <var title="">position</var> as follows:</p> <dl class=switch><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt> <dd> <ol><li>Let <var title="">b</var> be the value of the byte at <var title="">position</var>.</li> <li>Advance <var title="">position</var> to the next byte.</li> <li>If the value of the byte at <var title="">position</var> is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get an attribute" algorithm. The attribute's name is the value of <var title="">attribute name</var>, and its value is the value of <var title="">attribute value</var>.</li> <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more than the value of the byte at <var title="">position</var>.</li> <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as the value of the byte at <var title="">position</var>.</li> <li>Return to the second step in these substeps.</li> </ol></dd> <dt>If it is 0x3E (ASCII >)</dt> <dd>Abort the "get an attribute" algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty string.</dd> <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII Z)</dt> <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute value</var> (where <var title="">b</var> is the value of the byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd> <dt>Anything else</dt> <dd>Append the Unicode character with the same code point as the value of the byte at <var title="">position</var>) to <var title="">attribute value</var>. Advance <var title="">position</var> to the next byte.</dd> </dl></li> <li><p>Process the byte at <var title="">position</var> as follows:</p> <dl class=switch><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII >)</dt> <dd>Abort the "get an attribute" algorithm. The attribute's name is the value of <var title="">attribute name</var> and its value is the value of <var title="">attribute value</var>.</dd> <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII Z)</dt> <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute value</var> (where <var title="">b</var> is the value of the byte at <var title="">position</var>).</dd> <dt>Anything else</dt> <dd>Append the Unicode character with the same code point as the value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd> </dl></li> <li><p>Advance <var title="">position</var> to the next byte and return to the previous step.</li> </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> </li> <li><p>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 title=concept-encoding-confidence>confidence</a> <i>tentative</i>, and abort these steps.</li> <li> <p>The user agent may attempt to autodetect the character encoding from applying frequency analysis or other algorithms to the data stream. Such algorithms may use information about the resource other than the resource's contents, including the address of the resource. If autodetection succeeds in determining a character encoding, then return that encoding, with the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> <i>tentative</i>, and abort these steps. <a href=#refsUNIVCHARDET>[UNIVCHARDET]</a></p> <p class=note>The UTF-8 encoding has a highly detectable bit pattern. Documents 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. User-agents are therefore encouraged to search for this common encoding. <a href=#refsPPUTF8>[PPUTF8]</a> <a href=#refsUTF8DET>[UTF8DET]</a></p> </li> <li> <p>Otherwise, return an implementation-defined or user-specified default character encoding, with the <a href=#concept-encoding-confidence title=concept-encoding-confidence>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 title="">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></p> <!-- based on mozilla 1.9.1 localizations: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= --> <table><thead><tr><th>Locale language <th>Suggested default encoding <tbody><tr><td>ar <td>UTF-8 <tr><td>be <td>ISO-8859-5 <tr><td>bg <td>windows-1251 <tr><td>cs<!-- -CZ --> <td>ISO-8859-2 <tr><td>cy <td>UTF-8 <tr><td>fa<!-- -IR --> <td>UTF-8 <tr><td>he<!-- -IL --> <td>windows-1255 <tr><td>hr <td>UTF-8 <tr><td>hu<!-- -HU --> <td>ISO-8859-2 <tr><td>ja <!-- and ja-JP-mac --> <td>Windows-31J <!-- Shift_JIS --> <tr><td>kk <td>UTF-8 <tr><td>ko<!-- -KR --> <td>windows-949 <!-- EUC-KR --> <tr><td>ku <td>windows-1254 <!-- ISO-8859-9 --> <tr><td>lt <td>windows-1257 <tr><td>lv<!-- -LV --> <td>ISO-8859-13 <tr><td>mk<!-- -MK --> <td>UTF-8 <tr><td>or <td>UTF-8 <tr><td>pl<!-- -PL --> <td>ISO-8859-2 <tr><td>ro <td>UTF-8 <tr><td>ru <td>windows-1251 <tr><td>sk <td>windows-1250 <tr><td>sl <td>ISO-8859-2 <tr><td>sr <td>UTF-8 <tr><td>th <td>windows-874 <!-- TIS-620 --> <tr><td>tr<!-- -TR --> <td>windows-1254 <!-- ISO-8859-9 --> <tr><td>uk <td>windows-1251 <tr><td>vi <td>UTF-8 <tr><td>zh-CN <td>GB18030 <tr><td>zh-TW <td>Big5 <tr><td>All other locales <td>windows-1252 </table></li> </ol><p>The <a href="#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 stream.</p> <!--(removed this since the specs are being changed) <p class="note">This algorithm is a <span>willful violation</span> of the HTTP specification, which requires that the encoding be assumed to be ISO-8859-1 in the absence of a <span>character encoding declaration</span> to the contrary, and of RFC 2046, which requires that the encoding be assumed to be US-ASCII in the absence of a <span>character encoding declaration</span> to the contrary. This specification's third approach is motivated by a desire to be maximally compatible with legacy content. <a href="#refsHTTP">[HTTP]</a> <a href="#refsRFC2046">[RFC2046]</a></p> --> <h5 id=character-encodings-0><span class=secno>13.2.2.2 </span>Character encodings</h5> <p>User agents must at a minimum support the UTF-8 and Windows-1252 encodings, but may support more. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWIN1252>[WIN1252]</a></p> <p class=note>It is not unusual for Web browsers to support dozens if not upwards of a hundred distinct character encodings.</p> <p>User agents must support the <a href=#preferred-mime-name>preferred MIME name</a> of every character encoding they support, and should support all the IANA-registered names and aliases of every character encoding they support. <a href=#refsIANACHARSET>[IANACHARSET]</a></p> <p>When comparing a string specifying a character encoding with the name or alias of a character encoding to determine if they are equal, user agents must remove any leading or trailing <a href=#space-character title="space character">space characters</a> in both names, and then perform the comparison in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner.</p> <hr><p>When a user agent would otherwise use an encoding given in the first column of the following table to either convert content to Unicode characters or convert Unicode characters to bytes, it must instead use the encoding given in the cell in the second column of the same row. When a byte or sequence of bytes is treated differently due to this encoding aliasing, it is said to have been <dfn id=misinterpreted-for-compatibility>misinterpreted for compatibility</dfn>.</p> <table id=table-encoding-overrides><caption>Character encoding overrides</caption> <thead><tr><th> Input encoding <th> Replacement encoding <th> References <tbody><tr><td> EUC-KR <td> windows-949 <td> <a href=#refsEUCKR>[EUCKR]</a> <a href=#refsWIN949>[WIN949]</a> <tr><td> EUC-JP <td> CP51932 <td> <a href=#refsEUCJP>[EUCJP]</a> <a href=#refsCP51932>[CP51932]</a> <tr><td> GB2312 <td> GBK <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsGBK>[GBK]</a> <tr><td> GB_2312-80 <td> GBK <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsGBK>[GBK]</a> <tr><td> ISO-2022-JP <td> CP50220 <td> <a href=#refsRFC1468>[RFC1468]</a><!-- ISO-2022-JP --> <a href=#refsRFC2237>[RFC2237]</a><!-- ISO-2022-JP-1 --> <a href=#refsRFC1554>[RFC1554]</a><!-- ISO-2022-JP-2 --> <a href=#refsCP50220>[CP50220]</a><!-- CP50220, the compatibility replacement for ISO-2022-JP --> <tr><td> ISO-8859-1 <td> windows-1252 <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsWIN1252>[WIN1252]</a> <tr><td> ISO-8859-9 <td> windows-1254 <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsWIN1254>[WIN1254]</a> <tr><td> ISO-8859-11 <td> windows-874 <td> <a href=#refsISO885911>[ISO885911]</a> <a href=#refsWIN874>[WIN874]</a> <tr><td> KS_C_5601-1987 <td> windows-949 <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsWIN949>[WIN949]</a> <tr><td> Shift_JIS <td> Windows-31J <td> <a href=#refsSHIFTJIS>[SHIFTJIS]</a> <a href=#refsWIN31J>[WIN31J]</a> <tr><td> TIS-620 <td> windows-874 <td> <a href=#refsTIS620>[TIS620]</a> <a href=#refsWIN874>[WIN874]</a> <tr><td> US-ASCII <td> windows-1252 <td> <a href=#refsRFC1345>[RFC1345]</a> <a href=#refsWIN1252>[WIN1252]</a> </table><p class=note>The requirement to treat certain encodings as other encodings according to the table above is a <a href=#willful-violation>willful violation</a> of the W3C Character Model specification, motivated by a desire for compatibility with legacy content. <a href=#refsCHARMOD>[CHARMOD]</a></p> <p>When a user agent is to use the self-describing UTF-16 encoding but no BOM has been found, user agents must default to little-endian UTF-16.</p> <p class=note>The requirement to default UTF-16 to little-endian rather than big-endian is a <a href=#willful-violation>willful violation</a> of RFC 2781, motivated by a desire for compatibility with legacy content. <a href=#refsRFC2781>[RFC2781]</a></p> <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU encodings. <a href=#refsCESU8>[CESU8]</a> <a href=#refsUTF7>[UTF7]</a> <a href=#refsBOCU1>[BOCU1]</a> <a href=#refsSCSU>[SCSU]</a></p> <p>Support for encodings based on EBCDIC is not recommended. This encoding is rarely used for publicly-facing Web content.</p> <p>Support for UTF-32 is not recommended. This encoding is rarely used, and frequently implemented incorrectly.</p> <p class=note>This specification does not make any attempt to support EBCDIC-based encodings and UTF-32 in its algorithms; support and use of these encodings can thus lead to unexpected behavior in implementations of this specification.</p> <h5 id=preprocessing-the-input-stream><span class=secno>13.2.2.3 </span>Preprocessing the input stream</h5> <p>Given an encoding, the bytes in the input stream must be converted to Unicode code points for the tokenizer, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below).</p> <!-- this is to prevent two leading BOMs from being both stripped, once by the decoder, and once by the parser --> <p>Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode code points must be converted to U+FFFD REPLACEMENT CHARACTERs. Specifically, if the encoding is UTF-8, the bytes must be <a href=#decoded-as-utf-8,-with-error-handling title="decoded as UTF-8, with error handling">decoded with the error handling</a> defined in this specification.</p> <p class=note>Bytes or sequences of bytes in the original byte stream that did not conform to the encoding specification (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are errors that conformance checkers are expected to report.</p> <p>Any byte or sequence of bytes in the original byte stream that is <a href=#misinterpreted-for-compatibility>misinterpreted for compatibility</a> is a <a href=#parse-error>parse error</a>.</p> <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.</p> <p class=note>The requirement to strip a U+FEFF BYTE ORDER MARK character regardless of whether that character was used to determine the byte order is a <a href=#willful-violation>willful violation</a> of Unicode, motivated by a desire to increase the resilience of user agents in the face of naïve transcoders.</p> <p>Any occurrences of any characters in the ranges U+0001 to U+0008, <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF, CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0 to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are <a href=#parse-error title="parse error">parse errors</a>. These are all control characters or permanently undefined Unicode characters (noncharacters).</p> <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF) characters are treated specially. Any CR characters that are followed by LF characters must be removed, and any CR characters not followed by LF characters must 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>tokenization</a> stage.</p> <p>The <dfn id=next-input-character>next input character</dfn> is the first character in the input stream that has not yet been <dfn id=consumed>consumed</dfn>. Initially, the <i><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><a href=#consumed>consumed</a></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 title=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=#the-input-stream>input stream</a>. If the parser is a <a href=#script-created-parser>script-created parser</a>, then the end of the <a href=#the-input-stream>input stream</a> is reached when an <dfn id=explicit-eof-character>explicit "EOF" character</dfn> (inserted by the <code title=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> <h5 id=changing-the-encoding-while-parsing><span class=secno>13.2.2.4 </span>Changing the encoding while parsing</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>encoding sniffing algorithm</a> described above failed to find an encoding, or if it found an encoding that was not the actual encoding of the file.</p> <ol><li>If the encoding that is already being used to interpret the input stream is <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, then set the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> to <i>certain</i> and abort these steps. The new encoding is ignored; if it was anything but the same encoding, then it would be clearly incorrect.</li> <li>If the new encoding is <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, change it to UTF-8.</li> <li>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 title=concept-encoding-confidence>confidence</a> to <i>certain</i> and abort these steps. This happens when the encoding information found in the file matches what the <a href=#encoding-sniffing-algorithm>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> <li>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 href="#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 title=concept-encoding-confidence>confidence</a> to <i>certain</i>, and abort these steps.</li> <li>Otherwise, <a href=#navigate>navigate</a><!--DONAV reparse--> to the document again, with <a href=#replacement-enabled>replacement enabled</a>, and using the same <a href=#source-browsing-context>source browsing context</a>, but this time skip the <a href=#encoding-sniffing-algorithm>encoding sniffing algorithm</a> and instead just set the encoding to the new encoding and the <a href=#concept-encoding-confidence title=concept-encoding-confidence>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 HTTP GET (<a href=#concept-http-equivalent-get title=concept-http-equivalent-get>or equivalent</a> for non-HTTP URLs), then instead set the <a href=#concept-encoding-confidence title=concept-encoding-confidence>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.</li> </ol></div> <div class=impl> <h4 id=parse-state><span class=secno>13.2.3 </span>Parse state</h4> <h5 id=the-insertion-mode><span class=secno>13.2.3.1 </span>The insertion mode</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>insertion mode</a> is "<a href=#the-initial-insertion-mode title="insertion mode: initial">initial</a>". It can change to "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>", "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>", "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>", "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>", "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-incdata title="insertion mode: text">text</a>", "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>", "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>", "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>", "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>", "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>", "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>", "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>", "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>", "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>", "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>", and "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" during the course of the parsing, as described in the <a href=#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 title="insertion mode: in head">in head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>", and "<a href=#parsing-main-inselect title="insertion mode: in select">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 title="">m</var> insertion mode", where <var title="">m</var> is one of these modes, the user agent must use the rules described under the <var title="">m</var> <a href=#insertion-mode>insertion mode</a>'s section, but must leave the <a href=#insertion-mode>insertion mode</a> unchanged unless the rules in <var title="">m</var> themselves switch the <a href=#insertion-mode>insertion mode</a> to a new value.</p> <p>When the insertion mode is switched to "<a href=#parsing-main-incdata title="insertion mode: text">text</a>" or "<a href=#parsing-main-intabletext title="insertion mode: in table text">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> <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>Let <var title="">last</var> be false.</li> <li>Let <var title="">node</var> be the last node in the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><i>Loop</i>: If <var title="">node</var> is the first node in the stack of open elements, then set <var title="">last</var> to true and set <var title="">node</var> to the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element. (<a href=#fragment-case>fragment case</a>)</li> <li>If <var title="">node</var> is a <code><a href=#the-select-element>select</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" and abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <li>If <var title="">node</var> is a <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> element and <var title="">last</var> is false, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#the-tr-element>tr</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tfoot-element>tfoot</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#the-caption-element>caption</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#the-colgroup-element>colgroup</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" and abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <li>If <var title="">node</var> is a <code><a href=#the-table-element>table</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" ("<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"! <em> not "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>"</em>!) and abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <!-- This is only here for now in case people think that the spec accidentally omitted it and try to "fix" it. Note that noscript-in-head is also handled this way. This is all intentional. The only thing it doesn't handle is the scripting-disabled fragment parsing case for a <head> element containing a <noscript> which itself contains something other than a <link> or a <style> element; you'd expect that to break out of the <noscript> but it doesn't. This is an edge case that doesn't affect the spec, since the algorithm for fragment parsing is only used for innerHTML/outerHTML/insertAdjacentHTML(), where we know scripting is enabled. --> <li>If <var title="">node</var> is a <code><a href=#the-body-element>body</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and abort these steps.</li> <li>If <var title="">node</var> is a <code><a href=#frameset>frameset</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" and abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <li>If <var title="">node</var> is an <code><a href=#the-html-element>html</a></code> element, then <!--: if the <span><code title="">head</code> element pointer</span> is null,--> switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>"<!--, otherwise, switch the <span>insertion mode</span> to "<span title="insertion mode: after head">after head</span>".--> Then, <!-- in either case, --> abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <!-- if the head element pointer can ever be non-null when we're going through these steps, we'll need to uncomment out the commented-out bits --> <li>If <var title="">last</var> is true, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and abort these steps. (<a href=#fragment-case>fragment case</a>)</li> <li>Let <var title="">node</var> now be the node before <var title="">node</var> in the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li>Return to the step labeled <i>loop</i>.</li> </ol><h5 id=the-stack-of-open-elements><span class=secno>13.2.3.2 </span>The stack of open elements</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>The "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a> creates the <code><a href=#the-html-element>html</a></code> root element node, which is then added to the stack.</p> <p>In the <a href=#fragment-case>fragment case</a>, the <a href=#stack-of-open-elements>stack of open elements</a> is initialized to contain an <code><a href=#the-html-element>html</a></code> element that is created as part of <a href=#html-fragment-parsing-algorithm title="html fragment parsing algorithm">that algorithm</a>. (The <a href=#fragment-case>fragment case</a> skips the "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a>.)</p> <p>The <code><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 title="stop parsing">finishes</a>.</p> <p>The <dfn id=current-node>current node</dfn> is the bottommost node in this stack.</p> <p>The <dfn id=current-table>current table</dfn> is the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is one. If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> (<a href=#fragment-case>fragment case</a>), then the <a href=#current-table>current table</a> is the first element in the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element).</p> <p>Elements in the stack fall into the following categories:</p> <dl><dt><dfn id=special>Special</dfn></dt> <dd><p>The following elements have varying levels of special parsing rules: HTML's <code><a href=#the-address-element>address</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-article-element>article</a></code>, <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>, <code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-br-element>br</a></code>, <code><a href=#the-button-element>button</a></code>, <code><a href=#the-caption-element>caption</a></code>, <code><a href=#center>center</a></code>, <code><a href=#the-col-element>col</a></code>, <code><a href=#the-colgroup-element>colgroup</a></code>, <code><a href=#the-command-element>command</a></code>, <code><a href=#the-dd-element>dd</a></code>, <code><a href=#the-details-element>details</a></code>, <code><a href=#dir>dir</a></code>, <code><a href=#the-div-element>div</a></code>, <code><a href=#the-dl-element>dl</a></code>, <code><a href=#the-dt-element>dt</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#the-figcaption-element>figcaption</a></code>, <code><a href=#the-figure-element>figure</a></code>, <code><a href=#the-footer-element>footer</a></code>, <code><a href=#the-form-element>form</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#frameset>frameset</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code><a href=#the-head-element>head</a></code>, <code><a href=#the-header-element>header</a></code>, <code><a href=#the-hgroup-element>hgroup</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-html-element>html</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <!-- <code>image</code>, (commented out because this isn't an element that can end up on the stack, so it doesn't matter) --> <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#isindex-0>isindex</a></code>, <code><a href=#the-li-element>li</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#listing>listing</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-menu-element>menu</a></code>, <code><a href=#the-meta-element>meta</a></code>, <code><a href=#the-nav-element>nav</a></code>, <code><a href=#noembed>noembed</a></code>, <code><a href=#noframes>noframes</a></code>, <code><a href=#the-noscript-element>noscript</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-ol-element>ol</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>, <code><a href=#the-script-element>script</a></code>, <code><a href=#the-section-element>section</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-style-element>style</a></code>, <code><a href=#the-summary-element>summary</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-td-element>td</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-title-element>title</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-track-element>track</a></code>, <code><a href=#the-ul-element>ul</a></code>, <code><a href=#the-wbr-element>wbr</a></code>, and <code><a href=#xmp>xmp</a></code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code title="">annotation-xml</code>; and SVG's <code title="">foreignObject</code>, <code title="">desc</code>, and <code title="">title</code>.</dd> <!-- we could actually put all non-HTML elements in this list, I think --> <dt><dfn id=formatting>Formatting</dfn></dt> <dd><p>The following HTML elements are those that end up in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>: <code><a href=#the-a-element>a</a></code>, <code><a href=#the-b-element>b</a></code>, <code><a href=#big>big</a></code>, <code><a href=#the-code-element>code</a></code>, <code><a href=#the-em-element>em</a></code>, <code><a href=#font>font</a></code>, <code><a href=#the-i-element>i</a></code>, <code><a href=#nobr>nobr</a></code>, <code><a href=#the-s-element>s</a></code>, <code><a href=#the-small-element>small</a></code>, <code><a href=#strike>strike</a></code>, <code><a href=#the-strong-element>strong</a></code>, <code><a href=#tt>tt</a></code>, and <code><a href=#the-u-element>u</a></code>.</dd> <dt><dfn id=ordinary>Ordinary</dfn></dt> <dd><p>All other elements found while parsing an HTML document.</dd> </dl><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-the-specific-scope title="has an element in the specific scope">have an element in a specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a match state:</p> <ol><li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current node</a> (the bottommost node of the stack).</li> <li><p>If <var title="">node</var> is the target node, terminate in a match state.</li> <li><p>Otherwise, if <var title="">node</var> is one of the element types in <var title="">list</var>, terminate in a failure state.</li> <li><p>Otherwise, set <var title="">node</var> to the previous entry in the <a href=#stack-of-open-elements>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><a href=#the-html-element>html</a></code> element — is reached.)</li> </ol><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-scope title="has an element in scope">have an element in scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific scope</a> consisting of the following element types:</p> <ul class=brief><li><code><a href=#the-applet-element>applet</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-caption-element>caption</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) --> <li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-td-element>td</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-th-element>th</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-marquee-element>marquee</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-object-element>object</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code title="">mi</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">mo</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">mn</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">ms</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">mtext</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">annotation-xml</code> in the <a href=#mathml-namespace>MathML namespace</a></li> <li><code title="">foreignObject</code> in the <a href=#svg-namespace>SVG namespace</a></li> <li><code title="">desc</code> in the <a href=#svg-namespace>SVG namespace</a></li> <li><code title="">title</code> in the <a href=#svg-namespace>SVG namespace</a></li> </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-list-item-scope title="has an element in list item scope">have an element in list item scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an 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><a href=#has-an-element-in-scope>has an element in scope</a></i> algorithm.</li> <li><code><a href=#the-ol-element>ol</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-ul-element>ul</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-button-scope title="has an element in button scope">have an element in button scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an 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><a href=#has-an-element-in-scope>has an element in scope</a></i> algorithm.</li> <li><code><a href=#the-button-element>button</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific scope</a> consisting of the following element types:</p> <ul class=brief><li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) --> <li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope title="has an element in select scope">have an element in select scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific scope</a> consisting of all element types <em>except</em> the following:</p> <ul class=brief><!--<li><code>select</code> in the <span>HTML namespace</span></li>--><li><code><a href=#the-optgroup-element>optgroup</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <li><code><a href=#the-option-element>option</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> </ul><p>Nothing happens if at any time any of the elements in the <a href=#stack-of-open-elements>stack of open elements</a> are moved to a new location in, or removed from, the <code><a href=#document>Document</a></code> tree. In particular, the stack is not changed in this situation. This can cause, amongst other strange effects, content to be appended to nodes that are no longer in the DOM.</p> <p class=note>In some cases (namely, when <a href=#adoptionAgency>closing misnested formatting elements</a>), the stack is manipulated in a random-access fashion.</p> <h5 id=the-list-of-active-formatting-elements><span class=secno>13.2.3.3 </span>The list of active formatting elements</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 title=formatting>formatting element tags</a>.</p> <p>The list contains elements in the <a href=#formatting>formatting</a> category, and scope markers. The scope markers are inserted when entering <code><a href=#the-applet-element>applet</a></code> elements, buttons, <code><a href=#the-object-element>object</a></code> elements, marquees, table cells, and table captions, and are used to prevent formatting from "leaking" <em>into</em> <code><a href=#the-applet-element>applet</a></code> elements, buttons, <code><a href=#the-object-element>object</a></code> elements, marquees, and tables.</p> <p class=note>The scope markers are unrelated to the concept of an element being <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>.</p> <p>In addition, each element in the <a href=#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 title="">element</var>, the UA must perform the following steps:</p> <ol><li><p>If there are already three elements in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> after the last list marker, if any, or anywhere in the list if there are no list markers, that have the same tag name, namespace, and attributes as <var title="">element</var>, then remove the earliest such element from the <a href=#list-of-active-formatting-elements>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> <!-- A sort of polyamorous Noah's Ark, if you will. --> <li><p>Add <var title="">element</var> to the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> </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>If there are no entries in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>, then there is nothing to reconstruct; stop this algorithm.</li> <li>If the last (most recently added) entry in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> is a marker, or if it is an element that is in the <a href=#stack-of-open-elements>stack of open elements</a>, then there is nothing to reconstruct; stop this algorithm.</li> <li>Let <var title="">entry</var> be the last (most recently added) element in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li>If there are no entries before <var title="">entry</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>, then jump to step 8.</li> <li>Let <var title="">entry</var> be the entry one earlier than <var title="">entry</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li>If <var title="">entry</var> is neither a marker nor an element that is also in the <a href=#stack-of-open-elements>stack of open elements</a>, go to step 4.</li> <li>Let <var title="">entry</var> be the element one later than <var title="">entry</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li> <li>Append <var title="">new element</var> to the <a href=#current-node>current node</a> and push it onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new <a href=#current-node>current node</a>.</li> <li>Replace the entry for <var title="">entry</var> in the list with an entry for <var title="">new element</var>.</li> <li>If the entry for <var title="">new element</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> is not the last entry in the list, return to step 7.</li> </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>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 8 to 11 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>Let <var title="">entry</var> be the last (most recently added) entry in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li>Remove <var title="">entry</var> from the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li>If <var title="">entry</var> was a marker, then stop the algorithm at this point. The list has been cleared up to the last marker.</li> <li>Go to step 1.</li> </ol><h5 id=the-element-pointers><span class=secno>13.2.3.4 </span>The element pointers</h5> <p>Initially, the <dfn id=head-element-pointer><code title="">head</code> element pointer</dfn> and the <dfn id=form-element-pointer><code title="">form</code> element pointer</dfn> are both null.</p> <p>Once a <code><a href=#the-head-element>head</a></code> element has been parsed (whether implicitly or explicitly) the <a href=#head-element-pointer><code title="">head</code> element pointer</a> gets set to point to this node.</p> <p>The <a href=#form-element-pointer><code title="">form</code> element pointer</a> points to the last <code><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.</p> <h5 id=other-parsing-state-flags><span class=secno>13.2.3.5 </span>Other parsing state flags</h5> <p>The <dfn id=scripting-flag>scripting flag</dfn> is set to "enabled" if <a href=#concept-n-script title=concept-n-script>scripting was enabled</a> for the <code><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>scripting flag</a> can be enabled even when the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, even though <code><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> </div> <div class=impl> <h4 id=tokenization><span class=secno>13.2.4 </span><dfn>Tokenization</dfn></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>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 <em>reconsume</em> the same character, or switches it to a new state (to consume the next character), or repeats 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>The exact behavior of certain states depends on the <a href=#insertion-mode>insertion mode</a> and the <a href=#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.</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 <i>force-quirks flag</i>. 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>force-quirks flag</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 <i>self-closing flag</i>, 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>self-closing flag</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>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><a href=#the-script-element>script</a></code> element can result in scripts executing and using the <a href=#dynamic-markup-insertion>dynamic markup insertion</a> APIs to insert characters into the stream being tokenized.)</p> <p>When a start tag token is emitted with its <i>self-closing flag</i> set, if the flag is not <dfn id=acknowledge-self-closing-flag title="acknowledge self-closing flag">acknowledged</dfn> when it is processed by the tree construction stage, that is a <a href=#parse-error>parse error</a>.</p> <p>When an end tag token is emitted with attributes, that is a <a href=#parse-error>parse error</a>.</p> <p>When an end tag token is emitted with its <i>self-closing flag</i> set, that is a <a href=#parse-error>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>Before each step of the tokenizer, the user agent must first check the <a href=#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> <!-- Order of the lists below is supposed to be non-error then error, by unicode, then EOF, ending with "anything else" --> <h5 id=data-state><span class=secno>13.2.4.1 </span><dfn>Data state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#character-reference-in-data-state>character reference in data state</a>.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#tag-open-state>tag open state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>EOF</dt> <dd>Emit an end-of-file token.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=character-reference-in-data-state><span class=secno>13.2.4.2 </span><dfn>Character reference in data state</dfn></h5> <p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>, with no <a href=#additional-allowed-character>additional allowed character</a>.</p> <p>If nothing is returned, emit a U+0026 AMPERSAND character (&) token.</p> <p>Otherwise, emit the character tokens that were returned.</p> <p>Finally, switch to the <a href=#data-state>data state</a>.</p> <h5 id=rcdata-state><span class=secno>13.2.4.3 </span><dfn>RCDATA state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#character-reference-in-rcdata-state>character reference in RCDATA state</a>.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#rcdata-less-than-sign-state>RCDATA less-than sign state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd>Emit an end-of-file token.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=character-reference-in-rcdata-state><span class=secno>13.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5> <p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>, with no <a href=#additional-allowed-character>additional allowed character</a>.</p> <p>If nothing is returned, emit a U+0026 AMPERSAND character (&) token.</p> <p>Otherwise, emit the character tokens that were returned.</p> <p>Finally, switch to the <a href=#rcdata-state>RCDATA state</a>.</p> <h5 id=rawtext-state><span class=secno>13.2.4.5 </span><dfn>RAWTEXT state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#rawtext-less-than-sign-state>RAWTEXT less-than sign state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd>Emit an end-of-file token.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-state><span class=secno>13.2.4.6 </span><dfn>Script data state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-less-than-sign-state>script data less-than sign state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd>Emit an end-of-file token.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=plaintext-state><span class=secno>13.2.4.7 </span><dfn>PLAINTEXT state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd>Emit an end-of-file token.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=tag-open-state><span class=secno>13.2.4.8 </span><dfn>Tag open state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0021 EXCLAMATION MARK (!)</dt> <dd>Switch to the <a href=#markup-declaration-open-state>markup declaration open state</a>.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#end-tag-open-state>end tag open state</a>.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new start tag token, set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point), then switch to the <a href=#tag-name-state>tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new start tag token, set its tag name to the <a href=#current-input-character>current input character</a>, then switch to the <a href=#tag-name-state>tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+003F QUESTION MARK (?)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#bogus-comment-state>bogus comment state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+003C LESS-THAN SIGN character token and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#data-state>data state</a>.</dd> </dl><h5 id=end-tag-open-state><span class=secno>13.2.4.9 </span><dfn>End tag open state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new end tag token, set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point), then switch to the <a href=#tag-name-state>tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new end tag token, set its tag name to the <a href=#current-input-character>current input character</a>, then switch to the <a href=#tag-name-state>tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#data-state>data state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#bogus-comment-state>bogus comment state</a>.</dd> </dl><h5 id=tag-name-state><span class=secno>13.2.4.10 </span><dfn>Tag name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-attribute-name-state>before attribute name state</a>.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the current tag token's tag name.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current tag token's tag name.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current tag token's tag name.</dd> </dl><h5 id=rcdata-less-than-sign-state><span class=secno>13.2.4.11 </span><dfn>RCDATA less-than sign state</dfn></h5> <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002F SOLIDUS (/)</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to the <a href=#rcdata-end-tag-open-state>RCDATA end tag open state</a>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rcdata-state>RCDATA state</a>.</dd> </dl><h5 id=rcdata-end-tag-open-state><span class=secno>13.2.4.12 </span><dfn>RCDATA end tag open state</dfn></h5> <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point). Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#rcdata-end-tag-name-state>RCDATA end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the <a href=#current-input-character>current input character</a>. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#rcdata-end-tag-name-state>RCDATA end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rcdata-state>RCDATA state</a>.</dd> </dl><h5 id=rcdata-end-tag-name-state><span class=secno>13.2.4.13 </span><dfn>RCDATA end tag name state</dfn></h5> <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then emit the current tag token and switch to the <a href=#data-state>data state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#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>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current tag token's tag name. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, a character token for each of the characters in the <var><a href=#temporary-buffer>temporary buffer</a></var> (in the order they were added to the buffer), and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rcdata-state>RCDATA state</a>.</dd> </dl><h5 id=rawtext-less-than-sign-state><span class=secno>13.2.4.14 </span><dfn>RAWTEXT less-than sign state</dfn></h5> <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002F SOLIDUS (/)</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to the <a href=#rawtext-end-tag-open-state>RAWTEXT end tag open state</a>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rawtext-state>RAWTEXT state</a>.</dd> </dl><h5 id=rawtext-end-tag-open-state><span class=secno>13.2.4.15 </span><dfn>RAWTEXT end tag open state</dfn></h5> <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point). Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#rawtext-end-tag-name-state>RAWTEXT end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the <a href=#current-input-character>current input character</a>. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#rawtext-end-tag-name-state>RAWTEXT end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rawtext-state>RAWTEXT state</a>.</dd> </dl><h5 id=rawtext-end-tag-name-state><span class=secno>13.2.4.16 </span><dfn>RAWTEXT end tag name state</dfn></h5> <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then emit the current tag token and switch to the <a href=#data-state>data state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#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>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current tag token's tag name. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, a character token for each of the characters in the <var><a href=#temporary-buffer>temporary buffer</a></var> (in the order they were added to the buffer), and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#rawtext-state>RAWTEXT state</a>.</dd> </dl><h5 id=script-data-less-than-sign-state><span class=secno>13.2.4.17 </span><dfn>Script data less-than sign state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002F SOLIDUS (/)</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to the <a href=#script-data-end-tag-open-state>script data end tag open state</a>.</dd> <dt>U+0021 EXCLAMATION MARK (!)</dt> <dd>Switch to the <a href=#script-data-escape-start-state>script data escape start state</a>. Emit a U+003C LESS-THAN SIGN character token and a U+0021 EXCLAMATION MARK character token.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data state</a>.</dd> </dl><h5 id=script-data-end-tag-open-state><span class=secno>13.2.4.18 </span><dfn>Script data end tag open state</dfn></h5> <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point). Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#script-data-end-tag-name-state>script data end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the <a href=#current-input-character>current input character</a>. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#script-data-end-tag-name-state>script data end tag name state</a>. (Don't emit the token yet; further details will be filled in before it is emitted.)</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data state</a>.</dd> </dl><h5 id=script-data-end-tag-name-state><span class=secno>13.2.4.19 </span><dfn>Script data end tag name state</dfn></h5> <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g --> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then emit the current tag token and switch to the <a href=#data-state>data state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#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>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current tag token's tag name. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, a character token for each of the characters in the <var><a href=#temporary-buffer>temporary buffer</a></var> (in the order they were added to the buffer), and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data state</a>.</dd> </dl><h5 id=script-data-escape-start-state><span class=secno>13.2.4.20 </span><dfn>Script data escape start state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-escape-start-dash-state>script data escape start dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>Anything else</dt> <dd>Reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data state</a>.</dd> </dl><h5 id=script-data-escape-start-dash-state><span class=secno>13.2.4.21 </span><dfn>Script data escape start dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-escaped-dash-dash-state>script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>Anything else</dt> <dd>Reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data state</a>.</dd> </dl><h5 id=script-data-escaped-state><span class=secno>13.2.4.22 </span><dfn>Script data escaped state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-escaped-dash-state>script data escaped dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-escaped-dash-state><span class=secno>13.2.4.23 </span><dfn>Script data escaped dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-escaped-dash-dash-state>script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-escaped-dash-dash-state><span class=secno>13.2.4.24 </span><dfn>Script data escaped dash dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#script-data-state>script data state</a>. Emit a U+003E GREATER-THAN SIGN character token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-escaped-less-than-sign-state><span class=secno>13.2.4.25 </span><dfn>Script data escaped less-than sign state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002F SOLIDUS (/)</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to the <a href=#script-data-escaped-end-tag-open-state>script data escaped end tag open state</a>.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Switch to the <a href=#script-data-double-escape-start-state>script data double escape start state</a>. Emit a U+003C LESS-THAN SIGN character token and the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Switch to the <a href=#script-data-double-escape-start-state>script data double escape start state</a>. Emit a U+003C LESS-THAN SIGN character token and the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd> </dl><h5 id=script-data-escaped-end-tag-open-state><span class=secno>13.2.4.26 </span><dfn>Script data escaped end tag open state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point). Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#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.)</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Create a new end tag token, and set its tag name to the <a href=#current-input-character>current input character</a>. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Finally, switch to the <a href=#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.)</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd> </dl><h5 id=script-data-escaped-end-tag-name-state><span class=secno>13.2.4.27 </span><dfn>Script data escaped end tag name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the current end tag token is an <a href=#appropriate-end-tag-token>appropriate end tag token</a>, then emit the current tag token and switch to the <a href=#data-state>data state</a>. Otherwise, treat it as per the "anything else" entry below.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#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>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current tag token's tag name. Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>.</dd> <dt>Anything else</dt> <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, a character token for each of the characters in the <var><a href=#temporary-buffer>temporary buffer</a></var> (in the order they were added to the buffer), and reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd> </dl><h5 id=script-data-double-escape-start-state><span class=secno>13.2.4.28 </span><dfn>Script data double escape start state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dt>U+002F SOLIDUS (/)</dt> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the <var><a href=#temporary-buffer>temporary buffer</a></var> is the string "<code title="">script</code>", then switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Otherwise, switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>Anything else</dt> <dd>Reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd> </dl><h5 id=script-data-double-escaped-state><span class=secno>13.2.4.29 </span><dfn>Script data double escaped state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-double-escaped-dash-state>script data double escaped dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C LESS-THAN SIGN character token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-double-escaped-dash-state><span class=secno>13.2.4.30 </span><dfn>Script data double escaped dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#script-data-double-escaped-dash-dash-state>script data double escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C LESS-THAN SIGN character token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-double-escaped-dash-dash-state><span class=secno>13.2.4.31 </span><dfn>Script data double escaped dash dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Emit a U+002D HYPHEN-MINUS character token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C LESS-THAN SIGN character token.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#script-data-state>script data state</a>. Emit a U+003E GREATER-THAN SIGN character token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> </dl><h5 id=script-data-double-escaped-less-than-sign-state><span class=secno>13.2.4.32 </span><dfn>Script data double escaped less-than sign state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002F SOLIDUS (/)</dt> <dd>Set the <var><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to the <a href=#script-data-double-escape-end-state>script data double escape end state</a>. Emit a U+002F SOLIDUS character token.</dd> <dt>Anything else</dt> <dd>Reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-double-escaped-state>script data double escaped state</a>.</dd> </dl><h5 id=script-data-double-escape-end-state><span class=secno>13.2.4.33 </span><dfn>Script data double escape end state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dt>U+002F SOLIDUS (/)</dt> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>If the <var><a href=#temporary-buffer>temporary buffer</a></var> is the string "<code title="">script</code>", then switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Otherwise, switch to the <a href=#script-data-double-escaped-state>script data double escaped state</a>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the <var><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character>current input character</a> as a character token.</dd> <dt>Anything else</dt> <dd>Reconsume the <a href=#current-input-character>current input character</a> in the <a href=#script-data-double-escaped-state>script data double escaped state</a>.</dd> </dl><h5 id=before-attribute-name-state><span class=secno>13.2.4.34 </span><dfn>Before attribute name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Start a new attribute in the current tag token. Set that attribute's name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point), and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Start a new attribute in the current tag token. Set that attribute's name to a U+FFFD REPLACEMENT CHARACTER character, and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dt>U+0027 APOSTROPHE (')</dt> <dt>U+003C LESS-THAN SIGN (<)</dt> <dt>U+003D EQUALS SIGN (=)</dt> <dd><a href=#parse-error>Parse error</a>. Treat it as per the "anything else" entry below.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Start a new attribute in the current tag token. Set that attribute's name to the <a href=#current-input-character>current input character</a>, and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> </dl><h5 id=attribute-name-state><span class=secno>13.2.4.35 </span><dfn>Attribute name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#after-attribute-name-state>after attribute name state</a>.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>.</dd> <dt>U+003D EQUALS SIGN (=)</dt> <dd>Switch to the <a href=#before-attribute-value-state>before attribute value state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the current attribute's name.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's name.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dt>U+0027 APOSTROPHE (')</dt> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd><a href=#parse-error>Parse error</a>. Treat it as per the "anything else" entry below.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current attribute's name.</dd> </dl><p>When the user agent leaves the attribute name state (and before emitting the tag token, if appropriate), the complete attribute's name must be compared to the other attributes on the same token; if there is already an attribute on the token with the exact same name, then this is a <a href=#parse-error>parse error</a> and the new attribute must be dropped, along with the value that gets associated with it (if any).</p> <h5 id=after-attribute-name-state><span class=secno>13.2.4.36 </span><dfn>After attribute name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>.</dd> <dt>U+003D EQUALS SIGN (=)</dt> <dd>Switch to the <a href=#before-attribute-value-state>before attribute value state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Start a new attribute in the current tag token. Set that attribute's name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point), and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Start a new attribute in the current tag token. Set that attribute's name to a U+FFFD REPLACEMENT CHARACTER character, and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dt>U+0027 APOSTROPHE (')</dt> <dt>U+003C LESS-THAN SIGN (<)</dt> <dd><a href=#parse-error>Parse error</a>. Treat it as per the "anything else" entry below.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Start a new attribute in the current tag token. Set that attribute's name to the <a href=#current-input-character>current input character</a>, and its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name state</a>.</dd> </dl><h5 id=before-attribute-value-state><span class=secno>13.2.4.37 </span><dfn>Before attribute value state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dd>Switch to the <a href=#attribute-value-(double-quoted)-state>attribute value (double-quoted) state</a>.</dd> <dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#attribute-value-(unquoted)-state>attribute value (unquoted) state</a> and reconsume this <a href=#current-input-character>current input character</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <dd>Switch to the <a href=#attribute-value-(single-quoted)-state>attribute value (single-quoted) state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's value. Switch to the <a href=#attribute-value-(unquoted)-state>attribute value (unquoted) state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+003C LESS-THAN SIGN (<)</dt> <dt>U+003D EQUALS SIGN (=)</dt> <dt>U+0060 GRAVE ACCENT (`)</dt> <dd><a href=#parse-error>Parse error</a>. Treat it as per the "anything else" entry below.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current attribute's value. Switch to the <a href=#attribute-value-(unquoted)-state>attribute value (unquoted) state</a>.</dd> </dl><h5 id=attribute-value-(double-quoted)-state><span class=secno>13.2.4.38 </span><dfn>Attribute value (double-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0022 QUOTATION MARK (")</dt> <dd>Switch to the <a href=#after-attribute-value-(quoted)-state>after attribute value (quoted) state</a>.</dd> <dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#character-reference-in-attribute-value-state>character reference in attribute value state</a>, with the <a href=#additional-allowed-character>additional allowed character</a> being U+0022 QUOTATION MARK (").</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's value.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current attribute's value.</dd> </dl><h5 id=attribute-value-(single-quoted)-state><span class=secno>13.2.4.39 </span><dfn>Attribute value (single-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0027 APOSTROPHE (')</dt> <dd>Switch to the <a href=#after-attribute-value-(quoted)-state>after attribute value (quoted) state</a>.</dd> <dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#character-reference-in-attribute-value-state>character reference in attribute value state</a>, with the <a href=#additional-allowed-character>additional allowed character</a> being U+0027 APOSTROPHE (').</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's value.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current attribute's value.</dd> </dl><h5 id=attribute-value-(unquoted)-state><span class=secno>13.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-attribute-name-state>before attribute name state</a>.</dd> <dt>U+0026 AMPERSAND (&)</dt> <dd>Switch to the <a href=#character-reference-in-attribute-value-state>character reference in attribute value state</a>, with the <a href=#additional-allowed-character>additional allowed character</a> being U+003E GREATER-THAN SIGN (>).</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's value.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dt>U+0027 APOSTROPHE (')</dt> <dt>U+003C LESS-THAN SIGN (<)</dt> <dt>U+003D EQUALS SIGN (=)</dt> <dt>U+0060 GRAVE ACCENT (`)</dt> <dd><a href=#parse-error>Parse error</a>. Treat it as per the "anything else" entry below.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current attribute's value.</dd> </dl><h5 id=character-reference-in-attribute-value-state><span class=secno>13.2.4.41 </span><dfn>Character reference in attribute value state</dfn></h5> <p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>.</p> <p>If nothing is returned, append a U+0026 AMPERSAND character (&) to the current attribute's value.</p> <p>Otherwise, append the returned character tokens to the current attribute's value.</p> <p>Finally, switch back to the attribute value state that switched into this state.</p> <h5 id=after-attribute-value-(quoted)-state><span class=secno>13.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-attribute-name-state>before attribute name state</a>.</dd> <dt>U+002F SOLIDUS (/)</dt> <dd>Switch to the <a href=#self-closing-start-tag-state>self-closing start tag state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the character in the <a href=#before-attribute-name-state>before attribute name state</a>.</dd> </dl><h5 id=self-closing-start-tag-state><span class=secno>13.2.4.43 </span><dfn>Self-closing start tag state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Set the <i>self-closing flag</i> of the current tag token. Switch to the <a href=#data-state>data state</a>. Emit the current tag token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the character in the <a href=#before-attribute-name-state>before attribute name state</a>.</dd> </dl><h5 id=bogus-comment-state><span class=secno>13.2.4.44 </span><dfn>Bogus comment state</dfn></h5> <p>Consume every character up to and including the first U+003E GREATER-THAN SIGN character (>) or the end of the file (EOF), whichever comes first. Emit a comment token whose data is the concatenation of all the characters starting from and including the character that caused the state machine to switch into the bogus comment state, up to and including the character immediately before the last consumed character (i.e. up to the character just before the U+003E or EOF character), but with any U+0000 NULL characters replaced by U+FFFD REPLACEMENT CHARACTER characters. (If the comment was started by the end of the file (EOF), the token is empty.)</p> <p>Switch to the <a href=#data-state>data state</a>.</p> <p>If the end of the file was reached, reconsume the EOF character.</p> <h5 id=markup-declaration-open-state><span class=secno>13.2.4.45 </span><dfn>Markup declaration open state</dfn></h5> <p>If the next two characters are both U+002D HYPHEN-MINUS characters (-), consume those two characters, create a comment token whose data is the empty string, and switch to the <a href=#comment-start-state>comment start state</a>.</p> <p>Otherwise, if the next seven characters are an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the word "DOCTYPE", then consume those characters and switch to the <a href=#doctype-state>DOCTYPE state</a>.</p> <p>Otherwise, if there is a <a href=#current-node>current node</a> and it is not an element in the <a href=#html-namespace-0>HTML namespace</a> and the next seven characters are a <a href=#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), then consume those characters and switch to the <a href=#cdata-section-state>CDATA section state</a>.</p> <p>Otherwise, this is a <a href=#parse-error>parse error</a>. Switch to the <a href=#bogus-comment-state>bogus comment state</a>. The next character that is consumed, if any, is the first character that will be in the comment.</p> <h5 id=comment-start-state><span class=secno>13.2.4.46 </span><dfn>Comment start state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#comment-start-dash-state>comment start dash state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#data-state>data state</a>. Emit the comment token.</dd> <!-- see comment in comment end state --> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> </dl><h5 id=comment-start-dash-state><span class=secno>13.2.4.47 </span><dfn>Comment start dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#comment-end-state>comment end state</a></dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+002D HYPHEN-MINUS character (-) and a U+FFFD REPLACEMENT CHARACTER character to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#data-state>data state</a>. Emit the comment token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <!-- see comment in comment end state --> <dt>Anything else</dt> <dd>Append a U+002D HYPHEN-MINUS character (-) and the <a href=#current-input-character>current input character</a> to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> </dl><h5 id=comment-state><span class=secno>13.2.4.48 </span><dfn id=comment>Comment state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#comment-end-dash-state>comment end dash state</a></dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <!-- see comment in comment end state --> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the comment token's data.</dd> </dl><h5 id=comment-end-dash-state><span class=secno>13.2.4.49 </span><dfn>Comment end dash state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Switch to the <a href=#comment-end-state>comment end state</a></dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+002D HYPHEN-MINUS character (-) and a U+FFFD REPLACEMENT CHARACTER character to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <!-- see comment in comment end state --> <dt>Anything else</dt> <dd>Append a U+002D HYPHEN-MINUS character (-) and the <a href=#current-input-character>current input character</a> to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> </dl><h5 id=comment-end-state><span class=secno>13.2.4.50 </span><dfn>Comment end state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the comment token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append two U+002D HYPHEN-MINUS characters (-) and a U+FFFD REPLACEMENT CHARACTER character to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> <dt>U+0021 EXCLAMATION MARK (!)</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#comment-end-bang-state>comment end bang state</a>.</dd> <dt>U+002D HYPHEN-MINUS (-)</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <!-- For security reasons: otherwise, hostile user could put a <script> in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't read, and then the commented <script> tag would be treated as live code --> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Append two U+002D HYPHEN-MINUS characters (-) and the <a href=#current-input-character>current input character</a> to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> </dl><h5 id=comment-end-bang-state><span class=secno>13.2.4.51 </span><dfn>Comment end bang state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+002D HYPHEN-MINUS (-)</dt> <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to the comment token's data. Switch to the <a href=#comment-end-dash-state>comment end dash state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the comment token.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append two U+002D HYPHEN-MINUS characters (-), a U+0021 EXCLAMATION MARK character (!), and a U+FFFD REPLACEMENT CHARACTER character to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Emit the comment token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <!-- see comment in comment end state --> <dt>Anything else</dt> <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021 EXCLAMATION MARK character (!), and the <a href=#current-input-character>current input character</a> to the comment token's data. Switch to the <a href=#comment-state>comment state</a>.</dd> </dl><h5 id=doctype-state><span class=secno>13.2.4.52 </span><dfn>DOCTYPE state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-doctype-name-state>before DOCTYPE name state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Create a new DOCTYPE token. Set its <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Reconsume the character in the <a href=#before-doctype-name-state>before DOCTYPE name state</a>.</dd> </dl><h5 id=before-doctype-name-state><span class=secno>13.2.4.53 </span><dfn>Before DOCTYPE name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Create a new DOCTYPE token. Set the token's name to the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point). Switch to the <a href=#doctype-name-state>DOCTYPE name state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>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>DOCTYPE name state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Create a new DOCTYPE token. Set its <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit the token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Create a new DOCTYPE token. Set its <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Create a new DOCTYPE token. Set the token's name to the <a href=#current-input-character>current input character</a>. Switch to the <a href=#doctype-name-state>DOCTYPE name state</a>.</dd> </dl><h5 id=doctype-name-state><span class=secno>13.2.4.54 </span><dfn>DOCTYPE name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#after-doctype-name-state>after DOCTYPE name state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current DOCTYPE token.</dd> <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt> <dd>Append the lowercase version of the <a href=#current-input-character>current input character</a> (add 0x0020 to the character's code point) to the current DOCTYPE token's name.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's name.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current DOCTYPE token's name.</dd> </dl><h5 id=after-doctype-name-state><span class=secno>13.2.4.55 </span><dfn>After DOCTYPE name state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd> <p>If the six characters starting from the <a href=#current-input-character>current input character</a> are an <a href=#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>after DOCTYPE public keyword state</a>.</p> <p>Otherwise, if the six characters starting from the <a href=#current-input-character>current input character</a> are an <a href=#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>after DOCTYPE system keyword state</a>.</p> <p>Otherwise, this is the <a href=#parse-error>parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</p> </dd> </dl><h5 id=after-doctype-public-keyword-state><span class=secno>13.2.4.56 </span><dfn>After DOCTYPE public keyword state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-doctype-public-identifier-state>before DOCTYPE public identifier state</a>.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dd><a href=#parse-error>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>DOCTYPE public identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <dd><a href=#parse-error>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>DOCTYPE public identifier (single-quoted) state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=before-doctype-public-identifier-state><span class=secno>13.2.4.57 </span><dfn>Before DOCTYPE public identifier state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <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>DOCTYPE public identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <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>DOCTYPE public identifier (single-quoted) state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=doctype-public-identifier-(double-quoted)-state><span class=secno>13.2.4.58 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0022 QUOTATION MARK (")</dt> <dd>Switch to the <a href=#after-doctype-public-identifier-state>after DOCTYPE public identifier state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's public identifier.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current DOCTYPE token's public identifier.</dd> </dl><h5 id=doctype-public-identifier-(single-quoted)-state><span class=secno>13.2.4.59 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0027 APOSTROPHE (')</dt> <dd>Switch to the <a href=#after-doctype-public-identifier-state>after DOCTYPE public identifier state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's public identifier.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current DOCTYPE token's public identifier.</dd> </dl><h5 id=after-doctype-public-identifier-state><span class=secno>13.2.4.60 </span><dfn>After DOCTYPE public identifier state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#between-doctype-public-and-system-identifiers-state>between DOCTYPE public and system identifiers state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current DOCTYPE token.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dd><a href=#parse-error>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>DOCTYPE system identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <dd><a href=#parse-error>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>DOCTYPE system identifier (single-quoted) state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=between-doctype-public-and-system-identifiers-state><span class=secno>13.2.4.61 </span><dfn>Between DOCTYPE public and system identifiers state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current DOCTYPE token.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <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>DOCTYPE system identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <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>DOCTYPE system identifier (single-quoted) state</a>.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=after-doctype-system-keyword-state><span class=secno>13.2.4.62 </span><dfn>After DOCTYPE system keyword state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Switch to the <a href=#before-doctype-system-identifier-state>before DOCTYPE system identifier state</a>.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <dd><a href=#parse-error>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>DOCTYPE system identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <dd><a href=#parse-error>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>DOCTYPE system identifier (single-quoted) state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=before-doctype-system-identifier-state><span class=secno>13.2.4.63 </span><dfn>Before DOCTYPE system identifier state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+0022 QUOTATION MARK (")</dt> <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>DOCTYPE system identifier (double-quoted) state</a>.</dd> <dt>U+0027 APOSTROPHE (')</dt> <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>DOCTYPE system identifier (single-quoted) state</a>.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>.</dd> </dl><h5 id=doctype-system-identifier-(double-quoted)-state><span class=secno>13.2.4.64 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0022 QUOTATION MARK (")</dt> <dd>Switch to the <a href=#after-doctype-system-identifier-state>after DOCTYPE system identifier state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's system identifier.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current DOCTYPE token's system identifier.</dd> </dl><h5 id=doctype-system-identifier-(single-quoted)-state><span class=secno>13.2.4.65 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0027 APOSTROPHE (')</dt> <dd>Switch to the <a href=#after-doctype-system-identifier-state>after DOCTYPE system identifier state</a>.</dd> <dt>U+0000 NULL</dt> <dd><a href=#parse-error>Parse error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's system identifier.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#data-state>data state</a>. Emit that DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Append the <a href=#current-input-character>current input character</a> to the current DOCTYPE token's system identifier.</dd> </dl><h5 id=after-doctype-system-identifier-state><span class=secno>13.2.4.66 </span><dfn>After DOCTYPE system identifier state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dd>Ignore the character.</dd> <dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the current DOCTYPE token.</dd> <dt>EOF</dt> <dd><a href=#parse-error>Parse error</a>. Set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#bogus-doctype-state>bogus DOCTYPE state</a>. (This does <em>not</em> set the DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>.)</dd> </dl><h5 id=bogus-doctype-state><span class=secno>13.2.4.67 </span><dfn>Bogus DOCTYPE state</dfn></h5> <p>Consume the <a href=#next-input-character>next input character</a>:</p> <dl class=switch><dt>U+003E GREATER-THAN SIGN (>)</dt> <dd>Switch to the <a href=#data-state>data state</a>. Emit the DOCTYPE token.</dd> <dt>EOF</dt> <dd>Emit the DOCTYPE token. Reconsume the EOF character in the <a href=#data-state>data state</a>.</dd> <dt>Anything else</dt> <dd>Ignore the character.</dd> </dl><h5 id=cdata-section-state><span class=secno>13.2.4.68 </span><dfn>CDATA section state</dfn></h5> <p>Consume every character up to the next occurrence of the three character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the end of the file (EOF), whichever comes first. Emit a series of character tokens consisting of all the characters consumed except the matching three character sequence at the end (if one was found before the end of the file)<!--(not needed; taken care of by the tree constructor), but with any U+0000 NULL characters replaced by U+FFFD REPLACEMENT CHARACTER characters-->.</p> <p>Switch to the <a href=#data-state>data state</a>.</p> <p>If the end of the file was reached, reconsume the EOF character.</p> <h5 id=tokenizing-character-references><span class=secno>13.2.4.69 </span>Tokenizing character references</h5> <p>This section defines how to <dfn id=consume-a-character-reference>consume a character reference</dfn>. This definition is used when parsing character references <a href=#character-reference-in-data-state title="character reference in data state">in text</a> and <a href=#character-reference-in-attribute-value-state title="character reference in attribute value state">in attributes</a>.</p> <p>The behavior depends on the identity of the next character (the one immediately after the U+0026 AMPERSAND character):</p> <dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)</dt> <dt>U+000A LINE FEED (LF)</dt> <dt>U+000C FORM FEED (FF)</dt> <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>--> <dt>U+0020 SPACE</dt> <dt>U+003C LESS-THAN SIGN</dt> <dt>U+0026 AMPERSAND</dt> <dt>EOF</dt> <dt>The <dfn id=additional-allowed-character>additional allowed character</dfn>, if there is one</dt> <dd>Not a character reference. No characters are consumed, and nothing is returned. (This is not an error, either.)</dd> <dt>U+0023 NUMBER SIGN (#)</dt> <dd> <p>Consume the U+0023 NUMBER SIGN.</p> <p>The behavior further depends on the character after the U+0023 NUMBER SIGN:</p> <dl class=switch><dt>U+0078 LATIN SMALL LETTER X</dt> <dt>U+0058 LATIN CAPITAL LETTER X</dt> <dd> <p>Consume the X.</p> <p>Follow the steps below, but using the range of characters U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other words, 0-9, A-F, a-f).</p> <p>When it comes to interpreting the number, interpret it as a hexadecimal number.</p> </dd> <dt>Anything else</dt> <dd> <p>Follow the steps below, but using the range of characters U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p> <p>When it comes to interpreting the number, interpret it as a decimal number.</p> </dd> </dl><p>Consume as many characters as match the range of characters given above.</p> <p>If no characters match the range, then don't consume any characters (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, the X character). This is a <a href=#parse-error>parse error</a>; nothing is returned.</p> <p>Otherwise, if the next character is a U+003B SEMICOLON, consume that too. If it isn't, there is a <a href=#parse-error>parse error</a>.</p> <p>If one or more characters match the range, then take them all and interpret the string of characters as a number (either hexadecimal or decimal as appropriate).</p> <p>If that number is one of the numbers in the first column of the following table, then this is a <a href=#parse-error>parse error</a>. Find the row with that number in the first column, and return a character token for the Unicode character given in the second column of that row.</p> <table id=table-charref-overrides><thead><tr><th>Number <th colspan=2>Unicode character <tbody><tr><td>0x00 <td>U+FFFD <td>REPLACEMENT CHARACTER <tr><td>0x0D <td>U+000D <td>CARRIAGE RETURN (CR) <tr><td>0x80 <td>U+20AC <td>EURO SIGN (€) <tr><td>0x81 <td>U+0081 <td><control> <tr><td>0x82 <td>U+201A <td>SINGLE LOW-9 QUOTATION MARK (‚) <tr><td>0x83 <td>U+0192 <td>LATIN SMALL LETTER F WITH HOOK (ƒ) <tr><td>0x84 <td>U+201E <td>DOUBLE LOW-9 QUOTATION MARK („) <tr><td>0x85 <td>U+2026 <td>HORIZONTAL ELLIPSIS (…) <tr><td>0x86 <td>U+2020 <td>DAGGER (†) <tr><td>0x87 <td>U+2021 <td>DOUBLE DAGGER (‡) <tr><td>0x88 <td>U+02C6 <td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ) <tr><td>0x89 <td>U+2030 <td>PER MILLE SIGN (‰) <tr><td>0x8A <td>U+0160 <td>LATIN CAPITAL LETTER S WITH CARON (Š) <tr><td>0x8B <td>U+2039 <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹) <tr><td>0x8C <td>U+0152 <td>LATIN CAPITAL LIGATURE OE (Œ) <tr><td>0x8D <td>U+008D <td><control> <tr><td>0x8E <td>U+017D <td>LATIN CAPITAL LETTER Z WITH CARON (Ž) <tr><td>0x8F <td>U+008F <td><control> <tr><td>0x90 <td>U+0090 <td><control> <tr><td>0x91 <td>U+2018 <td>LEFT SINGLE QUOTATION MARK (‘) <tr><td>0x92 <td>U+2019 <td>RIGHT SINGLE QUOTATION MARK (’) <tr><td>0x93 <td>U+201C <td>LEFT DOUBLE QUOTATION MARK (“) <tr><td>0x94 <td>U+201D <td>RIGHT DOUBLE QUOTATION MARK (”) <tr><td>0x95 <td>U+2022 <td>BULLET (•) <tr><td>0x96 <td>U+2013 <td>EN DASH (–) <tr><td>0x97 <td>U+2014 <td>EM DASH (—) <tr><td>0x98 <td>U+02DC <td>SMALL TILDE (˜) <tr><td>0x99 <td>U+2122 <td>TRADE MARK SIGN (™) <tr><td>0x9A <td>U+0161 <td>LATIN SMALL LETTER S WITH CARON (š) <tr><td>0x9B <td>U+203A <td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›) <tr><td>0x9C <td>U+0153 <td>LATIN SMALL LIGATURE OE (œ) <tr><td>0x9D <td>U+009D <td><control> <tr><td>0x9E <td>U+017E <td>LATIN SMALL LETTER Z WITH CARON (ž) <tr><td>0x9F <td>U+0178 <td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ) </table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!-- surrogates --> or is greater than 0x10FFFF, then this is a <a href=#parse-error>parse error</a>. Return a U+FFFD REPLACEMENT CHARACTER.</p> <p>Otherwise, return a character token for the Unicode character whose code point is that number. <!-- this is the same as the equivalent list in the input stream section --> If the number is in the range 0x0001 to 0x0008, <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF, CR allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, or 0x10FFFF, then this is a <a href=#parse-error>parse error</a>.</p> </dd> <dt>Anything else</dt> <dd> <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>named character references</a> table (in a <a href=#case-sensitive>case-sensitive</a> manner).</p> <p>If no match can be made, then no characters are consumed, and nothing is returned. In this case, if the characters after the U+0026 AMPERSAND character (&) consist of a sequence of one or more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, followed by a U+003B SEMICOLON character (;), then this is a <a href=#parse-error>parse error</a>.</p> <p>If the character reference is being consumed <a href=#character-reference-in-attribute-value-state title="character reference in attribute value state">as part of an attribute</a>, and the last character matched is not a U+003B SEMICOLON character (;), and the next character is either a U+003D EQUALS SIGN character (=) or in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for historical reasons, all the characters that were matched after the U+0026 AMPERSAND character (&) must be unconsumed, and nothing is returned.</p> <!-- "=" added because of http://www.w3.org/Bugs/Public/show_bug.cgi?id=9207#c5 --> <p>Otherwise, a character reference is parsed. If the last character matched is not a U+003B SEMICOLON character (;), there is a <a href=#parse-error>parse error</a>.</p> <p>Return one or two character tokens for the character(s) corresponding to the character reference name (as given by the second column of the <a href=#named-character-references>named character references</a> table).</p> <div class=example> <p>If the markup contains (not in an attribute) the string <code title="">I'm &notit; I tell you</code>, the character reference is parsed as "not", as in, <code title="">I'm ¬it; I tell you</code> (and this is a parse error). But if the markup was <code title="">I'm &notin; I tell you</code>, the character reference would be parsed as "notin;", resulting in <code title="">I'm ∉ I tell you</code> (and no parse error).</p> </div> </dd> </dl></div> <div class=impl> <!-- v2: One thing that this doesn't define is handling deeply nested documents. There are compatibility requirements around that: you can't throw away the elements altogether, consider Tux made only with opening <font> elements, one per character. Seems that the best thing to do is to close some formatting elements from the middle of the stack when you hit a limit, or something. --> <h4 id=tree-construction><span class=secno>13.2.5 </span><dfn>Tree construction</dfn></h4> <p>The input to the tree construction stage is a sequence of tokens from the <a href=#tokenization>tokenization</a> stage. The tree construction stage is associated with a DOM <code><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><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:</p> <dl class=switch><dt>If there is no <a href=#current-node>current node</a></dt> <dt>If the <a href=#current-node>current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt> <dt>If the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"</dt> <dt>If the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a character token</dt> <dt>If the <a href=#current-node>current node</a> is an <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> and the token is a start tag whose tag name is "svg"</dt> <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a start tag</dt> <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a character token</dt> <dt>If the token is an end-of-file token</dt> <dd>Process the token according to the rules given in the section corresponding to the current <a href=#insertion-mode>insertion mode</a> in HTML content.</dd> <dt>Otherwise</dt> <dd>Process the token according to the rules given in the section for parsing tokens <a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign content</a>.</dd> </dl><p>The <a href=#current-node>current node</a> 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>An <code title="">mi</code> element in the <a href=#mathml-namespace>MathML namespace</a></li> <li>An <code title="">mo</code> element in the <a href=#mathml-namespace>MathML namespace</a></li> <li>An <code title="">mn</code> element in the <a href=#mathml-namespace>MathML namespace</a></li> <li>An <code title="">ms</code> element in the <a href=#mathml-namespace>MathML namespace</a></li> <li>An <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a></li> </ul><p>The <a href=#current-node>current node</a> is an <dfn id=html-integration-point>HTML integration point</dfn> if it is one of the following elements:</p> <ul class=brief><li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/html</code>"</li> <li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">application/xhtml+xml</code>"</li> <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li> <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li> <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li> </ul><hr><p>When the steps below require the UA to <dfn id=insert-a-character>insert a character</dfn> into a node, if that node has a child immediately before where the character is to be inserted, and that child is a <code><a href=#text>Text</a></code> node, then the character must be appended to that <code><a href=#text>Text</a></code> node; otherwise, a new <code><a href=#text>Text</a></code> node whose data is just that character must be inserted in the appropriate place.</p> <div class=example> <p>Here are some sample inputs to the parser and the corresponding number of text nodes that they result in, assuming a user agent that executes scripts.</p> <table><thead><tr><th>Input <th>Number of text nodes <tbody><tr><td><pre>A<script> var script = document.getElementsByTagName('script')[0]; document.body.removeChild(script); </script>B</pre> <td>One text node in the document, containing "AB". <tr><td><pre>A<script> var text = document.createTextNode('B'); document.body.appendChild(text); </script>C</pre> <td>Three text nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the text node created by the script). <tr><td><pre>A<script> var text = document.getElementsByTagName('script')[0].firstChild; text.data = 'B'; document.body.appendChild(text); </script>C</pre> <td>Two adjacent text nodes in the document, containing "A" and "BC". <tr><td><pre>A<table>B<tr>C</tr>D</table></pre> <td>One text node before the table, containing "ABCD". (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.) <tr><td><pre>A<table><tr> B</tr> C</table></pre> <td>One text node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.) <tr><td><pre>A<table><tr> B</tr> </em>C</table></pre> <td>One text node before the table, containing "A BC" (A-space-B-C), and one text node inside the table (as a child of a <code><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 title="foster parent">foster parenting</a>, even if those other tokens then get ignored.) </table></div> <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA parsing the document. (Conceptually, the parser is not mutating the DOM, it is constructing it.) This includes the parsing of any content inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p> <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, text nodes, etc. While implementors 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-elements><span class=secno>13.2.5.1 </span>Creating and inserting elements</h5> <p>When the steps below require the UA to <dfn id=create-an-element-for-the-token title="create an element for the token">create an element for a token</dfn> in a particular namespace, the UA must create a node implementing the interface appropriate for the element type corresponding to the tag name of the token in the given namespace (as given in the specification that defines that element, e.g. for an <code><a href=#the-a-element>a</a></code> element in the <a href=#html-namespace-0>HTML namespace</a>, this specification defines it to be the <code><a href=#htmlanchorelement>HTMLAnchorElement</a></code> interface), with the tag name being the name of that element, with the node being in the given namespace, and with the attributes on the node being those given in the given token.</p> <p>The interface appropriate for an element in the <a href=#html-namespace-0>HTML namespace</a> that is not defined in this specification (or <a href=#other-applicable-specifications>other applicable specifications</a>) is <code><a href=#htmlunknownelement>HTMLUnknownElement</a></code>. Element in other namespaces whose interface is not defined by that namespace's specification must use the interface <code><a href=#element>Element</a></code>.</p> <p>When a <a href=#category-reset title=category-reset>resettable element</a> is created in this manner, its <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> must be invoked once the attributes are set. (This initializes the element's <a href=#concept-fe-value title=concept-fe-value>value</a> and <a href=#concept-fe-checked title=concept-fe-checked>checkedness</a> based on the element's attributes.)</p> <hr><p>When the steps below require the UA to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token, the UA must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>, and then append this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new <a href=#current-node>current node</a>.</p> <p>The steps below may also require that the UA insert an HTML element in a particular place, in which case the UA must follow the same steps except that it must insert or append the new node in the location specified instead of appending it to the <a href=#current-node>current node</a>. (This happens in particular during the parsing of tables with invalid content.)</p> <p>If an element created by the <a href=#insert-an-html-element>insert an HTML element</a> algorithm is a <a href=#form-associated-element>form-associated element</a>, and the <a href=#form-element-pointer><code title="">form</code> element pointer</a> is not null, and the newly created element doesn't have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute, the user agent must <a href=#concept-form-association title=concept-form-association>associate</a> the newly created element with the <code><a href=#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer><code title="">form</code> element pointer</a> when the element is inserted, instead of running the <a href=#reset-the-form-owner>reset the form owner</a> algorithm.</p> <hr><p>When the steps below require the UA to <dfn id=insert-a-foreign-element>insert a foreign element</dfn> for a token, the UA must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the given namespace, and then append this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new <a href=#current-node>current node</a>. If the newly created element has an <code title="">xmlns</code> attribute in the <a href=#xmlns-namespace>XMLNS namespace</a> whose value is not exactly the same as the element's namespace, that is a <a href=#parse-error>parse error</a>. Similarly, if the newly created element has an <code title="">xmlns:xlink</code> attribute in the <a href=#xmlns-namespace>XMLNS namespace</a> whose value is not the <a href=#xlink-namespace>XLink Namespace</a>, that is a <a href=#parse-error>parse error</a>.</p> <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 title="">definitionurl</code>, change its name to <code title="">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 title="">attributename</code> <td> <code title="">attributeName</code> <tr><td> <code title="">attributetype</code> <td> <code title="">attributeType</code> <tr><td> <code title="">basefrequency</code> <td> <code title="">baseFrequency</code> <tr><td> <code title="">baseprofile</code> <td> <code title="">baseProfile</code> <tr><td> <code title="">calcmode</code> <td> <code title="">calcMode</code> <tr><td> <code title="">clippathunits</code> <td> <code title="">clipPathUnits</code> <tr><td> <code title="">contentscripttype</code> <td> <code title="">contentScriptType</code> <tr><td> <code title="">contentstyletype</code> <td> <code title="">contentStyleType</code> <tr><td> <code title="">diffuseconstant</code> <td> <code title="">diffuseConstant</code> <tr><td> <code title="">edgemode</code> <td> <code title="">edgeMode</code> <tr><td> <code title="">externalresourcesrequired</code> <td> <code title="">externalResourcesRequired</code> <tr><td> <code title="">filterres</code> <td> <code title="">filterRes</code> <tr><td> <code title="">filterunits</code> <td> <code title="">filterUnits</code> <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code> <tr><td> <code title="">gradienttransform</code> <td> <code title="">gradientTransform</code> <tr><td> <code title="">gradientunits</code> <td> <code title="">gradientUnits</code> <tr><td> <code title="">kernelmatrix</code> <td> <code title="">kernelMatrix</code> <tr><td> <code title="">kernelunitlength</code> <td> <code title="">kernelUnitLength</code> <tr><td> <code title="">keypoints</code> <td> <code title="">keyPoints</code> <tr><td> <code title="">keysplines</code> <td> <code title="">keySplines</code> <tr><td> <code title="">keytimes</code> <td> <code title="">keyTimes</code> <tr><td> <code title="">lengthadjust</code> <td> <code title="">lengthAdjust</code> <tr><td> <code title="">limitingconeangle</code> <td> <code title="">limitingConeAngle</code> <tr><td> <code title="">markerheight</code> <td> <code title="">markerHeight</code> <tr><td> <code title="">markerunits</code> <td> <code title="">markerUnits</code> <tr><td> <code title="">markerwidth</code> <td> <code title="">markerWidth</code> <tr><td> <code title="">maskcontentunits</code> <td> <code title="">maskContentUnits</code> <tr><td> <code title="">maskunits</code> <td> <code title="">maskUnits</code> <tr><td> <code title="">numoctaves</code> <td> <code title="">numOctaves</code> <tr><td> <code title="">pathlength</code> <td> <code title="">pathLength</code> <tr><td> <code title="">patterncontentunits</code> <td> <code title="">patternContentUnits</code> <tr><td> <code title="">patterntransform</code> <td> <code title="">patternTransform</code> <tr><td> <code title="">patternunits</code> <td> <code title="">patternUnits</code> <tr><td> <code title="">pointsatx</code> <td> <code title="">pointsAtX</code> <tr><td> <code title="">pointsaty</code> <td> <code title="">pointsAtY</code> <tr><td> <code title="">pointsatz</code> <td> <code title="">pointsAtZ</code> <tr><td> <code title="">preservealpha</code> <td> <code title="">preserveAlpha</code> <tr><td> <code title="">preserveaspectratio</code> <td> <code title="">preserveAspectRatio</code> <tr><td> <code title="">primitiveunits</code> <td> <code title="">primitiveUnits</code> <tr><td> <code title="">refx</code> <td> <code title="">refX</code> <tr><td> <code title="">refy</code> <td> <code title="">refY</code> <tr><td> <code title="">repeatcount</code> <td> <code title="">repeatCount</code> <tr><td> <code title="">repeatdur</code> <td> <code title="">repeatDur</code> <tr><td> <code title="">requiredextensions</code> <td> <code title="">requiredExtensions</code> <tr><td> <code title="">requiredfeatures</code> <td> <code title="">requiredFeatures</code> <tr><td> <code title="">specularconstant</code> <td> <code title="">specularConstant</code> <tr><td> <code title="">specularexponent</code> <td> <code title="">specularExponent</code> <tr><td> <code title="">spreadmethod</code> <td> <code title="">spreadMethod</code> <tr><td> <code title="">startoffset</code> <td> <code title="">startOffset</code> <tr><td> <code title="">stddeviation</code> <td> <code title="">stdDeviation</code> <tr><td> <code title="">stitchtiles</code> <td> <code title="">stitchTiles</code> <tr><td> <code title="">surfacescale</code> <td> <code title="">surfaceScale</code> <tr><td> <code title="">systemlanguage</code> <td> <code title="">systemLanguage</code> <tr><td> <code title="">tablevalues</code> <td> <code title="">tableValues</code> <tr><td> <code title="">targetx</code> <td> <code title="">targetX</code> <tr><td> <code title="">targety</code> <td> <code title="">targetY</code> <tr><td> <code title="">textlength</code> <td> <code title="">textLength</code> <tr><td> <code title="">viewbox</code> <td> <code title="">viewBox</code> <tr><td> <code title="">viewtarget</code> <td> <code title="">viewTarget</code> <tr><td> <code title="">xchannelselector</code> <td> <code title="">xChannelSelector</code> <tr><td> <code title="">ychannelselector</code> <td> <code title="">yChannelSelector</code> <tr><td> <code title="">zoomandpan</code> <td> <code title="">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 title=attr-xml-lang><code title="">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 title="">xlink:actuate</code> <td> <code title="">xlink</code> <td> <code title="">actuate</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:arcrole</code> <td> <code title="">xlink</code> <td> <code title="">arcrole</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:href</code> <td> <code title="">xlink</code> <td> <code title="">href</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:role</code> <td> <code title="">xlink</code> <td> <code title="">role</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:show</code> <td> <code title="">xlink</code> <td> <code title="">show</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:title</code> <td> <code title="">xlink</code> <td> <code title="">title</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xlink:type</code> <td> <code title="">xlink</code> <td> <code title="">type</code> <td> <a href=#xlink-namespace>XLink namespace</a> <tr><td> <code title="">xml:base</code> <td> <code title="">xml</code> <td> <code title="">base</code> <td> <a href=#xml-namespace>XML namespace</a> <!-- attr-xml-base --> <tr><td> <code title="">xml:lang</code> <td> <code title="">xml</code> <td> <code title="">lang</code> <td> <a href=#xml-namespace>XML namespace</a> <tr><td> <code title="">xml:space</code> <td> <code title="">xml</code> <td> <code title="">space</code> <td> <a href=#xml-namespace>XML namespace</a> <tr><td> <code title="">xmlns</code> <td> (none) <td> <code title="">xmlns</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a> <tr><td> <code title="">xmlns:xlink</code> <td> <code title="">xmlns</code> <td> <code title="">xlink</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a> </table><hr><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>Insert an HTML element</a> for the token.</li> <li><p>If the algorithm that was invoked is the <a href=#generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>, switch the tokenizer to the <a href=#rawtext-state>RAWTEXT state</a>; otherwise the algorithm invoked was the <a href=#generic-rcdata-element-parsing-algorithm>generic RCDATA element parsing algorithm</a>, switch the tokenizer to the <a href=#rcdata-state>RCDATA state</a>.</li> <li><p>Let the <a href=#original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode>insertion mode</a>.</p> <li><p>Then, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode: text">text</a>".</li> </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>13.2.5.2 </span>Closing elements that have implied end tags</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>current node</a> is a <code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an <code><a href=#the-li-element>li</a></code> element, an <code><a href=#the-option-element>option</a></code> element, an <code><a href=#the-optgroup-element>optgroup</a></code> element, a <code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, or an <code><a href=#the-rt-element>rt</a></code> element, the UA must pop the <a href=#current-node>current node</a> off the <a href=#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> <h5 id=foster-parenting><span class=secno>13.2.5.3 </span>Foster parenting</h5> <p>Foster parenting happens when content is misnested in tables.</p> <p>When a node <var title="">node</var> is to be <dfn id=foster-parent title="foster parent">foster parented</dfn>, the node <var title="">node</var> must be inserted into the <i><a href=#foster-parent-element>foster parent element</a></i>.</p> <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and it has such a parent element.</p> <p class=note>It might have no parent or some other kind parent if a script manipulated the DOM after the element was inserted by the parser.</p> <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> (<a href=#fragment-case>fragment case</a>), then the <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise, if there is a <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, but the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its parent node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the element before the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, then <var title="">node</var> must be inserted into the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>; otherwise, <var title="">node</var> must be <em>appended</em> to the <i><a href=#foster-parent-element>foster parent element</a></i>.</p> <h5 id=parsing-main-inhtml><span class=secno>13.2.5.4 </span>The rules for parsing tokens in HTML content</h5> <h6 id=the-initial-insertion-mode><span class=secno>13.2.5.4.1 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-initial-insertion-mode title="insertion mode: initial">initial</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p>Ignore the token.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <code><a href=#document>Document</a></code> object with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p>If the DOCTYPE token's name is not a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">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>case-sensitive</a> match for the string "<code><a href=#about:legacy-compat>about:legacy-compat</a></code>", and none of the sets of conditions in the following list are matched, then there is a <a href=#parse-error>parse error</a>.</p> <ul><!-- only things that trigger no-quirks mode and were valid in some other spec are allowed in this list --><li>The DOCTYPE token's name is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and the token's system identifier is either missing or the <a href=#case-sensitive>case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li> <li>The DOCTYPE token's name is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and the token's system identifier is either missing or the <a href=#case-sensitive>case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li> <li>The DOCTYPE token's name is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>", and the token's system identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li> <li>The DOCTYPE token's name is a <a href=#case-sensitive>case-sensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and the token's system identifier is the <a href=#case-sensitive>case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li> </ul><p>Conformance checkers may, based on the values (including presence or lack thereof) of the DOCTYPE token's name, public identifier, or system identifier, switch to a conformance checking mode for another language (e.g. based on the DOCTYPE token a conformance checker could recognize that the document is an HTML4-era document, and defer to an HTML4 conformance checker.)</p> <p>Append a <code><a href=#documenttype>DocumentType</a></code> node to the <code><a href=#document>Document</a></code> node, with the <code title="">name</code> attribute set to the name given in the DOCTYPE token, or the empty string if the name was missing; the <code title="">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 title="">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><a href=#documenttype>DocumentType</a></code> objects set to null and empty lists as appropriate. Associate the <code><a href=#documenttype>DocumentType</a></code> node with the <code><a href=#document>Document</a></code> object so that it is returned as the value of the <code title="">doctype</code> attribute of the <code><a href=#document>Document</a></code> object.</p> <p id=quirks-mode-doctypes>Then, if the DOCTYPE token matches one of the conditions in the following list, then set the <code><a href=#document>Document</a></code> to <a href=#quirks-mode>quirks mode</a>:</p> <ul class=brief><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li> <li> The name is set to anything other than "<code title="">html</code>" (compared <a href=#case-sensitive title=case-sensitive>case-sensitively</a>). </li> <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>--> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>--> <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>--> <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li> <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>--> <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li> <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li> <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li> <li> The public identifier is set to: "<code title="">HTML</code>" </li> <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li> <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li> <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li> </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions in the following list, then set the <code><a href=#document>Document</a></code> to <a href=#limited-quirks-mode>limited-quirks mode</a>:</p> <ul class=brief><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li> <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li> <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li> <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li> </ul><p>The system identifier and public identifier strings must be compared to the values given in the lists above in an <a href=#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>insertion mode</a> to "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>".</p> </dd> <dt>Anything else</dt> <dd> <p>If the document is <em>not</em> <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>, then this is a <a href=#parse-error>parse error</a>; set the <code><a href=#document>Document</a></code> to <a href=#quirks-mode>quirks mode</a>.</p> <p>In any case, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>", then reprocess the current token.</p> </dd> </dl><h6 id=the-before-html-insertion-mode><span class=secno>13.2.5.4.2 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <code><a href=#document>Document</a></code> object with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p>Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p><a href=#create-an-element-for-the-token>Create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>. Append it to the <code><a href=#document>Document</a></code> object. Put this element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p id=parser-appcache>If the <code><a href=#document>Document</a></code> is being loaded as part of <a href=#navigate title=navigate>navigation</a> of a <a href=#browsing-context>browsing context</a>, then: if the newly created element has a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value is not the empty string, then <a href=#resolve-a-url title="resolve a url">resolve</a> the value of that attribute to an <a href=#absolute-url>absolute URL</a>, relative to the newly created element, and if that is successful, run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with the resulting <a href=#absolute-url>absolute URL</a> with any <a href=#url-fragment title=url-fragment><fragment></a> component removed; otherwise, if there is no such attribute, or its value is the empty string, or resolving its value fails, run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest. The algorithm must be passed the <code><a href=#document>Document</a></code> object.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>".</p> </dd> <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt> <dd> <p>Act as described in the "anything else" entry below.</p> </dd> <dt>Any other end tag</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Create an <code><a href=#the-html-element>html</a></code> element. Append it to the <code><a href=#document>Document</a></code> object. Put this element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>If the <code><a href=#document>Document</a></code> is being loaded as part of <a href=#navigate title=navigate>navigation</a> of a <a href=#browsing-context>browsing context</a>, then: run the <a href=#concept-appcache-init title=concept-appcache-init>application cache selection algorithm</a> with no manifest, passing it the <code><a href=#document>Document</a></code> object.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>", then reprocess the current token.</p> </dd> </dl><p>The root element can end up being removed from the <code><a href=#document>Document</a></code> object, e.g. by scripts; nothing in particular happens in such cases, content continues being appended to the nodes as described in the next section.</p> <h6 id=the-before-head-insertion-mode><span class=secno>13.2.5.4.3 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p>Ignore the token.</p> <!-- :-( --> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "head"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Set the <a href=#head-element-pointer><code title="">head</code> element pointer</a> to the newly created <code><a href=#the-head-element>head</a></code> element.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p> </dd> <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt> <dd> <p>Act as if a start tag token with the tag name "head" and no attributes had been seen, then reprocess the current token.</p> </dd> <dt>Any other end tag</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Act as if a start tag token with the tag name "head" and no attributes had been seen, then reprocess the current token.</p> </dd> </dl><h6 id=parsing-main-inhead><span class=secno>13.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "command", "link"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">Acknowledge the token's <i>self-closing flag</i></a>, if it is set.</p> </dd> <dt>A start tag whose tag name is "meta"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">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 title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute, and its value is either a supported <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a> or <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, and the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> is currently <i>tentative</i>, then <a href=#change-the-encoding>change the encoding</a> to the encoding given by the value of the <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code> attribute.</p> <p>Otherwise, if the element has an <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">Content-Type</code>", and the element has a <code title=attr-meta-content><a href=#attr-meta-content>content</a></code> attribute, and applying the <a href=#algorithm-for-extracting-an-encoding-from-a-meta-element>algorithm for extracting an encoding from a <code>meta</code> element</a> to that attribute's value returns a supported <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a> or <a href=#a-utf-16-encoding>a UTF-16 encoding</a>, and the <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> is currently <i>tentative</i>, then <a href=#change-the-encoding>change the encoding</a> to the extracted encoding.</p> </dd> <dt>A start tag whose tag name is "title"</dt> <dd> <p>Follow the <a href=#generic-rcdata-element-parsing-algorithm>generic RCDATA element parsing algorithm</a>.</p> </dd> <dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag>scripting flag</a> is enabled</dt> <dt>A start tag whose tag name is one of: "noframes", "style"</dt> <dd> <p>Follow the <a href=#generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p> </dd> <dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag>scripting flag</a> is disabled</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>".</p> </dd> <dt id=scriptTag>A start tag whose tag name is "script"</dt> <dd> <p>Run these steps:</p> <ol><li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>.</li> <li> <p>Mark the element as being <a href=#parser-inserted>"parser-inserted"</a> and unset the element's <a href=#force-async>"force-async"</a> flag.</p> <p class=note>This ensures that, if the script is external, any <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls in the script will execute in-line, instead of blowing the document away, as would happen in most other cases. It also prevents the script from executing until the end tag is seen.</p> </li> <li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, then mark the <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already started"</a>. (<a href=#fragment-case>fragment case</a>)</li> <li><p>Append the new element to the <a href=#current-node>current node</a> and push it onto the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><p>Switch the tokenizer to the <a href=#script-data-state>script data state</a>.</li> <li><p>Let the <a href=#original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode>insertion mode</a>.</p> <li><p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode: text">text</a>".</li> </ol></dd> <dt>An end tag whose tag name is "head"</dt> <dd> <p>Pop the <a href=#current-node>current node</a> (which will be the <code><a href=#the-head-element>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>".</p> </dd> <dt>An end tag whose tag name is one of: "body", "html", "br"</dt> <dd> <p>Act as described in the "anything else" entry below.</p> </dd> <dt>A start tag whose tag name is "head"</dt> <dt>Any other end tag</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <!-- can't get here with an EOF and a fragment case --> <p>Act as if an end tag token with the tag name "head" had been seen, and reprocess the current token.</p> </dd> </dl><h6 id=parsing-main-inheadnoscript><span class=secno>13.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end tag whose tag name is "noscript"</dt> <dd> <p>Pop the <a href=#current-node>current node</a> (which will be a <code><a href=#the-noscript-element>noscript</a></code> element) from the <a href=#stack-of-open-elements>stack of open elements</a>; the new <a href=#current-node>current node</a> will be a <code><a href=#the-head-element>head</a></code> element.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p> </dd> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dt>A comment token</dt> <dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes", "style"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end tag whose tag name is "br"</dt> <dd> <p>Act as described in the "anything else" entry below.</p> </dd> <dt>A start tag whose tag name is one of: "head", "noscript"</dt> <dt>Any other end tag</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <!-- can't get here with an EOF and a fragment case --> <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag name "noscript" had been seen and reprocess the current token.</p> </dd> </dl><h6 id=the-after-head-insertion-mode><span class=secno>13.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "body"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p> </dd> <dt>A start tag whose tag name is "frameset"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>".</p> </dd> <dt>A start tag token whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>Push the node pointed to by the <a href=#head-element-pointer><code title="">head</code> element pointer</a> onto the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> <p>Remove the node pointed to by the <a href=#head-element-pointer><code title="">head</code> element pointer</a> from the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p class=note>The <a href=#head-element-pointer><code title="">head</code> element pointer</a> cannot be null at this point.</p> </dd> <dt>An end tag whose tag name is one of: "body", "html", "br"</dt> <dd> <p>Act as described in the "anything else" entry below.</p> </dd> <dt>A start tag whose tag name is "head"</dt> <dt>Any other end tag</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Act as if a start tag token with the tag name "body" and no attributes had been seen, then set the <a href=#frameset-ok-flag>frameset-ok flag</a> back to "ok", and then reprocess the current token.</p> </dd> </dl><h6 id=parsing-main-inbody><span class=secno>13.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is U+0000 NULL</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> <!-- The D-Link DSL-G604T ADSL router has a zero byte in its configuration UI before a <frameset>, which is why U+0000 is special-cased here. refs: https://bugzilla.mozilla.org/show_bug.cgi?id=563526 http://www.w3.org/Bugs/Public/show_bug.cgi?id=9659 --> </dd> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>Any other character token</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p><a href=#parse-error>Parse error</a>. 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>stack of open elements</a>. If it is not, add the attribute and its corresponding value to that element.</p> </dd> <dt>A start tag token whose tag name is one of: "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "body"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the second element on the <a href=#stack-of-open-elements>stack of open elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it, then ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, set the <a href=#frameset-ok-flag>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><a href=#the-body-element>body</a></code> element (the second element) on the <a href=#stack-of-open-elements>stack of open elements</a>, and if it is not, add the attribute and its corresponding value to that element.</p> </dd> <dt>A start tag whose tag name is "frameset"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the second element on the <a href=#stack-of-open-elements>stack of open elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it, then ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>If the <a href=#frameset-ok-flag>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>stack of open elements</a> from its parent node, if it has one.</li> <li><p>Pop all the nodes from the bottom of the <a href=#stack-of-open-elements>stack of open elements</a>, from the <a href=#current-node>current node</a> up to, but not including, the root <code><a href=#the-html-element>html</a></code> element.</p> <li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</li> <li><p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>".</p> </ol></dd> <dt>An end-of-file token</dt> <dd> <p>If there is a node in the <a href=#stack-of-open-elements>stack of open elements</a> that is not either a <code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an <code><a href=#the-li-element>li</a></code> element, a <code><a href=#the-p-element>p</a></code> element, a <code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a <code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a <code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element>body</a></code> element, or the <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are fragment cases) --> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>An end tag whose tag name is "body"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have a <code>body</code> element in scope</a>, this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <!-- if we get here, the insertion mode here is forcibly "in body". --> <p>Otherwise, if there is a node in the <a href=#stack-of-open-elements>stack of open elements</a> that is not either a <code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an <code><a href=#the-li-element>li</a></code> element, an <code><a href=#the-optgroup-element>optgroup</a></code> element, an <code><a href=#the-option-element>option</a></code> element, a <code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, an <code><a href=#the-rt-element>rt</a></code> element, a <code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a <code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a <code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element>body</a></code> element, or the <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are fragment cases, e.g. for <tbody> you'd have hit the first paragraph since the <body> wouldn't be in scope, unless it was a fragment case) --> <!-- If we ever change the frameset-ok flag to an insertion mode, then we'd have to somehow keep track of its state when we switch to after-body. --> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>".</p> </dd> <dt>An end tag whose tag name is "html"</dt> <dd> <p>Act as if an end tag with tag name "body" had been seen, then, if that token wasn't ignored, reprocess the current token.</p> </dd> <!-- start tags for non-phrasing flow content elements --> <!-- the normal ones --> <dt>A start tag whose tag name is one of: "address", "article", "aside", "blockquote", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "menu", "nav", "ol", "p", "section", "summary", "ul"</dt> <dd> <!-- As of May 2008 this doesn't match any browser exactly, but is as close to what IE does as I can get without doing the non-tree DOM nonsense, and thus should actually afford better compatibility when implemented by the other browsers. --> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <!-- as normal, but close h1-h6 if it's the current node --> <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p>If the <a href=#current-node>current node</a> is an element whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a <a href=#parse-error>parse error</a>; pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 --> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <!-- as normal, but drops leading newline --> <dt>A start tag whose tag name is one of: "pre", "listing"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>If the next token 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><a href=#the-pre-element>pre</a></code> blocks are ignored as an authoring convenience.)</p> <!-- <pre>[CR]X will eat the [CR], <pre>X will eat the , but <pre>X will not eat the . --> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <!-- as normal, but interacts with the form element pointer --> <dt>A start tag whose tag name is "form"</dt> <dd> <p>If the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> is not null, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise:</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, and set the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to point to the element created.</p> </dd> <!-- as normal, but imply </li> when there's another <li> open in weird cases --> <dt>A start tag whose tag name is "li"</dt> <dd> <p>Run these steps:</p> <ol><li><p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</li> <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current node</a> (the bottommost node of the stack).</li> <li><p><i>Loop</i>: If <var title="">node</var> is an <code><a href=#the-li-element>li</a></code> element, then act as if an end tag with the tag name "li" had been seen, then jump to the last step.</li> <li><p>If <var title="">node</var> is in the <a href=#special>special</a> category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>, or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li> <!-- an element <foo> is in this list if the following markup: <!DOCTYPE html><body><ol><li><foo><li> ...results in the second <li> not being (in any way) a descendant of the first <li>, or if <foo> is a formatting element that gets reopened later. --> <li><p>Otherwise, set <var title="">node</var> to the previous entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to the step labeled <i>loop</i>.</li> <li> <p>This is the last step.</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</p> </li> </ol></dd> <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases --> <dt>A start tag whose tag name is one of: "dd", "dt"</dt> <dd> <p>Run these steps:</p> <ol><li><p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</li> <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current node</a> (the bottommost node of the stack).</li> <li><p><i>Loop</i>: If <var title="">node</var> is a <code><a href=#the-dd-element>dd</a></code> or <code><a href=#the-dt-element>dt</a></code> element, then act as if an end tag with the same tag name as <var title="">node</var> had been seen, then jump to the last step.</li> <li><p>If <var title="">node</var> is in the <a href=#special>special</a> category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>, or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li> <!-- an element <foo> is in this list if the following markup: <!DOCTYPE html><body><dl><dt><foo><dt> ...results in the second <dt> not being (in any way) a descendant of the first <dt>, or if <foo> is a formatting element that gets reopened later. --> <li><p>Otherwise, set <var title="">node</var> to the previous entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to the step labeled <i>loop</i>.</li> <li> <p>This is the last step.</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</p> </li> </ol></dd> <!-- same as normal, but effectively ends parsing --> <dt>A start tag whose tag name is "plaintext"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Switch the tokenizer to the <a href=#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>PLAINTEXT state</a>.</p> </dd> <!-- button is a hybrid --> <dt>A start tag whose tag name is "button"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has an element in scope">has a <code>button</code> element in scope</a>, then this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name "button" had been seen, then reprocess the token.</p> <p>Otherwise:</p> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <!-- end tags for non-phrasing flow content elements (and button) --> <!-- the normal ones --> <dt>An end tag whose tag name is one of: "address", "article", "aside", "blockquote", "button", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "listing", "menu", "nav", "ol", "pre", "section", "summary", "ul"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have an element in scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element with the same tag name as the token has been popped from the stack.</li> </ol></dd> <!-- removes the form element pointer instead of the matching node --> <dt>An end tag whose tag name is "form"</dt> <dd> <p>Let <var title="">node</var> be the element that the <a href=#form-element-pointer><code title="">form</code> element pointer</a> is set to.</p> <p>Set the <a href=#form-element-pointer><code title="">form</code> element pointer</a> to null.</p> <p>If <var title="">node</var> is null or the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have <var title="">node</var> in scope</a>, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li> <li><p>If the <a href=#current-node>current node</a> is not <var title="">node</var>, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Remove <var title="">node</var> from the <a href=#stack-of-open-elements>stack of open elements</a>.</li> </ol></dd> <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags --> <dt>An end tag whose tag name is "p"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-button-scope title="has an element in button scope">have an element in button scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>; act as if a start tag with the tag name "p" had been seen, then reprocess the current token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for elements with the same tag name as the token.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element with the same tag name as the token has been popped from the stack.</li> </ol></dd> <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> --> <dt>An end tag whose tag name is "li"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-list-item-scope title="has an element in list item scope">have an element in list item scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for elements with the same tag name as the token.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element with the same tag name as the token has been popped from the stack.</li> </ol></dd> <!-- as normal, but needs care as the elements have optional tags --> <dt>An end tag whose tag name is one of: "dd", "dt"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have an element in scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for elements with the same tag name as the token.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element with the same tag name as the token has been popped from the stack.</li> </ol></dd> <!-- as normal, except acts as a closer for any of the h1-h6 elements --> <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have an element in scope</a> whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6" has been popped from the stack.</li> </ol></dd> <!-- see also applet/marquee/object lower down --> <dt>An end tag whose tag name is "sarcasm"</dt> <dd> <p>Take a deep breath, then act as described in the "any other end tag" entry below.</p> </dd> <!-- ADOPTION AGENCY ELEMENTS Mozilla-only: bdo blink del ins sub sup q Safari-only: code dfn kbd nobr samp var wbr Both: a b big em font i s small strike strong tt u --> <dt>A start tag whose tag name is "a"</dt> <dd> <p>If the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> contains an element whose tag name is "a" between the end of the list and the last marker on the list (or the start of the list if there is no marker on the list), then this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name "a" had been seen, then remove that element from the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> and the <a href=#stack-of-open-elements>stack of open elements</a> if the end tag didn't already remove it (it might not have if the element is not <a href=#has-an-element-in-table-scope title="has an element in table scope">in table scope</a>).</p> <p class=example>In the non-conforming stream <code><a href="a">a<table><a href="b">b</table>x</code>, the first <code><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><a href=#the-a-element>a</a></code> element is not in table scope (meaning that a regular <code></a></code> end tag at the start of the table wouldn't close the outer <code><a href=#the-a-element>a</a></code> element). The result is that the two <code><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>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push onto the list of active formatting elements</a> that element.</p> </dd> <dt>A start tag whose tag name is one of: "b", "big", "code", "em", "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push onto the list of active formatting elements</a> that element.</p> </dd> <dt>A start tag whose tag name is "nobr"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has an element in scope">has a <code>nobr</code> element in scope</a>, then this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name "nobr" had been seen, then once again <a href=#reconstruct-the-active-formatting-elements>reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements>Push onto the list of active formatting elements</a> that element.</p> </dd> <dt id=adoptionAgency>An end tag whose tag name is one of: "a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u"</dt> <dd> <p>Run these steps:</p> <ol><li><p>Let <var title="">outer loop counter</var> be zero.</li> <li><p><i>Outer loop</i>: If <var title="">outer loop counter</var> is greater than or equal to eight, then abort these steps.</li> <li><p>Increment <var title="">outer loop counter</var> by one.</li> <li> <p>Let the <var title="">formatting element</var> be the last element in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> that:</p> <ul><li>is between the end of the list and the last scope marker in the list, if any, or the start of the list otherwise, and</li> <li>has the same tag name as the token.</li> </ul><p>If there is no such node, then abort these steps and instead act as described in the "any other end tag" entry below.</p> <p>Otherwise, if there is such a node, but that node is not in the <a href=#stack-of-open-elements>stack of open elements</a>, then this is a <a href=#parse-error>parse error</a>; remove the element from the list, and abort these steps.</p> <p>Otherwise, if there is such a node, and that node is also in the <a href=#stack-of-open-elements>stack of open elements</a>, but the element is not <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>, then this is a <a href=#parse-error>parse error</a>; ignore the token, and abort these steps.</p> <p>Otherwise, there is a <var title="">formatting element</var> and that element is in <a href=#stack-of-open-elements title="stack of open elements">the stack</a> and is <a href=#has-an-element-in-scope title="has an element in scope">in scope</a>. If the element is not the <a href=#current-node>current node</a>, this is a <a href=#parse-error>parse error</a>. In any case, proceed with the algorithm as written in the following steps.</p> </li> <li><p>Let the <var title="">furthest block</var> be the topmost node in the <a href=#stack-of-open-elements>stack of open elements</a> that is lower in the stack than the <var title="">formatting element</var>, and is an element in the <a href=#special>special</a> category. There might not be one.</li> <li><p>If there is no <var title="">furthest block</var>, then the UA must skip the subsequent steps and instead just pop all the nodes from the bottom of the <a href=#stack-of-open-elements>stack of open elements</a>, from the <a href=#current-node>current node</a> up to and including the <var title="">formatting element</var>, and remove the <var title="">formatting element</var> from the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li><p>Let the <var title="">common ancestor</var> be the element immediately above the <var title="">formatting element</var> in the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><p>Let a bookmark note the position of the <var title="">formatting element</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> relative to the elements on either side of it in the list.</li> <li> <p>Let <var title="">node</var> and <var title="">last node</var> be the <var title="">furthest block</var>. Follow these steps:</p> <ol><li><p>Let <var title="">inner loop counter</var> be zero.</li> <li><p><i>Inner loop</i>: If <var title="">inner loop counter</var> is greater than or equal to three, then abort these steps.</li> <li><p>Increment <var title="">inner loop counter</var> by one.</li> <li>Let <var title="">node</var> be the element immediately above <var title="">node</var> in the <a href=#stack-of-open-elements>stack of open elements</a>, or if <var title="">node</var> is no longer in the <a href=#stack-of-open-elements>stack of open elements</a> (e.g. because it got removed by the next step), the element that was immediately above <var title="">node</var> in the <a href=#stack-of-open-elements>stack of open elements</a> before <var title="">node</var> was removed.</li> <li>If <var title="">node</var> is not in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>, then remove <var title="">node</var> from the <a href=#stack-of-open-elements>stack of open elements</a> and then go back to the step labeled <i>inner loop</i>.</li> <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step in the overall algorithm.</li> <li><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the element <var title="">node</var> was created, replace the entry for <var title="">node</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> with an entry for the new element, replace the entry for <var title="">node</var> in the <a href=#stack-of-open-elements>stack of open elements</a> with an entry for the new element, and let <var title="">node</var> be the new element.</li> <li>If <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned bookmark to be immediately after the new <var title="">node</var> in the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</li> <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous parent node if any.</li> <li>Let <var title="">last node</var> be <var title="">node</var>.</li> <li>Return to the step labeled <i>inner loop</i>.</li> </ol></li> <li> <p>If the <var title="">common ancestor</var> node is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element, then, <a href=#foster-parent>foster parent</a> whatever <var title="">last node</var> ended up being in the previous step, first removing it from its previous parent node if any.</p> <p>Otherwise, append whatever <var title="">last node</var> ended up being in the previous step to the <var title="">common ancestor</var> node, first removing it from its previous parent node if any.</p> </li> <li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the <var title="">formatting element</var> was created.</li> <li><p>Take all of the child nodes of the <var title="">furthest block</var> and append them to the element created in the last step.</li> <li><p>Append that new element to the <var title="">furthest block</var>.</li> <li><p>Remove the <var title="">formatting element</var> from the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>, and insert the new element into the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> at the position of the aforementioned bookmark.</li> <li><p>Remove the <var title="">formatting element</var> from the <a href=#stack-of-open-elements>stack of open elements</a>, and insert the new element into the <a href=#stack-of-open-elements>stack of open elements</a> immediately below the position of the <var title="">furthest block</var> in that stack.</li> <li><p>Jump back to the step labeled <i>outer loop</i>.</li> </ol><p class=note>Because of the way this algorithm causes elements to change parents, it has been dubbed the "adoption agency algorithm" (in contrast with other possible algorithms for dealing with misnested content, which included the "incest algorithm", the "secret affair algorithm", and the "Heisenberg algorithm").</p> </dd> <dt>A start tag token whose tag name is one of: "applet", "marquee", "object"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Insert a marker at the end of the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <dt>An end tag token whose tag name is one of: "applet", "marquee", "object"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have an element in scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>; ignore the token.</p> <p>Otherwise, run these steps:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li> <li><p>If the <a href=#current-node>current node</a> is not an element with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an element with the same tag name as the token has been popped from the stack.</li> <li><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the last marker</a>.</li> </ol></dd> <dt>A start tag whose tag name is "table"</dt> <dd> <p>If the <code><a href=#document>Document</a></code> is <em>not</em> set to <a href=#quirks-mode>quirks mode</a>, and the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <!-- i hate myself (this quirk was basically caused by acid2; if i'd realised we could change the specs when i wrote acid2, we could have avoided having any parsing-mode quirks) -Hixie --> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p> </dd> <dt>A start tag whose tag name is one of: "area", "br", "embed", "img", "keygen", "wbr"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="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>frameset-ok flag</a> to "not ok".</p> <!-- shouldn't really do this for <area> --> </dd> <dt>A start tag whose tag name is "input"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">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 href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">hidden</code>", then: set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <dt>A start tag whose tag name is one of: "param", "source", "track"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">Acknowledge the token's <i>self-closing flag</i></a>, if it is set.</p> </dd> <dt>A start tag whose tag name is "hr"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="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>frameset-ok flag</a> to "not ok".</p> </dd> <dt>A start tag whose tag name is "image"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Change the token's tag name to "img" and reprocess it. (Don't ask.)</p> <!-- As of 2005-12, studies showed that around 0.2% of pages used the <image> element. --> </dd> <dt id=isindex>A start tag whose tag name is "isindex"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the <a href=#form-element-pointer><code title="">form</code> element pointer</a> is not null, then ignore the token.</p> <p>Otherwise:</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">Acknowledge the token's <i>self-closing flag</i></a>, if it is set.</p> <!-- purely to reduce the number of errors (we don't care if they included the /, they're not supposed to be including the tag at all! --> <p>Act as if a start tag token with the tag name "form" had been seen.</p> <p>If the token has an attribute called "action", set the <code title=attr-fs-action><a href=#attr-fs-action>action</a></code> attribute on the resulting <code><a href=#the-form-element>form</a></code> element to the value of the "action" attribute of the token.</p> <p>Act as if a start tag token with the tag name "hr" had been seen.</p> <p>Act as if a start tag token with the tag name "label" had been seen.</p> <p>Act as if a stream of character tokens had been seen (see below for what they should say).</p> <p>Act as if a start tag token with the tag name "input" had been seen, with all the attributes from the "isindex" token except "name", "action", and "prompt". Set the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute of the resulting <code><a href=#the-input-element>input</a></code> element to the value "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>".</p> <p>Act as if a stream of character tokens had been seen (see below for what they should say).</p> <p>Act as if an end tag token with the tag name "label" had been seen.</p> <p>Act as if a start tag token with the tag name "hr" had been seen.</p> <p>Act as if an end tag token with the tag name "form" had been seen.</p> <p>If the token has an attribute with the name "prompt", then the first stream of characters must be the same string as given in that attribute, and the second stream of characters must be empty. Otherwise, the two streams of character tokens together should, together with the <code><a href=#the-input-element>input</a></code> element, express the equivalent of "This is a searchable index. Enter search keywords: (input field)" in the user's preferred language.</p> </dd> <dt>A start tag whose tag name is "textarea"</dt> <dd> <p>Run these steps:</p> <ol><li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</li> <li><p>If the next token 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><a href=#the-textarea-element>textarea</a></code> elements are ignored as an authoring convenience.)</li> <!-- see comment in <pre> start tag bit --> <li><p>Switch the tokenizer to the <a href=#rcdata-state>RCDATA state</a>.</li> <li><p>Let the <a href=#original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode>insertion mode</a>.</p> <li><p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</li> <li><p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode: text">text</a>".</li> </ol></dd> <dt>A start tag whose tag name is "xmp"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a <code>p</code> element in button scope</a>, then act as if an end tag with the tag name "p" had been seen.</p> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> <p>Follow the <a href=#generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p> </dd> <dt>A start tag whose tag name is "iframe"</dt> <dd> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> <p>Follow the <a href=#generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p> </dd> <dt>A start tag whose tag name is "noembed"</dt> <dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag>scripting flag</a> is enabled</dt> <dd> <p>Follow the <a href=#generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p> </dd> <dt>A start tag whose tag name is "select"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> <p>If the <a href=#insertion-mode>insertion mode</a> is one of "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>", "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>", "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>", "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>", or "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>", then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>". Otherwise, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>".</p> </dd> <dt>A start tag whose tag name is one of: "optgroup", "option"</dt> <dd> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code> element, then act as if an end tag with the tag name "option" had been seen.</p> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <dt>A start tag whose tag name is one of: "rp", "rt"</dt> <dd> <!-- the parsing rules for ruby really don't match IE much at all, but in practice the markup used is very simple and so strict compatibility with IE isn't required. For example, as defined here we get very, very different behaviour than IE for pathological cases like: <ruby><ol><li><p>a<rt>b <ruby>a<rt>b<p>c But in practice most ruby markup falls into these cases: <ruby>a<rt>b</ruby> <ruby>a<rp>b<rt>c<rp>d</ruby> <ruby>a<rt>b</rt></ruby> <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby> (Note: the comment above was written when this section did something slightly more radical for handling <rp> and <rt> elements, so it might be out of date now.) --> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has an element in scope">has a <code>ruby</code> element in scope</a>, then <a href=#generate-implied-end-tags>generate implied end tags</a>. If the <a href=#current-node>current node</a> is not then a <code><a href=#the-ruby-element>ruby</a></code> element, this is a <a href=#parse-error>parse error</a>.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <dt>An end tag whose tag name is "br"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if a start tag token with the tag name "br" had been seen. Ignore the end tag token.</p> </dd> <dt>A start tag whose tag name is "math"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#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>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>Insert a foreign element</a> for the token, in the <a href=#mathml-namespace>MathML namespace</a>.</p> <!-- If we ever change the frameset-ok flag to an insertion mode, the following change would be implied, except we'd have to do it even in the face of a self-closed tag: <p>Set the <span>frameset-ok flag</span> to "not ok".</p> --> <p>If the token has its <i>self-closing flag</i> set, pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">acknowledge the token's <i>self-closing flag</i></a>.</p> </dd> <dt>A start tag whose tag name is "svg"</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#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>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>Insert a foreign element</a> for the token, in the <a href=#svg-namespace>SVG namespace</a>.</p> <!-- If we ever change the frameset-ok flag to an insertion mode, the following change would be implied, except we'd have to do it even in the face of a self-closed tag: <p>Set the <span>frameset-ok flag</span> to "not ok".</p> --> <p>If the token has its <i>self-closing flag</i> set, pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">acknowledge the token's <i>self-closing flag</i></a>.</p> </dd> <dt>A start <!--or end--> tag whose tag name is one of: "caption", "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th", "thead", "tr"</dt> <!--<dt>An end tag whose tag name is one of: "area", "base", "basefont", "bgsound", "command", "embed", "hr", "iframe", "image", "img", "input", "isindex", "keygen", "link", "meta", "noembed", "noframes", "param", "script", "select", "source", "style", "table", "textarea", "title", "track", "wbr"</dt>--> <!--<dt>An end tag whose tag name is "noscript", if the <span>scripting flag</span> is enabled</dt>--> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> <!-- end tags are commented out because since they can never end up on the stack anyway, the default end tag clause will automatically handle them. we don't want to have text in the spec that is just an optimisation, as that detracts from the spec itself --> </dd> <dt>Any other start tag</dt> <dd> <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p class=note>This element will be an <a href=#ordinary>ordinary</a> element.</p> </dd> <dt>Any other end tag</dt> <dd> <p>Run these steps:</p> <ol><li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current node</a> (the bottommost node of the stack).</li> <li><p><i>Loop</i>: If <var title="">node</var> has the same tag name as the token, then:</p> <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for elements with the same tag name as the token.</li> <li><p>If the tag name of the end tag token does not match the tag name of the <a href=#current-node>current node</a>, this is a <a href=#parse-error>parse error</a>.</li> <li><p>Pop all the nodes from the <a href=#current-node>current node</a> up to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</li> </ol></li> <li><p>Otherwise, if <var title="">node</var> is in the <a href=#special>special</a> category, then this is a <a href=#parse-error>parse error</a>; ignore the token, and abort these steps.</li> <li><p>Set <var title="">node</var> to the previous entry in the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><p>Return to the step labeled <i>loop</i>.</li> </ol></dd> </dl><h6 id=parsing-main-incdata><span class=secno>13.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incdata title="insertion mode: text">text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> <p class=note>This can never be a U+0000 NULL character; the tokenizer converts those to U+FFFD REPLACEMENT CHARACTER characters.</p> </dd> <dt>An end-of-file token</dt> <dd> <!-- can't be the fragment case --> <p><a href=#parse-error>Parse error</a>.</p> <p>If the <a href=#current-node>current node</a> is a <code><a href=#the-script-element>script</a></code> element, mark the <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already started"</a>.</p> <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to the <a href=#original-insertion-mode>original insertion mode</a> and reprocess the current token.</p> </dd> <dt id=scriptEndTag>An end tag whose tag name is "script"</dt> <dd> <p><a href=#provide-a-stable-state>Provide a stable state</a>.</p> <p>Let <var title="">script</var> be the <a href=#current-node>current node</a> (which will be a <code><a href=#the-script-element>script</a></code> element).</p> <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to the <a href=#original-insertion-mode>original insertion mode</a>.</p> <p>Let the <var title="">old insertion point</var> have the same value as the current <a href=#insertion-point>insertion point</a>. Let the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next input character</a>.</p> <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by one.</p> <p><a href=#prepare-a-script title="prepare a script">Prepare</a> the <var title="">script</var>. This might cause some script to execute, which might cause <a href=#dom-document-write title=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>script nesting level</a> by one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero, then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p> <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the <a href=#insertion-point>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>pending parsing-blocking script</a>, then:</p> <dl class=switch><dt>If the <a href=#script-nesting-level>script nesting level</a> is not zero:</dt> <dd> <p>Set the <a href=#parser-pause-flag>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 title=dom-document-write><a href=#dom-document-write>document.write()</a></code>.</p> </dd> <dt>Otherwise:</dt> <dd> <p>Run these steps:</p> <ol><li><p>Let <var title="">the script</var> be the <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>. There is no longer a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>.</li> <li><p>Block the <a href=#tokenization title=tokenization>tokenizer</a> for this instance of the <a href=#html-parser>HTML parser</a>, such that the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a>.</li> <li><p>If the parser's <code><a href=#document>Document</a></code> <a href=#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking scripts</a> or <var title="">the script</var>'s <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is not set: <a href=#spin-the-event-loop>spin the event loop</a> until the parser's <code><a href=#document>Document</a></code> <a href=#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that is blocking scripts</a> and <var title="">the script</var>'s <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is set.</li> <li><p>Unblock the <a href=#tokenization title=tokenization>tokenizer</a> for this instance of the <a href=#html-parser>HTML parser</a>, such that <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a> can again be run.</li> <li><p>Let the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next input character</a>.</li> <li><p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by one (it should be zero before this step, so this sets it to one).</li> <li><p><a href=#execute-the-script-block title="execute the script block">Execute</a> <var title="">the script</var>.</li> <li><p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero (which it always should be at this point), then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p> <li><p>Let the <a href=#insertion-point>insertion point</a> be undefined again.</li> <li><p>If there is once again a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then repeat these steps from step 1.</li> </ol></dd> </dl></dd> <dt>Any other end tag</dt> <dd> <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to the <a href=#original-insertion-mode>original insertion mode</a>.</p> </dd> </dl><h6 id=parsing-main-intable><span class=secno>13.2.5.4.9 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token</dt> <dd> <p>Let the <dfn id=pending-table-character-tokens><var>pending table character tokens</var></dfn> be an empty list of tokens.</p> <p>Let the <a href=#original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode>insertion mode</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>" and reprocess the token.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "caption"</dt> <dd> <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See below.)</p> <p>Insert a marker at the end of the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>".</p> </dd> <dt>A start tag whose tag name is "colgroup"</dt> <dd> <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See below.)</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>".</p> </dd> <dt>A start tag whose tag name is "col"</dt> <dd> <p>Act as if a start tag token with the tag name "colgroup" had been seen, then reprocess the current token.</p> </dd> <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt> <dd> <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See below.)</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>".</p> </dd> <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt> <dd> <p>Act as if a start tag token with the tag name "tbody" had been seen, then reprocess the current token.</p> </dd> <dt>A start tag whose tag name is "table"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if an end tag token with the tag name "table" had been seen, then, if that token wasn't ignored, reprocess the current token.</p> <p class=note>The fake end tag token here can only be ignored in the <a href=#fragment-case>fragment case</a>.</p> </dd> <dt>An end tag whose tag name is "table"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise:</p> <p>Pop elements from this stack until a <code><a href=#the-table-element>table</a></code> element has been popped from the stack.</p> <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p> </dd> <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is one of: "style", "script"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "input"</dt> <dd> <p>If the token does not have an attribute with the name "type", or if it does, but that attribute's value is not an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything else" entry below.</p> <p>Otherwise:</p> <p><a href=#parse-error>Parse error</a>.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> <p>Pop that <code><a href=#the-input-element>input</a></code> element off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> </dd> <dt>A start tag whose tag name is "form"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> is not null, ignore the token.</p> <p>Otherwise:</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, and set the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to point to the element created.</p> <p>Pop that <code><a href=#the-form-element>form</a></code> element off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> </dd> <!-- "form" end tag falls through to in-body, which does the right thing --> <dt>An end-of-file token</dt> <dd> <p>If the <a href=#current-node>current node</a> is not the root <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <p class=note>The <a href=#current-node>current node</a> can only be the root <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>, except that if the <a href=#current-node>current node</a> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element, then, whenever a node would be inserted into the <a href=#current-node>current node</a>, it must instead be <a href=#foster-parent title="foster parent">foster parented</a>.</p> </dd> </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>current node</a> is not a <code><a href=#the-table-element>table</a></code> element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p class=note>The <a href=#current-node>current node</a> being an <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment case</a>.</p> <h6 id=parsing-main-intabletext><span class=secno>13.2.5.4.10 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is U+0000 NULL</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Any other character token</dt> <dd> <p>Append the character token to the <var><a href=#pending-table-character-tokens>pending table character tokens</a></var> list.</p> </dd> <dt>Anything else</dt> <dd> <p>If any of the tokens in the <var><a href=#pending-table-character-tokens>pending table character tokens</a></var> list are character tokens that are not <a href=#space-character title="space character">space characters</a>, then reprocess the character tokens in the <var><a href=#pending-table-character-tokens>pending table character tokens</a></var> list using the rules given in the "anything else" entry in the "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" insertion mode.</p> <p>Otherwise, <a href=#insert-a-character title="insert a character">insert the characters</a> given by the <var><a href=#pending-table-character-tokens>pending table character tokens</a></var> list into the <a href=#current-node>current node</a>.</p> <!-- no need to empty the list, we're leaving the insertion mode and the list is always emptied before we reenter the mode --> <p>Switch the <a href=#insertion-mode>insertion mode</a> to the <a href=#original-insertion-mode>original insertion mode</a> and reprocess the token.</p> </dd> </dl><h6 id=parsing-main-incaption><span class=secno>13.2.5.4.11 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>An end tag whose tag name is "caption"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise:</p> <p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</p> <p>Now, if the <a href=#current-node>current node</a> is not a <code><a href=#the-caption-element>caption</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <p>Pop elements from this stack until a <code><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>Clear the list of active formatting elements up to the last marker</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p> </dd> <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt> <dt>An end tag whose tag name is "table"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag name "caption" had been seen, then, if that token wasn't ignored, reprocess the current token.</p> <p class=note>The fake end tag token here can only be ignored in the <a href=#fragment-case>fragment case</a>.</p> </dd> <dt>An end tag whose tag name is one of: "body", "col", "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> </dl><h6 id=parsing-main-incolgroup><span class=secno>13.2.5.4.12 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "col"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">Acknowledge the token's <i>self-closing flag</i></a>, if it is set.</p> </dd> <dt>An end tag whose tag name is "colgroup"</dt> <dd> <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>; ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, pop the <a href=#current-node>current node</a> (which will be a <code><a href=#the-colgroup-element>colgroup</a></code> element) from the <a href=#stack-of-open-elements>stack of open elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p> </dd> <dt>An end tag whose tag name is "col"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>An end-of-file token</dt> <dd> <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code> element, then <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, act as described in the "anything else" entry below.</p> </dd> <dt>Anything else</dt> <dd> <p>Act as if an end tag with the tag name "colgroup" had been seen, and then, if that token wasn't ignored, reprocess the current token.</p> <p class=note>The fake end tag token here can only be ignored in the <a href=#fragment-case>fragment case</a>.</p> </dd> </dl><h6 id=parsing-main-intbody><span class=secno>13.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A start tag whose tag name is "tr"</dt> <dd> <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body context</a>. (See below.)</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>".</p> </dd> <dt>A start tag whose tag name is one of: "th", "td"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if a start tag with the tag name "tr" had been seen, then reprocess the current token.</p> </dd> <dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token.</p> <p>Otherwise:</p> <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body context</a>. (See below.)</p> <p>Pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p> </dd> <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot", "thead"</dt> <dt>An end tag whose tag name is "table"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element in table scope</a>, this is a <a href=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise:</p> <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body context</a>. (See below.)</p> <p>Act as if an end tag with the same tag name as the <a href=#current-node>current node</a> ("tbody", "tfoot", or "thead") had been seen, then reprocess the current token.</p> </dd> <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td", "th", "tr"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> </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>current node</a> is not a <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element>html</a></code> element, pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p class=note>The <a href=#current-node>current node</a> being an <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment case</a>.</p> <h6 id=parsing-main-intr><span class=secno>13.2.5.4.14 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A start tag whose tag name is one of: "th", "td"</dt> <dd> <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row context</a>. (See below.)</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>".</p> <p>Insert a marker at the end of the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</p> </dd> <dt>An end tag whose tag name is "tr"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise:</p> <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row context</a>. (See below.)</p> <p>Pop the <a href=#current-node>current node</a> (which will be a <code><a href=#the-tr-element>tr</a></code> element) from the <a href=#stack-of-open-elements>stack of open elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>".</p> </dd> <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot", "thead", "tr"</dt> <dt>An end tag whose tag name is "table"</dt> <dd> <p>Act as if an end tag with the tag name "tr" had been seen, then, if that token wasn't ignored, reprocess the current token.</p> <p class=note>The fake end tag token here can only be ignored in the <a href=#fragment-case>fragment case</a>.</p> </dd> <dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token.</p> <p>Otherwise, act as if an end tag with the tag name "tr" had been seen, then reprocess the current token.</p> </dd> <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td", "th"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> </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>current node</a> is not a <code><a href=#the-tr-element>tr</a></code> element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p class=note>The <a href=#current-node>current node</a> being an <code><a href=#the-html-element>html</a></code> element after this process is a <a href=#fragment-case>fragment case</a>.</p> <h6 id=parsing-main-intd><span class=secno>13.2.5.4.15 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>An end tag whose tag name is one of: "td", "th"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse error</a> and the token must be ignored.</p> <p>Otherwise:</p> <p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</p> <p>Now, if the <a href=#current-node>current node</a> is not an element with the same tag name as the token, then this is a <a href=#parse-error>parse error</a>.</p> <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> stack until an element 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>Clear the list of active formatting elements up to the last marker</a>.</p> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>".</p> <!-- current node here will be a <tr> normally; but could be <html> in the fragment case --> </dd> <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does <em>not</em> <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>td</code> or <code>th</code> element in table scope</a>, then this is a <a href=#parse-error>parse error</a>; ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, <a href=#close-the-cell>close the cell</a> (see below) and reprocess the current token.</p> </dd> <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>An end tag whose tag name is one of: "table", "tbody", "tfoot", "thead", "tr"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table scope</a> with the same tag name as that of the token (which can only happen for "tbody", "tfoot" and "thead", or in the <a href=#fragment-case>fragment case</a>), then this is a <a href=#parse-error>parse error</a> and the token must be ignored.</p> <p>Otherwise, <a href=#close-the-cell>close the cell</a> (see below) and reprocess the current token.</p> </dd> <dt>Anything else</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> </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>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope title="has an element in table scope">has a <code>td</code> element in table scope</a>, then act as if an end tag token with the tag name "td" had been seen.</li> <li><p>Otherwise, the <a href=#stack-of-open-elements>stack of open elements</a> will <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>th</code> element in table scope</a>; act as if an end tag token with the tag name "th" had been seen.</li> </ol><p class=note>The <a href=#stack-of-open-elements>stack of open elements</a> cannot have both a <code><a href=#the-td-element>td</a></code> and a <code><a href=#the-th-element>th</a></code> element <a href=#has-an-element-in-table-scope title="has an element in table scope">in table scope</a> at the same time, nor can it have neither when the <a href=#close-the-cell>close the cell</a> algorithm is invoked.</p> <h6 id=parsing-main-inselect><span class=secno>13.2.5.4.16 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is U+0000 NULL</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>Any other character token</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "option"</dt> <dd> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code> element, act as if an end tag with the tag name "option" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <dt>A start tag whose tag name is "optgroup"</dt> <dd> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code> element, act as if an end tag with the tag name "option" had been seen.</p> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-optgroup-element>optgroup</a></code> element, act as if an end tag with the tag name "optgroup" had been seen.</p> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <dt>An end tag whose tag name is "optgroup"</dt> <dd> <p>First, if the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code> element, and the node immediately before it in the <a href=#stack-of-open-elements>stack of open elements</a> is an <code><a href=#the-optgroup-element>optgroup</a></code> element, then act as if an end tag with the tag name "option" had been seen.</p> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-optgroup-element>optgroup</a></code> element, then pop that node from the <a href=#stack-of-open-elements>stack of open elements</a>. Otherwise, this is a <a href=#parse-error>parse error</a>; ignore the token.</p> </dd> <dt>An end tag whose tag name is "option"</dt> <dd> <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code> element, then pop that node from the <a href=#stack-of-open-elements>stack of open elements</a>. Otherwise, this is a <a href=#parse-error>parse error</a>; ignore the token.</p> </dd> <dt>An end tag whose tag name is "select"</dt> <dd> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-select-scope title="has an element in select scope">have an element in select scope</a> with the same tag name as the token, this is a <a href=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise:</p> <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-select-element>select</a></code> element has been popped from the stack.</p> <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p> </dd> <dt>A start tag whose tag name is "select"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if the token had been an end tag with the tag name "select" instead.</p> </dd> <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-select-scope title="has an element in select scope">have a <code>select</code> element in select scope</a>, ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, act as if an end tag with the tag name "select" had been seen, and reprocess the token.</p> </dd> <dt>A start tag token whose tag name is "script"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end-of-file token</dt> <dd> <p>If the <a href=#current-node>current node</a> is not the root <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <p class=note>The <a href=#current-node>current node</a> can only be the root <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> </dl><h6 id=parsing-main-inselectintable><span class=secno>13.2.5.4.17 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" <a href=#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"</dt> <dd> <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag name "select" had been seen, and reprocess the token.</p> </dd> <dt>An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th"</dt> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope>has an element in table scope</a> with the same tag name as that of the token, then act as if an end tag with the tag name "select" had been seen, and reprocess the token. Otherwise, ignore the token.</p> </dd> <dt>Anything else</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> </dl><h6 id=parsing-main-afterbody><span class=secno>13.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the first element in the <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element), with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end tag whose tag name is "html"</dt> <dd> <p>If the parser was originally created as part of the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, this is a <a href=#parse-error>parse error</a>; ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>".</p> </dd> <dt>An end-of-file token</dt> <dd> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and reprocess the token.</p> </dd> </dl><h6 id=parsing-main-inframeset><span class=secno>13.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>A start tag whose tag name is "frameset"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p> </dd> <dt>An end tag whose tag name is "frameset"</dt> <dd> <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>; ignore the token. (<a href=#fragment-case>fragment case</a>)</p> <p>Otherwise, pop the <a href=#current-node>current node</a> from the <a href=#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>HTML fragment parsing algorithm</a> (<a href=#fragment-case>fragment case</a>), and the <a href=#current-node>current node</a> is no longer a <code><a href=#frameset>frameset</a></code> element, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>".</p> </dd> <dt>A start tag whose tag name is "frame"</dt> <dd> <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p><a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">Acknowledge the token's <i>self-closing flag</i></a>, if it is set.</p> </dd> <dt>A start tag whose tag name is "noframes"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end-of-file token</dt> <dd> <p>If the <a href=#current-node>current node</a> is not the root <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse error</a>.</p> <p class=note>The <a href=#current-node>current node</a> can only be the root <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> </dl><h6 id=parsing-main-afterframeset><span class=secno>13.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case --> <dl class=switch><dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end tag whose tag name is "html"</dt> <dd> <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>".</p> </dd> <dt>A start tag whose tag name is "noframes"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end-of-file token</dt> <dd> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>13.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <code><a href=#document>Document</a></code> object with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end-of-file token</dt> <dd> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and reprocess the token.</p> </dd> </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>13.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6> <p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p> <dl class=switch><dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <code><a href=#document>Document</a></code> object with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dt>A start tag whose tag name is "html"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>An end-of-file token</dt> <dd> <p><a href=#stop-parsing>Stop parsing</a>.</p> </dd> <dt>A start tag whose tag name is "noframes"</dt> <dd> <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>.</p> </dd> <dt>Anything else</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> </dl><h5 id=parsing-main-inforeign><span class=secno>13.2.5.5 </span>The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></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</dt> <dd> <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a character">Insert a U+FFFD REPLACEMENT CHARACTER character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> </dd> <dt>Any other character token</dt> <dd> <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current node</a>.</p> <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p> </dd> <dt>A comment token</dt> <dd> <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p> </dd> <dt>A DOCTYPE token</dt> <dd> <p><a href=#parse-error>Parse error</a>. Ignore the token.</p> </dd> <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big", "blockquote", "body"<!--by inspection-->, "br", "center", "code", "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled uniformly throughout the parser -->, "em", "embed", "h1", "h2", "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for completeness-->, "head"<!--by inspection-->, "hr", "i", "img", "li", "listing"<!-- so that pre and listing can be handled uniformly throughout the parser -->, "menu", "meta", "nobr", "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small", "span", "strong", "strike"<!-- so that s and strike can be handled uniformly throughout the parser -->, <!--"style",--> "sub", "sup", "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this list was determined empirically by studying over 6,000,000,000 pages that were specifically not XML pages --> <dt>A start tag whose tag name is "font", if the token has any attributes named "color", "face", or "size"</dt> <!-- the attributes here are required so that SVG <font> will go through as SVG but legacy <font>s won't --> <dd> <p><a href=#parse-error>Parse error</a>.</p> <p>Pop an element from the <a href=#stack-of-open-elements>stack of open elements</a>, and then keep popping more elements from the <a href=#stack-of-open-elements>stack of open elements</a> until the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point>HTML integration point</a>, or an element in the <a href=#html-namespace-0>HTML namespace</a>.</p> <p>Then, reprocess the token.</p> </dd> <dt>Any other start tag</dt> <dd> <p>If the <a href=#current-node>current node</a> is an element in the <a href=#mathml-namespace>MathML namespace</a>, <a href=#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=#current-node>current node</a> is an element in the <a href=#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 title="">altglyph</code> <td> <code title="">altGlyph</code> <tr><td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code> <tr><td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code> <tr><td> <code title="">animatecolor</code> <td> <code title="">animateColor</code> <tr><td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code> <tr><td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code> <tr><td> <code title="">clippath</code> <td> <code title="">clipPath</code> <tr><td> <code title="">feblend</code> <td> <code title="">feBlend</code> <tr><td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code> <tr><td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code> <tr><td> <code title="">fecomposite</code> <td> <code title="">feComposite</code> <tr><td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code> <tr><td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code> <tr><td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code> <tr><td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code> <tr><td> <code title="">feflood</code> <td> <code title="">feFlood</code> <tr><td> <code title="">fefunca</code> <td> <code title="">feFuncA</code> <tr><td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code> <tr><td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code> <tr><td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code> <tr><td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code> <tr><td> <code title="">feimage</code> <td> <code title="">feImage</code> <tr><td> <code title="">femerge</code> <td> <code title="">feMerge</code> <tr><td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code> <tr><td> <code title="">femorphology</code> <td> <code title="">feMorphology</code> <tr><td> <code title="">feoffset</code> <td> <code title="">feOffset</code> <tr><td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code> <tr><td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code> <tr><td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code> <tr><td> <code title="">fetile</code> <td> <code title="">feTile</code> <tr><td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code> <tr><td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code> <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code> <tr><td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code> <tr><td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code> <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)--> <tr><td> <code title="">textpath</code> <td> <code title="">textPath</code> </table><p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG namespace</a>, <a href=#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>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>Insert a foreign element</a> for the token, in the same namespace as the <a href=#current-node>current node</a>.</p> <p>If the token has its <i>self-closing flag</i> set, pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing flag">acknowledge the token's <i>self-closing flag</i></a>.</p> </dd> <dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node>current node</a> is a <code title="">script</code> element in the <a href=#svg-namespace>SVG namespace</a></dt> <dd> <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p> <p>Let the <var title="">old insertion point</var> have the same value as the current <a href=#insertion-point>insertion point</a>. Let the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next input character</a>.</p> <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by one. Set the <a href=#parser-pause-flag>parser pause flag</a> to true.</p> <p><a href=http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process the <code title="">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 title=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>parser pause flag</a> is true.</p> <p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero, then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p> <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the <a href=#insertion-point>insertion point</a> to its previous value. This value might be the "undefined" value.)</p> </dd> <dt>Any other end tag</dt> <dd> <p>Run these steps:</p> <ol><li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current node</a> (the bottommost node of the stack).</li> <li><p>If <var title="">node</var> is not an element with the same tag name as the token, then this is a <a href=#parse-error>parse error</a>.</li> <li><p><i>Loop</i>: If <var title="">node</var>'s tag name, <a href=#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>stack of open elements</a> until <var title="">node</var> has been popped from the stack, and then abort these steps.</li> <li><p>Set <var title="">node</var> to the previous entry in the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><p>If <var title="">node</var> is not an element in the <a href=#html-namespace-0>HTML namespace</a>, return to the step labeled <i>loop</i>.</li> <li><p>Otherwise, process the token according to the rules given in the section corresponding to the current <a href=#insertion-mode>insertion mode</a> in HTML content.</li> </ol></dd> </dl></div> <div class=impl> <h4 id=the-end><span class=secno>13.2.6 </span>The end</h4> <p>Once the user agent <dfn id=stop-parsing title="stop parsing">stops parsing</dfn> the document, the user agent must run the following steps:</p> <ol><!-- this happens as part of one of the tasks that runs the parser --><li><p>Set the <a href=#current-document-readiness>current document readiness</a> to "<code title="">interactive</code>" <!-- this also synchronously fires an event --> and the <a href=#insertion-point>insertion point</a> to undefined.</li> <li><p>Pop <em>all</em> the nodes off the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <li><p>If the <a href=#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>Spin the event loop</a> until the first <code><a href=#the-script-element>script</a></code> in the <a href=#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> has its <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag set <em>and</em> the parser's <code><a href=#document>Document</a></code> <a href=#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that is blocking scripts</a>.</li> <li><p><a href=#execute-the-script-block title="execute the script block">Execute</a> the first <code><a href=#the-script-element>script</a></code> in the <a href=#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>.</li> <li><p>Remove the first <code><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>list of scripts that will execute when the document has finished parsing</a> (i.e. shift out the first entry in the list).</li> <li><p>If the <a href=#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 still not empty, repeat these substeps again from substep 1.</p> </ol></li> <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the <code><a href=#document>Document</a></code>.</li> <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the <a href=#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>list of scripts that will execute in order as soon as possible</a> are empty.</li> <!-- this step is not redundant with the next one, since <script> nodes delay the load event of the document they are in, but they might change document between being added to one document's set/list and executing those scripts, so they might be delaying another document but still be in this document's set/list. --> <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is nothing that <dfn id=delay-the-load-event title="delay the load event">delays the load event</dfn> in the <code><a href=#document>Document</a></code>.</li> <li><p><a href=#queue-a-task>Queue a task</a> to set the <a href=#current-document-readiness>current document readiness</a> to "<code title="">complete</code>". <!-- this also fires an event synchronously during the task --></li> <li><p>If the <code><a href=#document>Document</a></code> is in a <a href=#browsing-context>browsing context</a>, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object, but with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the <code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the <code><a href=#window>Window</a></code> object).</li> <li><p>If the <code><a href=#document>Document</a></code> is in a <a href=#browsing-context>browsing context</a>, then <a href=#queue-a-task>queue a task</a> to fire a <code title=event-pageshow><a href=#event-pageshow>pageshow</a></code> event at the <code><a href=#window>Window</a></code> object of the <code><a href=#document>Document</a></code>, but with its <code title=dom-event-target><a href=#dom-event-target>target</a></code> set to the <code><a href=#document>Document</a></code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the <code><a href=#window>Window</a></code> object), using the <code><a href=#pagetransitionevent>PageTransitionEvent</a></code> interface, with the <code title=dom-PageTransitionEvent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to false. This event must not bubble, must not be cancelable, and has no default action.</li> <li><p>If the <code><a href=#document>Document</a></code> has any <a href=#pending-application-cache-download-process-tasks>pending application cache download process tasks</a>, then <a href=#queue-a-task title="queue a task">queue</a> each such <a href=#concept-task title=concept-task>task</a> in the order they were added to the list of <a href=#pending-application-cache-download-process-tasks>pending application cache download process tasks</a>, and then empty the list of <a href=#pending-application-cache-download-process-tasks>pending application cache download process tasks</a>. The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#networking-task-source>networking task source</a>.</li> <li><p>If the <code><a href=#document>Document</a></code>'s <a href=#print-when-loaded>print when loaded</a> flag is set, then run the <a href=#printing-steps>printing steps</a>.</li> <li><p>The <code><a href=#document>Document</a></code> is now <dfn id=ready-for-post-load-tasks>ready for post-load tasks</dfn>.</li> <li><p><a href=#queue-a-task>Queue a task</a> to mark the <code><a href=#document>Document</a></code> as <dfn id=completely-loaded>completely loaded</dfn>.</li> </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=#the-input-stream>input stream</a>, and discard any future content that would have been added to it.</li> <li><p>Pop <em>all</em> the nodes off the <a href=#stack-of-open-elements>stack of open elements</a>.</li> <!-- anything else? this is things that happen when you call document.open() on a document that's still being parsed, or when you navigate a document that's still parsing, or navigate the parent of a frame with a document that's still parsing, or the user hits "stop". Should the pending scripts be blown away or anything? --> </ol><p>Except where otherwise specified, the <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> mentioned in this section is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> </div> <div class=impl> <h4 id=coercing-an-html-dom-into-an-infoset><span class=secno>13.2.7 </span>Coercing an HTML DOM into an infoset</h4> <p>When an application uses an <a href=#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 title="">xmlns</code>, since they conflict with the Namespaces in XML syntax. There is also some data that the <a href=#html-parser>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 title="">xmlns</code>", attributes whose names start with "<code title="">xmlns:</code>", or attributes in the <a href=#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 Unicode 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 title="">foo<bar</code>, which can be output by the <a href=#html-parser>HTML parser</a>, though it is neither a legal HTML element name nor a well-formed XML element name, would be converted into <code title="">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 title="adjust foreign attributes">adjusted</a>, an attribute with a prefix "<code title="">xlink</code>" and a local name "<code title="">href</code>". However, used on an HTML element, it becomes an attribute with no prefix and the local name "<code title="">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 title="">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>HTML parser</a>, since those are all either lowercase or those listed in the <a href=#adjust-foreign-attributes>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><a href=#no-quirks-mode>no-quirks mode</a></i>, <i><a href=#limited-quirks-mode>limited-quirks mode</a></i>, or <i><a href=#quirks-mode>quirks mode</a></i></li> <li>The association between form controls and forms that aren't their nearest <code><a href=#the-form-element>form</a></code> element ancestor (use of the <a href=#form-element-pointer><code>form</code> element pointer</a> in the parser)</li> </ul><p class=note>The mutations allowed by this section apply <em>after</em> the <a href=#html-parser>HTML parser</a>'s rules have been applied. For example, a <code title=""><a::></code> start tag will be closed by a <code title=""></a::></code> end tag, and never by a <code title=""></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 title="">aU00003AU00003A</code> for that start tag.</p> </div> <div class=impl> <h4 id=an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>13.2.8 </span>An introduction to error handling and strange cases in the parser</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>HTML parser</a> handles these cases.</p> <h5 id=misnested-tags:-b-i-/b-/i><span class=secno>13.2.8.1 </span>Misnested tags: <b><i></b></i></h5> <p><i>This section is non-normative.</i></p> <p>The most-often discussed example of erroneous markup is as follows:</p> <pre><p>1<b>2<i>3</b>4</i>5</p></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><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has five elements on it: <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-p-element>p</a></code>, <code><a href=#the-b-element>b</a></code>, and <code><a href=#the-i-element>i</a></code>. The <a href=#list-of-active-formatting-elements>list of active formatting elements</a> just has two: <code><a href=#the-b-element>b</a></code> and <code><a href=#the-i-element>i</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">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 title="">formatting element</var> is the <code><a href=#the-b-element>b</a></code> element, and there is no <var title="">furthest block</var>. Thus, the <a href=#stack-of-open-elements>stack of open elements</a> ends up with just three elements: <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, and <code><a href=#the-p-element>p</a></code>, while the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> has just one: <code><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 title="reconstruct the active formatting elements">reconstruction of the active formatting elements</a>, in this case just the <code><a href=#the-i-element>i</a></code> element. A new <code><a href=#the-i-element>i</a></code> element is thus created for the "4" text node. After the end tag token for the "i" is also received, and the "5" text node is inserted, the DOM looks as follows:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></h5> <p><i>This section is non-normative.</i></p> <p>A case similar to the previous one is the following:</p> <pre><b>1<p>2</b>3</p></pre> <p>Up to the "2" the parsing here is straightforward:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">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>stack of open elements</a> has four elements on it: <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-b-element>b</a></code>, and <code><a href=#the-p-element>p</a></code>. The <a href=#list-of-active-formatting-elements>list of active formatting elements</a> just has the one: <code><a href=#the-b-element>b</a></code>. The <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion mode: in body">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 title="">furthest block</var>, namely the <code><a href=#the-p-element>p</a></code> element. Thus, this time the adoption agency algorithm isn't skipped over.</p> <p>The <var title="">common ancestor</var> is the <code><a href=#the-body-element>body</a></code> element. A conceptual "bookmark" marks the position of the <code><a href=#the-b-element>b</a></code> in the <a href=#list-of-active-formatting-elements>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 title="">node</var> ends up set to the formatting element (<code><a href=#the-b-element>b</a></code>), and <var title="">last node</var> ends up set to the <var title="">furthest block</var> (<code><a href=#the-p-element>p</a></code>).</p> <p>The <var title="">last node</var> gets appended (moved) to the <var title="">common ancestor</var>, so that the DOM looks like:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul><p>A new <code><a href=#the-b-element>b</a></code> element is created, and the children of the <code><a href=#the-p-element>p</a></code> element are moved to it:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code></ul></ul></ul><ul class=domTree><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul><p>Finally, the new <code><a href=#the-b-element>b</a></code> element is appended to the <code><a href=#the-p-element>p</a></code> element, so that the DOM looks like:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul></ul></ul></ul></ul><p>The <code><a href=#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> and the <a href=#stack-of-open-elements>stack of open elements</a>, so that when the "3" is parsed, it is appended to the <code><a href=#the-p-element>p</a></code> element:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</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><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre> <p>The highlighted <code><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 title="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><a href=#the-table-element>table</a></code> element's start tag has been seen:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>...and then immediately after the <code><a href=#the-b-element>b</a></code> element start tag has been seen:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code></ul></ul></ul><p>At this point, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-table-element>table</a></code>, and <code><a href=#the-b-element>b</a></code> (in that order, despite the resulting DOM tree); the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> just has the <code><a href=#the-b-element>b</a></code> element in it; and the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p> <p>The <code><a href=#the-tr-element>tr</a></code> start tag causes the <code><a href=#the-b-element>b</a></code> element to be popped off the stack and a <code><a href=#the-tbody-element>tbody</a></code> start tag to be implied; the <code><a href=#the-tbody-element>tbody</a></code> and <code><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 title="insertion mode: in table body">in table body</a>" and "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" insertion modes, after which the DOM looks as follows:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code></ul></ul></ul></ul></ul><p>Here, the <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tr-element>tr</a></code>; the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> still has the <code><a href=#the-b-element>b</a></code> element in it; and the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>".</p> <p>The <code><a href=#the-td-element>td</a></code> element start tag token, after putting a <code><a href=#the-td-element>td</a></code> element on the tree, puts a marker on the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> (it also switches to the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion mode</a>).</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul><p>The marker means that when the "aaa" character tokens are seen, no <code><a href=#the-b-element>b</a></code> element is created to hold the resulting text node:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">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>stack of open elements</a> has on it the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-table-element>table</a></code>, and <code><a href=#the-tbody-element>tbody</a></code>; the <a href=#list-of-active-formatting-elements>list of active formatting elements</a> still has the <code><a href=#the-b-element>b</a></code> element in it (the marker having been removed by the "td" end tag token); and the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>".</p> <p>Thus it is that the "bbb" character tokens are found. These trigger the "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>" insertion mode to be used (with the <a href=#original-insertion-mode>original insertion mode</a> set to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>"). The character tokens are collected, and when the next token (the <code><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 title="insertion mode: in table">in table</a>" insertion mode, which defer to the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" insertion mode but with <a href=#foster-parent title="foster parent">foster parenting</a>.</p> <p>When <a href=#reconstruct-the-active-formatting-elements title="reconstruct the active formatting elements">the active formatting elements are reconstructed</a>, a <code><a href=#the-b-element>b</a></code> element is created and <a href=#foster-parent title="foster parent">foster parented</a>, and then the "bbb" text node is appended to it:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul></ul></ul></ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> has on it the elements <code><a href=#the-html-element>html</a></code>, <code><a href=#the-body-element>body</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and the new <code><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>list of active formatting elements</a> has the new <code><a href=#the-b-element>b</a></code> element in it; and the <a href=#insertion-mode>insertion mode</a> is still "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>".</p> <p>Had the character tokens been only <a href=#space-character title="space character">space characters</a> instead of "bbb", then those <a href=#space-character title="space character">space characters</a> would just be appended to the <code><a href=#the-tbody-element>tbody</a></code> element.</p> <p>Finally, the <code><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>stack of open elements</a> up to and including the <code><a href=#the-table-element>table</a></code> element, but it doesn't affect the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>, so the "ccc" character tokens after the table result in yet another <code><a href=#the-b-element>b</a></code> element being created, this time after the table:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is being parsed</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 href=#url>URL</a> <code title="">http://example.com/inner</code>, being rendered as the content of an <code><a href=#the-iframe-element>iframe</a></code> in another document with the <a href=#url>URL</a> <code title="">http://example.com/outer</code>:</p> <pre><div id=a> <script> var div = document.getElementById('a'); parent.document.body.appendChild(div); </script> <script> alert(document.URL); </script> </div> <script> alert(document.URL); </script></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><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-div-element>div</a></code> <span class=t2 title=""><code class="attribute name">id</code>="<code class="attribute value"><a href=#the-a-element>a</a></code>"</span><ul><li class=t3><code>#text</code>: <span title=""> </span><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">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><a href=#the-div-element>div</a></code> element and its child <code><a href=#the-script-element>script</a></code> element are gone:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code></ul></ul><p>They are, at this point, in the <code><a href=#document>Document</a></code> of the aforementioned outer <a href=#browsing-context>browsing context</a>. However, the <a href=#stack-of-open-elements>stack of open elements</a> <em>still contains the <code><a href=#the-div-element>div</a></code> element</em>.</p> <p>Thus, when the second <code><a href=#the-script-element>script</a></code> element is parsed, it is inserted <em>into the outer <code><a href=#document>Document</a></code> object</em>.</p> <p>This parsed into different <code><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><a href=#the-div-element>div</a></code> element's end tag is parsed, the <code><a href=#the-div-element>div</a></code> element is popped off the stack, and so the next <code><a href=#the-script-element>script</a></code> element is in the inner <code><a href=#document>Document</a></code>:</p> <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This script does execute, resulting in an alert that says "http://example.com/inner".</p> <h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</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><a href=#the-script-element>script</a></code> element is an external script (i.e. one with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute). Since the element was not in the parser's <code><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><a href=#the-script-element>script</a></code> element with a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute is parsed normally into its parser's <code><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><a href=#the-script-element>script</a></code> elements between <code><a href=#document>Document</a></code>s is considered a bad practice.</p> <h5 id=unclosed-formatting-elements><span class=secno>13.2.8.6 </span>Unclosed formatting elements</h5> <p><i>This section is non-normative.</i></p> <p>The following markup shows how nested formatting elements (such as <code><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><!DOCTYPE html> <p><b class=x><b class=x><b><b class=x><b class=x><b>X <p>X <p><b><b class=x><b>X <p></b></b></b></b></b></b>X</pre> <p>The resulting DOM tree is as follows:</p> <ul class=domTree><li class=t10>DOCTYPE: <code><a href=#the-html-element>html</a></code><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code> <span class=t2 title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">X⏎</span></ul></ul></ul></ul><p>Note how the second <code><a href=#the-p-element>p</a></code> element in the markup has no explicit <code><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><a href=#the-b-element>b</a></code> elements with the class attribute, and two unadorned <code><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><a href=#the-b-element>b</a></code> end tags are needed to completely clear the list of formatting elements, even though nine <code><a href=#the-b-element>b</a></code> start tags have been seen up to this point.</p> <h3 id=serializing-html-fragments><span class=secno>13.3 </span>Serializing HTML fragments</h3> <p>The following steps form the <dfn id=html-fragment-serialization-algorithm>HTML fragment serialization algorithm</dfn>. The algorithm takes as input a DOM <code><a href=#element>Element</a></code>, <code><a href=#document>Document</a></code>, or <code><a href=#documentfragment>DocumentFragment</a></code> referred to as <var title="">the node</var>, and either returns a string or throws an exception.</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 title="">s</var> be a string, and initialize it to the empty string.</li> <li> <p>For each child node of <var title="">the node</var>, in <a href=#tree-order>tree order</a>, run the following steps: <ol><li><p>Let <var title="">current node</var> be the child node being processed.</li> <li> <p>Append the appropriate string from the following list to <var title="">s</var>:</p> <dl class=switch><dt>If <var title="">current node</var> is an <code title="">Element</code></dt> <dd> <p>If <var title="">current node</var> is an element in the <a href=#html-namespace-0>HTML namespace</a>, the <a href=#mathml-namespace>MathML namespace</a>, or the <a href=#svg-namespace>SVG namespace</a>, then let <var title="">tagname</var> be <var title="">current node</var>'s local name. Otherwise, let <var title="">tagname</var> be <var title="">current node</var>'s qualified name.</p> <p>Append a U+003C LESS-THAN SIGN character (<), followed by <var title="">tagname</var>.</p> <p class=note>For <a href=#html-elements>HTML elements</a> created by the <a href=#html-parser>HTML parser</a> or <code title="">Document.createElement()</code>, <var title="">tagname</var> will be lowercase.</p> <p>For each attribute that the element has, append a U+0020 SPACE character, the <a href="#attribute's-serialized-name" title="attribute's serialized 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 title="escaping a string">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-serialized-name">attribute's serialized name</dfn> for the purposes of the previous paragraph must be determined as follows:</p> <dl class=switch><dt>If the attribute has no namespace</dt> <dd> <p>The attribute's serialized name is the attribute's local name.</p> <p class=note>For attributes on <a href=#html-elements>HTML elements</a> set by the <a href=#html-parser>HTML parser</a> or by <code title="">Element.setAttributeNode()</code> or <code title="">Element.setAttribute()</code>, the local name will be lowercase.</p> </dd> <dt>If the attribute is in the <a href=#xml-namespace>XML namespace</a></dt> <dd><p>The attribute's serialized name is the string "<code title="">xml:</code>" followed by the attribute's local name.</dd> <dt>If the attribute is in the <a href=#xmlns-namespace>XMLNS namespace</a> and the attribute's local name is <code title="">xmlns</code></dt> <dd><p>The attribute's serialized name is the string "<code title="">xmlns</code>".</dd> <dt>If the attribute is in the <a href=#xmlns-namespace>XMLNS namespace</a> and the attribute's local name is not <code title="">xmlns</code></dt> <dd><p>The attribute's serialized name is the string "<code title="">xmlns:</code>" followed by the attribute's local name.</dd> <dt>If the attribute is in the <a href=#xlink-namespace>XLink namespace</a></dt> <dd><p>The attribute's serialized name is the string "<code title="">xlink:</code>" followed by the attribute's local name.</dd> <dt>If the attribute is in some other namespace</dt> <dd><p>The attribute's serialized name is the attribute's qualified name.</dd> </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 title="">current node</var> is an <code><a href=#the-area-element>area</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>, <code><a href=#the-br-element>br</a></code>, <code><a href=#the-col-element>col</a></code>, <code><a href=#the-command-element>command</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#the-hr-element>hr</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#the-keygen-element>keygen</a></code>, <code><a href=#the-link-element>link</a></code>, <code><a href=#the-meta-element>meta</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#the-source-element>source</a></code>, <code><a href=#the-track-element>track</a></code> or <code><a href=#the-wbr-element>wbr</a></code> element, then continue on to the next child node at this point.</p> <!-- VOIDLIST superset --> <!-- also, i guess: image and isindex, but we don't list those because we don't consider those "elements", more "macros", and thus we should never serialize them --> <p>If <var title="">current node</var> is a <code><a href=#the-pre-element>pre</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, or <code><a href=#listing>listing</a></code> element, append a U+000A LINE FEED (LF) character.</p> <p>Append the value of running the <a href=#html-fragment-serialization-algorithm>HTML fragment serialization algorithm</a> on the <var title="">current node</var> element (thus recursing into this algorithm for that element), followed by a U+003C LESS-THAN SIGN character (<), a U+002F SOLIDUS character (/), <var title="">tagname</var> again, and finally a U+003E GREATER-THAN SIGN character (>).</p> </dd> <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code> node</dt> <dd> <p>If the parent of <var title="">current node</var> is a <code><a href=#the-style-element>style</a></code>, <code><a href=#the-script-element>script</a></code>, <code><a href=#xmp>xmp</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#noembed>noembed</a></code>, <code><a href=#noframes>noframes</a></code>, or <code><a href=#plaintext>plaintext</a></code> element, or if the parent of <var title="">current node</var> is <code><a href=#the-noscript-element>noscript</a></code> element and <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> for the node, then append the value of <var title="">current node</var>'s <code title="">data</code> IDL attribute literally.</p> <p>Otherwise, append the value of <var title="">current node</var>'s <code title="">data</code> IDL attribute, <a href=#escapingString title="escaping a string">escaped as described below</a>.</p> </dd> <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt> <dd> <p>Append the literal string <code><!--</code> (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">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> </dd> <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt> <dd> <p>Append the literal string <code><?</code> (U+003C LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL attribute, followed by a single U+003E GREATER-THAN SIGN character (>).</p> </dd> <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt> <dd> <p>Append the literal string <code><!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 title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal string <code>></code> (U+003E GREATER-THAN SIGN).</p> </dd> </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot occur as children of elements. If, despite this, they somehow do occur, this algorithm must throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception.</p> </li> </ol></li> <li><p>The result of the algorithm is the string <var title="">s</var>.</li> </ol><!-- <p class="note">Entity reference nodes are <a href="#entity-references">assumed to be expanded</a> by the user agent, and are therefore not covered in the algorithm above.</p> --><!--ENTITY--><p class=warning>It is possible that the output of this algorithm, if parsed with an <a href=#html-parser>HTML parser</a>, will not return the original tree structure.</p> <div class=example> <p>For instance, if a <code><a href=#the-textarea-element>textarea</a></code> element to which a <code title="">Comment</code> node has been appended is serialized and the output is then reparsed, the comment will end up being displayed in the text field. Similarly, if, as a result of DOM manipulation, an element contains a comment that contains the literal string "<code title="">--></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><a href=#the-script-element>script</a></code> element contain a text node with the text string "<code></script></code>", or having a <code><a href=#the-p-element>p</a></code> element that contains a <code><a href=#the-ul-element>ul</a></code> element (as the <code><a href=#the-ul-element>ul</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> would imply the end tag for the <code><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 names that are then inserted into a CSS <code><a href=#the-style-element>style</a></code> block via the DOM and which then uses the <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> IDL attribute to get the HTML serialization of that <code><a href=#the-style-element>style</a></code> element: if the user enters "<code></style><script>attack</script></code>" as a font name, <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> will return markup that, if parsed in a different context, would contain a <code><a href=#the-script-element>script</a></code> node, even though no <code><a href=#the-script-element>script</a></code> node existed in the original DOM.</p> </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 title="">&</code>" character by the string "<code title="">&amp;</code>".</li> <li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>".</li> <li><p>If the algorithm was invoked in the <i>attribute mode</i>, replace any occurrences of the "<code title="">"</code>" character by the string "<code title="">&quot;</code>".</li> <li><p>If the algorithm was <em>not</em> invoked in the <i>attribute mode</i>, replace any occurrences of the "<code title=""><</code>" character by the string "<code title="">&lt;</code>", and any occurrences of the "<code title="">></code>" character by the string "<code title="">&gt;</code>".</li> </ol><h3 id=parsing-html-fragments><span class=secno>13.4 </span>Parsing HTML fragments</h3> <p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing algorithm</dfn>. The algorithm optionally takes as input an <code><a href=#element>Element</a></code> node, referred to as the <dfn id=concept-frag-parse-context title=concept-frag-parse-context><var>context</var></dfn> element, which gives the context for the parser, as well as <var title="">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 (and with a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element). 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>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><a href=#document>Document</a></code> node, and mark it as being an <a href=#html-documents title="HTML documents">HTML document</a>.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, and the <code><a href=#document>Document</a></code> of the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element is in <a href=#quirks-mode>quirks mode</a>, then let the <code><a href=#document>Document</a></code> be in <a href=#quirks-mode>quirks mode</a>. Otherwise, if there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, and the <code><a href=#document>Document</a></code> of the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element is in <a href=#limited-quirks-mode>limited-quirks mode</a>, then let the <code><a href=#document>Document</a></code> be in <a href=#limited-quirks-mode>limited-quirks mode</a>. Otherwise, leave the <code><a href=#document>Document</a></code> in <a href=#no-quirks-mode>no-quirks mode</a>.</p> </li> <li> <p>Create a new <a href=#html-parser>HTML parser</a>, and associate it with the just created <code><a href=#document>Document</a></code> node.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, run these substeps:</p> <ol><li> <p>Set the state of the <a href=#html-parser>HTML parser</a>'s <a href=#tokenization>tokenization</a> stage as follows:</p> <dl class=switch><dt>If it is a <code><a href=#the-title-element>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code> element</dt> <dd>Switch the tokenizer to the <a href=#rcdata-state>RCDATA state</a>.</dd> <dt>If it is a <code><a href=#the-style-element>style</a></code>, <code><a href=#xmp>xmp</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#noembed>noembed</a></code>, or <code><a href=#noframes>noframes</a></code> element</dt> <dd>Switch the tokenizer to the <a href=#rawtext-state>RAWTEXT state</a>.</dd> <dt>If it is a <code><a href=#the-script-element>script</a></code> element</dt> <dd>Switch the tokenizer to the <a href=#script-data-state>script data state</a>.</dd> <dt>If it is a <code><a href=#the-noscript-element>noscript</a></code> element</dt> <dd>If the <a href=#scripting-flag>scripting flag</a> is enabled, switch the tokenizer to the <a href=#rawtext-state>RAWTEXT state</a>. Otherwise, leave the tokenizer in the <a href=#data-state>data state</a>.</dd> <dt>If it is a <code><a href=#plaintext>plaintext</a></code> element</dt> <dd>Switch the tokenizer to the <a href=#plaintext-state>PLAINTEXT state</a>.</dd> <dt>Otherwise</dt> <dd>Leave the tokenizer in the <a href=#data-state>data state</a>.</dd> </dl><p class=note>For performance reasons, an implementation that does not report errors and that uses the actual state machine described in this specification directly could use the PLAINTEXT state instead of the RAWTEXT and script data states where those are mentioned in the list above. Except for rules regarding parse errors, they are equivalent, since there is no <a href=#appropriate-end-tag-token>appropriate end tag token</a> in the fragment case, yet they involve far fewer state transitions.</p> </li> <li> <p>Let <var title="">root</var> be a new <code><a href=#the-html-element>html</a></code> element with no attributes.</p> </li> <li> <p>Append the element <var title="">root</var> to the <code><a href=#document>Document</a></code> node created above.</p> </li> <li> <p>Set up the parser's <a href=#stack-of-open-elements>stack of open elements</a> so that it contains just the single element <var title="">root</var>.</p> </li> <li> <p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the parser's insertion mode appropriately</a>.</p> <p class=note>The parser will reference the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element as part of that algorithm.</p> </li> <li> <p>Set the parser's <a href=#form-element-pointer><code>form</code> element pointer</a> to the nearest node to the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element that is a <code><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><a href=#the-form-element>form</a></code> element), or, if there is no such <code><a href=#the-form-element>form</a></code> element, to null.</p> </li> </ol></li> <li> <p>Place into the <a href=#the-input-stream>input stream</a> for the <a href=#html-parser>HTML parser</a> just created the <var title="">input</var>. The encoding <a href=#concept-encoding-confidence title=concept-encoding-confidence>confidence</a> is <i>irrelevant</i>.</p> </li> <li> <p>Start the parser and let it run until it has consumed all the characters just inserted into the input stream.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, return the child nodes of <var title="">root</var>, in <a href=#tree-order>tree order</a>.</p> <p>Otherwise, return the children of the <code><a href=#document>Document</a></code> object, in <a href=#tree-order>tree order</a>.</p> </li> </ol><p class=note>This algorithm is invoked without a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element in the case of <code title=dom-Document-innerHTML>Document.innerHTML</code>.</p> </div> <h3 id=named-character-references><span class=secno>13.5 </span><dfn>Named character references</dfn></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> <th> Character(s) </th> <th> Glyph </th> <tbody><tr id=entity-Aacute><td> <code title="">Aacute;</code> </td> <td> U+000C1 </td> <td> <span class=glyph title="">Á</span> </td> <tr class=impl id=entity-Aacute-legacy><td> <code title="">Aacute</code> </td> <td> U+000C1 </td> <td> <span title="">Á</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-aacute><td> <code title="">aacute;</code> </td> <td> U+000E1 </td> <td> <span class=glyph title="">á</span> </td> <tr class=impl id=entity-aacute-legacy><td> <code title="">aacute</code> </td> <td> U+000E1 </td> <td> <span title="">á</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Abreve><td> <code title="">Abreve;</code> </td> <td> U+00102 </td> <td> <span class=glyph title="">Ă</span> </td> <tr id=entity-abreve><td> <code title="">abreve;</code> </td> <td> U+00103 </td> <td> <span class=glyph title="">ă</span> </td> <tr id=entity-ac><td> <code title="">ac;</code> </td> <td> U+0223E </td> <td> <span class=glyph title="">∾</span> </td> <tr id=entity-acd><td> <code title="">acd;</code> </td> <td> U+0223F </td> <td> <span class=glyph title="">∿</span> </td> <tr id=entity-acE><td> <code title="">acE;</code> </td> <td> U+0223E U+00333 </td> <td> <span class="glyph compound" title="">∾̳</span> </td> <tr id=entity-Acirc><td> <code title="">Acirc;</code> </td> <td> U+000C2 </td> <td> <span class=glyph title="">Â</span> </td> <tr class=impl id=entity-Acirc-legacy><td> <code title="">Acirc</code> </td> <td> U+000C2 </td> <td> <span title="">Â</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-acirc><td> <code title="">acirc;</code> </td> <td> U+000E2 </td> <td> <span class=glyph title="">â</span> </td> <tr class=impl id=entity-acirc-legacy><td> <code title="">acirc</code> </td> <td> U+000E2 </td> <td> <span title="">â</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-acute><td> <code title="">acute;</code> </td> <td> U+000B4 </td> <td> <span class=glyph title="">´</span> </td> <tr class=impl id=entity-acute-legacy><td> <code title="">acute</code> </td> <td> U+000B4 </td> <td> <span title="">´</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Acy><td> <code title="">Acy;</code> </td> <td> U+00410 </td> <td> <span class=glyph title="">А</span> </td> <tr id=entity-acy><td> <code title="">acy;</code> </td> <td> U+00430 </td> <td> <span class=glyph title="">а</span> </td> <tr id=entity-AElig><td> <code title="">AElig;</code> </td> <td> U+000C6 </td> <td> <span class=glyph title="">Æ</span> </td> <tr class=impl id=entity-AElig-legacy><td> <code title="">AElig</code> </td> <td> U+000C6 </td> <td> <span title="">Æ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-aelig><td> <code title="">aelig;</code> </td> <td> U+000E6 </td> <td> <span class=glyph title="">æ</span> </td> <tr class=impl id=entity-aelig-legacy><td> <code title="">aelig</code> </td> <td> U+000E6 </td> <td> <span title="">æ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-af><td> <code title="">af;</code> </td> <td> U+02061 </td> <td> <span class=glyph title="">⁡</span> </td> <tr id=entity-Afr><td> <code title="">Afr;</code> </td> <td> U+1D504 </td> <td> <span class=glyph title="">𝔄</span> </td> <tr id=entity-afr><td> <code title="">afr;</code> </td> <td> U+1D51E </td> <td> <span class=glyph title="">𝔞</span> </td> <tr id=entity-Agrave><td> <code title="">Agrave;</code> </td> <td> U+000C0 </td> <td> <span class=glyph title="">À</span> </td> <tr class=impl id=entity-Agrave-legacy><td> <code title="">Agrave</code> </td> <td> U+000C0 </td> <td> <span title="">À</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-agrave><td> <code title="">agrave;</code> </td> <td> U+000E0 </td> <td> <span class=glyph title="">à</span> </td> <tr class=impl id=entity-agrave-legacy><td> <code title="">agrave</code> </td> <td> U+000E0 </td> <td> <span title="">à</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-alefsym><td> <code title="">alefsym;</code> </td> <td> U+02135 </td> <td> <span class=glyph title="">ℵ</span> </td> <tr id=entity-aleph><td> <code title="">aleph;</code> </td> <td> U+02135 </td> <td> <span class=glyph title="">ℵ</span> </td> <tr id=entity-Alpha><td> <code title="">Alpha;</code> </td> <td> U+00391 </td> <td> <span class=glyph title="">Α</span> </td> <tr id=entity-alpha><td> <code title="">alpha;</code> </td> <td> U+003B1 </td> <td> <span class=glyph title="">α</span> </td> <tr id=entity-Amacr><td> <code title="">Amacr;</code> </td> <td> U+00100 </td> <td> <span class=glyph title="">Ā</span> </td> <tr id=entity-amacr><td> <code title="">amacr;</code> </td> <td> U+00101 </td> <td> <span class=glyph title="">ā</span> </td> <tr id=entity-amalg><td> <code title="">amalg;</code> </td> <td> U+02A3F </td> <td> <span class=glyph title="">⨿</span> </td> <tr id=entity-AMP><td> <code title="">AMP;</code> </td> <td> U+00026 </td> <td> <span class=glyph title="">&</span> </td> <tr class=impl id=entity-AMP-legacy><td> <code title="">AMP</code> </td> <td> U+00026 </td> <td> <span title="">&</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-amp><td> <code title="">amp;</code> </td> <td> U+00026 </td> <td> <span class=glyph title="">&</span> </td> <tr class=impl id=entity-amp-legacy><td> <code title="">amp</code> </td> <td> U+00026 </td> <td> <span title="">&</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-And><td> <code title="">And;</code> </td> <td> U+02A53 </td> <td> <span class=glyph title="">⩓</span> </td> <tr id=entity-and><td> <code title="">and;</code> </td> <td> U+02227 </td> <td> <span class=glyph title="">∧</span> </td> <tr id=entity-andand><td> <code title="">andand;</code> </td> <td> U+02A55 </td> <td> <span class=glyph title="">⩕</span> </td> <tr id=entity-andd><td> <code title="">andd;</code> </td> <td> U+02A5C </td> <td> <span class=glyph title="">⩜</span> </td> <tr id=entity-andslope><td> <code title="">andslope;</code> </td> <td> U+02A58 </td> <td> <span class=glyph title="">⩘</span> </td> <tr id=entity-andv><td> <code title="">andv;</code> </td> <td> U+02A5A </td> <td> <span class=glyph title="">⩚</span> </td> <tr id=entity-ang><td> <code title="">ang;</code> </td> <td> U+02220 </td> <td> <span class=glyph title="">∠</span> </td> <tr id=entity-ange><td> <code title="">ange;</code> </td> <td> U+029A4 </td> <td> <span class=glyph title="">⦤</span> </td> <tr id=entity-angle><td> <code title="">angle;</code> </td> <td> U+02220 </td> <td> <span class=glyph title="">∠</span> </td> <tr id=entity-angmsd><td> <code title="">angmsd;</code> </td> <td> U+02221 </td> <td> <span class=glyph title="">∡</span> </td> <tr id=entity-angmsdaa><td> <code title="">angmsdaa;</code> </td> <td> U+029A8 </td> <td> <span class=glyph title="">⦨</span> </td> <tr id=entity-angmsdab><td> <code title="">angmsdab;</code> </td> <td> U+029A9 </td> <td> <span class=glyph title="">⦩</span> </td> <tr id=entity-angmsdac><td> <code title="">angmsdac;</code> </td> <td> U+029AA </td> <td> <span class=glyph title="">⦪</span> </td> <tr id=entity-angmsdad><td> <code title="">angmsdad;</code> </td> <td> U+029AB </td> <td> <span class=glyph title="">⦫</span> </td> <tr id=entity-angmsdae><td> <code title="">angmsdae;</code> </td> <td> U+029AC </td> <td> <span class=glyph title="">⦬</span> </td> <tr id=entity-angmsdaf><td> <code title="">angmsdaf;</code> </td> <td> U+029AD </td> <td> <span class=glyph title="">⦭</span> </td> <tr id=entity-angmsdag><td> <code title="">angmsdag;</code> </td> <td> U+029AE </td> <td> <span class=glyph title="">⦮</span> </td> <tr id=entity-angmsdah><td> <code title="">angmsdah;</code> </td> <td> U+029AF </td> <td> <span class=glyph title="">⦯</span> </td> <tr id=entity-angrt><td> <code title="">angrt;</code> </td> <td> U+0221F </td> <td> <span class=glyph title="">∟</span> </td> <tr id=entity-angrtvb><td> <code title="">angrtvb;</code> </td> <td> U+022BE </td> <td> <span class=glyph title="">⊾</span> </td> <tr id=entity-angrtvbd><td> <code title="">angrtvbd;</code> </td> <td> U+0299D </td> <td> <span class=glyph title="">⦝</span> </td> <tr id=entity-angsph><td> <code title="">angsph;</code> </td> <td> U+02222 </td> <td> <span class=glyph title="">∢</span> </td> <tr id=entity-angst><td> <code title="">angst;</code> </td> <td> U+000C5 </td> <td> <span class=glyph title="">Å</span> </td> <tr id=entity-angzarr><td> <code title="">angzarr;</code> </td> <td> U+0237C </td> <td> <span class=glyph title="">⍼</span> </td> <tr id=entity-Aogon><td> <code title="">Aogon;</code> </td> <td> U+00104 </td> <td> <span class=glyph title="">Ą</span> </td> <tr id=entity-aogon><td> <code title="">aogon;</code> </td> <td> U+00105 </td> <td> <span class=glyph title="">ą</span> </td> <tr id=entity-Aopf><td> <code title="">Aopf;</code> </td> <td> U+1D538 </td> <td> <span class=glyph title="">𝔸</span> </td> <tr id=entity-aopf><td> <code title="">aopf;</code> </td> <td> U+1D552 </td> <td> <span class=glyph title="">𝕒</span> </td> <tr id=entity-ap><td> <code title="">ap;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-apacir><td> <code title="">apacir;</code> </td> <td> U+02A6F </td> <td> <span class=glyph title="">⩯</span> </td> <tr id=entity-apE><td> <code title="">apE;</code> </td> <td> U+02A70 </td> <td> <span class=glyph title="">⩰</span> </td> <tr id=entity-ape><td> <code title="">ape;</code> </td> <td> U+0224A </td> <td> <span class=glyph title="">≊</span> </td> <tr id=entity-apid><td> <code title="">apid;</code> </td> <td> U+0224B </td> <td> <span class=glyph title="">≋</span> </td> <tr id=entity-apos><td> <code title="">apos;</code> </td> <td> U+00027 </td> <td> <span class=glyph title="">'</span> </td> <tr id=entity-ApplyFunction><td> <code title="">ApplyFunction;</code> </td> <td> U+02061 </td> <td> <span class=glyph title="">⁡</span> </td> <tr id=entity-approx><td> <code title="">approx;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-approxeq><td> <code title="">approxeq;</code> </td> <td> U+0224A </td> <td> <span class=glyph title="">≊</span> </td> <tr id=entity-Aring><td> <code title="">Aring;</code> </td> <td> U+000C5 </td> <td> <span class=glyph title="">Å</span> </td> <tr class=impl id=entity-Aring-legacy><td> <code title="">Aring</code> </td> <td> U+000C5 </td> <td> <span title="">Å</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-aring><td> <code title="">aring;</code> </td> <td> U+000E5 </td> <td> <span class=glyph title="">å</span> </td> <tr class=impl id=entity-aring-legacy><td> <code title="">aring</code> </td> <td> U+000E5 </td> <td> <span title="">å</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Ascr><td> <code title="">Ascr;</code> </td> <td> U+1D49C </td> <td> <span class=glyph title="">𝒜</span> </td> <tr id=entity-ascr><td> <code title="">ascr;</code> </td> <td> U+1D4B6 </td> <td> <span class=glyph title="">𝒶</span> </td> <tr id=entity-Assign><td> <code title="">Assign;</code> </td> <td> U+02254 </td> <td> <span class=glyph title="">≔</span> </td> <tr id=entity-ast><td> <code title="">ast;</code> </td> <td> U+0002A </td> <td> <span class=glyph title="">*</span> </td> <tr id=entity-asymp><td> <code title="">asymp;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-asympeq><td> <code title="">asympeq;</code> </td> <td> U+0224D </td> <td> <span class=glyph title="">≍</span> </td> <tr id=entity-Atilde><td> <code title="">Atilde;</code> </td> <td> U+000C3 </td> <td> <span class=glyph title="">Ã</span> </td> <tr class=impl id=entity-Atilde-legacy><td> <code title="">Atilde</code> </td> <td> U+000C3 </td> <td> <span title="">Ã</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-atilde><td> <code title="">atilde;</code> </td> <td> U+000E3 </td> <td> <span class=glyph title="">ã</span> </td> <tr class=impl id=entity-atilde-legacy><td> <code title="">atilde</code> </td> <td> U+000E3 </td> <td> <span title="">ã</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Auml><td> <code title="">Auml;</code> </td> <td> U+000C4 </td> <td> <span class=glyph title="">Ä</span> </td> <tr class=impl id=entity-Auml-legacy><td> <code title="">Auml</code> </td> <td> U+000C4 </td> <td> <span title="">Ä</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-auml><td> <code title="">auml;</code> </td> <td> U+000E4 </td> <td> <span class=glyph title="">ä</span> </td> <tr class=impl id=entity-auml-legacy><td> <code title="">auml</code> </td> <td> U+000E4 </td> <td> <span title="">ä</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-awconint><td> <code title="">awconint;</code> </td> <td> U+02233 </td> <td> <span class=glyph title="">∳</span> </td> <tr id=entity-awint><td> <code title="">awint;</code> </td> <td> U+02A11 </td> <td> <span class=glyph title="">⨑</span> </td> <tr id=entity-backcong><td> <code title="">backcong;</code> </td> <td> U+0224C </td> <td> <span class=glyph title="">≌</span> </td> <tr id=entity-backepsilon><td> <code title="">backepsilon;</code> </td> <td> U+003F6 </td> <td> <span class=glyph title="">϶</span> </td> <tr id=entity-backprime><td> <code title="">backprime;</code> </td> <td> U+02035 </td> <td> <span class=glyph title="">‵</span> </td> <tr id=entity-backsim><td> <code title="">backsim;</code> </td> <td> U+0223D </td> <td> <span class=glyph title="">∽</span> </td> <tr id=entity-backsimeq><td> <code title="">backsimeq;</code> </td> <td> U+022CD </td> <td> <span class=glyph title="">⋍</span> </td> <tr id=entity-Backslash><td> <code title="">Backslash;</code> </td> <td> U+02216 </td> <td> <span class=glyph title="">∖</span> </td> <tr id=entity-Barv><td> <code title="">Barv;</code> </td> <td> U+02AE7 </td> <td> <span class=glyph title="">⫧</span> </td> <tr id=entity-barvee><td> <code title="">barvee;</code> </td> <td> U+022BD </td> <td> <span class=glyph title="">⊽</span> </td> <tr id=entity-Barwed><td> <code title="">Barwed;</code> </td> <td> U+02306 </td> <td> <span class=glyph title="">⌆</span> </td> <tr id=entity-barwed><td> <code title="">barwed;</code> </td> <td> U+02305 </td> <td> <span class=glyph title="">⌅</span> </td> <tr id=entity-barwedge><td> <code title="">barwedge;</code> </td> <td> U+02305 </td> <td> <span class=glyph title="">⌅</span> </td> <tr id=entity-bbrk><td> <code title="">bbrk;</code> </td> <td> U+023B5 </td> <td> <span class=glyph title="">⎵</span> </td> <tr id=entity-bbrktbrk><td> <code title="">bbrktbrk;</code> </td> <td> U+023B6 </td> <td> <span class=glyph title="">⎶</span> </td> <tr id=entity-bcong><td> <code title="">bcong;</code> </td> <td> U+0224C </td> <td> <span class=glyph title="">≌</span> </td> <tr id=entity-Bcy><td> <code title="">Bcy;</code> </td> <td> U+00411 </td> <td> <span class=glyph title="">Б</span> </td> <tr id=entity-bcy><td> <code title="">bcy;</code> </td> <td> U+00431 </td> <td> <span class=glyph title="">б</span> </td> <tr id=entity-bdquo><td> <code title="">bdquo;</code> </td> <td> U+0201E </td> <td> <span class=glyph title="">„</span> </td> <tr id=entity-becaus><td> <code title="">becaus;</code> </td> <td> U+02235 </td> <td> <span class=glyph title="">∵</span> </td> <tr id=entity-Because><td> <code title="">Because;</code> </td> <td> U+02235 </td> <td> <span class=glyph title="">∵</span> </td> <tr id=entity-because><td> <code title="">because;</code> </td> <td> U+02235 </td> <td> <span class=glyph title="">∵</span> </td> <tr id=entity-bemptyv><td> <code title="">bemptyv;</code> </td> <td> U+029B0 </td> <td> <span class=glyph title="">⦰</span> </td> <tr id=entity-bepsi><td> <code title="">bepsi;</code> </td> <td> U+003F6 </td> <td> <span class=glyph title="">϶</span> </td> <tr id=entity-bernou><td> <code title="">bernou;</code> </td> <td> U+0212C </td> <td> <span class=glyph title="">ℬ</span> </td> <tr id=entity-Bernoullis><td> <code title="">Bernoullis;</code> </td> <td> U+0212C </td> <td> <span class=glyph title="">ℬ</span> </td> <tr id=entity-Beta><td> <code title="">Beta;</code> </td> <td> U+00392 </td> <td> <span class=glyph title="">Β</span> </td> <tr id=entity-beta><td> <code title="">beta;</code> </td> <td> U+003B2 </td> <td> <span class=glyph title="">β</span> </td> <tr id=entity-beth><td> <code title="">beth;</code> </td> <td> U+02136 </td> <td> <span class=glyph title="">ℶ</span> </td> <tr id=entity-between><td> <code title="">between;</code> </td> <td> U+0226C </td> <td> <span class=glyph title="">≬</span> </td> <tr id=entity-Bfr><td> <code title="">Bfr;</code> </td> <td> U+1D505 </td> <td> <span class=glyph title="">𝔅</span> </td> <tr id=entity-bfr><td> <code title="">bfr;</code> </td> <td> U+1D51F </td> <td> <span class=glyph title="">𝔟</span> </td> <tr id=entity-bigcap><td> <code title="">bigcap;</code> </td> <td> U+022C2 </td> <td> <span class=glyph title="">⋂</span> </td> <tr id=entity-bigcirc><td> <code title="">bigcirc;</code> </td> <td> U+025EF </td> <td> <span class=glyph title="">◯</span> </td> <tr id=entity-bigcup><td> <code title="">bigcup;</code> </td> <td> U+022C3 </td> <td> <span class=glyph title="">⋃</span> </td> <tr id=entity-bigodot><td> <code title="">bigodot;</code> </td> <td> U+02A00 </td> <td> <span class=glyph title="">⨀</span> </td> <tr id=entity-bigoplus><td> <code title="">bigoplus;</code> </td> <td> U+02A01 </td> <td> <span class=glyph title="">⨁</span> </td> <tr id=entity-bigotimes><td> <code title="">bigotimes;</code> </td> <td> U+02A02 </td> <td> <span class=glyph title="">⨂</span> </td> <tr id=entity-bigsqcup><td> <code title="">bigsqcup;</code> </td> <td> U+02A06 </td> <td> <span class=glyph title="">⨆</span> </td> <tr id=entity-bigstar><td> <code title="">bigstar;</code> </td> <td> U+02605 </td> <td> <span class=glyph title="">★</span> </td> <tr id=entity-bigtriangledown><td> <code title="">bigtriangledown;</code> </td> <td> U+025BD </td> <td> <span class=glyph title="">▽</span> </td> <tr id=entity-bigtriangleup><td> <code title="">bigtriangleup;</code> </td> <td> U+025B3 </td> <td> <span class=glyph title="">△</span> </td> <tr id=entity-biguplus><td> <code title="">biguplus;</code> </td> <td> U+02A04 </td> <td> <span class=glyph title="">⨄</span> </td> <tr id=entity-bigvee><td> <code title="">bigvee;</code> </td> <td> U+022C1 </td> <td> <span class=glyph title="">⋁</span> </td> <tr id=entity-bigwedge><td> <code title="">bigwedge;</code> </td> <td> U+022C0 </td> <td> <span class=glyph title="">⋀</span> </td> <tr id=entity-bkarow><td> <code title="">bkarow;</code> </td> <td> U+0290D </td> <td> <span class=glyph title="">⤍</span> </td> <tr id=entity-blacklozenge><td> <code title="">blacklozenge;</code> </td> <td> U+029EB </td> <td> <span class=glyph title="">⧫</span> </td> <tr id=entity-blacksquare><td> <code title="">blacksquare;</code> </td> <td> U+025AA </td> <td> <span class=glyph title="">▪</span> </td> <tr id=entity-blacktriangle><td> <code title="">blacktriangle;</code> </td> <td> U+025B4 </td> <td> <span class=glyph title="">▴</span> </td> <tr id=entity-blacktriangledown><td> <code title="">blacktriangledown;</code> </td> <td> U+025BE </td> <td> <span class=glyph title="">▾</span> </td> <tr id=entity-blacktriangleleft><td> <code title="">blacktriangleleft;</code> </td> <td> U+025C2 </td> <td> <span class=glyph title="">◂</span> </td> <tr id=entity-blacktriangleright><td> <code title="">blacktriangleright;</code> </td> <td> U+025B8 </td> <td> <span class=glyph title="">▸</span> </td> <tr id=entity-blank><td> <code title="">blank;</code> </td> <td> U+02423 </td> <td> <span class=glyph title="">␣</span> </td> <tr id=entity-blk12><td> <code title="">blk12;</code> </td> <td> U+02592 </td> <td> <span class=glyph title="">▒</span> </td> <tr id=entity-blk14><td> <code title="">blk14;</code> </td> <td> U+02591 </td> <td> <span class=glyph title="">░</span> </td> <tr id=entity-blk34><td> <code title="">blk34;</code> </td> <td> U+02593 </td> <td> <span class=glyph title="">▓</span> </td> <tr id=entity-block><td> <code title="">block;</code> </td> <td> U+02588 </td> <td> <span class=glyph title="">█</span> </td> <tr id=entity-bne><td> <code title="">bne;</code> </td> <td> U+0003D U+020E5 </td> <td> <span class="glyph compound" title="">=⃥</span> </td> <tr id=entity-bnequiv><td> <code title="">bnequiv;</code> </td> <td> U+02261 U+020E5 </td> <td> <span class="glyph compound" title="">≡⃥</span> </td> <tr id=entity-bNot><td> <code title="">bNot;</code> </td> <td> U+02AED </td> <td> <span class=glyph title="">⫭</span> </td> <tr id=entity-bnot><td> <code title="">bnot;</code> </td> <td> U+02310 </td> <td> <span class=glyph title="">⌐</span> </td> <tr id=entity-Bopf><td> <code title="">Bopf;</code> </td> <td> U+1D539 </td> <td> <span class=glyph title="">𝔹</span> </td> <tr id=entity-bopf><td> <code title="">bopf;</code> </td> <td> U+1D553 </td> <td> <span class=glyph title="">𝕓</span> </td> <tr id=entity-bot><td> <code title="">bot;</code> </td> <td> U+022A5 </td> <td> <span class=glyph title="">⊥</span> </td> <tr id=entity-bottom><td> <code title="">bottom;</code> </td> <td> U+022A5 </td> <td> <span class=glyph title="">⊥</span> </td> <tr id=entity-bowtie><td> <code title="">bowtie;</code> </td> <td> U+022C8 </td> <td> <span class=glyph title="">⋈</span> </td> <tr id=entity-boxbox><td> <code title="">boxbox;</code> </td> <td> U+029C9 </td> <td> <span class=glyph title="">⧉</span> </td> <tr id=entity-boxDL><td> <code title="">boxDL;</code> </td> <td> U+02557 </td> <td> <span class=glyph title="">╗</span> </td> <tr id=entity-boxDl><td> <code title="">boxDl;</code> </td> <td> U+02556 </td> <td> <span class=glyph title="">╖</span> </td> <tr id=entity-boxdL><td> <code title="">boxdL;</code> </td> <td> U+02555 </td> <td> <span class=glyph title="">╕</span> </td> <tr id=entity-boxdl><td> <code title="">boxdl;</code> </td> <td> U+02510 </td> <td> <span class=glyph title="">┐</span> </td> <tr id=entity-boxDR><td> <code title="">boxDR;</code> </td> <td> U+02554 </td> <td> <span class=glyph title="">╔</span> </td> <tr id=entity-boxDr><td> <code title="">boxDr;</code> </td> <td> U+02553 </td> <td> <span class=glyph title="">╓</span> </td> <tr id=entity-boxdR><td> <code title="">boxdR;</code> </td> <td> U+02552 </td> <td> <span class=glyph title="">╒</span> </td> <tr id=entity-boxdr><td> <code title="">boxdr;</code> </td> <td> U+0250C </td> <td> <span class=glyph title="">┌</span> </td> <tr id=entity-boxH><td> <code title="">boxH;</code> </td> <td> U+02550 </td> <td> <span class=glyph title="">═</span> </td> <tr id=entity-boxh><td> <code title="">boxh;</code> </td> <td> U+02500 </td> <td> <span class=glyph title="">─</span> </td> <tr id=entity-boxHD><td> <code title="">boxHD;</code> </td> <td> U+02566 </td> <td> <span class=glyph title="">╦</span> </td> <tr id=entity-boxHd><td> <code title="">boxHd;</code> </td> <td> U+02564 </td> <td> <span class=glyph title="">╤</span> </td> <tr id=entity-boxhD><td> <code title="">boxhD;</code> </td> <td> U+02565 </td> <td> <span class=glyph title="">╥</span> </td> <tr id=entity-boxhd><td> <code title="">boxhd;</code> </td> <td> U+0252C </td> <td> <span class=glyph title="">┬</span> </td> <tr id=entity-boxHU><td> <code title="">boxHU;</code> </td> <td> U+02569 </td> <td> <span class=glyph title="">╩</span> </td> <tr id=entity-boxHu><td> <code title="">boxHu;</code> </td> <td> U+02567 </td> <td> <span class=glyph title="">╧</span> </td> <tr id=entity-boxhU><td> <code title="">boxhU;</code> </td> <td> U+02568 </td> <td> <span class=glyph title="">╨</span> </td> <tr id=entity-boxhu><td> <code title="">boxhu;</code> </td> <td> U+02534 </td> <td> <span class=glyph title="">┴</span> </td> <tr id=entity-boxminus><td> <code title="">boxminus;</code> </td> <td> U+0229F </td> <td> <span class=glyph title="">⊟</span> </td> <tr id=entity-boxplus><td> <code title="">boxplus;</code> </td> <td> U+0229E </td> <td> <span class=glyph title="">⊞</span> </td> <tr id=entity-boxtimes><td> <code title="">boxtimes;</code> </td> <td> U+022A0 </td> <td> <span class=glyph title="">⊠</span> </td> <tr id=entity-boxUL><td> <code title="">boxUL;</code> </td> <td> U+0255D </td> <td> <span class=glyph title="">╝</span> </td> <tr id=entity-boxUl><td> <code title="">boxUl;</code> </td> <td> U+0255C </td> <td> <span class=glyph title="">╜</span> </td> <tr id=entity-boxuL><td> <code title="">boxuL;</code> </td> <td> U+0255B </td> <td> <span class=glyph title="">╛</span> </td> <tr id=entity-boxul><td> <code title="">boxul;</code> </td> <td> U+02518 </td> <td> <span class=glyph title="">┘</span> </td> <tr id=entity-boxUR><td> <code title="">boxUR;</code> </td> <td> U+0255A </td> <td> <span class=glyph title="">╚</span> </td> <tr id=entity-boxUr><td> <code title="">boxUr;</code> </td> <td> U+02559 </td> <td> <span class=glyph title="">╙</span> </td> <tr id=entity-boxuR><td> <code title="">boxuR;</code> </td> <td> U+02558 </td> <td> <span class=glyph title="">╘</span> </td> <tr id=entity-boxur><td> <code title="">boxur;</code> </td> <td> U+02514 </td> <td> <span class=glyph title="">└</span> </td> <tr id=entity-boxV><td> <code title="">boxV;</code> </td> <td> U+02551 </td> <td> <span class=glyph title="">║</span> </td> <tr id=entity-boxv><td> <code title="">boxv;</code> </td> <td> U+02502 </td> <td> <span class=glyph title="">│</span> </td> <tr id=entity-boxVH><td> <code title="">boxVH;</code> </td> <td> U+0256C </td> <td> <span class=glyph title="">╬</span> </td> <tr id=entity-boxVh><td> <code title="">boxVh;</code> </td> <td> U+0256B </td> <td> <span class=glyph title="">╫</span> </td> <tr id=entity-boxvH><td> <code title="">boxvH;</code> </td> <td> U+0256A </td> <td> <span class=glyph title="">╪</span> </td> <tr id=entity-boxvh><td> <code title="">boxvh;</code> </td> <td> U+0253C </td> <td> <span class=glyph title="">┼</span> </td> <tr id=entity-boxVL><td> <code title="">boxVL;</code> </td> <td> U+02563 </td> <td> <span class=glyph title="">╣</span> </td> <tr id=entity-boxVl><td> <code title="">boxVl;</code> </td> <td> U+02562 </td> <td> <span class=glyph title="">╢</span> </td> <tr id=entity-boxvL><td> <code title="">boxvL;</code> </td> <td> U+02561 </td> <td> <span class=glyph title="">╡</span> </td> <tr id=entity-boxvl><td> <code title="">boxvl;</code> </td> <td> U+02524 </td> <td> <span class=glyph title="">┤</span> </td> <tr id=entity-boxVR><td> <code title="">boxVR;</code> </td> <td> U+02560 </td> <td> <span class=glyph title="">╠</span> </td> <tr id=entity-boxVr><td> <code title="">boxVr;</code> </td> <td> U+0255F </td> <td> <span class=glyph title="">╟</span> </td> <tr id=entity-boxvR><td> <code title="">boxvR;</code> </td> <td> U+0255E </td> <td> <span class=glyph title="">╞</span> </td> <tr id=entity-boxvr><td> <code title="">boxvr;</code> </td> <td> U+0251C </td> <td> <span class=glyph title="">├</span> </td> <tr id=entity-bprime><td> <code title="">bprime;</code> </td> <td> U+02035 </td> <td> <span class=glyph title="">‵</span> </td> <tr id=entity-Breve><td> <code title="">Breve;</code> </td> <td> U+002D8 </td> <td> <span class=glyph title="">˘</span> </td> <tr id=entity-breve><td> <code title="">breve;</code> </td> <td> U+002D8 </td> <td> <span class=glyph title="">˘</span> </td> <tr id=entity-brvbar><td> <code title="">brvbar;</code> </td> <td> U+000A6 </td> <td> <span class=glyph title="">¦</span> </td> <tr class=impl id=entity-brvbar-legacy><td> <code title="">brvbar</code> </td> <td> U+000A6 </td> <td> <span title="">¦</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Bscr><td> <code title="">Bscr;</code> </td> <td> U+0212C </td> <td> <span class=glyph title="">ℬ</span> </td> <tr id=entity-bscr><td> <code title="">bscr;</code> </td> <td> U+1D4B7 </td> <td> <span class=glyph title="">𝒷</span> </td> <tr id=entity-bsemi><td> <code title="">bsemi;</code> </td> <td> U+0204F </td> <td> <span class=glyph title="">⁏</span> </td> <tr id=entity-bsim><td> <code title="">bsim;</code> </td> <td> U+0223D </td> <td> <span class=glyph title="">∽</span> </td> <tr id=entity-bsime><td> <code title="">bsime;</code> </td> <td> U+022CD </td> <td> <span class=glyph title="">⋍</span> </td> <tr id=entity-bsol><td> <code title="">bsol;</code> </td> <td> U+0005C </td> <td> <span class=glyph title="">\</span> </td> <tr id=entity-bsolb><td> <code title="">bsolb;</code> </td> <td> U+029C5 </td> <td> <span class=glyph title="">⧅</span> </td> <tr id=entity-bsolhsub><td> <code title="">bsolhsub;</code> </td> <td> U+027C8 </td> <td> <span class=glyph title="">⟈</span> </td> <tr id=entity-bull><td> <code title="">bull;</code> </td> <td> U+02022 </td> <td> <span class=glyph title="">•</span> </td> <tr id=entity-bullet><td> <code title="">bullet;</code> </td> <td> U+02022 </td> <td> <span class=glyph title="">•</span> </td> <tr id=entity-bump><td> <code title="">bump;</code> </td> <td> U+0224E </td> <td> <span class=glyph title="">≎</span> </td> <tr id=entity-bumpE><td> <code title="">bumpE;</code> </td> <td> U+02AAE </td> <td> <span class=glyph title="">⪮</span> </td> <tr id=entity-bumpe><td> <code title="">bumpe;</code> </td> <td> U+0224F </td> <td> <span class=glyph title="">≏</span> </td> <tr id=entity-Bumpeq><td> <code title="">Bumpeq;</code> </td> <td> U+0224E </td> <td> <span class=glyph title="">≎</span> </td> <tr id=entity-bumpeq><td> <code title="">bumpeq;</code> </td> <td> U+0224F </td> <td> <span class=glyph title="">≏</span> </td> <tr id=entity-Cacute><td> <code title="">Cacute;</code> </td> <td> U+00106 </td> <td> <span class=glyph title="">Ć</span> </td> <tr id=entity-cacute><td> <code title="">cacute;</code> </td> <td> U+00107 </td> <td> <span class=glyph title="">ć</span> </td> <tr id=entity-Cap><td> <code title="">Cap;</code> </td> <td> U+022D2 </td> <td> <span class=glyph title="">⋒</span> </td> <tr id=entity-cap><td> <code title="">cap;</code> </td> <td> U+02229 </td> <td> <span class=glyph title="">∩</span> </td> <tr id=entity-capand><td> <code title="">capand;</code> </td> <td> U+02A44 </td> <td> <span class=glyph title="">⩄</span> </td> <tr id=entity-capbrcup><td> <code title="">capbrcup;</code> </td> <td> U+02A49 </td> <td> <span class=glyph title="">⩉</span> </td> <tr id=entity-capcap><td> <code title="">capcap;</code> </td> <td> U+02A4B </td> <td> <span class=glyph title="">⩋</span> </td> <tr id=entity-capcup><td> <code title="">capcup;</code> </td> <td> U+02A47 </td> <td> <span class=glyph title="">⩇</span> </td> <tr id=entity-capdot><td> <code title="">capdot;</code> </td> <td> U+02A40 </td> <td> <span class=glyph title="">⩀</span> </td> <tr id=entity-CapitalDifferentialD><td> <code title="">CapitalDifferentialD;</code> </td> <td> U+02145 </td> <td> <span class=glyph title="">ⅅ</span> </td> <tr id=entity-caps><td> <code title="">caps;</code> </td> <td> U+02229 U+0FE00 </td> <td> <span class="glyph compound" title="">∩︀</span> </td> <tr id=entity-caret><td> <code title="">caret;</code> </td> <td> U+02041 </td> <td> <span class=glyph title="">⁁</span> </td> <tr id=entity-caron><td> <code title="">caron;</code> </td> <td> U+002C7 </td> <td> <span class=glyph title="">ˇ</span> </td> <tr id=entity-Cayleys><td> <code title="">Cayleys;</code> </td> <td> U+0212D </td> <td> <span class=glyph title="">ℭ</span> </td> <tr id=entity-ccaps><td> <code title="">ccaps;</code> </td> <td> U+02A4D </td> <td> <span class=glyph title="">⩍</span> </td> <tr id=entity-Ccaron><td> <code title="">Ccaron;</code> </td> <td> U+0010C </td> <td> <span class=glyph title="">Č</span> </td> <tr id=entity-ccaron><td> <code title="">ccaron;</code> </td> <td> U+0010D </td> <td> <span class=glyph title="">č</span> </td> <tr id=entity-Ccedil><td> <code title="">Ccedil;</code> </td> <td> U+000C7 </td> <td> <span class=glyph title="">Ç</span> </td> <tr class=impl id=entity-Ccedil-legacy><td> <code title="">Ccedil</code> </td> <td> U+000C7 </td> <td> <span title="">Ç</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ccedil><td> <code title="">ccedil;</code> </td> <td> U+000E7 </td> <td> <span class=glyph title="">ç</span> </td> <tr class=impl id=entity-ccedil-legacy><td> <code title="">ccedil</code> </td> <td> U+000E7 </td> <td> <span title="">ç</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Ccirc><td> <code title="">Ccirc;</code> </td> <td> U+00108 </td> <td> <span class=glyph title="">Ĉ</span> </td> <tr id=entity-ccirc><td> <code title="">ccirc;</code> </td> <td> U+00109 </td> <td> <span class=glyph title="">ĉ</span> </td> <tr id=entity-Cconint><td> <code title="">Cconint;</code> </td> <td> U+02230 </td> <td> <span class=glyph title="">∰</span> </td> <tr id=entity-ccups><td> <code title="">ccups;</code> </td> <td> U+02A4C </td> <td> <span class=glyph title="">⩌</span> </td> <tr id=entity-ccupssm><td> <code title="">ccupssm;</code> </td> <td> U+02A50 </td> <td> <span class=glyph title="">⩐</span> </td> <tr id=entity-Cdot><td> <code title="">Cdot;</code> </td> <td> U+0010A </td> <td> <span class=glyph title="">Ċ</span> </td> <tr id=entity-cdot><td> <code title="">cdot;</code> </td> <td> U+0010B </td> <td> <span class=glyph title="">ċ</span> </td> <tr id=entity-cedil><td> <code title="">cedil;</code> </td> <td> U+000B8 </td> <td> <span class=glyph title="">¸</span> </td> <tr class=impl id=entity-cedil-legacy><td> <code title="">cedil</code> </td> <td> U+000B8 </td> <td> <span title="">¸</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Cedilla><td> <code title="">Cedilla;</code> </td> <td> U+000B8 </td> <td> <span class=glyph title="">¸</span> </td> <tr id=entity-cemptyv><td> <code title="">cemptyv;</code> </td> <td> U+029B2 </td> <td> <span class=glyph title="">⦲</span> </td> <tr id=entity-cent><td> <code title="">cent;</code> </td> <td> U+000A2 </td> <td> <span class=glyph title="">¢</span> </td> <tr class=impl id=entity-cent-legacy><td> <code title="">cent</code> </td> <td> U+000A2 </td> <td> <span title="">¢</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-CenterDot><td> <code title="">CenterDot;</code> </td> <td> U+000B7 </td> <td> <span class=glyph title="">·</span> </td> <tr id=entity-centerdot><td> <code title="">centerdot;</code> </td> <td> U+000B7 </td> <td> <span class=glyph title="">·</span> </td> <tr id=entity-Cfr><td> <code title="">Cfr;</code> </td> <td> U+0212D </td> <td> <span class=glyph title="">ℭ</span> </td> <tr id=entity-cfr><td> <code title="">cfr;</code> </td> <td> U+1D520 </td> <td> <span class=glyph title="">𝔠</span> </td> <tr id=entity-CHcy><td> <code title="">CHcy;</code> </td> <td> U+00427 </td> <td> <span class=glyph title="">Ч</span> </td> <tr id=entity-chcy><td> <code title="">chcy;</code> </td> <td> U+00447 </td> <td> <span class=glyph title="">ч</span> </td> <tr id=entity-check><td> <code title="">check;</code> </td> <td> U+02713 </td> <td> <span class=glyph title="">✓</span> </td> <tr id=entity-checkmark><td> <code title="">checkmark;</code> </td> <td> U+02713 </td> <td> <span class=glyph title="">✓</span> </td> <tr id=entity-Chi><td> <code title="">Chi;</code> </td> <td> U+003A7 </td> <td> <span class=glyph title="">Χ</span> </td> <tr id=entity-chi><td> <code title="">chi;</code> </td> <td> U+003C7 </td> <td> <span class=glyph title="">χ</span> </td> <tr id=entity-cir><td> <code title="">cir;</code> </td> <td> U+025CB </td> <td> <span class=glyph title="">○</span> </td> <tr id=entity-circ><td> <code title="">circ;</code> </td> <td> U+002C6 </td> <td> <span class=glyph title="">ˆ</span> </td> <tr id=entity-circeq><td> <code title="">circeq;</code> </td> <td> U+02257 </td> <td> <span class=glyph title="">≗</span> </td> <tr id=entity-circlearrowleft><td> <code title="">circlearrowleft;</code> </td> <td> U+021BA </td> <td> <span class=glyph title="">↺</span> </td> <tr id=entity-circlearrowright><td> <code title="">circlearrowright;</code> </td> <td> U+021BB </td> <td> <span class=glyph title="">↻</span> </td> <tr id=entity-circledast><td> <code title="">circledast;</code> </td> <td> U+0229B </td> <td> <span class=glyph title="">⊛</span> </td> <tr id=entity-circledcirc><td> <code title="">circledcirc;</code> </td> <td> U+0229A </td> <td> <span class=glyph title="">⊚</span> </td> <tr id=entity-circleddash><td> <code title="">circleddash;</code> </td> <td> U+0229D </td> <td> <span class=glyph title="">⊝</span> </td> <tr id=entity-CircleDot><td> <code title="">CircleDot;</code> </td> <td> U+02299 </td> <td> <span class=glyph title="">⊙</span> </td> <tr id=entity-circledR><td> <code title="">circledR;</code> </td> <td> U+000AE </td> <td> <span class=glyph title="">®</span> </td> <tr id=entity-circledS><td> <code title="">circledS;</code> </td> <td> U+024C8 </td> <td> <span class=glyph title="">Ⓢ</span> </td> <tr id=entity-CircleMinus><td> <code title="">CircleMinus;</code> </td> <td> U+02296 </td> <td> <span class=glyph title="">⊖</span> </td> <tr id=entity-CirclePlus><td> <code title="">CirclePlus;</code> </td> <td> U+02295 </td> <td> <span class=glyph title="">⊕</span> </td> <tr id=entity-CircleTimes><td> <code title="">CircleTimes;</code> </td> <td> U+02297 </td> <td> <span class=glyph title="">⊗</span> </td> <tr id=entity-cirE><td> <code title="">cirE;</code> </td> <td> U+029C3 </td> <td> <span class=glyph title="">⧃</span> </td> <tr id=entity-cire><td> <code title="">cire;</code> </td> <td> U+02257 </td> <td> <span class=glyph title="">≗</span> </td> <tr id=entity-cirfnint><td> <code title="">cirfnint;</code> </td> <td> U+02A10 </td> <td> <span class=glyph title="">⨐</span> </td> <tr id=entity-cirmid><td> <code title="">cirmid;</code> </td> <td> U+02AEF </td> <td> <span class=glyph title="">⫯</span> </td> <tr id=entity-cirscir><td> <code title="">cirscir;</code> </td> <td> U+029C2 </td> <td> <span class=glyph title="">⧂</span> </td> <tr id=entity-ClockwiseContourIntegral><td> <code title="">ClockwiseContourIntegral;</code> </td> <td> U+02232 </td> <td> <span class=glyph title="">∲</span> </td> <tr id=entity-CloseCurlyDoubleQuote><td> <code title="">CloseCurlyDoubleQuote;</code> </td> <td> U+0201D </td> <td> <span class=glyph title="">”</span> </td> <tr id=entity-CloseCurlyQuote><td> <code title="">CloseCurlyQuote;</code> </td> <td> U+02019 </td> <td> <span class=glyph title="">’</span> </td> <tr id=entity-clubs><td> <code title="">clubs;</code> </td> <td> U+02663 </td> <td> <span class=glyph title="">♣</span> </td> <tr id=entity-clubsuit><td> <code title="">clubsuit;</code> </td> <td> U+02663 </td> <td> <span class=glyph title="">♣</span> </td> <tr id=entity-Colon><td> <code title="">Colon;</code> </td> <td> U+02237 </td> <td> <span class=glyph title="">∷</span> </td> <tr id=entity-colon><td> <code title="">colon;</code> </td> <td> U+0003A </td> <td> <span class=glyph title="">:</span> </td> <tr id=entity-Colone><td> <code title="">Colone;</code> </td> <td> U+02A74 </td> <td> <span class=glyph title="">⩴</span> </td> <tr id=entity-colone><td> <code title="">colone;</code> </td> <td> U+02254 </td> <td> <span class=glyph title="">≔</span> </td> <tr id=entity-coloneq><td> <code title="">coloneq;</code> </td> <td> U+02254 </td> <td> <span class=glyph title="">≔</span> </td> <tr id=entity-comma><td> <code title="">comma;</code> </td> <td> U+0002C </td> <td> <span class=glyph title="">,</span> </td> <tr id=entity-commat><td> <code title="">commat;</code> </td> <td> U+00040 </td> <td> <span class=glyph title="">@</span> </td> <tr id=entity-comp><td> <code title="">comp;</code> </td> <td> U+02201 </td> <td> <span class=glyph title="">∁</span> </td> <tr id=entity-compfn><td> <code title="">compfn;</code> </td> <td> U+02218 </td> <td> <span class=glyph title="">∘</span> </td> <tr id=entity-complement><td> <code title="">complement;</code> </td> <td> U+02201 </td> <td> <span class=glyph title="">∁</span> </td> <tr id=entity-complexes><td> <code title="">complexes;</code> </td> <td> U+02102 </td> <td> <span class=glyph title="">ℂ</span> </td> <tr id=entity-cong><td> <code title="">cong;</code> </td> <td> U+02245 </td> <td> <span class=glyph title="">≅</span> </td> <tr id=entity-congdot><td> <code title="">congdot;</code> </td> <td> U+02A6D </td> <td> <span class=glyph title="">⩭</span> </td> <tr id=entity-Congruent><td> <code title="">Congruent;</code> </td> <td> U+02261 </td> <td> <span class=glyph title="">≡</span> </td> <tr id=entity-Conint><td> <code title="">Conint;</code> </td> <td> U+0222F </td> <td> <span class=glyph title="">∯</span> </td> <tr id=entity-conint><td> <code title="">conint;</code> </td> <td> U+0222E </td> <td> <span class=glyph title="">∮</span> </td> <tr id=entity-ContourIntegral><td> <code title="">ContourIntegral;</code> </td> <td> U+0222E </td> <td> <span class=glyph title="">∮</span> </td> <tr id=entity-Copf><td> <code title="">Copf;</code> </td> <td> U+02102 </td> <td> <span class=glyph title="">ℂ</span> </td> <tr id=entity-copf><td> <code title="">copf;</code> </td> <td> U+1D554 </td> <td> <span class=glyph title="">𝕔</span> </td> <tr id=entity-coprod><td> <code title="">coprod;</code> </td> <td> U+02210 </td> <td> <span class=glyph title="">∐</span> </td> <tr id=entity-Coproduct><td> <code title="">Coproduct;</code> </td> <td> U+02210 </td> <td> <span class=glyph title="">∐</span> </td> <tr id=entity-COPY><td> <code title="">COPY;</code> </td> <td> U+000A9 </td> <td> <span class=glyph title="">©</span> </td> <tr class=impl id=entity-COPY-legacy><td> <code title="">COPY</code> </td> <td> U+000A9 </td> <td> <span title="">©</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-copy><td> <code title="">copy;</code> </td> <td> U+000A9 </td> <td> <span class=glyph title="">©</span> </td> <tr class=impl id=entity-copy-legacy><td> <code title="">copy</code> </td> <td> U+000A9 </td> <td> <span title="">©</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-copysr><td> <code title="">copysr;</code> </td> <td> U+02117 </td> <td> <span class=glyph title="">℗</span> </td> <tr id=entity-CounterClockwiseContourIntegral><td> <code title="">CounterClockwiseContourIntegral;</code> </td> <td> U+02233 </td> <td> <span class=glyph title="">∳</span> </td> <tr id=entity-crarr><td> <code title="">crarr;</code> </td> <td> U+021B5 </td> <td> <span class=glyph title="">↵</span> </td> <tr id=entity-Cross><td> <code title="">Cross;</code> </td> <td> U+02A2F </td> <td> <span class=glyph title="">⨯</span> </td> <tr id=entity-cross><td> <code title="">cross;</code> </td> <td> U+02717 </td> <td> <span class=glyph title="">✗</span> </td> <tr id=entity-Cscr><td> <code title="">Cscr;</code> </td> <td> U+1D49E </td> <td> <span class=glyph title="">𝒞</span> </td> <tr id=entity-cscr><td> <code title="">cscr;</code> </td> <td> U+1D4B8 </td> <td> <span class=glyph title="">𝒸</span> </td> <tr id=entity-csub><td> <code title="">csub;</code> </td> <td> U+02ACF </td> <td> <span class=glyph title="">⫏</span> </td> <tr id=entity-csube><td> <code title="">csube;</code> </td> <td> U+02AD1 </td> <td> <span class=glyph title="">⫑</span> </td> <tr id=entity-csup><td> <code title="">csup;</code> </td> <td> U+02AD0 </td> <td> <span class=glyph title="">⫐</span> </td> <tr id=entity-csupe><td> <code title="">csupe;</code> </td> <td> U+02AD2 </td> <td> <span class=glyph title="">⫒</span> </td> <tr id=entity-ctdot><td> <code title="">ctdot;</code> </td> <td> U+022EF </td> <td> <span class=glyph title="">⋯</span> </td> <tr id=entity-cudarrl><td> <code title="">cudarrl;</code> </td> <td> U+02938 </td> <td> <span class=glyph title="">⤸</span> </td> <tr id=entity-cudarrr><td> <code title="">cudarrr;</code> </td> <td> U+02935 </td> <td> <span class=glyph title="">⤵</span> </td> <tr id=entity-cuepr><td> <code title="">cuepr;</code> </td> <td> U+022DE </td> <td> <span class=glyph title="">⋞</span> </td> <tr id=entity-cuesc><td> <code title="">cuesc;</code> </td> <td> U+022DF </td> <td> <span class=glyph title="">⋟</span> </td> <tr id=entity-cularr><td> <code title="">cularr;</code> </td> <td> U+021B6 </td> <td> <span class=glyph title="">↶</span> </td> <tr id=entity-cularrp><td> <code title="">cularrp;</code> </td> <td> U+0293D </td> <td> <span class=glyph title="">⤽</span> </td> <tr id=entity-Cup><td> <code title="">Cup;</code> </td> <td> U+022D3 </td> <td> <span class=glyph title="">⋓</span> </td> <tr id=entity-cup><td> <code title="">cup;</code> </td> <td> U+0222A </td> <td> <span class=glyph title="">∪</span> </td> <tr id=entity-cupbrcap><td> <code title="">cupbrcap;</code> </td> <td> U+02A48 </td> <td> <span class=glyph title="">⩈</span> </td> <tr id=entity-CupCap><td> <code title="">CupCap;</code> </td> <td> U+0224D </td> <td> <span class=glyph title="">≍</span> </td> <tr id=entity-cupcap><td> <code title="">cupcap;</code> </td> <td> U+02A46 </td> <td> <span class=glyph title="">⩆</span> </td> <tr id=entity-cupcup><td> <code title="">cupcup;</code> </td> <td> U+02A4A </td> <td> <span class=glyph title="">⩊</span> </td> <tr id=entity-cupdot><td> <code title="">cupdot;</code> </td> <td> U+0228D </td> <td> <span class=glyph title="">⊍</span> </td> <tr id=entity-cupor><td> <code title="">cupor;</code> </td> <td> U+02A45 </td> <td> <span class=glyph title="">⩅</span> </td> <tr id=entity-cups><td> <code title="">cups;</code> </td> <td> U+0222A U+0FE00 </td> <td> <span class="glyph compound" title="">∪︀</span> </td> <tr id=entity-curarr><td> <code title="">curarr;</code> </td> <td> U+021B7 </td> <td> <span class=glyph title="">↷</span> </td> <tr id=entity-curarrm><td> <code title="">curarrm;</code> </td> <td> U+0293C </td> <td> <span class=glyph title="">⤼</span> </td> <tr id=entity-curlyeqprec><td> <code title="">curlyeqprec;</code> </td> <td> U+022DE </td> <td> <span class=glyph title="">⋞</span> </td> <tr id=entity-curlyeqsucc><td> <code title="">curlyeqsucc;</code> </td> <td> U+022DF </td> <td> <span class=glyph title="">⋟</span> </td> <tr id=entity-curlyvee><td> <code title="">curlyvee;</code> </td> <td> U+022CE </td> <td> <span class=glyph title="">⋎</span> </td> <tr id=entity-curlywedge><td> <code title="">curlywedge;</code> </td> <td> U+022CF </td> <td> <span class=glyph title="">⋏</span> </td> <tr id=entity-curren><td> <code title="">curren;</code> </td> <td> U+000A4 </td> <td> <span class=glyph title="">¤</span> </td> <tr class=impl id=entity-curren-legacy><td> <code title="">curren</code> </td> <td> U+000A4 </td> <td> <span title="">¤</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-curvearrowleft><td> <code title="">curvearrowleft;</code> </td> <td> U+021B6 </td> <td> <span class=glyph title="">↶</span> </td> <tr id=entity-curvearrowright><td> <code title="">curvearrowright;</code> </td> <td> U+021B7 </td> <td> <span class=glyph title="">↷</span> </td> <tr id=entity-cuvee><td> <code title="">cuvee;</code> </td> <td> U+022CE </td> <td> <span class=glyph title="">⋎</span> </td> <tr id=entity-cuwed><td> <code title="">cuwed;</code> </td> <td> U+022CF </td> <td> <span class=glyph title="">⋏</span> </td> <tr id=entity-cwconint><td> <code title="">cwconint;</code> </td> <td> U+02232 </td> <td> <span class=glyph title="">∲</span> </td> <tr id=entity-cwint><td> <code title="">cwint;</code> </td> <td> U+02231 </td> <td> <span class=glyph title="">∱</span> </td> <tr id=entity-cylcty><td> <code title="">cylcty;</code> </td> <td> U+0232D </td> <td> <span class=glyph title="">⌭</span> </td> <tr id=entity-Dagger><td> <code title="">Dagger;</code> </td> <td> U+02021 </td> <td> <span class=glyph title="">‡</span> </td> <tr id=entity-dagger><td> <code title="">dagger;</code> </td> <td> U+02020 </td> <td> <span class=glyph title="">†</span> </td> <tr id=entity-daleth><td> <code title="">daleth;</code> </td> <td> U+02138 </td> <td> <span class=glyph title="">ℸ</span> </td> <tr id=entity-Darr><td> <code title="">Darr;</code> </td> <td> U+021A1 </td> <td> <span class=glyph title="">↡</span> </td> <tr id=entity-dArr><td> <code title="">dArr;</code> </td> <td> U+021D3 </td> <td> <span class=glyph title="">⇓</span> </td> <tr id=entity-darr><td> <code title="">darr;</code> </td> <td> U+02193 </td> <td> <span class=glyph title="">↓</span> </td> <tr id=entity-dash><td> <code title="">dash;</code> </td> <td> U+02010 </td> <td> <span class=glyph title="">‐</span> </td> <tr id=entity-Dashv><td> <code title="">Dashv;</code> </td> <td> U+02AE4 </td> <td> <span class=glyph title="">⫤</span> </td> <tr id=entity-dashv><td> <code title="">dashv;</code> </td> <td> U+022A3 </td> <td> <span class=glyph title="">⊣</span> </td> <tr id=entity-dbkarow><td> <code title="">dbkarow;</code> </td> <td> U+0290F </td> <td> <span class=glyph title="">⤏</span> </td> <tr id=entity-dblac><td> <code title="">dblac;</code> </td> <td> U+002DD </td> <td> <span class=glyph title="">˝</span> </td> <tr id=entity-Dcaron><td> <code title="">Dcaron;</code> </td> <td> U+0010E </td> <td> <span class=glyph title="">Ď</span> </td> <tr id=entity-dcaron><td> <code title="">dcaron;</code> </td> <td> U+0010F </td> <td> <span class=glyph title="">ď</span> </td> <tr id=entity-Dcy><td> <code title="">Dcy;</code> </td> <td> U+00414 </td> <td> <span class=glyph title="">Д</span> </td> <tr id=entity-dcy><td> <code title="">dcy;</code> </td> <td> U+00434 </td> <td> <span class=glyph title="">д</span> </td> <tr id=entity-DD><td> <code title="">DD;</code> </td> <td> U+02145 </td> <td> <span class=glyph title="">ⅅ</span> </td> <tr id=entity-dd><td> <code title="">dd;</code> </td> <td> U+02146 </td> <td> <span class=glyph title="">ⅆ</span> </td> <tr id=entity-ddagger><td> <code title="">ddagger;</code> </td> <td> U+02021 </td> <td> <span class=glyph title="">‡</span> </td> <tr id=entity-ddarr><td> <code title="">ddarr;</code> </td> <td> U+021CA </td> <td> <span class=glyph title="">⇊</span> </td> <tr id=entity-DDotrahd><td> <code title="">DDotrahd;</code> </td> <td> U+02911 </td> <td> <span class=glyph title="">⤑</span> </td> <tr id=entity-ddotseq><td> <code title="">ddotseq;</code> </td> <td> U+02A77 </td> <td> <span class=glyph title="">⩷</span> </td> <tr id=entity-deg><td> <code title="">deg;</code> </td> <td> U+000B0 </td> <td> <span class=glyph title="">°</span> </td> <tr class=impl id=entity-deg-legacy><td> <code title="">deg</code> </td> <td> U+000B0 </td> <td> <span title="">°</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Del><td> <code title="">Del;</code> </td> <td> U+02207 </td> <td> <span class=glyph title="">∇</span> </td> <tr id=entity-Delta><td> <code title="">Delta;</code> </td> <td> U+00394 </td> <td> <span class=glyph title="">Δ</span> </td> <tr id=entity-delta><td> <code title="">delta;</code> </td> <td> U+003B4 </td> <td> <span class=glyph title="">δ</span> </td> <tr id=entity-demptyv><td> <code title="">demptyv;</code> </td> <td> U+029B1 </td> <td> <span class=glyph title="">⦱</span> </td> <tr id=entity-dfisht><td> <code title="">dfisht;</code> </td> <td> U+0297F </td> <td> <span class=glyph title="">⥿</span> </td> <tr id=entity-Dfr><td> <code title="">Dfr;</code> </td> <td> U+1D507 </td> <td> <span class=glyph title="">𝔇</span> </td> <tr id=entity-dfr><td> <code title="">dfr;</code> </td> <td> U+1D521 </td> <td> <span class=glyph title="">𝔡</span> </td> <tr id=entity-dHar><td> <code title="">dHar;</code> </td> <td> U+02965 </td> <td> <span class=glyph title="">⥥</span> </td> <tr id=entity-dharl><td> <code title="">dharl;</code> </td> <td> U+021C3 </td> <td> <span class=glyph title="">⇃</span> </td> <tr id=entity-dharr><td> <code title="">dharr;</code> </td> <td> U+021C2 </td> <td> <span class=glyph title="">⇂</span> </td> <tr id=entity-DiacriticalAcute><td> <code title="">DiacriticalAcute;</code> </td> <td> U+000B4 </td> <td> <span class=glyph title="">´</span> </td> <tr id=entity-DiacriticalDot><td> <code title="">DiacriticalDot;</code> </td> <td> U+002D9 </td> <td> <span class=glyph title="">˙</span> </td> <tr id=entity-DiacriticalDoubleAcute><td> <code title="">DiacriticalDoubleAcute;</code> </td> <td> U+002DD </td> <td> <span class=glyph title="">˝</span> </td> <tr id=entity-DiacriticalGrave><td> <code title="">DiacriticalGrave;</code> </td> <td> U+00060 </td> <td> <span class=glyph title="">`</span> </td> <tr id=entity-DiacriticalTilde><td> <code title="">DiacriticalTilde;</code> </td> <td> U+002DC </td> <td> <span class=glyph title="">˜</span> </td> <tr id=entity-diam><td> <code title="">diam;</code> </td> <td> U+022C4 </td> <td> <span class=glyph title="">⋄</span> </td> <tr id=entity-Diamond><td> <code title="">Diamond;</code> </td> <td> U+022C4 </td> <td> <span class=glyph title="">⋄</span> </td> <tr id=entity-diamond><td> <code title="">diamond;</code> </td> <td> U+022C4 </td> <td> <span class=glyph title="">⋄</span> </td> <tr id=entity-diamondsuit><td> <code title="">diamondsuit;</code> </td> <td> U+02666 </td> <td> <span class=glyph title="">♦</span> </td> <tr id=entity-diams><td> <code title="">diams;</code> </td> <td> U+02666 </td> <td> <span class=glyph title="">♦</span> </td> <tr id=entity-die><td> <code title="">die;</code> </td> <td> U+000A8 </td> <td> <span class=glyph title="">¨</span> </td> <tr id=entity-DifferentialD><td> <code title="">DifferentialD;</code> </td> <td> U+02146 </td> <td> <span class=glyph title="">ⅆ</span> </td> <tr id=entity-digamma><td> <code title="">digamma;</code> </td> <td> U+003DD </td> <td> <span class=glyph title="">ϝ</span> </td> <tr id=entity-disin><td> <code title="">disin;</code> </td> <td> U+022F2 </td> <td> <span class=glyph title="">⋲</span> </td> <tr id=entity-div><td> <code title="">div;</code> </td> <td> U+000F7 </td> <td> <span class=glyph title="">÷</span> </td> <tr id=entity-divide><td> <code title="">divide;</code> </td> <td> U+000F7 </td> <td> <span class=glyph title="">÷</span> </td> <tr class=impl id=entity-divide-legacy><td> <code title="">divide</code> </td> <td> U+000F7 </td> <td> <span title="">÷</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-divideontimes><td> <code title="">divideontimes;</code> </td> <td> U+022C7 </td> <td> <span class=glyph title="">⋇</span> </td> <tr id=entity-divonx><td> <code title="">divonx;</code> </td> <td> U+022C7 </td> <td> <span class=glyph title="">⋇</span> </td> <tr id=entity-DJcy><td> <code title="">DJcy;</code> </td> <td> U+00402 </td> <td> <span class=glyph title="">Ђ</span> </td> <tr id=entity-djcy><td> <code title="">djcy;</code> </td> <td> U+00452 </td> <td> <span class=glyph title="">ђ</span> </td> <tr id=entity-dlcorn><td> <code title="">dlcorn;</code> </td> <td> U+0231E </td> <td> <span class=glyph title="">⌞</span> </td> <tr id=entity-dlcrop><td> <code title="">dlcrop;</code> </td> <td> U+0230D </td> <td> <span class=glyph title="">⌍</span> </td> <tr id=entity-dollar><td> <code title="">dollar;</code> </td> <td> U+00024 </td> <td> <span class=glyph title="">$</span> </td> <tr id=entity-Dopf><td> <code title="">Dopf;</code> </td> <td> U+1D53B </td> <td> <span class=glyph title="">𝔻</span> </td> <tr id=entity-dopf><td> <code title="">dopf;</code> </td> <td> U+1D555 </td> <td> <span class=glyph title="">𝕕</span> </td> <tr id=entity-Dot><td> <code title="">Dot;</code> </td> <td> U+000A8 </td> <td> <span class=glyph title="">¨</span> </td> <tr id=entity-dot><td> <code title="">dot;</code> </td> <td> U+002D9 </td> <td> <span class=glyph title="">˙</span> </td> <tr id=entity-DotDot><td> <code title="">DotDot;</code> </td> <td> U+020DC </td> <td> <span class="glyph composition" title="">◌⃜</span> </td> <tr id=entity-doteq><td> <code title="">doteq;</code> </td> <td> U+02250 </td> <td> <span class=glyph title="">≐</span> </td> <tr id=entity-doteqdot><td> <code title="">doteqdot;</code> </td> <td> U+02251 </td> <td> <span class=glyph title="">≑</span> </td> <tr id=entity-DotEqual><td> <code title="">DotEqual;</code> </td> <td> U+02250 </td> <td> <span class=glyph title="">≐</span> </td> <tr id=entity-dotminus><td> <code title="">dotminus;</code> </td> <td> U+02238 </td> <td> <span class=glyph title="">∸</span> </td> <tr id=entity-dotplus><td> <code title="">dotplus;</code> </td> <td> U+02214 </td> <td> <span class=glyph title="">∔</span> </td> <tr id=entity-dotsquare><td> <code title="">dotsquare;</code> </td> <td> U+022A1 </td> <td> <span class=glyph title="">⊡</span> </td> <tr id=entity-doublebarwedge><td> <code title="">doublebarwedge;</code> </td> <td> U+02306 </td> <td> <span class=glyph title="">⌆</span> </td> <tr id=entity-DoubleContourIntegral><td> <code title="">DoubleContourIntegral;</code> </td> <td> U+0222F </td> <td> <span class=glyph title="">∯</span> </td> <tr id=entity-DoubleDot><td> <code title="">DoubleDot;</code> </td> <td> U+000A8 </td> <td> <span class=glyph title="">¨</span> </td> <tr id=entity-DoubleDownArrow><td> <code title="">DoubleDownArrow;</code> </td> <td> U+021D3 </td> <td> <span class=glyph title="">⇓</span> </td> <tr id=entity-DoubleLeftArrow><td> <code title="">DoubleLeftArrow;</code> </td> <td> U+021D0 </td> <td> <span class=glyph title="">⇐</span> </td> <tr id=entity-DoubleLeftRightArrow><td> <code title="">DoubleLeftRightArrow;</code> </td> <td> U+021D4 </td> <td> <span class=glyph title="">⇔</span> </td> <tr id=entity-DoubleLeftTee><td> <code title="">DoubleLeftTee;</code> </td> <td> U+02AE4 </td> <td> <span class=glyph title="">⫤</span> </td> <tr id=entity-DoubleLongLeftArrow><td> <code title="">DoubleLongLeftArrow;</code> </td> <td> U+027F8 </td> <td> <span class=glyph title="">⟸</span> </td> <tr id=entity-DoubleLongLeftRightArrow><td> <code title="">DoubleLongLeftRightArrow;</code> </td> <td> U+027FA </td> <td> <span class=glyph title="">⟺</span> </td> <tr id=entity-DoubleLongRightArrow><td> <code title="">DoubleLongRightArrow;</code> </td> <td> U+027F9 </td> <td> <span class=glyph title="">⟹</span> </td> <tr id=entity-DoubleRightArrow><td> <code title="">DoubleRightArrow;</code> </td> <td> U+021D2 </td> <td> <span class=glyph title="">⇒</span> </td> <tr id=entity-DoubleRightTee><td> <code title="">DoubleRightTee;</code> </td> <td> U+022A8 </td> <td> <span class=glyph title="">⊨</span> </td> <tr id=entity-DoubleUpArrow><td> <code title="">DoubleUpArrow;</code> </td> <td> U+021D1 </td> <td> <span class=glyph title="">⇑</span> </td> <tr id=entity-DoubleUpDownArrow><td> <code title="">DoubleUpDownArrow;</code> </td> <td> U+021D5 </td> <td> <span class=glyph title="">⇕</span> </td> <tr id=entity-DoubleVerticalBar><td> <code title="">DoubleVerticalBar;</code> </td> <td> U+02225 </td> <td> <span class=glyph title="">∥</span> </td> <tr id=entity-DownArrow><td> <code title="">DownArrow;</code> </td> <td> U+02193 </td> <td> <span class=glyph title="">↓</span> </td> <tr id=entity-Downarrow><td> <code title="">Downarrow;</code> </td> <td> U+021D3 </td> <td> <span class=glyph title="">⇓</span> </td> <tr id=entity-downarrow><td> <code title="">downarrow;</code> </td> <td> U+02193 </td> <td> <span class=glyph title="">↓</span> </td> <tr id=entity-DownArrowBar><td> <code title="">DownArrowBar;</code> </td> <td> U+02913 </td> <td> <span class=glyph title="">⤓</span> </td> <tr id=entity-DownArrowUpArrow><td> <code title="">DownArrowUpArrow;</code> </td> <td> U+021F5 </td> <td> <span class=glyph title="">⇵</span> </td> <tr id=entity-DownBreve><td> <code title="">DownBreve;</code> </td> <td> U+00311 </td> <td> <span class="glyph composition" title="">◌̑</span> </td> <tr id=entity-downdownarrows><td> <code title="">downdownarrows;</code> </td> <td> U+021CA </td> <td> <span class=glyph title="">⇊</span> </td> <tr id=entity-downharpoonleft><td> <code title="">downharpoonleft;</code> </td> <td> U+021C3 </td> <td> <span class=glyph title="">⇃</span> </td> <tr id=entity-downharpoonright><td> <code title="">downharpoonright;</code> </td> <td> U+021C2 </td> <td> <span class=glyph title="">⇂</span> </td> <tr id=entity-DownLeftRightVector><td> <code title="">DownLeftRightVector;</code> </td> <td> U+02950 </td> <td> <span class=glyph title="">⥐</span> </td> <tr id=entity-DownLeftTeeVector><td> <code title="">DownLeftTeeVector;</code> </td> <td> U+0295E </td> <td> <span class=glyph title="">⥞</span> </td> <tr id=entity-DownLeftVector><td> <code title="">DownLeftVector;</code> </td> <td> U+021BD </td> <td> <span class=glyph title="">↽</span> </td> <tr id=entity-DownLeftVectorBar><td> <code title="">DownLeftVectorBar;</code> </td> <td> U+02956 </td> <td> <span class=glyph title="">⥖</span> </td> <tr id=entity-DownRightTeeVector><td> <code title="">DownRightTeeVector;</code> </td> <td> U+0295F </td> <td> <span class=glyph title="">⥟</span> </td> <tr id=entity-DownRightVector><td> <code title="">DownRightVector;</code> </td> <td> U+021C1 </td> <td> <span class=glyph title="">⇁</span> </td> <tr id=entity-DownRightVectorBar><td> <code title="">DownRightVectorBar;</code> </td> <td> U+02957 </td> <td> <span class=glyph title="">⥗</span> </td> <tr id=entity-DownTee><td> <code title="">DownTee;</code> </td> <td> U+022A4 </td> <td> <span class=glyph title="">⊤</span> </td> <tr id=entity-DownTeeArrow><td> <code title="">DownTeeArrow;</code> </td> <td> U+021A7 </td> <td> <span class=glyph title="">↧</span> </td> <tr id=entity-drbkarow><td> <code title="">drbkarow;</code> </td> <td> U+02910 </td> <td> <span class=glyph title="">⤐</span> </td> <tr id=entity-drcorn><td> <code title="">drcorn;</code> </td> <td> U+0231F </td> <td> <span class=glyph title="">⌟</span> </td> <tr id=entity-drcrop><td> <code title="">drcrop;</code> </td> <td> U+0230C </td> <td> <span class=glyph title="">⌌</span> </td> <tr id=entity-Dscr><td> <code title="">Dscr;</code> </td> <td> U+1D49F </td> <td> <span class=glyph title="">𝒟</span> </td> <tr id=entity-dscr><td> <code title="">dscr;</code> </td> <td> U+1D4B9 </td> <td> <span class=glyph title="">𝒹</span> </td> <tr id=entity-DScy><td> <code title="">DScy;</code> </td> <td> U+00405 </td> <td> <span class=glyph title="">Ѕ</span> </td> <tr id=entity-dscy><td> <code title="">dscy;</code> </td> <td> U+00455 </td> <td> <span class=glyph title="">ѕ</span> </td> <tr id=entity-dsol><td> <code title="">dsol;</code> </td> <td> U+029F6 </td> <td> <span class=glyph title="">⧶</span> </td> <tr id=entity-Dstrok><td> <code title="">Dstrok;</code> </td> <td> U+00110 </td> <td> <span class=glyph title="">Đ</span> </td> <tr id=entity-dstrok><td> <code title="">dstrok;</code> </td> <td> U+00111 </td> <td> <span class=glyph title="">đ</span> </td> <tr id=entity-dtdot><td> <code title="">dtdot;</code> </td> <td> U+022F1 </td> <td> <span class=glyph title="">⋱</span> </td> <tr id=entity-dtri><td> <code title="">dtri;</code> </td> <td> U+025BF </td> <td> <span class=glyph title="">▿</span> </td> <tr id=entity-dtrif><td> <code title="">dtrif;</code> </td> <td> U+025BE </td> <td> <span class=glyph title="">▾</span> </td> <tr id=entity-duarr><td> <code title="">duarr;</code> </td> <td> U+021F5 </td> <td> <span class=glyph title="">⇵</span> </td> <tr id=entity-duhar><td> <code title="">duhar;</code> </td> <td> U+0296F </td> <td> <span class=glyph title="">⥯</span> </td> <tr id=entity-dwangle><td> <code title="">dwangle;</code> </td> <td> U+029A6 </td> <td> <span class=glyph title="">⦦</span> </td> <tr id=entity-DZcy><td> <code title="">DZcy;</code> </td> <td> U+0040F </td> <td> <span class=glyph title="">Џ</span> </td> <tr id=entity-dzcy><td> <code title="">dzcy;</code> </td> <td> U+0045F </td> <td> <span class=glyph title="">џ</span> </td> <tr id=entity-dzigrarr><td> <code title="">dzigrarr;</code> </td> <td> U+027FF </td> <td> <span class=glyph title="">⟿</span> </td> <tr id=entity-Eacute><td> <code title="">Eacute;</code> </td> <td> U+000C9 </td> <td> <span class=glyph title="">É</span> </td> <tr class=impl id=entity-Eacute-legacy><td> <code title="">Eacute</code> </td> <td> U+000C9 </td> <td> <span title="">É</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-eacute><td> <code title="">eacute;</code> </td> <td> U+000E9 </td> <td> <span class=glyph title="">é</span> </td> <tr class=impl id=entity-eacute-legacy><td> <code title="">eacute</code> </td> <td> U+000E9 </td> <td> <span title="">é</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-easter><td> <code title="">easter;</code> </td> <td> U+02A6E </td> <td> <span class=glyph title="">⩮</span> </td> <tr id=entity-Ecaron><td> <code title="">Ecaron;</code> </td> <td> U+0011A </td> <td> <span class=glyph title="">Ě</span> </td> <tr id=entity-ecaron><td> <code title="">ecaron;</code> </td> <td> U+0011B </td> <td> <span class=glyph title="">ě</span> </td> <tr id=entity-ecir><td> <code title="">ecir;</code> </td> <td> U+02256 </td> <td> <span class=glyph title="">≖</span> </td> <tr id=entity-Ecirc><td> <code title="">Ecirc;</code> </td> <td> U+000CA </td> <td> <span class=glyph title="">Ê</span> </td> <tr class=impl id=entity-Ecirc-legacy><td> <code title="">Ecirc</code> </td> <td> U+000CA </td> <td> <span title="">Ê</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ecirc><td> <code title="">ecirc;</code> </td> <td> U+000EA </td> <td> <span class=glyph title="">ê</span> </td> <tr class=impl id=entity-ecirc-legacy><td> <code title="">ecirc</code> </td> <td> U+000EA </td> <td> <span title="">ê</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ecolon><td> <code title="">ecolon;</code> </td> <td> U+02255 </td> <td> <span class=glyph title="">≕</span> </td> <tr id=entity-Ecy><td> <code title="">Ecy;</code> </td> <td> U+0042D </td> <td> <span class=glyph title="">Э</span> </td> <tr id=entity-ecy><td> <code title="">ecy;</code> </td> <td> U+0044D </td> <td> <span class=glyph title="">э</span> </td> <tr id=entity-eDDot><td> <code title="">eDDot;</code> </td> <td> U+02A77 </td> <td> <span class=glyph title="">⩷</span> </td> <tr id=entity-Edot><td> <code title="">Edot;</code> </td> <td> U+00116 </td> <td> <span class=glyph title="">Ė</span> </td> <tr id=entity-eDot><td> <code title="">eDot;</code> </td> <td> U+02251 </td> <td> <span class=glyph title="">≑</span> </td> <tr id=entity-edot><td> <code title="">edot;</code> </td> <td> U+00117 </td> <td> <span class=glyph title="">ė</span> </td> <tr id=entity-ee><td> <code title="">ee;</code> </td> <td> U+02147 </td> <td> <span class=glyph title="">ⅇ</span> </td> <tr id=entity-efDot><td> <code title="">efDot;</code> </td> <td> U+02252 </td> <td> <span class=glyph title="">≒</span> </td> <tr id=entity-Efr><td> <code title="">Efr;</code> </td> <td> U+1D508 </td> <td> <span class=glyph title="">𝔈</span> </td> <tr id=entity-efr><td> <code title="">efr;</code> </td> <td> U+1D522 </td> <td> <span class=glyph title="">𝔢</span> </td> <tr id=entity-eg><td> <code title="">eg;</code> </td> <td> U+02A9A </td> <td> <span class=glyph title="">⪚</span> </td> <tr id=entity-Egrave><td> <code title="">Egrave;</code> </td> <td> U+000C8 </td> <td> <span class=glyph title="">È</span> </td> <tr class=impl id=entity-Egrave-legacy><td> <code title="">Egrave</code> </td> <td> U+000C8 </td> <td> <span title="">È</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-egrave><td> <code title="">egrave;</code> </td> <td> U+000E8 </td> <td> <span class=glyph title="">è</span> </td> <tr class=impl id=entity-egrave-legacy><td> <code title="">egrave</code> </td> <td> U+000E8 </td> <td> <span title="">è</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-egs><td> <code title="">egs;</code> </td> <td> U+02A96 </td> <td> <span class=glyph title="">⪖</span> </td> <tr id=entity-egsdot><td> <code title="">egsdot;</code> </td> <td> U+02A98 </td> <td> <span class=glyph title="">⪘</span> </td> <tr id=entity-el><td> <code title="">el;</code> </td> <td> U+02A99 </td> <td> <span class=glyph title="">⪙</span> </td> <tr id=entity-Element><td> <code title="">Element;</code> </td> <td> U+02208 </td> <td> <span class=glyph title="">∈</span> </td> <tr id=entity-elinters><td> <code title="">elinters;</code> </td> <td> U+023E7 </td> <td> <span class=glyph title="">⏧</span> </td> <tr id=entity-ell><td> <code title="">ell;</code> </td> <td> U+02113 </td> <td> <span class=glyph title="">ℓ</span> </td> <tr id=entity-els><td> <code title="">els;</code> </td> <td> U+02A95 </td> <td> <span class=glyph title="">⪕</span> </td> <tr id=entity-elsdot><td> <code title="">elsdot;</code> </td> <td> U+02A97 </td> <td> <span class=glyph title="">⪗</span> </td> <tr id=entity-Emacr><td> <code title="">Emacr;</code> </td> <td> U+00112 </td> <td> <span class=glyph title="">Ē</span> </td> <tr id=entity-emacr><td> <code title="">emacr;</code> </td> <td> U+00113 </td> <td> <span class=glyph title="">ē</span> </td> <tr id=entity-empty><td> <code title="">empty;</code> </td> <td> U+02205 </td> <td> <span class=glyph title="">∅</span> </td> <tr id=entity-emptyset><td> <code title="">emptyset;</code> </td> <td> U+02205 </td> <td> <span class=glyph title="">∅</span> </td> <tr id=entity-EmptySmallSquare><td> <code title="">EmptySmallSquare;</code> </td> <td> U+025FB </td> <td> <span class=glyph title="">◻</span> </td> <tr id=entity-emptyv><td> <code title="">emptyv;</code> </td> <td> U+02205 </td> <td> <span class=glyph title="">∅</span> </td> <tr id=entity-EmptyVerySmallSquare><td> <code title="">EmptyVerySmallSquare;</code> </td> <td> U+025AB </td> <td> <span class=glyph title="">▫</span> </td> <tr id=entity-emsp><td> <code title="">emsp;</code> </td> <td> U+02003 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-emsp13><td> <code title="">emsp13;</code> </td> <td> U+02004 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-emsp14><td> <code title="">emsp14;</code> </td> <td> U+02005 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-ENG><td> <code title="">ENG;</code> </td> <td> U+0014A </td> <td> <span class=glyph title="">Ŋ</span> </td> <tr id=entity-eng><td> <code title="">eng;</code> </td> <td> U+0014B </td> <td> <span class=glyph title="">ŋ</span> </td> <tr id=entity-ensp><td> <code title="">ensp;</code> </td> <td> U+02002 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-Eogon><td> <code title="">Eogon;</code> </td> <td> U+00118 </td> <td> <span class=glyph title="">Ę</span> </td> <tr id=entity-eogon><td> <code title="">eogon;</code> </td> <td> U+00119 </td> <td> <span class=glyph title="">ę</span> </td> <tr id=entity-Eopf><td> <code title="">Eopf;</code> </td> <td> U+1D53C </td> <td> <span class=glyph title="">𝔼</span> </td> <tr id=entity-eopf><td> <code title="">eopf;</code> </td> <td> U+1D556 </td> <td> <span class=glyph title="">𝕖</span> </td> <tr id=entity-epar><td> <code title="">epar;</code> </td> <td> U+022D5 </td> <td> <span class=glyph title="">⋕</span> </td> <tr id=entity-eparsl><td> <code title="">eparsl;</code> </td> <td> U+029E3 </td> <td> <span class=glyph title="">⧣</span> </td> <tr id=entity-eplus><td> <code title="">eplus;</code> </td> <td> U+02A71 </td> <td> <span class=glyph title="">⩱</span> </td> <tr id=entity-epsi><td> <code title="">epsi;</code> </td> <td> U+003B5 </td> <td> <span class=glyph title="">ε</span> </td> <tr id=entity-Epsilon><td> <code title="">Epsilon;</code> </td> <td> U+00395 </td> <td> <span class=glyph title="">Ε</span> </td> <tr id=entity-epsilon><td> <code title="">epsilon;</code> </td> <td> U+003B5 </td> <td> <span class=glyph title="">ε</span> </td> <tr id=entity-epsiv><td> <code title="">epsiv;</code> </td> <td> U+003F5 </td> <td> <span class=glyph title="">ϵ</span> </td> <tr id=entity-eqcirc><td> <code title="">eqcirc;</code> </td> <td> U+02256 </td> <td> <span class=glyph title="">≖</span> </td> <tr id=entity-eqcolon><td> <code title="">eqcolon;</code> </td> <td> U+02255 </td> <td> <span class=glyph title="">≕</span> </td> <tr id=entity-eqsim><td> <code title="">eqsim;</code> </td> <td> U+02242 </td> <td> <span class=glyph title="">≂</span> </td> <tr id=entity-eqslantgtr><td> <code title="">eqslantgtr;</code> </td> <td> U+02A96 </td> <td> <span class=glyph title="">⪖</span> </td> <tr id=entity-eqslantless><td> <code title="">eqslantless;</code> </td> <td> U+02A95 </td> <td> <span class=glyph title="">⪕</span> </td> <tr id=entity-Equal><td> <code title="">Equal;</code> </td> <td> U+02A75 </td> <td> <span class=glyph title="">⩵</span> </td> <tr id=entity-equals><td> <code title="">equals;</code> </td> <td> U+0003D </td> <td> <span class=glyph title="">=</span> </td> <tr id=entity-EqualTilde><td> <code title="">EqualTilde;</code> </td> <td> U+02242 </td> <td> <span class=glyph title="">≂</span> </td> <tr id=entity-equest><td> <code title="">equest;</code> </td> <td> U+0225F </td> <td> <span class=glyph title="">≟</span> </td> <tr id=entity-Equilibrium><td> <code title="">Equilibrium;</code> </td> <td> U+021CC </td> <td> <span class=glyph title="">⇌</span> </td> <tr id=entity-equiv><td> <code title="">equiv;</code> </td> <td> U+02261 </td> <td> <span class=glyph title="">≡</span> </td> <tr id=entity-equivDD><td> <code title="">equivDD;</code> </td> <td> U+02A78 </td> <td> <span class=glyph title="">⩸</span> </td> <tr id=entity-eqvparsl><td> <code title="">eqvparsl;</code> </td> <td> U+029E5 </td> <td> <span class=glyph title="">⧥</span> </td> <tr id=entity-erarr><td> <code title="">erarr;</code> </td> <td> U+02971 </td> <td> <span class=glyph title="">⥱</span> </td> <tr id=entity-erDot><td> <code title="">erDot;</code> </td> <td> U+02253 </td> <td> <span class=glyph title="">≓</span> </td> <tr id=entity-Escr><td> <code title="">Escr;</code> </td> <td> U+02130 </td> <td> <span class=glyph title="">ℰ</span> </td> <tr id=entity-escr><td> <code title="">escr;</code> </td> <td> U+0212F </td> <td> <span class=glyph title="">ℯ</span> </td> <tr id=entity-esdot><td> <code title="">esdot;</code> </td> <td> U+02250 </td> <td> <span class=glyph title="">≐</span> </td> <tr id=entity-Esim><td> <code title="">Esim;</code> </td> <td> U+02A73 </td> <td> <span class=glyph title="">⩳</span> </td> <tr id=entity-esim><td> <code title="">esim;</code> </td> <td> U+02242 </td> <td> <span class=glyph title="">≂</span> </td> <tr id=entity-Eta><td> <code title="">Eta;</code> </td> <td> U+00397 </td> <td> <span class=glyph title="">Η</span> </td> <tr id=entity-eta><td> <code title="">eta;</code> </td> <td> U+003B7 </td> <td> <span class=glyph title="">η</span> </td> <tr id=entity-ETH><td> <code title="">ETH;</code> </td> <td> U+000D0 </td> <td> <span class=glyph title="">Ð</span> </td> <tr class=impl id=entity-ETH-legacy><td> <code title="">ETH</code> </td> <td> U+000D0 </td> <td> <span title="">Ð</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-eth><td> <code title="">eth;</code> </td> <td> U+000F0 </td> <td> <span class=glyph title="">ð</span> </td> <tr class=impl id=entity-eth-legacy><td> <code title="">eth</code> </td> <td> U+000F0 </td> <td> <span title="">ð</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Euml><td> <code title="">Euml;</code> </td> <td> U+000CB </td> <td> <span class=glyph title="">Ë</span> </td> <tr class=impl id=entity-Euml-legacy><td> <code title="">Euml</code> </td> <td> U+000CB </td> <td> <span title="">Ë</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-euml><td> <code title="">euml;</code> </td> <td> U+000EB </td> <td> <span class=glyph title="">ë</span> </td> <tr class=impl id=entity-euml-legacy><td> <code title="">euml</code> </td> <td> U+000EB </td> <td> <span title="">ë</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-euro><td> <code title="">euro;</code> </td> <td> U+020AC </td> <td> <span class=glyph title="">€</span> </td> <tr id=entity-excl><td> <code title="">excl;</code> </td> <td> U+00021 </td> <td> <span class=glyph title="">!</span> </td> <tr id=entity-exist><td> <code title="">exist;</code> </td> <td> U+02203 </td> <td> <span class=glyph title="">∃</span> </td> <tr id=entity-Exists><td> <code title="">Exists;</code> </td> <td> U+02203 </td> <td> <span class=glyph title="">∃</span> </td> <tr id=entity-expectation><td> <code title="">expectation;</code> </td> <td> U+02130 </td> <td> <span class=glyph title="">ℰ</span> </td> <tr id=entity-ExponentialE><td> <code title="">ExponentialE;</code> </td> <td> U+02147 </td> <td> <span class=glyph title="">ⅇ</span> </td> <tr id=entity-exponentiale><td> <code title="">exponentiale;</code> </td> <td> U+02147 </td> <td> <span class=glyph title="">ⅇ</span> </td> <tr id=entity-fallingdotseq><td> <code title="">fallingdotseq;</code> </td> <td> U+02252 </td> <td> <span class=glyph title="">≒</span> </td> <tr id=entity-Fcy><td> <code title="">Fcy;</code> </td> <td> U+00424 </td> <td> <span class=glyph title="">Ф</span> </td> <tr id=entity-fcy><td> <code title="">fcy;</code> </td> <td> U+00444 </td> <td> <span class=glyph title="">ф</span> </td> <tr id=entity-female><td> <code title="">female;</code> </td> <td> U+02640 </td> <td> <span class=glyph title="">♀</span> </td> <tr id=entity-ffilig><td> <code title="">ffilig;</code> </td> <td> U+0FB03 </td> <td> <span class=glyph title="">ffi</span> </td> <tr id=entity-fflig><td> <code title="">fflig;</code> </td> <td> U+0FB00 </td> <td> <span class=glyph title="">ff</span> </td> <tr id=entity-ffllig><td> <code title="">ffllig;</code> </td> <td> U+0FB04 </td> <td> <span class=glyph title="">ffl</span> </td> <tr id=entity-Ffr><td> <code title="">Ffr;</code> </td> <td> U+1D509 </td> <td> <span class=glyph title="">𝔉</span> </td> <tr id=entity-ffr><td> <code title="">ffr;</code> </td> <td> U+1D523 </td> <td> <span class=glyph title="">𝔣</span> </td> <tr id=entity-filig><td> <code title="">filig;</code> </td> <td> U+0FB01 </td> <td> <span class=glyph title="">fi</span> </td> <tr id=entity-FilledSmallSquare><td> <code title="">FilledSmallSquare;</code> </td> <td> U+025FC </td> <td> <span class=glyph title="">◼</span> </td> <tr id=entity-FilledVerySmallSquare><td> <code title="">FilledVerySmallSquare;</code> </td> <td> U+025AA </td> <td> <span class=glyph title="">▪</span> </td> <tr id=entity-fjlig><td> <code title="">fjlig;</code> </td> <td> U+00066 U+0006A </td> <td> <span class="glyph compound" title="">fj</span> </td> <tr id=entity-flat><td> <code title="">flat;</code> </td> <td> U+0266D </td> <td> <span class=glyph title="">♭</span> </td> <tr id=entity-fllig><td> <code title="">fllig;</code> </td> <td> U+0FB02 </td> <td> <span class=glyph title="">fl</span> </td> <tr id=entity-fltns><td> <code title="">fltns;</code> </td> <td> U+025B1 </td> <td> <span class=glyph title="">▱</span> </td> <tr id=entity-fnof><td> <code title="">fnof;</code> </td> <td> U+00192 </td> <td> <span class=glyph title="">ƒ</span> </td> <tr id=entity-Fopf><td> <code title="">Fopf;</code> </td> <td> U+1D53D </td> <td> <span class=glyph title="">𝔽</span> </td> <tr id=entity-fopf><td> <code title="">fopf;</code> </td> <td> U+1D557 </td> <td> <span class=glyph title="">𝕗</span> </td> <tr id=entity-ForAll><td> <code title="">ForAll;</code> </td> <td> U+02200 </td> <td> <span class=glyph title="">∀</span> </td> <tr id=entity-forall><td> <code title="">forall;</code> </td> <td> U+02200 </td> <td> <span class=glyph title="">∀</span> </td> <tr id=entity-fork><td> <code title="">fork;</code> </td> <td> U+022D4 </td> <td> <span class=glyph title="">⋔</span> </td> <tr id=entity-forkv><td> <code title="">forkv;</code> </td> <td> U+02AD9 </td> <td> <span class=glyph title="">⫙</span> </td> <tr id=entity-Fouriertrf><td> <code title="">Fouriertrf;</code> </td> <td> U+02131 </td> <td> <span class=glyph title="">ℱ</span> </td> <tr id=entity-fpartint><td> <code title="">fpartint;</code> </td> <td> U+02A0D </td> <td> <span class=glyph title="">⨍</span> </td> <tr id=entity-frac12><td> <code title="">frac12;</code> </td> <td> U+000BD </td> <td> <span class=glyph title="">½</span> </td> <tr class=impl id=entity-frac12-legacy><td> <code title="">frac12</code> </td> <td> U+000BD </td> <td> <span title="">½</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-frac13><td> <code title="">frac13;</code> </td> <td> U+02153 </td> <td> <span class=glyph title="">⅓</span> </td> <tr id=entity-frac14><td> <code title="">frac14;</code> </td> <td> U+000BC </td> <td> <span class=glyph title="">¼</span> </td> <tr class=impl id=entity-frac14-legacy><td> <code title="">frac14</code> </td> <td> U+000BC </td> <td> <span title="">¼</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-frac15><td> <code title="">frac15;</code> </td> <td> U+02155 </td> <td> <span class=glyph title="">⅕</span> </td> <tr id=entity-frac16><td> <code title="">frac16;</code> </td> <td> U+02159 </td> <td> <span class=glyph title="">⅙</span> </td> <tr id=entity-frac18><td> <code title="">frac18;</code> </td> <td> U+0215B </td> <td> <span class=glyph title="">⅛</span> </td> <tr id=entity-frac23><td> <code title="">frac23;</code> </td> <td> U+02154 </td> <td> <span class=glyph title="">⅔</span> </td> <tr id=entity-frac25><td> <code title="">frac25;</code> </td> <td> U+02156 </td> <td> <span class=glyph title="">⅖</span> </td> <tr id=entity-frac34><td> <code title="">frac34;</code> </td> <td> U+000BE </td> <td> <span class=glyph title="">¾</span> </td> <tr class=impl id=entity-frac34-legacy><td> <code title="">frac34</code> </td> <td> U+000BE </td> <td> <span title="">¾</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-frac35><td> <code title="">frac35;</code> </td> <td> U+02157 </td> <td> <span class=glyph title="">⅗</span> </td> <tr id=entity-frac38><td> <code title="">frac38;</code> </td> <td> U+0215C </td> <td> <span class=glyph title="">⅜</span> </td> <tr id=entity-frac45><td> <code title="">frac45;</code> </td> <td> U+02158 </td> <td> <span class=glyph title="">⅘</span> </td> <tr id=entity-frac56><td> <code title="">frac56;</code> </td> <td> U+0215A </td> <td> <span class=glyph title="">⅚</span> </td> <tr id=entity-frac58><td> <code title="">frac58;</code> </td> <td> U+0215D </td> <td> <span class=glyph title="">⅝</span> </td> <tr id=entity-frac78><td> <code title="">frac78;</code> </td> <td> U+0215E </td> <td> <span class=glyph title="">⅞</span> </td> <tr id=entity-frasl><td> <code title="">frasl;</code> </td> <td> U+02044 </td> <td> <span class=glyph title="">⁄</span> </td> <tr id=entity-frown><td> <code title="">frown;</code> </td> <td> U+02322 </td> <td> <span class=glyph title="">⌢</span> </td> <tr id=entity-Fscr><td> <code title="">Fscr;</code> </td> <td> U+02131 </td> <td> <span class=glyph title="">ℱ</span> </td> <tr id=entity-fscr><td> <code title="">fscr;</code> </td> <td> U+1D4BB </td> <td> <span class=glyph title="">𝒻</span> </td> <tr id=entity-gacute><td> <code title="">gacute;</code> </td> <td> U+001F5 </td> <td> <span class=glyph title="">ǵ</span> </td> <tr id=entity-Gamma><td> <code title="">Gamma;</code> </td> <td> U+00393 </td> <td> <span class=glyph title="">Γ</span> </td> <tr id=entity-gamma><td> <code title="">gamma;</code> </td> <td> U+003B3 </td> <td> <span class=glyph title="">γ</span> </td> <tr id=entity-Gammad><td> <code title="">Gammad;</code> </td> <td> U+003DC </td> <td> <span class=glyph title="">Ϝ</span> </td> <tr id=entity-gammad><td> <code title="">gammad;</code> </td> <td> U+003DD </td> <td> <span class=glyph title="">ϝ</span> </td> <tr id=entity-gap><td> <code title="">gap;</code> </td> <td> U+02A86 </td> <td> <span class=glyph title="">⪆</span> </td> <tr id=entity-Gbreve><td> <code title="">Gbreve;</code> </td> <td> U+0011E </td> <td> <span class=glyph title="">Ğ</span> </td> <tr id=entity-gbreve><td> <code title="">gbreve;</code> </td> <td> U+0011F </td> <td> <span class=glyph title="">ğ</span> </td> <tr id=entity-Gcedil><td> <code title="">Gcedil;</code> </td> <td> U+00122 </td> <td> <span class=glyph title="">Ģ</span> </td> <tr id=entity-Gcirc><td> <code title="">Gcirc;</code> </td> <td> U+0011C </td> <td> <span class=glyph title="">Ĝ</span> </td> <tr id=entity-gcirc><td> <code title="">gcirc;</code> </td> <td> U+0011D </td> <td> <span class=glyph title="">ĝ</span> </td> <tr id=entity-Gcy><td> <code title="">Gcy;</code> </td> <td> U+00413 </td> <td> <span class=glyph title="">Г</span> </td> <tr id=entity-gcy><td> <code title="">gcy;</code> </td> <td> U+00433 </td> <td> <span class=glyph title="">г</span> </td> <tr id=entity-Gdot><td> <code title="">Gdot;</code> </td> <td> U+00120 </td> <td> <span class=glyph title="">Ġ</span> </td> <tr id=entity-gdot><td> <code title="">gdot;</code> </td> <td> U+00121 </td> <td> <span class=glyph title="">ġ</span> </td> <tr id=entity-gE><td> <code title="">gE;</code> </td> <td> U+02267 </td> <td> <span class=glyph title="">≧</span> </td> <tr id=entity-ge><td> <code title="">ge;</code> </td> <td> U+02265 </td> <td> <span class=glyph title="">≥</span> </td> <tr id=entity-gEl><td> <code title="">gEl;</code> </td> <td> U+02A8C </td> <td> <span class=glyph title="">⪌</span> </td> <tr id=entity-gel><td> <code title="">gel;</code> </td> <td> U+022DB </td> <td> <span class=glyph title="">⋛</span> </td> <tr id=entity-geq><td> <code title="">geq;</code> </td> <td> U+02265 </td> <td> <span class=glyph title="">≥</span> </td> <tr id=entity-geqq><td> <code title="">geqq;</code> </td> <td> U+02267 </td> <td> <span class=glyph title="">≧</span> </td> <tr id=entity-geqslant><td> <code title="">geqslant;</code> </td> <td> U+02A7E </td> <td> <span class=glyph title="">⩾</span> </td> <tr id=entity-ges><td> <code title="">ges;</code> </td> <td> U+02A7E </td> <td> <span class=glyph title="">⩾</span> </td> <tr id=entity-gescc><td> <code title="">gescc;</code> </td> <td> U+02AA9 </td> <td> <span class=glyph title="">⪩</span> </td> <tr id=entity-gesdot><td> <code title="">gesdot;</code> </td> <td> U+02A80 </td> <td> <span class=glyph title="">⪀</span> </td> <tr id=entity-gesdoto><td> <code title="">gesdoto;</code> </td> <td> U+02A82 </td> <td> <span class=glyph title="">⪂</span> </td> <tr id=entity-gesdotol><td> <code title="">gesdotol;</code> </td> <td> U+02A84 </td> <td> <span class=glyph title="">⪄</span> </td> <tr id=entity-gesl><td> <code title="">gesl;</code> </td> <td> U+022DB U+0FE00 </td> <td> <span class="glyph compound" title="">⋛︀</span> </td> <tr id=entity-gesles><td> <code title="">gesles;</code> </td> <td> U+02A94 </td> <td> <span class=glyph title="">⪔</span> </td> <tr id=entity-Gfr><td> <code title="">Gfr;</code> </td> <td> U+1D50A </td> <td> <span class=glyph title="">𝔊</span> </td> <tr id=entity-gfr><td> <code title="">gfr;</code> </td> <td> U+1D524 </td> <td> <span class=glyph title="">𝔤</span> </td> <tr id=entity-Gg><td> <code title="">Gg;</code> </td> <td> U+022D9 </td> <td> <span class=glyph title="">⋙</span> </td> <tr id=entity-gg><td> <code title="">gg;</code> </td> <td> U+0226B </td> <td> <span class=glyph title="">≫</span> </td> <tr id=entity-ggg><td> <code title="">ggg;</code> </td> <td> U+022D9 </td> <td> <span class=glyph title="">⋙</span> </td> <tr id=entity-gimel><td> <code title="">gimel;</code> </td> <td> U+02137 </td> <td> <span class=glyph title="">ℷ</span> </td> <tr id=entity-GJcy><td> <code title="">GJcy;</code> </td> <td> U+00403 </td> <td> <span class=glyph title="">Ѓ</span> </td> <tr id=entity-gjcy><td> <code title="">gjcy;</code> </td> <td> U+00453 </td> <td> <span class=glyph title="">ѓ</span> </td> <tr id=entity-gl><td> <code title="">gl;</code> </td> <td> U+02277 </td> <td> <span class=glyph title="">≷</span> </td> <tr id=entity-gla><td> <code title="">gla;</code> </td> <td> U+02AA5 </td> <td> <span class=glyph title="">⪥</span> </td> <tr id=entity-glE><td> <code title="">glE;</code> </td> <td> U+02A92 </td> <td> <span class=glyph title="">⪒</span> </td> <tr id=entity-glj><td> <code title="">glj;</code> </td> <td> U+02AA4 </td> <td> <span class=glyph title="">⪤</span> </td> <tr id=entity-gnap><td> <code title="">gnap;</code> </td> <td> U+02A8A </td> <td> <span class=glyph title="">⪊</span> </td> <tr id=entity-gnapprox><td> <code title="">gnapprox;</code> </td> <td> U+02A8A </td> <td> <span class=glyph title="">⪊</span> </td> <tr id=entity-gnE><td> <code title="">gnE;</code> </td> <td> U+02269 </td> <td> <span class=glyph title="">≩</span> </td> <tr id=entity-gne><td> <code title="">gne;</code> </td> <td> U+02A88 </td> <td> <span class=glyph title="">⪈</span> </td> <tr id=entity-gneq><td> <code title="">gneq;</code> </td> <td> U+02A88 </td> <td> <span class=glyph title="">⪈</span> </td> <tr id=entity-gneqq><td> <code title="">gneqq;</code> </td> <td> U+02269 </td> <td> <span class=glyph title="">≩</span> </td> <tr id=entity-gnsim><td> <code title="">gnsim;</code> </td> <td> U+022E7 </td> <td> <span class=glyph title="">⋧</span> </td> <tr id=entity-Gopf><td> <code title="">Gopf;</code> </td> <td> U+1D53E </td> <td> <span class=glyph title="">𝔾</span> </td> <tr id=entity-gopf><td> <code title="">gopf;</code> </td> <td> U+1D558 </td> <td> <span class=glyph title="">𝕘</span> </td> <tr id=entity-grave><td> <code title="">grave;</code> </td> <td> U+00060 </td> <td> <span class=glyph title="">`</span> </td> <tr id=entity-GreaterEqual><td> <code title="">GreaterEqual;</code> </td> <td> U+02265 </td> <td> <span class=glyph title="">≥</span> </td> <tr id=entity-GreaterEqualLess><td> <code title="">GreaterEqualLess;</code> </td> <td> U+022DB </td> <td> <span class=glyph title="">⋛</span> </td> <tr id=entity-GreaterFullEqual><td> <code title="">GreaterFullEqual;</code> </td> <td> U+02267 </td> <td> <span class=glyph title="">≧</span> </td> <tr id=entity-GreaterGreater><td> <code title="">GreaterGreater;</code> </td> <td> U+02AA2 </td> <td> <span class=glyph title="">⪢</span> </td> <tr id=entity-GreaterLess><td> <code title="">GreaterLess;</code> </td> <td> U+02277 </td> <td> <span class=glyph title="">≷</span> </td> <tr id=entity-GreaterSlantEqual><td> <code title="">GreaterSlantEqual;</code> </td> <td> U+02A7E </td> <td> <span class=glyph title="">⩾</span> </td> <tr id=entity-GreaterTilde><td> <code title="">GreaterTilde;</code> </td> <td> U+02273 </td> <td> <span class=glyph title="">≳</span> </td> <tr id=entity-Gscr><td> <code title="">Gscr;</code> </td> <td> U+1D4A2 </td> <td> <span class=glyph title="">𝒢</span> </td> <tr id=entity-gscr><td> <code title="">gscr;</code> </td> <td> U+0210A </td> <td> <span class=glyph title="">ℊ</span> </td> <tr id=entity-gsim><td> <code title="">gsim;</code> </td> <td> U+02273 </td> <td> <span class=glyph title="">≳</span> </td> <tr id=entity-gsime><td> <code title="">gsime;</code> </td> <td> U+02A8E </td> <td> <span class=glyph title="">⪎</span> </td> <tr id=entity-gsiml><td> <code title="">gsiml;</code> </td> <td> U+02A90 </td> <td> <span class=glyph title="">⪐</span> </td> <tr id=entity-GT><td> <code title="">GT;</code> </td> <td> U+0003E </td> <td> <span class=glyph title="">></span> </td> <tr class=impl id=entity-GT-legacy><td> <code title="">GT</code> </td> <td> U+0003E </td> <td> <span title="">></span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Gt><td> <code title="">Gt;</code> </td> <td> U+0226B </td> <td> <span class=glyph title="">≫</span> </td> <tr id=entity-gt><td> <code title="">gt;</code> </td> <td> U+0003E </td> <td> <span class=glyph title="">></span> </td> <tr class=impl id=entity-gt-legacy><td> <code title="">gt</code> </td> <td> U+0003E </td> <td> <span title="">></span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-gtcc><td> <code title="">gtcc;</code> </td> <td> U+02AA7 </td> <td> <span class=glyph title="">⪧</span> </td> <tr id=entity-gtcir><td> <code title="">gtcir;</code> </td> <td> U+02A7A </td> <td> <span class=glyph title="">⩺</span> </td> <tr id=entity-gtdot><td> <code title="">gtdot;</code> </td> <td> U+022D7 </td> <td> <span class=glyph title="">⋗</span> </td> <tr id=entity-gtlPar><td> <code title="">gtlPar;</code> </td> <td> U+02995 </td> <td> <span class=glyph title="">⦕</span> </td> <tr id=entity-gtquest><td> <code title="">gtquest;</code> </td> <td> U+02A7C </td> <td> <span class=glyph title="">⩼</span> </td> <tr id=entity-gtrapprox><td> <code title="">gtrapprox;</code> </td> <td> U+02A86 </td> <td> <span class=glyph title="">⪆</span> </td> <tr id=entity-gtrarr><td> <code title="">gtrarr;</code> </td> <td> U+02978 </td> <td> <span class=glyph title="">⥸</span> </td> <tr id=entity-gtrdot><td> <code title="">gtrdot;</code> </td> <td> U+022D7 </td> <td> <span class=glyph title="">⋗</span> </td> <tr id=entity-gtreqless><td> <code title="">gtreqless;</code> </td> <td> U+022DB </td> <td> <span class=glyph title="">⋛</span> </td> <tr id=entity-gtreqqless><td> <code title="">gtreqqless;</code> </td> <td> U+02A8C </td> <td> <span class=glyph title="">⪌</span> </td> <tr id=entity-gtrless><td> <code title="">gtrless;</code> </td> <td> U+02277 </td> <td> <span class=glyph title="">≷</span> </td> <tr id=entity-gtrsim><td> <code title="">gtrsim;</code> </td> <td> U+02273 </td> <td> <span class=glyph title="">≳</span> </td> <tr id=entity-gvertneqq><td> <code title="">gvertneqq;</code> </td> <td> U+02269 U+0FE00 </td> <td> <span class="glyph compound" title="">≩︀</span> </td> <tr id=entity-gvnE><td> <code title="">gvnE;</code> </td> <td> U+02269 U+0FE00 </td> <td> <span class="glyph compound" title="">≩︀</span> </td> <tr id=entity-Hacek><td> <code title="">Hacek;</code> </td> <td> U+002C7 </td> <td> <span class=glyph title="">ˇ</span> </td> <tr id=entity-hairsp><td> <code title="">hairsp;</code> </td> <td> U+0200A </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-half><td> <code title="">half;</code> </td> <td> U+000BD </td> <td> <span class=glyph title="">½</span> </td> <tr id=entity-hamilt><td> <code title="">hamilt;</code> </td> <td> U+0210B </td> <td> <span class=glyph title="">ℋ</span> </td> <tr id=entity-HARDcy><td> <code title="">HARDcy;</code> </td> <td> U+0042A </td> <td> <span class=glyph title="">Ъ</span> </td> <tr id=entity-hardcy><td> <code title="">hardcy;</code> </td> <td> U+0044A </td> <td> <span class=glyph title="">ъ</span> </td> <tr id=entity-hArr><td> <code title="">hArr;</code> </td> <td> U+021D4 </td> <td> <span class=glyph title="">⇔</span> </td> <tr id=entity-harr><td> <code title="">harr;</code> </td> <td> U+02194 </td> <td> <span class=glyph title="">↔</span> </td> <tr id=entity-harrcir><td> <code title="">harrcir;</code> </td> <td> U+02948 </td> <td> <span class=glyph title="">⥈</span> </td> <tr id=entity-harrw><td> <code title="">harrw;</code> </td> <td> U+021AD </td> <td> <span class=glyph title="">↭</span> </td> <tr id=entity-Hat><td> <code title="">Hat;</code> </td> <td> U+0005E </td> <td> <span class=glyph title="">^</span> </td> <tr id=entity-hbar><td> <code title="">hbar;</code> </td> <td> U+0210F </td> <td> <span class=glyph title="">ℏ</span> </td> <tr id=entity-Hcirc><td> <code title="">Hcirc;</code> </td> <td> U+00124 </td> <td> <span class=glyph title="">Ĥ</span> </td> <tr id=entity-hcirc><td> <code title="">hcirc;</code> </td> <td> U+00125 </td> <td> <span class=glyph title="">ĥ</span> </td> <tr id=entity-hearts><td> <code title="">hearts;</code> </td> <td> U+02665 </td> <td> <span class=glyph title="">♥</span> </td> <tr id=entity-heartsuit><td> <code title="">heartsuit;</code> </td> <td> U+02665 </td> <td> <span class=glyph title="">♥</span> </td> <tr id=entity-hellip><td> <code title="">hellip;</code> </td> <td> U+02026 </td> <td> <span class=glyph title="">…</span> </td> <tr id=entity-hercon><td> <code title="">hercon;</code> </td> <td> U+022B9 </td> <td> <span class=glyph title="">⊹</span> </td> <tr id=entity-Hfr><td> <code title="">Hfr;</code> </td> <td> U+0210C </td> <td> <span class=glyph title="">ℌ</span> </td> <tr id=entity-hfr><td> <code title="">hfr;</code> </td> <td> U+1D525 </td> <td> <span class=glyph title="">𝔥</span> </td> <tr id=entity-HilbertSpace><td> <code title="">HilbertSpace;</code> </td> <td> U+0210B </td> <td> <span class=glyph title="">ℋ</span> </td> <tr id=entity-hksearow><td> <code title="">hksearow;</code> </td> <td> U+02925 </td> <td> <span class=glyph title="">⤥</span> </td> <tr id=entity-hkswarow><td> <code title="">hkswarow;</code> </td> <td> U+02926 </td> <td> <span class=glyph title="">⤦</span> </td> <tr id=entity-hoarr><td> <code title="">hoarr;</code> </td> <td> U+021FF </td> <td> <span class=glyph title="">⇿</span> </td> <tr id=entity-homtht><td> <code title="">homtht;</code> </td> <td> U+0223B </td> <td> <span class=glyph title="">∻</span> </td> <tr id=entity-hookleftarrow><td> <code title="">hookleftarrow;</code> </td> <td> U+021A9 </td> <td> <span class=glyph title="">↩</span> </td> <tr id=entity-hookrightarrow><td> <code title="">hookrightarrow;</code> </td> <td> U+021AA </td> <td> <span class=glyph title="">↪</span> </td> <tr id=entity-Hopf><td> <code title="">Hopf;</code> </td> <td> U+0210D </td> <td> <span class=glyph title="">ℍ</span> </td> <tr id=entity-hopf><td> <code title="">hopf;</code> </td> <td> U+1D559 </td> <td> <span class=glyph title="">𝕙</span> </td> <tr id=entity-horbar><td> <code title="">horbar;</code> </td> <td> U+02015 </td> <td> <span class=glyph title="">―</span> </td> <tr id=entity-HorizontalLine><td> <code title="">HorizontalLine;</code> </td> <td> U+02500 </td> <td> <span class=glyph title="">─</span> </td> <tr id=entity-Hscr><td> <code title="">Hscr;</code> </td> <td> U+0210B </td> <td> <span class=glyph title="">ℋ</span> </td> <tr id=entity-hscr><td> <code title="">hscr;</code> </td> <td> U+1D4BD </td> <td> <span class=glyph title="">𝒽</span> </td> <tr id=entity-hslash><td> <code title="">hslash;</code> </td> <td> U+0210F </td> <td> <span class=glyph title="">ℏ</span> </td> <tr id=entity-Hstrok><td> <code title="">Hstrok;</code> </td> <td> U+00126 </td> <td> <span class=glyph title="">Ħ</span> </td> <tr id=entity-hstrok><td> <code title="">hstrok;</code> </td> <td> U+00127 </td> <td> <span class=glyph title="">ħ</span> </td> <tr id=entity-HumpDownHump><td> <code title="">HumpDownHump;</code> </td> <td> U+0224E </td> <td> <span class=glyph title="">≎</span> </td> <tr id=entity-HumpEqual><td> <code title="">HumpEqual;</code> </td> <td> U+0224F </td> <td> <span class=glyph title="">≏</span> </td> <tr id=entity-hybull><td> <code title="">hybull;</code> </td> <td> U+02043 </td> <td> <span class=glyph title="">⁃</span> </td> <tr id=entity-hyphen><td> <code title="">hyphen;</code> </td> <td> U+02010 </td> <td> <span class=glyph title="">‐</span> </td> <tr id=entity-Iacute><td> <code title="">Iacute;</code> </td> <td> U+000CD </td> <td> <span class=glyph title="">Í</span> </td> <tr class=impl id=entity-Iacute-legacy><td> <code title="">Iacute</code> </td> <td> U+000CD </td> <td> <span title="">Í</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-iacute><td> <code title="">iacute;</code> </td> <td> U+000ED </td> <td> <span class=glyph title="">í</span> </td> <tr class=impl id=entity-iacute-legacy><td> <code title="">iacute</code> </td> <td> U+000ED </td> <td> <span title="">í</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ic><td> <code title="">ic;</code> </td> <td> U+02063 </td> <td> <span class=glyph title="">⁣</span> </td> <tr id=entity-Icirc><td> <code title="">Icirc;</code> </td> <td> U+000CE </td> <td> <span class=glyph title="">Î</span> </td> <tr class=impl id=entity-Icirc-legacy><td> <code title="">Icirc</code> </td> <td> U+000CE </td> <td> <span title="">Î</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-icirc><td> <code title="">icirc;</code> </td> <td> U+000EE </td> <td> <span class=glyph title="">î</span> </td> <tr class=impl id=entity-icirc-legacy><td> <code title="">icirc</code> </td> <td> U+000EE </td> <td> <span title="">î</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Icy><td> <code title="">Icy;</code> </td> <td> U+00418 </td> <td> <span class=glyph title="">И</span> </td> <tr id=entity-icy><td> <code title="">icy;</code> </td> <td> U+00438 </td> <td> <span class=glyph title="">и</span> </td> <tr id=entity-Idot><td> <code title="">Idot;</code> </td> <td> U+00130 </td> <td> <span class=glyph title="">İ</span> </td> <tr id=entity-IEcy><td> <code title="">IEcy;</code> </td> <td> U+00415 </td> <td> <span class=glyph title="">Е</span> </td> <tr id=entity-iecy><td> <code title="">iecy;</code> </td> <td> U+00435 </td> <td> <span class=glyph title="">е</span> </td> <tr id=entity-iexcl><td> <code title="">iexcl;</code> </td> <td> U+000A1 </td> <td> <span class=glyph title="">¡</span> </td> <tr class=impl id=entity-iexcl-legacy><td> <code title="">iexcl</code> </td> <td> U+000A1 </td> <td> <span title="">¡</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-iff><td> <code title="">iff;</code> </td> <td> U+021D4 </td> <td> <span class=glyph title="">⇔</span> </td> <tr id=entity-Ifr><td> <code title="">Ifr;</code> </td> <td> U+02111 </td> <td> <span class=glyph title="">ℑ</span> </td> <tr id=entity-ifr><td> <code title="">ifr;</code> </td> <td> U+1D526 </td> <td> <span class=glyph title="">𝔦</span> </td> <tr id=entity-Igrave><td> <code title="">Igrave;</code> </td> <td> U+000CC </td> <td> <span class=glyph title="">Ì</span> </td> <tr class=impl id=entity-Igrave-legacy><td> <code title="">Igrave</code> </td> <td> U+000CC </td> <td> <span title="">Ì</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-igrave><td> <code title="">igrave;</code> </td> <td> U+000EC </td> <td> <span class=glyph title="">ì</span> </td> <tr class=impl id=entity-igrave-legacy><td> <code title="">igrave</code> </td> <td> U+000EC </td> <td> <span title="">ì</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ii><td> <code title="">ii;</code> </td> <td> U+02148 </td> <td> <span class=glyph title="">ⅈ</span> </td> <tr id=entity-iiiint><td> <code title="">iiiint;</code> </td> <td> U+02A0C </td> <td> <span class=glyph title="">⨌</span> </td> <tr id=entity-iiint><td> <code title="">iiint;</code> </td> <td> U+0222D </td> <td> <span class=glyph title="">∭</span> </td> <tr id=entity-iinfin><td> <code title="">iinfin;</code> </td> <td> U+029DC </td> <td> <span class=glyph title="">⧜</span> </td> <tr id=entity-iiota><td> <code title="">iiota;</code> </td> <td> U+02129 </td> <td> <span class=glyph title="">℩</span> </td> <tr id=entity-IJlig><td> <code title="">IJlig;</code> </td> <td> U+00132 </td> <td> <span class=glyph title="">IJ</span> </td> <tr id=entity-ijlig><td> <code title="">ijlig;</code> </td> <td> U+00133 </td> <td> <span class=glyph title="">ij</span> </td> <tr id=entity-Im><td> <code title="">Im;</code> </td> <td> U+02111 </td> <td> <span class=glyph title="">ℑ</span> </td> <tr id=entity-Imacr><td> <code title="">Imacr;</code> </td> <td> U+0012A </td> <td> <span class=glyph title="">Ī</span> </td> <tr id=entity-imacr><td> <code title="">imacr;</code> </td> <td> U+0012B </td> <td> <span class=glyph title="">ī</span> </td> <tr id=entity-image><td> <code title="">image;</code> </td> <td> U+02111 </td> <td> <span class=glyph title="">ℑ</span> </td> <tr id=entity-ImaginaryI><td> <code title="">ImaginaryI;</code> </td> <td> U+02148 </td> <td> <span class=glyph title="">ⅈ</span> </td> <tr id=entity-imagline><td> <code title="">imagline;</code> </td> <td> U+02110 </td> <td> <span class=glyph title="">ℐ</span> </td> <tr id=entity-imagpart><td> <code title="">imagpart;</code> </td> <td> U+02111 </td> <td> <span class=glyph title="">ℑ</span> </td> <tr id=entity-imath><td> <code title="">imath;</code> </td> <td> U+00131 </td> <td> <span class=glyph title="">ı</span> </td> <tr id=entity-imof><td> <code title="">imof;</code> </td> <td> U+022B7 </td> <td> <span class=glyph title="">⊷</span> </td> <tr id=entity-imped><td> <code title="">imped;</code> </td> <td> U+001B5 </td> <td> <span class=glyph title="">Ƶ</span> </td> <tr id=entity-Implies><td> <code title="">Implies;</code> </td> <td> U+021D2 </td> <td> <span class=glyph title="">⇒</span> </td> <tr id=entity-in><td> <code title="">in;</code> </td> <td> U+02208 </td> <td> <span class=glyph title="">∈</span> </td> <tr id=entity-incare><td> <code title="">incare;</code> </td> <td> U+02105 </td> <td> <span class=glyph title="">℅</span> </td> <tr id=entity-infin><td> <code title="">infin;</code> </td> <td> U+0221E </td> <td> <span class=glyph title="">∞</span> </td> <tr id=entity-infintie><td> <code title="">infintie;</code> </td> <td> U+029DD </td> <td> <span class=glyph title="">⧝</span> </td> <tr id=entity-inodot><td> <code title="">inodot;</code> </td> <td> U+00131 </td> <td> <span class=glyph title="">ı</span> </td> <tr id=entity-Int><td> <code title="">Int;</code> </td> <td> U+0222C </td> <td> <span class=glyph title="">∬</span> </td> <tr id=entity-int><td> <code title="">int;</code> </td> <td> U+0222B </td> <td> <span class=glyph title="">∫</span> </td> <tr id=entity-intcal><td> <code title="">intcal;</code> </td> <td> U+022BA </td> <td> <span class=glyph title="">⊺</span> </td> <tr id=entity-integers><td> <code title="">integers;</code> </td> <td> U+02124 </td> <td> <span class=glyph title="">ℤ</span> </td> <tr id=entity-Integral><td> <code title="">Integral;</code> </td> <td> U+0222B </td> <td> <span class=glyph title="">∫</span> </td> <tr id=entity-intercal><td> <code title="">intercal;</code> </td> <td> U+022BA </td> <td> <span class=glyph title="">⊺</span> </td> <tr id=entity-Intersection><td> <code title="">Intersection;</code> </td> <td> U+022C2 </td> <td> <span class=glyph title="">⋂</span> </td> <tr id=entity-intlarhk><td> <code title="">intlarhk;</code> </td> <td> U+02A17 </td> <td> <span class=glyph title="">⨗</span> </td> <tr id=entity-intprod><td> <code title="">intprod;</code> </td> <td> U+02A3C </td> <td> <span class=glyph title="">⨼</span> </td> <tr id=entity-InvisibleComma><td> <code title="">InvisibleComma;</code> </td> <td> U+02063 </td> <td> <span class=glyph title="">⁣</span> </td> <tr id=entity-InvisibleTimes><td> <code title="">InvisibleTimes;</code> </td> <td> U+02062 </td> <td> <span class=glyph title="">⁢</span> </td> <tr id=entity-IOcy><td> <code title="">IOcy;</code> </td> <td> U+00401 </td> <td> <span class=glyph title="">Ё</span> </td> <tr id=entity-iocy><td> <code title="">iocy;</code> </td> <td> U+00451 </td> <td> <span class=glyph title="">ё</span> </td> <tr id=entity-Iogon><td> <code title="">Iogon;</code> </td> <td> U+0012E </td> <td> <span class=glyph title="">Į</span> </td> <tr id=entity-iogon><td> <code title="">iogon;</code> </td> <td> U+0012F </td> <td> <span class=glyph title="">į</span> </td> <tr id=entity-Iopf><td> <code title="">Iopf;</code> </td> <td> U+1D540 </td> <td> <span class=glyph title="">𝕀</span> </td> <tr id=entity-iopf><td> <code title="">iopf;</code> </td> <td> U+1D55A </td> <td> <span class=glyph title="">𝕚</span> </td> <tr id=entity-Iota><td> <code title="">Iota;</code> </td> <td> U+00399 </td> <td> <span class=glyph title="">Ι</span> </td> <tr id=entity-iota><td> <code title="">iota;</code> </td> <td> U+003B9 </td> <td> <span class=glyph title="">ι</span> </td> <tr id=entity-iprod><td> <code title="">iprod;</code> </td> <td> U+02A3C </td> <td> <span class=glyph title="">⨼</span> </td> <tr id=entity-iquest><td> <code title="">iquest;</code> </td> <td> U+000BF </td> <td> <span class=glyph title="">¿</span> </td> <tr class=impl id=entity-iquest-legacy><td> <code title="">iquest</code> </td> <td> U+000BF </td> <td> <span title="">¿</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Iscr><td> <code title="">Iscr;</code> </td> <td> U+02110 </td> <td> <span class=glyph title="">ℐ</span> </td> <tr id=entity-iscr><td> <code title="">iscr;</code> </td> <td> U+1D4BE </td> <td> <span class=glyph title="">𝒾</span> </td> <tr id=entity-isin><td> <code title="">isin;</code> </td> <td> U+02208 </td> <td> <span class=glyph title="">∈</span> </td> <tr id=entity-isindot><td> <code title="">isindot;</code> </td> <td> U+022F5 </td> <td> <span class=glyph title="">⋵</span> </td> <tr id=entity-isinE><td> <code title="">isinE;</code> </td> <td> U+022F9 </td> <td> <span class=glyph title="">⋹</span> </td> <tr id=entity-isins><td> <code title="">isins;</code> </td> <td> U+022F4 </td> <td> <span class=glyph title="">⋴</span> </td> <tr id=entity-isinsv><td> <code title="">isinsv;</code> </td> <td> U+022F3 </td> <td> <span class=glyph title="">⋳</span> </td> <tr id=entity-isinv><td> <code title="">isinv;</code> </td> <td> U+02208 </td> <td> <span class=glyph title="">∈</span> </td> <tr id=entity-it><td> <code title="">it;</code> </td> <td> U+02062 </td> <td> <span class=glyph title="">⁢</span> </td> <tr id=entity-Itilde><td> <code title="">Itilde;</code> </td> <td> U+00128 </td> <td> <span class=glyph title="">Ĩ</span> </td> <tr id=entity-itilde><td> <code title="">itilde;</code> </td> <td> U+00129 </td> <td> <span class=glyph title="">ĩ</span> </td> <tr id=entity-Iukcy><td> <code title="">Iukcy;</code> </td> <td> U+00406 </td> <td> <span class=glyph title="">І</span> </td> <tr id=entity-iukcy><td> <code title="">iukcy;</code> </td> <td> U+00456 </td> <td> <span class=glyph title="">і</span> </td> <tr id=entity-Iuml><td> <code title="">Iuml;</code> </td> <td> U+000CF </td> <td> <span class=glyph title="">Ï</span> </td> <tr class=impl id=entity-Iuml-legacy><td> <code title="">Iuml</code> </td> <td> U+000CF </td> <td> <span title="">Ï</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-iuml><td> <code title="">iuml;</code> </td> <td> U+000EF </td> <td> <span class=glyph title="">ï</span> </td> <tr class=impl id=entity-iuml-legacy><td> <code title="">iuml</code> </td> <td> U+000EF </td> <td> <span title="">ï</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Jcirc><td> <code title="">Jcirc;</code> </td> <td> U+00134 </td> <td> <span class=glyph title="">Ĵ</span> </td> <tr id=entity-jcirc><td> <code title="">jcirc;</code> </td> <td> U+00135 </td> <td> <span class=glyph title="">ĵ</span> </td> <tr id=entity-Jcy><td> <code title="">Jcy;</code> </td> <td> U+00419 </td> <td> <span class=glyph title="">Й</span> </td> <tr id=entity-jcy><td> <code title="">jcy;</code> </td> <td> U+00439 </td> <td> <span class=glyph title="">й</span> </td> <tr id=entity-Jfr><td> <code title="">Jfr;</code> </td> <td> U+1D50D </td> <td> <span class=glyph title="">𝔍</span> </td> <tr id=entity-jfr><td> <code title="">jfr;</code> </td> <td> U+1D527 </td> <td> <span class=glyph title="">𝔧</span> </td> <tr id=entity-jmath><td> <code title="">jmath;</code> </td> <td> U+00237 </td> <td> <span class=glyph title="">ȷ</span> </td> <tr id=entity-Jopf><td> <code title="">Jopf;</code> </td> <td> U+1D541 </td> <td> <span class=glyph title="">𝕁</span> </td> <tr id=entity-jopf><td> <code title="">jopf;</code> </td> <td> U+1D55B </td> <td> <span class=glyph title="">𝕛</span> </td> <tr id=entity-Jscr><td> <code title="">Jscr;</code> </td> <td> U+1D4A5 </td> <td> <span class=glyph title="">𝒥</span> </td> <tr id=entity-jscr><td> <code title="">jscr;</code> </td> <td> U+1D4BF </td> <td> <span class=glyph title="">𝒿</span> </td> <tr id=entity-Jsercy><td> <code title="">Jsercy;</code> </td> <td> U+00408 </td> <td> <span class=glyph title="">Ј</span> </td> <tr id=entity-jsercy><td> <code title="">jsercy;</code> </td> <td> U+00458 </td> <td> <span class=glyph title="">ј</span> </td> <tr id=entity-Jukcy><td> <code title="">Jukcy;</code> </td> <td> U+00404 </td> <td> <span class=glyph title="">Є</span> </td> <tr id=entity-jukcy><td> <code title="">jukcy;</code> </td> <td> U+00454 </td> <td> <span class=glyph title="">є</span> </td> <tr id=entity-Kappa><td> <code title="">Kappa;</code> </td> <td> U+0039A </td> <td> <span class=glyph title="">Κ</span> </td> <tr id=entity-kappa><td> <code title="">kappa;</code> </td> <td> U+003BA </td> <td> <span class=glyph title="">κ</span> </td> <tr id=entity-kappav><td> <code title="">kappav;</code> </td> <td> U+003F0 </td> <td> <span class=glyph title="">ϰ</span> </td> <tr id=entity-Kcedil><td> <code title="">Kcedil;</code> </td> <td> U+00136 </td> <td> <span class=glyph title="">Ķ</span> </td> <tr id=entity-kcedil><td> <code title="">kcedil;</code> </td> <td> U+00137 </td> <td> <span class=glyph title="">ķ</span> </td> <tr id=entity-Kcy><td> <code title="">Kcy;</code> </td> <td> U+0041A </td> <td> <span class=glyph title="">К</span> </td> <tr id=entity-kcy><td> <code title="">kcy;</code> </td> <td> U+0043A </td> <td> <span class=glyph title="">к</span> </td> <tr id=entity-Kfr><td> <code title="">Kfr;</code> </td> <td> U+1D50E </td> <td> <span class=glyph title="">𝔎</span> </td> <tr id=entity-kfr><td> <code title="">kfr;</code> </td> <td> U+1D528 </td> <td> <span class=glyph title="">𝔨</span> </td> <tr id=entity-kgreen><td> <code title="">kgreen;</code> </td> <td> U+00138 </td> <td> <span class=glyph title="">ĸ</span> </td> <tr id=entity-KHcy><td> <code title="">KHcy;</code> </td> <td> U+00425 </td> <td> <span class=glyph title="">Х</span> </td> <tr id=entity-khcy><td> <code title="">khcy;</code> </td> <td> U+00445 </td> <td> <span class=glyph title="">х</span> </td> <tr id=entity-KJcy><td> <code title="">KJcy;</code> </td> <td> U+0040C </td> <td> <span class=glyph title="">Ќ</span> </td> <tr id=entity-kjcy><td> <code title="">kjcy;</code> </td> <td> U+0045C </td> <td> <span class=glyph title="">ќ</span> </td> <tr id=entity-Kopf><td> <code title="">Kopf;</code> </td> <td> U+1D542 </td> <td> <span class=glyph title="">𝕂</span> </td> <tr id=entity-kopf><td> <code title="">kopf;</code> </td> <td> U+1D55C </td> <td> <span class=glyph title="">𝕜</span> </td> <tr id=entity-Kscr><td> <code title="">Kscr;</code> </td> <td> U+1D4A6 </td> <td> <span class=glyph title="">𝒦</span> </td> <tr id=entity-kscr><td> <code title="">kscr;</code> </td> <td> U+1D4C0 </td> <td> <span class=glyph title="">𝓀</span> </td> <tr id=entity-lAarr><td> <code title="">lAarr;</code> </td> <td> U+021DA </td> <td> <span class=glyph title="">⇚</span> </td> <tr id=entity-Lacute><td> <code title="">Lacute;</code> </td> <td> U+00139 </td> <td> <span class=glyph title="">Ĺ</span> </td> <tr id=entity-lacute><td> <code title="">lacute;</code> </td> <td> U+0013A </td> <td> <span class=glyph title="">ĺ</span> </td> <tr id=entity-laemptyv><td> <code title="">laemptyv;</code> </td> <td> U+029B4 </td> <td> <span class=glyph title="">⦴</span> </td> <tr id=entity-lagran><td> <code title="">lagran;</code> </td> <td> U+02112 </td> <td> <span class=glyph title="">ℒ</span> </td> <tr id=entity-Lambda><td> <code title="">Lambda;</code> </td> <td> U+0039B </td> <td> <span class=glyph title="">Λ</span> </td> <tr id=entity-lambda><td> <code title="">lambda;</code> </td> <td> U+003BB </td> <td> <span class=glyph title="">λ</span> </td> <tr id=entity-Lang><td> <code title="">Lang;</code> </td> <td> U+027EA </td> <td> <span class=glyph title="">⟪</span> </td> <tr id=entity-lang><td> <code title="">lang;</code> </td> <td> U+027E8 </td> <td> <span class=glyph title="">⟨</span> </td> <tr id=entity-langd><td> <code title="">langd;</code> </td> <td> U+02991 </td> <td> <span class=glyph title="">⦑</span> </td> <tr id=entity-langle><td> <code title="">langle;</code> </td> <td> U+027E8 </td> <td> <span class=glyph title="">⟨</span> </td> <tr id=entity-lap><td> <code title="">lap;</code> </td> <td> U+02A85 </td> <td> <span class=glyph title="">⪅</span> </td> <tr id=entity-Laplacetrf><td> <code title="">Laplacetrf;</code> </td> <td> U+02112 </td> <td> <span class=glyph title="">ℒ</span> </td> <tr id=entity-laquo><td> <code title="">laquo;</code> </td> <td> U+000AB </td> <td> <span class=glyph title="">«</span> </td> <tr class=impl id=entity-laquo-legacy><td> <code title="">laquo</code> </td> <td> U+000AB </td> <td> <span title="">«</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Larr><td> <code title="">Larr;</code> </td> <td> U+0219E </td> <td> <span class=glyph title="">↞</span> </td> <tr id=entity-lArr><td> <code title="">lArr;</code> </td> <td> U+021D0 </td> <td> <span class=glyph title="">⇐</span> </td> <tr id=entity-larr><td> <code title="">larr;</code> </td> <td> U+02190 </td> <td> <span class=glyph title="">←</span> </td> <tr id=entity-larrb><td> <code title="">larrb;</code> </td> <td> U+021E4 </td> <td> <span class=glyph title="">⇤</span> </td> <tr id=entity-larrbfs><td> <code title="">larrbfs;</code> </td> <td> U+0291F </td> <td> <span class=glyph title="">⤟</span> </td> <tr id=entity-larrfs><td> <code title="">larrfs;</code> </td> <td> U+0291D </td> <td> <span class=glyph title="">⤝</span> </td> <tr id=entity-larrhk><td> <code title="">larrhk;</code> </td> <td> U+021A9 </td> <td> <span class=glyph title="">↩</span> </td> <tr id=entity-larrlp><td> <code title="">larrlp;</code> </td> <td> U+021AB </td> <td> <span class=glyph title="">↫</span> </td> <tr id=entity-larrpl><td> <code title="">larrpl;</code> </td> <td> U+02939 </td> <td> <span class=glyph title="">⤹</span> </td> <tr id=entity-larrsim><td> <code title="">larrsim;</code> </td> <td> U+02973 </td> <td> <span class=glyph title="">⥳</span> </td> <tr id=entity-larrtl><td> <code title="">larrtl;</code> </td> <td> U+021A2 </td> <td> <span class=glyph title="">↢</span> </td> <tr id=entity-lat><td> <code title="">lat;</code> </td> <td> U+02AAB </td> <td> <span class=glyph title="">⪫</span> </td> <tr id=entity-lAtail><td> <code title="">lAtail;</code> </td> <td> U+0291B </td> <td> <span class=glyph title="">⤛</span> </td> <tr id=entity-latail><td> <code title="">latail;</code> </td> <td> U+02919 </td> <td> <span class=glyph title="">⤙</span> </td> <tr id=entity-late><td> <code title="">late;</code> </td> <td> U+02AAD </td> <td> <span class=glyph title="">⪭</span> </td> <tr id=entity-lates><td> <code title="">lates;</code> </td> <td> U+02AAD U+0FE00 </td> <td> <span class="glyph compound" title="">⪭︀</span> </td> <tr id=entity-lBarr><td> <code title="">lBarr;</code> </td> <td> U+0290E </td> <td> <span class=glyph title="">⤎</span> </td> <tr id=entity-lbarr><td> <code title="">lbarr;</code> </td> <td> U+0290C </td> <td> <span class=glyph title="">⤌</span> </td> <tr id=entity-lbbrk><td> <code title="">lbbrk;</code> </td> <td> U+02772 </td> <td> <span class=glyph title="">❲</span> </td> <tr id=entity-lbrace><td> <code title="">lbrace;</code> </td> <td> U+0007B </td> <td> <span class=glyph title="">{</span> </td> <tr id=entity-lbrack><td> <code title="">lbrack;</code> </td> <td> U+0005B </td> <td> <span class=glyph title="">[</span> </td> <tr id=entity-lbrke><td> <code title="">lbrke;</code> </td> <td> U+0298B </td> <td> <span class=glyph title="">⦋</span> </td> <tr id=entity-lbrksld><td> <code title="">lbrksld;</code> </td> <td> U+0298F </td> <td> <span class=glyph title="">⦏</span> </td> <tr id=entity-lbrkslu><td> <code title="">lbrkslu;</code> </td> <td> U+0298D </td> <td> <span class=glyph title="">⦍</span> </td> <tr id=entity-Lcaron><td> <code title="">Lcaron;</code> </td> <td> U+0013D </td> <td> <span class=glyph title="">Ľ</span> </td> <tr id=entity-lcaron><td> <code title="">lcaron;</code> </td> <td> U+0013E </td> <td> <span class=glyph title="">ľ</span> </td> <tr id=entity-Lcedil><td> <code title="">Lcedil;</code> </td> <td> U+0013B </td> <td> <span class=glyph title="">Ļ</span> </td> <tr id=entity-lcedil><td> <code title="">lcedil;</code> </td> <td> U+0013C </td> <td> <span class=glyph title="">ļ</span> </td> <tr id=entity-lceil><td> <code title="">lceil;</code> </td> <td> U+02308 </td> <td> <span class=glyph title="">⌈</span> </td> <tr id=entity-lcub><td> <code title="">lcub;</code> </td> <td> U+0007B </td> <td> <span class=glyph title="">{</span> </td> <tr id=entity-Lcy><td> <code title="">Lcy;</code> </td> <td> U+0041B </td> <td> <span class=glyph title="">Л</span> </td> <tr id=entity-lcy><td> <code title="">lcy;</code> </td> <td> U+0043B </td> <td> <span class=glyph title="">л</span> </td> <tr id=entity-ldca><td> <code title="">ldca;</code> </td> <td> U+02936 </td> <td> <span class=glyph title="">⤶</span> </td> <tr id=entity-ldquo><td> <code title="">ldquo;</code> </td> <td> U+0201C </td> <td> <span class=glyph title="">“</span> </td> <tr id=entity-ldquor><td> <code title="">ldquor;</code> </td> <td> U+0201E </td> <td> <span class=glyph title="">„</span> </td> <tr id=entity-ldrdhar><td> <code title="">ldrdhar;</code> </td> <td> U+02967 </td> <td> <span class=glyph title="">⥧</span> </td> <tr id=entity-ldrushar><td> <code title="">ldrushar;</code> </td> <td> U+0294B </td> <td> <span class=glyph title="">⥋</span> </td> <tr id=entity-ldsh><td> <code title="">ldsh;</code> </td> <td> U+021B2 </td> <td> <span class=glyph title="">↲</span> </td> <tr id=entity-lE><td> <code title="">lE;</code> </td> <td> U+02266 </td> <td> <span class=glyph title="">≦</span> </td> <tr id=entity-le><td> <code title="">le;</code> </td> <td> U+02264 </td> <td> <span class=glyph title="">≤</span> </td> <tr id=entity-LeftAngleBracket><td> <code title="">LeftAngleBracket;</code> </td> <td> U+027E8 </td> <td> <span class=glyph title="">⟨</span> </td> <tr id=entity-LeftArrow><td> <code title="">LeftArrow;</code> </td> <td> U+02190 </td> <td> <span class=glyph title="">←</span> </td> <tr id=entity-Leftarrow><td> <code title="">Leftarrow;</code> </td> <td> U+021D0 </td> <td> <span class=glyph title="">⇐</span> </td> <tr id=entity-leftarrow><td> <code title="">leftarrow;</code> </td> <td> U+02190 </td> <td> <span class=glyph title="">←</span> </td> <tr id=entity-LeftArrowBar><td> <code title="">LeftArrowBar;</code> </td> <td> U+021E4 </td> <td> <span class=glyph title="">⇤</span> </td> <tr id=entity-LeftArrowRightArrow><td> <code title="">LeftArrowRightArrow;</code> </td> <td> U+021C6 </td> <td> <span class=glyph title="">⇆</span> </td> <tr id=entity-leftarrowtail><td> <code title="">leftarrowtail;</code> </td> <td> U+021A2 </td> <td> <span class=glyph title="">↢</span> </td> <tr id=entity-LeftCeiling><td> <code title="">LeftCeiling;</code> </td> <td> U+02308 </td> <td> <span class=glyph title="">⌈</span> </td> <tr id=entity-LeftDoubleBracket><td> <code title="">LeftDoubleBracket;</code> </td> <td> U+027E6 </td> <td> <span class=glyph title="">⟦</span> </td> <tr id=entity-LeftDownTeeVector><td> <code title="">LeftDownTeeVector;</code> </td> <td> U+02961 </td> <td> <span class=glyph title="">⥡</span> </td> <tr id=entity-LeftDownVector><td> <code title="">LeftDownVector;</code> </td> <td> U+021C3 </td> <td> <span class=glyph title="">⇃</span> </td> <tr id=entity-LeftDownVectorBar><td> <code title="">LeftDownVectorBar;</code> </td> <td> U+02959 </td> <td> <span class=glyph title="">⥙</span> </td> <tr id=entity-LeftFloor><td> <code title="">LeftFloor;</code> </td> <td> U+0230A </td> <td> <span class=glyph title="">⌊</span> </td> <tr id=entity-leftharpoondown><td> <code title="">leftharpoondown;</code> </td> <td> U+021BD </td> <td> <span class=glyph title="">↽</span> </td> <tr id=entity-leftharpoonup><td> <code title="">leftharpoonup;</code> </td> <td> U+021BC </td> <td> <span class=glyph title="">↼</span> </td> <tr id=entity-leftleftarrows><td> <code title="">leftleftarrows;</code> </td> <td> U+021C7 </td> <td> <span class=glyph title="">⇇</span> </td> <tr id=entity-LeftRightArrow><td> <code title="">LeftRightArrow;</code> </td> <td> U+02194 </td> <td> <span class=glyph title="">↔</span> </td> <tr id=entity-Leftrightarrow><td> <code title="">Leftrightarrow;</code> </td> <td> U+021D4 </td> <td> <span class=glyph title="">⇔</span> </td> <tr id=entity-leftrightarrow><td> <code title="">leftrightarrow;</code> </td> <td> U+02194 </td> <td> <span class=glyph title="">↔</span> </td> <tr id=entity-leftrightarrows><td> <code title="">leftrightarrows;</code> </td> <td> U+021C6 </td> <td> <span class=glyph title="">⇆</span> </td> <tr id=entity-leftrightharpoons><td> <code title="">leftrightharpoons;</code> </td> <td> U+021CB </td> <td> <span class=glyph title="">⇋</span> </td> <tr id=entity-leftrightsquigarrow><td> <code title="">leftrightsquigarrow;</code> </td> <td> U+021AD </td> <td> <span class=glyph title="">↭</span> </td> <tr id=entity-LeftRightVector><td> <code title="">LeftRightVector;</code> </td> <td> U+0294E </td> <td> <span class=glyph title="">⥎</span> </td> <tr id=entity-LeftTee><td> <code title="">LeftTee;</code> </td> <td> U+022A3 </td> <td> <span class=glyph title="">⊣</span> </td> <tr id=entity-LeftTeeArrow><td> <code title="">LeftTeeArrow;</code> </td> <td> U+021A4 </td> <td> <span class=glyph title="">↤</span> </td> <tr id=entity-LeftTeeVector><td> <code title="">LeftTeeVector;</code> </td> <td> U+0295A </td> <td> <span class=glyph title="">⥚</span> </td> <tr id=entity-leftthreetimes><td> <code title="">leftthreetimes;</code> </td> <td> U+022CB </td> <td> <span class=glyph title="">⋋</span> </td> <tr id=entity-LeftTriangle><td> <code title="">LeftTriangle;</code> </td> <td> U+022B2 </td> <td> <span class=glyph title="">⊲</span> </td> <tr id=entity-LeftTriangleBar><td> <code title="">LeftTriangleBar;</code> </td> <td> U+029CF </td> <td> <span class=glyph title="">⧏</span> </td> <tr id=entity-LeftTriangleEqual><td> <code title="">LeftTriangleEqual;</code> </td> <td> U+022B4 </td> <td> <span class=glyph title="">⊴</span> </td> <tr id=entity-LeftUpDownVector><td> <code title="">LeftUpDownVector;</code> </td> <td> U+02951 </td> <td> <span class=glyph title="">⥑</span> </td> <tr id=entity-LeftUpTeeVector><td> <code title="">LeftUpTeeVector;</code> </td> <td> U+02960 </td> <td> <span class=glyph title="">⥠</span> </td> <tr id=entity-LeftUpVector><td> <code title="">LeftUpVector;</code> </td> <td> U+021BF </td> <td> <span class=glyph title="">↿</span> </td> <tr id=entity-LeftUpVectorBar><td> <code title="">LeftUpVectorBar;</code> </td> <td> U+02958 </td> <td> <span class=glyph title="">⥘</span> </td> <tr id=entity-LeftVector><td> <code title="">LeftVector;</code> </td> <td> U+021BC </td> <td> <span class=glyph title="">↼</span> </td> <tr id=entity-LeftVectorBar><td> <code title="">LeftVectorBar;</code> </td> <td> U+02952 </td> <td> <span class=glyph title="">⥒</span> </td> <tr id=entity-lEg><td> <code title="">lEg;</code> </td> <td> U+02A8B </td> <td> <span class=glyph title="">⪋</span> </td> <tr id=entity-leg><td> <code title="">leg;</code> </td> <td> U+022DA </td> <td> <span class=glyph title="">⋚</span> </td> <tr id=entity-leq><td> <code title="">leq;</code> </td> <td> U+02264 </td> <td> <span class=glyph title="">≤</span> </td> <tr id=entity-leqq><td> <code title="">leqq;</code> </td> <td> U+02266 </td> <td> <span class=glyph title="">≦</span> </td> <tr id=entity-leqslant><td> <code title="">leqslant;</code> </td> <td> U+02A7D </td> <td> <span class=glyph title="">⩽</span> </td> <tr id=entity-les><td> <code title="">les;</code> </td> <td> U+02A7D </td> <td> <span class=glyph title="">⩽</span> </td> <tr id=entity-lescc><td> <code title="">lescc;</code> </td> <td> U+02AA8 </td> <td> <span class=glyph title="">⪨</span> </td> <tr id=entity-lesdot><td> <code title="">lesdot;</code> </td> <td> U+02A7F </td> <td> <span class=glyph title="">⩿</span> </td> <tr id=entity-lesdoto><td> <code title="">lesdoto;</code> </td> <td> U+02A81 </td> <td> <span class=glyph title="">⪁</span> </td> <tr id=entity-lesdotor><td> <code title="">lesdotor;</code> </td> <td> U+02A83 </td> <td> <span class=glyph title="">⪃</span> </td> <tr id=entity-lesg><td> <code title="">lesg;</code> </td> <td> U+022DA U+0FE00 </td> <td> <span class="glyph compound" title="">⋚︀</span> </td> <tr id=entity-lesges><td> <code title="">lesges;</code> </td> <td> U+02A93 </td> <td> <span class=glyph title="">⪓</span> </td> <tr id=entity-lessapprox><td> <code title="">lessapprox;</code> </td> <td> U+02A85 </td> <td> <span class=glyph title="">⪅</span> </td> <tr id=entity-lessdot><td> <code title="">lessdot;</code> </td> <td> U+022D6 </td> <td> <span class=glyph title="">⋖</span> </td> <tr id=entity-lesseqgtr><td> <code title="">lesseqgtr;</code> </td> <td> U+022DA </td> <td> <span class=glyph title="">⋚</span> </td> <tr id=entity-lesseqqgtr><td> <code title="">lesseqqgtr;</code> </td> <td> U+02A8B </td> <td> <span class=glyph title="">⪋</span> </td> <tr id=entity-LessEqualGreater><td> <code title="">LessEqualGreater;</code> </td> <td> U+022DA </td> <td> <span class=glyph title="">⋚</span> </td> <tr id=entity-LessFullEqual><td> <code title="">LessFullEqual;</code> </td> <td> U+02266 </td> <td> <span class=glyph title="">≦</span> </td> <tr id=entity-LessGreater><td> <code title="">LessGreater;</code> </td> <td> U+02276 </td> <td> <span class=glyph title="">≶</span> </td> <tr id=entity-lessgtr><td> <code title="">lessgtr;</code> </td> <td> U+02276 </td> <td> <span class=glyph title="">≶</span> </td> <tr id=entity-LessLess><td> <code title="">LessLess;</code> </td> <td> U+02AA1 </td> <td> <span class=glyph title="">⪡</span> </td> <tr id=entity-lesssim><td> <code title="">lesssim;</code> </td> <td> U+02272 </td> <td> <span class=glyph title="">≲</span> </td> <tr id=entity-LessSlantEqual><td> <code title="">LessSlantEqual;</code> </td> <td> U+02A7D </td> <td> <span class=glyph title="">⩽</span> </td> <tr id=entity-LessTilde><td> <code title="">LessTilde;</code> </td> <td> U+02272 </td> <td> <span class=glyph title="">≲</span> </td> <tr id=entity-lfisht><td> <code title="">lfisht;</code> </td> <td> U+0297C </td> <td> <span class=glyph title="">⥼</span> </td> <tr id=entity-lfloor><td> <code title="">lfloor;</code> </td> <td> U+0230A </td> <td> <span class=glyph title="">⌊</span> </td> <tr id=entity-Lfr><td> <code title="">Lfr;</code> </td> <td> U+1D50F </td> <td> <span class=glyph title="">𝔏</span> </td> <tr id=entity-lfr><td> <code title="">lfr;</code> </td> <td> U+1D529 </td> <td> <span class=glyph title="">𝔩</span> </td> <tr id=entity-lg><td> <code title="">lg;</code> </td> <td> U+02276 </td> <td> <span class=glyph title="">≶</span> </td> <tr id=entity-lgE><td> <code title="">lgE;</code> </td> <td> U+02A91 </td> <td> <span class=glyph title="">⪑</span> </td> <tr id=entity-lHar><td> <code title="">lHar;</code> </td> <td> U+02962 </td> <td> <span class=glyph title="">⥢</span> </td> <tr id=entity-lhard><td> <code title="">lhard;</code> </td> <td> U+021BD </td> <td> <span class=glyph title="">↽</span> </td> <tr id=entity-lharu><td> <code title="">lharu;</code> </td> <td> U+021BC </td> <td> <span class=glyph title="">↼</span> </td> <tr id=entity-lharul><td> <code title="">lharul;</code> </td> <td> U+0296A </td> <td> <span class=glyph title="">⥪</span> </td> <tr id=entity-lhblk><td> <code title="">lhblk;</code> </td> <td> U+02584 </td> <td> <span class=glyph title="">▄</span> </td> <tr id=entity-LJcy><td> <code title="">LJcy;</code> </td> <td> U+00409 </td> <td> <span class=glyph title="">Љ</span> </td> <tr id=entity-ljcy><td> <code title="">ljcy;</code> </td> <td> U+00459 </td> <td> <span class=glyph title="">љ</span> </td> <tr id=entity-Ll><td> <code title="">Ll;</code> </td> <td> U+022D8 </td> <td> <span class=glyph title="">⋘</span> </td> <tr id=entity-ll><td> <code title="">ll;</code> </td> <td> U+0226A </td> <td> <span class=glyph title="">≪</span> </td> <tr id=entity-llarr><td> <code title="">llarr;</code> </td> <td> U+021C7 </td> <td> <span class=glyph title="">⇇</span> </td> <tr id=entity-llcorner><td> <code title="">llcorner;</code> </td> <td> U+0231E </td> <td> <span class=glyph title="">⌞</span> </td> <tr id=entity-Lleftarrow><td> <code title="">Lleftarrow;</code> </td> <td> U+021DA </td> <td> <span class=glyph title="">⇚</span> </td> <tr id=entity-llhard><td> <code title="">llhard;</code> </td> <td> U+0296B </td> <td> <span class=glyph title="">⥫</span> </td> <tr id=entity-lltri><td> <code title="">lltri;</code> </td> <td> U+025FA </td> <td> <span class=glyph title="">◺</span> </td> <tr id=entity-Lmidot><td> <code title="">Lmidot;</code> </td> <td> U+0013F </td> <td> <span class=glyph title="">Ŀ</span> </td> <tr id=entity-lmidot><td> <code title="">lmidot;</code> </td> <td> U+00140 </td> <td> <span class=glyph title="">ŀ</span> </td> <tr id=entity-lmoust><td> <code title="">lmoust;</code> </td> <td> U+023B0 </td> <td> <span class=glyph title="">⎰</span> </td> <tr id=entity-lmoustache><td> <code title="">lmoustache;</code> </td> <td> U+023B0 </td> <td> <span class=glyph title="">⎰</span> </td> <tr id=entity-lnap><td> <code title="">lnap;</code> </td> <td> U+02A89 </td> <td> <span class=glyph title="">⪉</span> </td> <tr id=entity-lnapprox><td> <code title="">lnapprox;</code> </td> <td> U+02A89 </td> <td> <span class=glyph title="">⪉</span> </td> <tr id=entity-lnE><td> <code title="">lnE;</code> </td> <td> U+02268 </td> <td> <span class=glyph title="">≨</span> </td> <tr id=entity-lne><td> <code title="">lne;</code> </td> <td> U+02A87 </td> <td> <span class=glyph title="">⪇</span> </td> <tr id=entity-lneq><td> <code title="">lneq;</code> </td> <td> U+02A87 </td> <td> <span class=glyph title="">⪇</span> </td> <tr id=entity-lneqq><td> <code title="">lneqq;</code> </td> <td> U+02268 </td> <td> <span class=glyph title="">≨</span> </td> <tr id=entity-lnsim><td> <code title="">lnsim;</code> </td> <td> U+022E6 </td> <td> <span class=glyph title="">⋦</span> </td> <tr id=entity-loang><td> <code title="">loang;</code> </td> <td> U+027EC </td> <td> <span class=glyph title="">⟬</span> </td> <tr id=entity-loarr><td> <code title="">loarr;</code> </td> <td> U+021FD </td> <td> <span class=glyph title="">⇽</span> </td> <tr id=entity-lobrk><td> <code title="">lobrk;</code> </td> <td> U+027E6 </td> <td> <span class=glyph title="">⟦</span> </td> <tr id=entity-LongLeftArrow><td> <code title="">LongLeftArrow;</code> </td> <td> U+027F5 </td> <td> <span class=glyph title="">⟵</span> </td> <tr id=entity-Longleftarrow><td> <code title="">Longleftarrow;</code> </td> <td> U+027F8 </td> <td> <span class=glyph title="">⟸</span> </td> <tr id=entity-longleftarrow><td> <code title="">longleftarrow;</code> </td> <td> U+027F5 </td> <td> <span class=glyph title="">⟵</span> </td> <tr id=entity-LongLeftRightArrow><td> <code title="">LongLeftRightArrow;</code> </td> <td> U+027F7 </td> <td> <span class=glyph title="">⟷</span> </td> <tr id=entity-Longleftrightarrow><td> <code title="">Longleftrightarrow;</code> </td> <td> U+027FA </td> <td> <span class=glyph title="">⟺</span> </td> <tr id=entity-longleftrightarrow><td> <code title="">longleftrightarrow;</code> </td> <td> U+027F7 </td> <td> <span class=glyph title="">⟷</span> </td> <tr id=entity-longmapsto><td> <code title="">longmapsto;</code> </td> <td> U+027FC </td> <td> <span class=glyph title="">⟼</span> </td> <tr id=entity-LongRightArrow><td> <code title="">LongRightArrow;</code> </td> <td> U+027F6 </td> <td> <span class=glyph title="">⟶</span> </td> <tr id=entity-Longrightarrow><td> <code title="">Longrightarrow;</code> </td> <td> U+027F9 </td> <td> <span class=glyph title="">⟹</span> </td> <tr id=entity-longrightarrow><td> <code title="">longrightarrow;</code> </td> <td> U+027F6 </td> <td> <span class=glyph title="">⟶</span> </td> <tr id=entity-looparrowleft><td> <code title="">looparrowleft;</code> </td> <td> U+021AB </td> <td> <span class=glyph title="">↫</span> </td> <tr id=entity-looparrowright><td> <code title="">looparrowright;</code> </td> <td> U+021AC </td> <td> <span class=glyph title="">↬</span> </td> <tr id=entity-lopar><td> <code title="">lopar;</code> </td> <td> U+02985 </td> <td> <span class=glyph title="">⦅</span> </td> <tr id=entity-Lopf><td> <code title="">Lopf;</code> </td> <td> U+1D543 </td> <td> <span class=glyph title="">𝕃</span> </td> <tr id=entity-lopf><td> <code title="">lopf;</code> </td> <td> U+1D55D </td> <td> <span class=glyph title="">𝕝</span> </td> <tr id=entity-loplus><td> <code title="">loplus;</code> </td> <td> U+02A2D </td> <td> <span class=glyph title="">⨭</span> </td> <tr id=entity-lotimes><td> <code title="">lotimes;</code> </td> <td> U+02A34 </td> <td> <span class=glyph title="">⨴</span> </td> <tr id=entity-lowast><td> <code title="">lowast;</code> </td> <td> U+02217 </td> <td> <span class=glyph title="">∗</span> </td> <tr id=entity-lowbar><td> <code title="">lowbar;</code> </td> <td> U+0005F </td> <td> <span class=glyph title="">_</span> </td> <tr id=entity-LowerLeftArrow><td> <code title="">LowerLeftArrow;</code> </td> <td> U+02199 </td> <td> <span class=glyph title="">↙</span> </td> <tr id=entity-LowerRightArrow><td> <code title="">LowerRightArrow;</code> </td> <td> U+02198 </td> <td> <span class=glyph title="">↘</span> </td> <tr id=entity-loz><td> <code title="">loz;</code> </td> <td> U+025CA </td> <td> <span class=glyph title="">◊</span> </td> <tr id=entity-lozenge><td> <code title="">lozenge;</code> </td> <td> U+025CA </td> <td> <span class=glyph title="">◊</span> </td> <tr id=entity-lozf><td> <code title="">lozf;</code> </td> <td> U+029EB </td> <td> <span class=glyph title="">⧫</span> </td> <tr id=entity-lpar><td> <code title="">lpar;</code> </td> <td> U+00028 </td> <td> <span class=glyph title="">(</span> </td> <tr id=entity-lparlt><td> <code title="">lparlt;</code> </td> <td> U+02993 </td> <td> <span class=glyph title="">⦓</span> </td> <tr id=entity-lrarr><td> <code title="">lrarr;</code> </td> <td> U+021C6 </td> <td> <span class=glyph title="">⇆</span> </td> <tr id=entity-lrcorner><td> <code title="">lrcorner;</code> </td> <td> U+0231F </td> <td> <span class=glyph title="">⌟</span> </td> <tr id=entity-lrhar><td> <code title="">lrhar;</code> </td> <td> U+021CB </td> <td> <span class=glyph title="">⇋</span> </td> <tr id=entity-lrhard><td> <code title="">lrhard;</code> </td> <td> U+0296D </td> <td> <span class=glyph title="">⥭</span> </td> <tr id=entity-lrm><td> <code title="">lrm;</code> </td> <td> U+0200E </td> <td> <span class=glyph title="">‎</span> </td> <tr id=entity-lrtri><td> <code title="">lrtri;</code> </td> <td> U+022BF </td> <td> <span class=glyph title="">⊿</span> </td> <tr id=entity-lsaquo><td> <code title="">lsaquo;</code> </td> <td> U+02039 </td> <td> <span class=glyph title="">‹</span> </td> <tr id=entity-Lscr><td> <code title="">Lscr;</code> </td> <td> U+02112 </td> <td> <span class=glyph title="">ℒ</span> </td> <tr id=entity-lscr><td> <code title="">lscr;</code> </td> <td> U+1D4C1 </td> <td> <span class=glyph title="">𝓁</span> </td> <tr id=entity-Lsh><td> <code title="">Lsh;</code> </td> <td> U+021B0 </td> <td> <span class=glyph title="">↰</span> </td> <tr id=entity-lsh><td> <code title="">lsh;</code> </td> <td> U+021B0 </td> <td> <span class=glyph title="">↰</span> </td> <tr id=entity-lsim><td> <code title="">lsim;</code> </td> <td> U+02272 </td> <td> <span class=glyph title="">≲</span> </td> <tr id=entity-lsime><td> <code title="">lsime;</code> </td> <td> U+02A8D </td> <td> <span class=glyph title="">⪍</span> </td> <tr id=entity-lsimg><td> <code title="">lsimg;</code> </td> <td> U+02A8F </td> <td> <span class=glyph title="">⪏</span> </td> <tr id=entity-lsqb><td> <code title="">lsqb;</code> </td> <td> U+0005B </td> <td> <span class=glyph title="">[</span> </td> <tr id=entity-lsquo><td> <code title="">lsquo;</code> </td> <td> U+02018 </td> <td> <span class=glyph title="">‘</span> </td> <tr id=entity-lsquor><td> <code title="">lsquor;</code> </td> <td> U+0201A </td> <td> <span class=glyph title="">‚</span> </td> <tr id=entity-Lstrok><td> <code title="">Lstrok;</code> </td> <td> U+00141 </td> <td> <span class=glyph title="">Ł</span> </td> <tr id=entity-lstrok><td> <code title="">lstrok;</code> </td> <td> U+00142 </td> <td> <span class=glyph title="">ł</span> </td> <tr id=entity-LT><td> <code title="">LT;</code> </td> <td> U+0003C </td> <td> <span class=glyph title=""><</span> </td> <tr class=impl id=entity-LT-legacy><td> <code title="">LT</code> </td> <td> U+0003C </td> <td> <span title=""><</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Lt><td> <code title="">Lt;</code> </td> <td> U+0226A </td> <td> <span class=glyph title="">≪</span> </td> <tr id=entity-lt><td> <code title="">lt;</code> </td> <td> U+0003C </td> <td> <span class=glyph title=""><</span> </td> <tr class=impl id=entity-lt-legacy><td> <code title="">lt</code> </td> <td> U+0003C </td> <td> <span title=""><</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ltcc><td> <code title="">ltcc;</code> </td> <td> U+02AA6 </td> <td> <span class=glyph title="">⪦</span> </td> <tr id=entity-ltcir><td> <code title="">ltcir;</code> </td> <td> U+02A79 </td> <td> <span class=glyph title="">⩹</span> </td> <tr id=entity-ltdot><td> <code title="">ltdot;</code> </td> <td> U+022D6 </td> <td> <span class=glyph title="">⋖</span> </td> <tr id=entity-lthree><td> <code title="">lthree;</code> </td> <td> U+022CB </td> <td> <span class=glyph title="">⋋</span> </td> <tr id=entity-ltimes><td> <code title="">ltimes;</code> </td> <td> U+022C9 </td> <td> <span class=glyph title="">⋉</span> </td> <tr id=entity-ltlarr><td> <code title="">ltlarr;</code> </td> <td> U+02976 </td> <td> <span class=glyph title="">⥶</span> </td> <tr id=entity-ltquest><td> <code title="">ltquest;</code> </td> <td> U+02A7B </td> <td> <span class=glyph title="">⩻</span> </td> <tr id=entity-ltri><td> <code title="">ltri;</code> </td> <td> U+025C3 </td> <td> <span class=glyph title="">◃</span> </td> <tr id=entity-ltrie><td> <code title="">ltrie;</code> </td> <td> U+022B4 </td> <td> <span class=glyph title="">⊴</span> </td> <tr id=entity-ltrif><td> <code title="">ltrif;</code> </td> <td> U+025C2 </td> <td> <span class=glyph title="">◂</span> </td> <tr id=entity-ltrPar><td> <code title="">ltrPar;</code> </td> <td> U+02996 </td> <td> <span class=glyph title="">⦖</span> </td> <tr id=entity-lurdshar><td> <code title="">lurdshar;</code> </td> <td> U+0294A </td> <td> <span class=glyph title="">⥊</span> </td> <tr id=entity-luruhar><td> <code title="">luruhar;</code> </td> <td> U+02966 </td> <td> <span class=glyph title="">⥦</span> </td> <tr id=entity-lvertneqq><td> <code title="">lvertneqq;</code> </td> <td> U+02268 U+0FE00 </td> <td> <span class="glyph compound" title="">≨︀</span> </td> <tr id=entity-lvnE><td> <code title="">lvnE;</code> </td> <td> U+02268 U+0FE00 </td> <td> <span class="glyph compound" title="">≨︀</span> </td> <tr id=entity-macr><td> <code title="">macr;</code> </td> <td> U+000AF </td> <td> <span class=glyph title="">¯</span> </td> <tr class=impl id=entity-macr-legacy><td> <code title="">macr</code> </td> <td> U+000AF </td> <td> <span title="">¯</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-male><td> <code title="">male;</code> </td> <td> U+02642 </td> <td> <span class=glyph title="">♂</span> </td> <tr id=entity-malt><td> <code title="">malt;</code> </td> <td> U+02720 </td> <td> <span class=glyph title="">✠</span> </td> <tr id=entity-maltese><td> <code title="">maltese;</code> </td> <td> U+02720 </td> <td> <span class=glyph title="">✠</span> </td> <tr id=entity-Map><td> <code title="">Map;</code> </td> <td> U+02905 </td> <td> <span class=glyph title="">⤅</span> </td> <tr id=entity-map><td> <code title="">map;</code> </td> <td> U+021A6 </td> <td> <span class=glyph title="">↦</span> </td> <tr id=entity-mapsto><td> <code title="">mapsto;</code> </td> <td> U+021A6 </td> <td> <span class=glyph title="">↦</span> </td> <tr id=entity-mapstodown><td> <code title="">mapstodown;</code> </td> <td> U+021A7 </td> <td> <span class=glyph title="">↧</span> </td> <tr id=entity-mapstoleft><td> <code title="">mapstoleft;</code> </td> <td> U+021A4 </td> <td> <span class=glyph title="">↤</span> </td> <tr id=entity-mapstoup><td> <code title="">mapstoup;</code> </td> <td> U+021A5 </td> <td> <span class=glyph title="">↥</span> </td> <tr id=entity-marker><td> <code title="">marker;</code> </td> <td> U+025AE </td> <td> <span class=glyph title="">▮</span> </td> <tr id=entity-mcomma><td> <code title="">mcomma;</code> </td> <td> U+02A29 </td> <td> <span class=glyph title="">⨩</span> </td> <tr id=entity-Mcy><td> <code title="">Mcy;</code> </td> <td> U+0041C </td> <td> <span class=glyph title="">М</span> </td> <tr id=entity-mcy><td> <code title="">mcy;</code> </td> <td> U+0043C </td> <td> <span class=glyph title="">м</span> </td> <tr id=entity-mdash><td> <code title="">mdash;</code> </td> <td> U+02014 </td> <td> <span class=glyph title="">—</span> </td> <tr id=entity-mDDot><td> <code title="">mDDot;</code> </td> <td> U+0223A </td> <td> <span class=glyph title="">∺</span> </td> <tr id=entity-measuredangle><td> <code title="">measuredangle;</code> </td> <td> U+02221 </td> <td> <span class=glyph title="">∡</span> </td> <tr id=entity-MediumSpace><td> <code title="">MediumSpace;</code> </td> <td> U+0205F </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-Mellintrf><td> <code title="">Mellintrf;</code> </td> <td> U+02133 </td> <td> <span class=glyph title="">ℳ</span> </td> <tr id=entity-Mfr><td> <code title="">Mfr;</code> </td> <td> U+1D510 </td> <td> <span class=glyph title="">𝔐</span> </td> <tr id=entity-mfr><td> <code title="">mfr;</code> </td> <td> U+1D52A </td> <td> <span class=glyph title="">𝔪</span> </td> <tr id=entity-mho><td> <code title="">mho;</code> </td> <td> U+02127 </td> <td> <span class=glyph title="">℧</span> </td> <tr id=entity-micro><td> <code title="">micro;</code> </td> <td> U+000B5 </td> <td> <span class=glyph title="">µ</span> </td> <tr class=impl id=entity-micro-legacy><td> <code title="">micro</code> </td> <td> U+000B5 </td> <td> <span title="">µ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-mid><td> <code title="">mid;</code> </td> <td> U+02223 </td> <td> <span class=glyph title="">∣</span> </td> <tr id=entity-midast><td> <code title="">midast;</code> </td> <td> U+0002A </td> <td> <span class=glyph title="">*</span> </td> <tr id=entity-midcir><td> <code title="">midcir;</code> </td> <td> U+02AF0 </td> <td> <span class=glyph title="">⫰</span> </td> <tr id=entity-middot><td> <code title="">middot;</code> </td> <td> U+000B7 </td> <td> <span class=glyph title="">·</span> </td> <tr class=impl id=entity-middot-legacy><td> <code title="">middot</code> </td> <td> U+000B7 </td> <td> <span title="">·</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-minus><td> <code title="">minus;</code> </td> <td> U+02212 </td> <td> <span class=glyph title="">−</span> </td> <tr id=entity-minusb><td> <code title="">minusb;</code> </td> <td> U+0229F </td> <td> <span class=glyph title="">⊟</span> </td> <tr id=entity-minusd><td> <code title="">minusd;</code> </td> <td> U+02238 </td> <td> <span class=glyph title="">∸</span> </td> <tr id=entity-minusdu><td> <code title="">minusdu;</code> </td> <td> U+02A2A </td> <td> <span class=glyph title="">⨪</span> </td> <tr id=entity-MinusPlus><td> <code title="">MinusPlus;</code> </td> <td> U+02213 </td> <td> <span class=glyph title="">∓</span> </td> <tr id=entity-mlcp><td> <code title="">mlcp;</code> </td> <td> U+02ADB </td> <td> <span class=glyph title="">⫛</span> </td> <tr id=entity-mldr><td> <code title="">mldr;</code> </td> <td> U+02026 </td> <td> <span class=glyph title="">…</span> </td> <tr id=entity-mnplus><td> <code title="">mnplus;</code> </td> <td> U+02213 </td> <td> <span class=glyph title="">∓</span> </td> <tr id=entity-models><td> <code title="">models;</code> </td> <td> U+022A7 </td> <td> <span class=glyph title="">⊧</span> </td> <tr id=entity-Mopf><td> <code title="">Mopf;</code> </td> <td> U+1D544 </td> <td> <span class=glyph title="">𝕄</span> </td> <tr id=entity-mopf><td> <code title="">mopf;</code> </td> <td> U+1D55E </td> <td> <span class=glyph title="">𝕞</span> </td> <tr id=entity-mp><td> <code title="">mp;</code> </td> <td> U+02213 </td> <td> <span class=glyph title="">∓</span> </td> <tr id=entity-Mscr><td> <code title="">Mscr;</code> </td> <td> U+02133 </td> <td> <span class=glyph title="">ℳ</span> </td> <tr id=entity-mscr><td> <code title="">mscr;</code> </td> <td> U+1D4C2 </td> <td> <span class=glyph title="">𝓂</span> </td> <tr id=entity-mstpos><td> <code title="">mstpos;</code> </td> <td> U+0223E </td> <td> <span class=glyph title="">∾</span> </td> <tr id=entity-Mu><td> <code title="">Mu;</code> </td> <td> U+0039C </td> <td> <span class=glyph title="">Μ</span> </td> <tr id=entity-mu><td> <code title="">mu;</code> </td> <td> U+003BC </td> <td> <span class=glyph title="">μ</span> </td> <tr id=entity-multimap><td> <code title="">multimap;</code> </td> <td> U+022B8 </td> <td> <span class=glyph title="">⊸</span> </td> <tr id=entity-mumap><td> <code title="">mumap;</code> </td> <td> U+022B8 </td> <td> <span class=glyph title="">⊸</span> </td> <tr id=entity-nabla><td> <code title="">nabla;</code> </td> <td> U+02207 </td> <td> <span class=glyph title="">∇</span> </td> <tr id=entity-Nacute><td> <code title="">Nacute;</code> </td> <td> U+00143 </td> <td> <span class=glyph title="">Ń</span> </td> <tr id=entity-nacute><td> <code title="">nacute;</code> </td> <td> U+00144 </td> <td> <span class=glyph title="">ń</span> </td> <tr id=entity-nang><td> <code title="">nang;</code> </td> <td> U+02220 U+020D2 </td> <td> <span class="glyph compound" title="">∠⃒</span> </td> <tr id=entity-nap><td> <code title="">nap;</code> </td> <td> U+02249 </td> <td> <span class=glyph title="">≉</span> </td> <tr id=entity-napE><td> <code title="">napE;</code> </td> <td> U+02A70 U+00338 </td> <td> <span class="glyph compound" title="">⩰̸</span> </td> <tr id=entity-napid><td> <code title="">napid;</code> </td> <td> U+0224B U+00338 </td> <td> <span class="glyph compound" title="">≋̸</span> </td> <tr id=entity-napos><td> <code title="">napos;</code> </td> <td> U+00149 </td> <td> <span class=glyph title="">ʼn</span> </td> <tr id=entity-napprox><td> <code title="">napprox;</code> </td> <td> U+02249 </td> <td> <span class=glyph title="">≉</span> </td> <tr id=entity-natur><td> <code title="">natur;</code> </td> <td> U+0266E </td> <td> <span class=glyph title="">♮</span> </td> <tr id=entity-natural><td> <code title="">natural;</code> </td> <td> U+0266E </td> <td> <span class=glyph title="">♮</span> </td> <tr id=entity-naturals><td> <code title="">naturals;</code> </td> <td> U+02115 </td> <td> <span class=glyph title="">ℕ</span> </td> <tr id=entity-nbsp><td> <code title="">nbsp;</code> </td> <td> U+000A0 </td> <td> <span class=glyph title=""> </span> </td> <tr class=impl id=entity-nbsp-legacy><td> <code title="">nbsp</code> </td> <td> U+000A0 </td> <td> <span title=""> </span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-nbump><td> <code title="">nbump;</code> </td> <td> U+0224E U+00338 </td> <td> <span class="glyph compound" title="">≎̸</span> </td> <tr id=entity-nbumpe><td> <code title="">nbumpe;</code> </td> <td> U+0224F U+00338 </td> <td> <span class="glyph compound" title="">≏̸</span> </td> <tr id=entity-ncap><td> <code title="">ncap;</code> </td> <td> U+02A43 </td> <td> <span class=glyph title="">⩃</span> </td> <tr id=entity-Ncaron><td> <code title="">Ncaron;</code> </td> <td> U+00147 </td> <td> <span class=glyph title="">Ň</span> </td> <tr id=entity-ncaron><td> <code title="">ncaron;</code> </td> <td> U+00148 </td> <td> <span class=glyph title="">ň</span> </td> <tr id=entity-Ncedil><td> <code title="">Ncedil;</code> </td> <td> U+00145 </td> <td> <span class=glyph title="">Ņ</span> </td> <tr id=entity-ncedil><td> <code title="">ncedil;</code> </td> <td> U+00146 </td> <td> <span class=glyph title="">ņ</span> </td> <tr id=entity-ncong><td> <code title="">ncong;</code> </td> <td> U+02247 </td> <td> <span class=glyph title="">≇</span> </td> <tr id=entity-ncongdot><td> <code title="">ncongdot;</code> </td> <td> U+02A6D U+00338 </td> <td> <span class="glyph compound" title="">⩭̸</span> </td> <tr id=entity-ncup><td> <code title="">ncup;</code> </td> <td> U+02A42 </td> <td> <span class=glyph title="">⩂</span> </td> <tr id=entity-Ncy><td> <code title="">Ncy;</code> </td> <td> U+0041D </td> <td> <span class=glyph title="">Н</span> </td> <tr id=entity-ncy><td> <code title="">ncy;</code> </td> <td> U+0043D </td> <td> <span class=glyph title="">н</span> </td> <tr id=entity-ndash><td> <code title="">ndash;</code> </td> <td> U+02013 </td> <td> <span class=glyph title="">–</span> </td> <tr id=entity-ne><td> <code title="">ne;</code> </td> <td> U+02260 </td> <td> <span class=glyph title="">≠</span> </td> <tr id=entity-nearhk><td> <code title="">nearhk;</code> </td> <td> U+02924 </td> <td> <span class=glyph title="">⤤</span> </td> <tr id=entity-neArr><td> <code title="">neArr;</code> </td> <td> U+021D7 </td> <td> <span class=glyph title="">⇗</span> </td> <tr id=entity-nearr><td> <code title="">nearr;</code> </td> <td> U+02197 </td> <td> <span class=glyph title="">↗</span> </td> <tr id=entity-nearrow><td> <code title="">nearrow;</code> </td> <td> U+02197 </td> <td> <span class=glyph title="">↗</span> </td> <tr id=entity-nedot><td> <code title="">nedot;</code> </td> <td> U+02250 U+00338 </td> <td> <span class="glyph compound" title="">≐̸</span> </td> <tr id=entity-NegativeMediumSpace><td> <code title="">NegativeMediumSpace;</code> </td> <td> U+0200B </td> <td> <span class=glyph title="">​</span> </td> <tr id=entity-NegativeThickSpace><td> <code title="">NegativeThickSpace;</code> </td> <td> U+0200B </td> <td> <span class=glyph title="">​</span> </td> <tr id=entity-NegativeThinSpace><td> <code title="">NegativeThinSpace;</code> </td> <td> U+0200B </td> <td> <span class=glyph title="">​</span> </td> <tr id=entity-NegativeVeryThinSpace><td> <code title="">NegativeVeryThinSpace;</code> </td> <td> U+0200B </td> <td> <span class=glyph title="">​</span> </td> <tr id=entity-nequiv><td> <code title="">nequiv;</code> </td> <td> U+02262 </td> <td> <span class=glyph title="">≢</span> </td> <tr id=entity-nesear><td> <code title="">nesear;</code> </td> <td> U+02928 </td> <td> <span class=glyph title="">⤨</span> </td> <tr id=entity-nesim><td> <code title="">nesim;</code> </td> <td> U+02242 U+00338 </td> <td> <span class="glyph compound" title="">≂̸</span> </td> <tr id=entity-NestedGreaterGreater><td> <code title="">NestedGreaterGreater;</code> </td> <td> U+0226B </td> <td> <span class=glyph title="">≫</span> </td> <tr id=entity-NestedLessLess><td> <code title="">NestedLessLess;</code> </td> <td> U+0226A </td> <td> <span class=glyph title="">≪</span> </td> <tr id=entity-NewLine><td> <code title="">NewLine;</code> </td> <td> U+0000A </td> <td> <span class="glyph control" title="">␊</span> </td> <tr id=entity-nexist><td> <code title="">nexist;</code> </td> <td> U+02204 </td> <td> <span class=glyph title="">∄</span> </td> <tr id=entity-nexists><td> <code title="">nexists;</code> </td> <td> U+02204 </td> <td> <span class=glyph title="">∄</span> </td> <tr id=entity-Nfr><td> <code title="">Nfr;</code> </td> <td> U+1D511 </td> <td> <span class=glyph title="">𝔑</span> </td> <tr id=entity-nfr><td> <code title="">nfr;</code> </td> <td> U+1D52B </td> <td> <span class=glyph title="">𝔫</span> </td> <tr id=entity-ngE><td> <code title="">ngE;</code> </td> <td> U+02267 U+00338 </td> <td> <span class="glyph compound" title="">≧̸</span> </td> <tr id=entity-nge><td> <code title="">nge;</code> </td> <td> U+02271 </td> <td> <span class=glyph title="">≱</span> </td> <tr id=entity-ngeq><td> <code title="">ngeq;</code> </td> <td> U+02271 </td> <td> <span class=glyph title="">≱</span> </td> <tr id=entity-ngeqq><td> <code title="">ngeqq;</code> </td> <td> U+02267 U+00338 </td> <td> <span class="glyph compound" title="">≧̸</span> </td> <tr id=entity-ngeqslant><td> <code title="">ngeqslant;</code> </td> <td> U+02A7E U+00338 </td> <td> <span class="glyph compound" title="">⩾̸</span> </td> <tr id=entity-nges><td> <code title="">nges;</code> </td> <td> U+02A7E U+00338 </td> <td> <span class="glyph compound" title="">⩾̸</span> </td> <tr id=entity-nGg><td> <code title="">nGg;</code> </td> <td> U+022D9 U+00338 </td> <td> <span class="glyph compound" title="">⋙̸</span> </td> <tr id=entity-ngsim><td> <code title="">ngsim;</code> </td> <td> U+02275 </td> <td> <span class=glyph title="">≵</span> </td> <tr id=entity-nGt><td> <code title="">nGt;</code> </td> <td> U+0226B U+020D2 </td> <td> <span class="glyph compound" title="">≫⃒</span> </td> <tr id=entity-ngt><td> <code title="">ngt;</code> </td> <td> U+0226F </td> <td> <span class=glyph title="">≯</span> </td> <tr id=entity-ngtr><td> <code title="">ngtr;</code> </td> <td> U+0226F </td> <td> <span class=glyph title="">≯</span> </td> <tr id=entity-nGtv><td> <code title="">nGtv;</code> </td> <td> U+0226B U+00338 </td> <td> <span class="glyph compound" title="">≫̸</span> </td> <tr id=entity-nhArr><td> <code title="">nhArr;</code> </td> <td> U+021CE </td> <td> <span class=glyph title="">⇎</span> </td> <tr id=entity-nharr><td> <code title="">nharr;</code> </td> <td> U+021AE </td> <td> <span class=glyph title="">↮</span> </td> <tr id=entity-nhpar><td> <code title="">nhpar;</code> </td> <td> U+02AF2 </td> <td> <span class=glyph title="">⫲</span> </td> <tr id=entity-ni><td> <code title="">ni;</code> </td> <td> U+0220B </td> <td> <span class=glyph title="">∋</span> </td> <tr id=entity-nis><td> <code title="">nis;</code> </td> <td> U+022FC </td> <td> <span class=glyph title="">⋼</span> </td> <tr id=entity-nisd><td> <code title="">nisd;</code> </td> <td> U+022FA </td> <td> <span class=glyph title="">⋺</span> </td> <tr id=entity-niv><td> <code title="">niv;</code> </td> <td> U+0220B </td> <td> <span class=glyph title="">∋</span> </td> <tr id=entity-NJcy><td> <code title="">NJcy;</code> </td> <td> U+0040A </td> <td> <span class=glyph title="">Њ</span> </td> <tr id=entity-njcy><td> <code title="">njcy;</code> </td> <td> U+0045A </td> <td> <span class=glyph title="">њ</span> </td> <tr id=entity-nlArr><td> <code title="">nlArr;</code> </td> <td> U+021CD </td> <td> <span class=glyph title="">⇍</span> </td> <tr id=entity-nlarr><td> <code title="">nlarr;</code> </td> <td> U+0219A </td> <td> <span class=glyph title="">↚</span> </td> <tr id=entity-nldr><td> <code title="">nldr;</code> </td> <td> U+02025 </td> <td> <span class=glyph title="">‥</span> </td> <tr id=entity-nlE><td> <code title="">nlE;</code> </td> <td> U+02266 U+00338 </td> <td> <span class="glyph compound" title="">≦̸</span> </td> <tr id=entity-nle><td> <code title="">nle;</code> </td> <td> U+02270 </td> <td> <span class=glyph title="">≰</span> </td> <tr id=entity-nLeftarrow><td> <code title="">nLeftarrow;</code> </td> <td> U+021CD </td> <td> <span class=glyph title="">⇍</span> </td> <tr id=entity-nleftarrow><td> <code title="">nleftarrow;</code> </td> <td> U+0219A </td> <td> <span class=glyph title="">↚</span> </td> <tr id=entity-nLeftrightarrow><td> <code title="">nLeftrightarrow;</code> </td> <td> U+021CE </td> <td> <span class=glyph title="">⇎</span> </td> <tr id=entity-nleftrightarrow><td> <code title="">nleftrightarrow;</code> </td> <td> U+021AE </td> <td> <span class=glyph title="">↮</span> </td> <tr id=entity-nleq><td> <code title="">nleq;</code> </td> <td> U+02270 </td> <td> <span class=glyph title="">≰</span> </td> <tr id=entity-nleqq><td> <code title="">nleqq;</code> </td> <td> U+02266 U+00338 </td> <td> <span class="glyph compound" title="">≦̸</span> </td> <tr id=entity-nleqslant><td> <code title="">nleqslant;</code> </td> <td> U+02A7D U+00338 </td> <td> <span class="glyph compound" title="">⩽̸</span> </td> <tr id=entity-nles><td> <code title="">nles;</code> </td> <td> U+02A7D U+00338 </td> <td> <span class="glyph compound" title="">⩽̸</span> </td> <tr id=entity-nless><td> <code title="">nless;</code> </td> <td> U+0226E </td> <td> <span class=glyph title="">≮</span> </td> <tr id=entity-nLl><td> <code title="">nLl;</code> </td> <td> U+022D8 U+00338 </td> <td> <span class="glyph compound" title="">⋘̸</span> </td> <tr id=entity-nlsim><td> <code title="">nlsim;</code> </td> <td> U+02274 </td> <td> <span class=glyph title="">≴</span> </td> <tr id=entity-nLt><td> <code title="">nLt;</code> </td> <td> U+0226A U+020D2 </td> <td> <span class="glyph compound" title="">≪⃒</span> </td> <tr id=entity-nlt><td> <code title="">nlt;</code> </td> <td> U+0226E </td> <td> <span class=glyph title="">≮</span> </td> <tr id=entity-nltri><td> <code title="">nltri;</code> </td> <td> U+022EA </td> <td> <span class=glyph title="">⋪</span> </td> <tr id=entity-nltrie><td> <code title="">nltrie;</code> </td> <td> U+022EC </td> <td> <span class=glyph title="">⋬</span> </td> <tr id=entity-nLtv><td> <code title="">nLtv;</code> </td> <td> U+0226A U+00338 </td> <td> <span class="glyph compound" title="">≪̸</span> </td> <tr id=entity-nmid><td> <code title="">nmid;</code> </td> <td> U+02224 </td> <td> <span class=glyph title="">∤</span> </td> <tr id=entity-NoBreak><td> <code title="">NoBreak;</code> </td> <td> U+02060 </td> <td> <span class=glyph title="">⁠</span> </td> <tr id=entity-NonBreakingSpace><td> <code title="">NonBreakingSpace;</code> </td> <td> U+000A0 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-Nopf><td> <code title="">Nopf;</code> </td> <td> U+02115 </td> <td> <span class=glyph title="">ℕ</span> </td> <tr id=entity-nopf><td> <code title="">nopf;</code> </td> <td> U+1D55F </td> <td> <span class=glyph title="">𝕟</span> </td> <tr id=entity-Not><td> <code title="">Not;</code> </td> <td> U+02AEC </td> <td> <span class=glyph title="">⫬</span> </td> <tr id=entity-not><td> <code title="">not;</code> </td> <td> U+000AC </td> <td> <span class=glyph title="">¬</span> </td> <tr class=impl id=entity-not-legacy><td> <code title="">not</code> </td> <td> U+000AC </td> <td> <span title="">¬</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-NotCongruent><td> <code title="">NotCongruent;</code> </td> <td> U+02262 </td> <td> <span class=glyph title="">≢</span> </td> <tr id=entity-NotCupCap><td> <code title="">NotCupCap;</code> </td> <td> U+0226D </td> <td> <span class=glyph title="">≭</span> </td> <tr id=entity-NotDoubleVerticalBar><td> <code title="">NotDoubleVerticalBar;</code> </td> <td> U+02226 </td> <td> <span class=glyph title="">∦</span> </td> <tr id=entity-NotElement><td> <code title="">NotElement;</code> </td> <td> U+02209 </td> <td> <span class=glyph title="">∉</span> </td> <tr id=entity-NotEqual><td> <code title="">NotEqual;</code> </td> <td> U+02260 </td> <td> <span class=glyph title="">≠</span> </td> <tr id=entity-NotEqualTilde><td> <code title="">NotEqualTilde;</code> </td> <td> U+02242 U+00338 </td> <td> <span class="glyph compound" title="">≂̸</span> </td> <tr id=entity-NotExists><td> <code title="">NotExists;</code> </td> <td> U+02204 </td> <td> <span class=glyph title="">∄</span> </td> <tr id=entity-NotGreater><td> <code title="">NotGreater;</code> </td> <td> U+0226F </td> <td> <span class=glyph title="">≯</span> </td> <tr id=entity-NotGreaterEqual><td> <code title="">NotGreaterEqual;</code> </td> <td> U+02271 </td> <td> <span class=glyph title="">≱</span> </td> <tr id=entity-NotGreaterFullEqual><td> <code title="">NotGreaterFullEqual;</code> </td> <td> U+02267 U+00338 </td> <td> <span class="glyph compound" title="">≧̸</span> </td> <tr id=entity-NotGreaterGreater><td> <code title="">NotGreaterGreater;</code> </td> <td> U+0226B U+00338 </td> <td> <span class="glyph compound" title="">≫̸</span> </td> <tr id=entity-NotGreaterLess><td> <code title="">NotGreaterLess;</code> </td> <td> U+02279 </td> <td> <span class=glyph title="">≹</span> </td> <tr id=entity-NotGreaterSlantEqual><td> <code title="">NotGreaterSlantEqual;</code> </td> <td> U+02A7E U+00338 </td> <td> <span class="glyph compound" title="">⩾̸</span> </td> <tr id=entity-NotGreaterTilde><td> <code title="">NotGreaterTilde;</code> </td> <td> U+02275 </td> <td> <span class=glyph title="">≵</span> </td> <tr id=entity-NotHumpDownHump><td> <code title="">NotHumpDownHump;</code> </td> <td> U+0224E U+00338 </td> <td> <span class="glyph compound" title="">≎̸</span> </td> <tr id=entity-NotHumpEqual><td> <code title="">NotHumpEqual;</code> </td> <td> U+0224F U+00338 </td> <td> <span class="glyph compound" title="">≏̸</span> </td> <tr id=entity-notin><td> <code title="">notin;</code> </td> <td> U+02209 </td> <td> <span class=glyph title="">∉</span> </td> <tr id=entity-notindot><td> <code title="">notindot;</code> </td> <td> U+022F5 U+00338 </td> <td> <span class="glyph compound" title="">⋵̸</span> </td> <tr id=entity-notinE><td> <code title="">notinE;</code> </td> <td> U+022F9 U+00338 </td> <td> <span class="glyph compound" title="">⋹̸</span> </td> <tr id=entity-notinva><td> <code title="">notinva;</code> </td> <td> U+02209 </td> <td> <span class=glyph title="">∉</span> </td> <tr id=entity-notinvb><td> <code title="">notinvb;</code> </td> <td> U+022F7 </td> <td> <span class=glyph title="">⋷</span> </td> <tr id=entity-notinvc><td> <code title="">notinvc;</code> </td> <td> U+022F6 </td> <td> <span class=glyph title="">⋶</span> </td> <tr id=entity-NotLeftTriangle><td> <code title="">NotLeftTriangle;</code> </td> <td> U+022EA </td> <td> <span class=glyph title="">⋪</span> </td> <tr id=entity-NotLeftTriangleBar><td> <code title="">NotLeftTriangleBar;</code> </td> <td> U+029CF U+00338 </td> <td> <span class="glyph compound" title="">⧏̸</span> </td> <tr id=entity-NotLeftTriangleEqual><td> <code title="">NotLeftTriangleEqual;</code> </td> <td> U+022EC </td> <td> <span class=glyph title="">⋬</span> </td> <tr id=entity-NotLess><td> <code title="">NotLess;</code> </td> <td> U+0226E </td> <td> <span class=glyph title="">≮</span> </td> <tr id=entity-NotLessEqual><td> <code title="">NotLessEqual;</code> </td> <td> U+02270 </td> <td> <span class=glyph title="">≰</span> </td> <tr id=entity-NotLessGreater><td> <code title="">NotLessGreater;</code> </td> <td> U+02278 </td> <td> <span class=glyph title="">≸</span> </td> <tr id=entity-NotLessLess><td> <code title="">NotLessLess;</code> </td> <td> U+0226A U+00338 </td> <td> <span class="glyph compound" title="">≪̸</span> </td> <tr id=entity-NotLessSlantEqual><td> <code title="">NotLessSlantEqual;</code> </td> <td> U+02A7D U+00338 </td> <td> <span class="glyph compound" title="">⩽̸</span> </td> <tr id=entity-NotLessTilde><td> <code title="">NotLessTilde;</code> </td> <td> U+02274 </td> <td> <span class=glyph title="">≴</span> </td> <tr id=entity-NotNestedGreaterGreater><td> <code title="">NotNestedGreaterGreater;</code> </td> <td> U+02AA2 U+00338 </td> <td> <span class="glyph compound" title="">⪢̸</span> </td> <tr id=entity-NotNestedLessLess><td> <code title="">NotNestedLessLess;</code> </td> <td> U+02AA1 U+00338 </td> <td> <span class="glyph compound" title="">⪡̸</span> </td> <tr id=entity-notni><td> <code title="">notni;</code> </td> <td> U+0220C </td> <td> <span class=glyph title="">∌</span> </td> <tr id=entity-notniva><td> <code title="">notniva;</code> </td> <td> U+0220C </td> <td> <span class=glyph title="">∌</span> </td> <tr id=entity-notnivb><td> <code title="">notnivb;</code> </td> <td> U+022FE </td> <td> <span class=glyph title="">⋾</span> </td> <tr id=entity-notnivc><td> <code title="">notnivc;</code> </td> <td> U+022FD </td> <td> <span class=glyph title="">⋽</span> </td> <tr id=entity-NotPrecedes><td> <code title="">NotPrecedes;</code> </td> <td> U+02280 </td> <td> <span class=glyph title="">⊀</span> </td> <tr id=entity-NotPrecedesEqual><td> <code title="">NotPrecedesEqual;</code> </td> <td> U+02AAF U+00338 </td> <td> <span class="glyph compound" title="">⪯̸</span> </td> <tr id=entity-NotPrecedesSlantEqual><td> <code title="">NotPrecedesSlantEqual;</code> </td> <td> U+022E0 </td> <td> <span class=glyph title="">⋠</span> </td> <tr id=entity-NotReverseElement><td> <code title="">NotReverseElement;</code> </td> <td> U+0220C </td> <td> <span class=glyph title="">∌</span> </td> <tr id=entity-NotRightTriangle><td> <code title="">NotRightTriangle;</code> </td> <td> U+022EB </td> <td> <span class=glyph title="">⋫</span> </td> <tr id=entity-NotRightTriangleBar><td> <code title="">NotRightTriangleBar;</code> </td> <td> U+029D0 U+00338 </td> <td> <span class="glyph compound" title="">⧐̸</span> </td> <tr id=entity-NotRightTriangleEqual><td> <code title="">NotRightTriangleEqual;</code> </td> <td> U+022ED </td> <td> <span class=glyph title="">⋭</span> </td> <tr id=entity-NotSquareSubset><td> <code title="">NotSquareSubset;</code> </td> <td> U+0228F U+00338 </td> <td> <span class="glyph compound" title="">⊏̸</span> </td> <tr id=entity-NotSquareSubsetEqual><td> <code title="">NotSquareSubsetEqual;</code> </td> <td> U+022E2 </td> <td> <span class=glyph title="">⋢</span> </td> <tr id=entity-NotSquareSuperset><td> <code title="">NotSquareSuperset;</code> </td> <td> U+02290 U+00338 </td> <td> <span class="glyph compound" title="">⊐̸</span> </td> <tr id=entity-NotSquareSupersetEqual><td> <code title="">NotSquareSupersetEqual;</code> </td> <td> U+022E3 </td> <td> <span class=glyph title="">⋣</span> </td> <tr id=entity-NotSubset><td> <code title="">NotSubset;</code> </td> <td> U+02282 U+020D2 </td> <td> <span class="glyph compound" title="">⊂⃒</span> </td> <tr id=entity-NotSubsetEqual><td> <code title="">NotSubsetEqual;</code> </td> <td> U+02288 </td> <td> <span class=glyph title="">⊈</span> </td> <tr id=entity-NotSucceeds><td> <code title="">NotSucceeds;</code> </td> <td> U+02281 </td> <td> <span class=glyph title="">⊁</span> </td> <tr id=entity-NotSucceedsEqual><td> <code title="">NotSucceedsEqual;</code> </td> <td> U+02AB0 U+00338 </td> <td> <span class="glyph compound" title="">⪰̸</span> </td> <tr id=entity-NotSucceedsSlantEqual><td> <code title="">NotSucceedsSlantEqual;</code> </td> <td> U+022E1 </td> <td> <span class=glyph title="">⋡</span> </td> <tr id=entity-NotSucceedsTilde><td> <code title="">NotSucceedsTilde;</code> </td> <td> U+0227F U+00338 </td> <td> <span class="glyph compound" title="">≿̸</span> </td> <tr id=entity-NotSuperset><td> <code title="">NotSuperset;</code> </td> <td> U+02283 U+020D2 </td> <td> <span class="glyph compound" title="">⊃⃒</span> </td> <tr id=entity-NotSupersetEqual><td> <code title="">NotSupersetEqual;</code> </td> <td> U+02289 </td> <td> <span class=glyph title="">⊉</span> </td> <tr id=entity-NotTilde><td> <code title="">NotTilde;</code> </td> <td> U+02241 </td> <td> <span class=glyph title="">≁</span> </td> <tr id=entity-NotTildeEqual><td> <code title="">NotTildeEqual;</code> </td> <td> U+02244 </td> <td> <span class=glyph title="">≄</span> </td> <tr id=entity-NotTildeFullEqual><td> <code title="">NotTildeFullEqual;</code> </td> <td> U+02247 </td> <td> <span class=glyph title="">≇</span> </td> <tr id=entity-NotTildeTilde><td> <code title="">NotTildeTilde;</code> </td> <td> U+02249 </td> <td> <span class=glyph title="">≉</span> </td> <tr id=entity-NotVerticalBar><td> <code title="">NotVerticalBar;</code> </td> <td> U+02224 </td> <td> <span class=glyph title="">∤</span> </td> <tr id=entity-npar><td> <code title="">npar;</code> </td> <td> U+02226 </td> <td> <span class=glyph title="">∦</span> </td> <tr id=entity-nparallel><td> <code title="">nparallel;</code> </td> <td> U+02226 </td> <td> <span class=glyph title="">∦</span> </td> <tr id=entity-nparsl><td> <code title="">nparsl;</code> </td> <td> U+02AFD U+020E5 </td> <td> <span class="glyph compound" title="">⫽⃥</span> </td> <tr id=entity-npart><td> <code title="">npart;</code> </td> <td> U+02202 U+00338 </td> <td> <span class="glyph compound" title="">∂̸</span> </td> <tr id=entity-npolint><td> <code title="">npolint;</code> </td> <td> U+02A14 </td> <td> <span class=glyph title="">⨔</span> </td> <tr id=entity-npr><td> <code title="">npr;</code> </td> <td> U+02280 </td> <td> <span class=glyph title="">⊀</span> </td> <tr id=entity-nprcue><td> <code title="">nprcue;</code> </td> <td> U+022E0 </td> <td> <span class=glyph title="">⋠</span> </td> <tr id=entity-npre><td> <code title="">npre;</code> </td> <td> U+02AAF U+00338 </td> <td> <span class="glyph compound" title="">⪯̸</span> </td> <tr id=entity-nprec><td> <code title="">nprec;</code> </td> <td> U+02280 </td> <td> <span class=glyph title="">⊀</span> </td> <tr id=entity-npreceq><td> <code title="">npreceq;</code> </td> <td> U+02AAF U+00338 </td> <td> <span class="glyph compound" title="">⪯̸</span> </td> <tr id=entity-nrArr><td> <code title="">nrArr;</code> </td> <td> U+021CF </td> <td> <span class=glyph title="">⇏</span> </td> <tr id=entity-nrarr><td> <code title="">nrarr;</code> </td> <td> U+0219B </td> <td> <span class=glyph title="">↛</span> </td> <tr id=entity-nrarrc><td> <code title="">nrarrc;</code> </td> <td> U+02933 U+00338 </td> <td> <span class="glyph compound" title="">⤳̸</span> </td> <tr id=entity-nrarrw><td> <code title="">nrarrw;</code> </td> <td> U+0219D U+00338 </td> <td> <span class="glyph compound" title="">↝̸</span> </td> <tr id=entity-nRightarrow><td> <code title="">nRightarrow;</code> </td> <td> U+021CF </td> <td> <span class=glyph title="">⇏</span> </td> <tr id=entity-nrightarrow><td> <code title="">nrightarrow;</code> </td> <td> U+0219B </td> <td> <span class=glyph title="">↛</span> </td> <tr id=entity-nrtri><td> <code title="">nrtri;</code> </td> <td> U+022EB </td> <td> <span class=glyph title="">⋫</span> </td> <tr id=entity-nrtrie><td> <code title="">nrtrie;</code> </td> <td> U+022ED </td> <td> <span class=glyph title="">⋭</span> </td> <tr id=entity-nsc><td> <code title="">nsc;</code> </td> <td> U+02281 </td> <td> <span class=glyph title="">⊁</span> </td> <tr id=entity-nsccue><td> <code title="">nsccue;</code> </td> <td> U+022E1 </td> <td> <span class=glyph title="">⋡</span> </td> <tr id=entity-nsce><td> <code title="">nsce;</code> </td> <td> U+02AB0 U+00338 </td> <td> <span class="glyph compound" title="">⪰̸</span> </td> <tr id=entity-Nscr><td> <code title="">Nscr;</code> </td> <td> U+1D4A9 </td> <td> <span class=glyph title="">𝒩</span> </td> <tr id=entity-nscr><td> <code title="">nscr;</code> </td> <td> U+1D4C3 </td> <td> <span class=glyph title="">𝓃</span> </td> <tr id=entity-nshortmid><td> <code title="">nshortmid;</code> </td> <td> U+02224 </td> <td> <span class=glyph title="">∤</span> </td> <tr id=entity-nshortparallel><td> <code title="">nshortparallel;</code> </td> <td> U+02226 </td> <td> <span class=glyph title="">∦</span> </td> <tr id=entity-nsim><td> <code title="">nsim;</code> </td> <td> U+02241 </td> <td> <span class=glyph title="">≁</span> </td> <tr id=entity-nsime><td> <code title="">nsime;</code> </td> <td> U+02244 </td> <td> <span class=glyph title="">≄</span> </td> <tr id=entity-nsimeq><td> <code title="">nsimeq;</code> </td> <td> U+02244 </td> <td> <span class=glyph title="">≄</span> </td> <tr id=entity-nsmid><td> <code title="">nsmid;</code> </td> <td> U+02224 </td> <td> <span class=glyph title="">∤</span> </td> <tr id=entity-nspar><td> <code title="">nspar;</code> </td> <td> U+02226 </td> <td> <span class=glyph title="">∦</span> </td> <tr id=entity-nsqsube><td> <code title="">nsqsube;</code> </td> <td> U+022E2 </td> <td> <span class=glyph title="">⋢</span> </td> <tr id=entity-nsqsupe><td> <code title="">nsqsupe;</code> </td> <td> U+022E3 </td> <td> <span class=glyph title="">⋣</span> </td> <tr id=entity-nsub><td> <code title="">nsub;</code> </td> <td> U+02284 </td> <td> <span class=glyph title="">⊄</span> </td> <tr id=entity-nsubE><td> <code title="">nsubE;</code> </td> <td> U+02AC5 U+00338 </td> <td> <span class="glyph compound" title="">⫅̸</span> </td> <tr id=entity-nsube><td> <code title="">nsube;</code> </td> <td> U+02288 </td> <td> <span class=glyph title="">⊈</span> </td> <tr id=entity-nsubset><td> <code title="">nsubset;</code> </td> <td> U+02282 U+020D2 </td> <td> <span class="glyph compound" title="">⊂⃒</span> </td> <tr id=entity-nsubseteq><td> <code title="">nsubseteq;</code> </td> <td> U+02288 </td> <td> <span class=glyph title="">⊈</span> </td> <tr id=entity-nsubseteqq><td> <code title="">nsubseteqq;</code> </td> <td> U+02AC5 U+00338 </td> <td> <span class="glyph compound" title="">⫅̸</span> </td> <tr id=entity-nsucc><td> <code title="">nsucc;</code> </td> <td> U+02281 </td> <td> <span class=glyph title="">⊁</span> </td> <tr id=entity-nsucceq><td> <code title="">nsucceq;</code> </td> <td> U+02AB0 U+00338 </td> <td> <span class="glyph compound" title="">⪰̸</span> </td> <tr id=entity-nsup><td> <code title="">nsup;</code> </td> <td> U+02285 </td> <td> <span class=glyph title="">⊅</span> </td> <tr id=entity-nsupE><td> <code title="">nsupE;</code> </td> <td> U+02AC6 U+00338 </td> <td> <span class="glyph compound" title="">⫆̸</span> </td> <tr id=entity-nsupe><td> <code title="">nsupe;</code> </td> <td> U+02289 </td> <td> <span class=glyph title="">⊉</span> </td> <tr id=entity-nsupset><td> <code title="">nsupset;</code> </td> <td> U+02283 U+020D2 </td> <td> <span class="glyph compound" title="">⊃⃒</span> </td> <tr id=entity-nsupseteq><td> <code title="">nsupseteq;</code> </td> <td> U+02289 </td> <td> <span class=glyph title="">⊉</span> </td> <tr id=entity-nsupseteqq><td> <code title="">nsupseteqq;</code> </td> <td> U+02AC6 U+00338 </td> <td> <span class="glyph compound" title="">⫆̸</span> </td> <tr id=entity-ntgl><td> <code title="">ntgl;</code> </td> <td> U+02279 </td> <td> <span class=glyph title="">≹</span> </td> <tr id=entity-Ntilde><td> <code title="">Ntilde;</code> </td> <td> U+000D1 </td> <td> <span class=glyph title="">Ñ</span> </td> <tr class=impl id=entity-Ntilde-legacy><td> <code title="">Ntilde</code> </td> <td> U+000D1 </td> <td> <span title="">Ñ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ntilde><td> <code title="">ntilde;</code> </td> <td> U+000F1 </td> <td> <span class=glyph title="">ñ</span> </td> <tr class=impl id=entity-ntilde-legacy><td> <code title="">ntilde</code> </td> <td> U+000F1 </td> <td> <span title="">ñ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ntlg><td> <code title="">ntlg;</code> </td> <td> U+02278 </td> <td> <span class=glyph title="">≸</span> </td> <tr id=entity-ntriangleleft><td> <code title="">ntriangleleft;</code> </td> <td> U+022EA </td> <td> <span class=glyph title="">⋪</span> </td> <tr id=entity-ntrianglelefteq><td> <code title="">ntrianglelefteq;</code> </td> <td> U+022EC </td> <td> <span class=glyph title="">⋬</span> </td> <tr id=entity-ntriangleright><td> <code title="">ntriangleright;</code> </td> <td> U+022EB </td> <td> <span class=glyph title="">⋫</span> </td> <tr id=entity-ntrianglerighteq><td> <code title="">ntrianglerighteq;</code> </td> <td> U+022ED </td> <td> <span class=glyph title="">⋭</span> </td> <tr id=entity-Nu><td> <code title="">Nu;</code> </td> <td> U+0039D </td> <td> <span class=glyph title="">Ν</span> </td> <tr id=entity-nu><td> <code title="">nu;</code> </td> <td> U+003BD </td> <td> <span class=glyph title="">ν</span> </td> <tr id=entity-num><td> <code title="">num;</code> </td> <td> U+00023 </td> <td> <span class=glyph title="">#</span> </td> <tr id=entity-numero><td> <code title="">numero;</code> </td> <td> U+02116 </td> <td> <span class=glyph title="">№</span> </td> <tr id=entity-numsp><td> <code title="">numsp;</code> </td> <td> U+02007 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-nvap><td> <code title="">nvap;</code> </td> <td> U+0224D U+020D2 </td> <td> <span class="glyph compound" title="">≍⃒</span> </td> <tr id=entity-nVDash><td> <code title="">nVDash;</code> </td> <td> U+022AF </td> <td> <span class=glyph title="">⊯</span> </td> <tr id=entity-nVdash><td> <code title="">nVdash;</code> </td> <td> U+022AE </td> <td> <span class=glyph title="">⊮</span> </td> <tr id=entity-nvDash><td> <code title="">nvDash;</code> </td> <td> U+022AD </td> <td> <span class=glyph title="">⊭</span> </td> <tr id=entity-nvdash><td> <code title="">nvdash;</code> </td> <td> U+022AC </td> <td> <span class=glyph title="">⊬</span> </td> <tr id=entity-nvge><td> <code title="">nvge;</code> </td> <td> U+02265 U+020D2 </td> <td> <span class="glyph compound" title="">≥⃒</span> </td> <tr id=entity-nvgt><td> <code title="">nvgt;</code> </td> <td> U+0003E U+020D2 </td> <td> <span class="glyph compound" title="">>⃒</span> </td> <tr id=entity-nvHarr><td> <code title="">nvHarr;</code> </td> <td> U+02904 </td> <td> <span class=glyph title="">⤄</span> </td> <tr id=entity-nvinfin><td> <code title="">nvinfin;</code> </td> <td> U+029DE </td> <td> <span class=glyph title="">⧞</span> </td> <tr id=entity-nvlArr><td> <code title="">nvlArr;</code> </td> <td> U+02902 </td> <td> <span class=glyph title="">⤂</span> </td> <tr id=entity-nvle><td> <code title="">nvle;</code> </td> <td> U+02264 U+020D2 </td> <td> <span class="glyph compound" title="">≤⃒</span> </td> <tr id=entity-nvlt><td> <code title="">nvlt;</code> </td> <td> U+0003C U+020D2 </td> <td> <span class="glyph compound" title=""><⃒</span> </td> <tr id=entity-nvltrie><td> <code title="">nvltrie;</code> </td> <td> U+022B4 U+020D2 </td> <td> <span class="glyph compound" title="">⊴⃒</span> </td> <tr id=entity-nvrArr><td> <code title="">nvrArr;</code> </td> <td> U+02903 </td> <td> <span class=glyph title="">⤃</span> </td> <tr id=entity-nvrtrie><td> <code title="">nvrtrie;</code> </td> <td> U+022B5 U+020D2 </td> <td> <span class="glyph compound" title="">⊵⃒</span> </td> <tr id=entity-nvsim><td> <code title="">nvsim;</code> </td> <td> U+0223C U+020D2 </td> <td> <span class="glyph compound" title="">∼⃒</span> </td> <tr id=entity-nwarhk><td> <code title="">nwarhk;</code> </td> <td> U+02923 </td> <td> <span class=glyph title="">⤣</span> </td> <tr id=entity-nwArr><td> <code title="">nwArr;</code> </td> <td> U+021D6 </td> <td> <span class=glyph title="">⇖</span> </td> <tr id=entity-nwarr><td> <code title="">nwarr;</code> </td> <td> U+02196 </td> <td> <span class=glyph title="">↖</span> </td> <tr id=entity-nwarrow><td> <code title="">nwarrow;</code> </td> <td> U+02196 </td> <td> <span class=glyph title="">↖</span> </td> <tr id=entity-nwnear><td> <code title="">nwnear;</code> </td> <td> U+02927 </td> <td> <span class=glyph title="">⤧</span> </td> <tr id=entity-Oacute><td> <code title="">Oacute;</code> </td> <td> U+000D3 </td> <td> <span class=glyph title="">Ó</span> </td> <tr class=impl id=entity-Oacute-legacy><td> <code title="">Oacute</code> </td> <td> U+000D3 </td> <td> <span title="">Ó</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-oacute><td> <code title="">oacute;</code> </td> <td> U+000F3 </td> <td> <span class=glyph title="">ó</span> </td> <tr class=impl id=entity-oacute-legacy><td> <code title="">oacute</code> </td> <td> U+000F3 </td> <td> <span title="">ó</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-oast><td> <code title="">oast;</code> </td> <td> U+0229B </td> <td> <span class=glyph title="">⊛</span> </td> <tr id=entity-ocir><td> <code title="">ocir;</code> </td> <td> U+0229A </td> <td> <span class=glyph title="">⊚</span> </td> <tr id=entity-Ocirc><td> <code title="">Ocirc;</code> </td> <td> U+000D4 </td> <td> <span class=glyph title="">Ô</span> </td> <tr class=impl id=entity-Ocirc-legacy><td> <code title="">Ocirc</code> </td> <td> U+000D4 </td> <td> <span title="">Ô</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ocirc><td> <code title="">ocirc;</code> </td> <td> U+000F4 </td> <td> <span class=glyph title="">ô</span> </td> <tr class=impl id=entity-ocirc-legacy><td> <code title="">ocirc</code> </td> <td> U+000F4 </td> <td> <span title="">ô</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Ocy><td> <code title="">Ocy;</code> </td> <td> U+0041E </td> <td> <span class=glyph title="">О</span> </td> <tr id=entity-ocy><td> <code title="">ocy;</code> </td> <td> U+0043E </td> <td> <span class=glyph title="">о</span> </td> <tr id=entity-odash><td> <code title="">odash;</code> </td> <td> U+0229D </td> <td> <span class=glyph title="">⊝</span> </td> <tr id=entity-Odblac><td> <code title="">Odblac;</code> </td> <td> U+00150 </td> <td> <span class=glyph title="">Ő</span> </td> <tr id=entity-odblac><td> <code title="">odblac;</code> </td> <td> U+00151 </td> <td> <span class=glyph title="">ő</span> </td> <tr id=entity-odiv><td> <code title="">odiv;</code> </td> <td> U+02A38 </td> <td> <span class=glyph title="">⨸</span> </td> <tr id=entity-odot><td> <code title="">odot;</code> </td> <td> U+02299 </td> <td> <span class=glyph title="">⊙</span> </td> <tr id=entity-odsold><td> <code title="">odsold;</code> </td> <td> U+029BC </td> <td> <span class=glyph title="">⦼</span> </td> <tr id=entity-OElig><td> <code title="">OElig;</code> </td> <td> U+00152 </td> <td> <span class=glyph title="">Œ</span> </td> <tr id=entity-oelig><td> <code title="">oelig;</code> </td> <td> U+00153 </td> <td> <span class=glyph title="">œ</span> </td> <tr id=entity-ofcir><td> <code title="">ofcir;</code> </td> <td> U+029BF </td> <td> <span class=glyph title="">⦿</span> </td> <tr id=entity-Ofr><td> <code title="">Ofr;</code> </td> <td> U+1D512 </td> <td> <span class=glyph title="">𝔒</span> </td> <tr id=entity-ofr><td> <code title="">ofr;</code> </td> <td> U+1D52C </td> <td> <span class=glyph title="">𝔬</span> </td> <tr id=entity-ogon><td> <code title="">ogon;</code> </td> <td> U+002DB </td> <td> <span class=glyph title="">˛</span> </td> <tr id=entity-Ograve><td> <code title="">Ograve;</code> </td> <td> U+000D2 </td> <td> <span class=glyph title="">Ò</span> </td> <tr class=impl id=entity-Ograve-legacy><td> <code title="">Ograve</code> </td> <td> U+000D2 </td> <td> <span title="">Ò</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ograve><td> <code title="">ograve;</code> </td> <td> U+000F2 </td> <td> <span class=glyph title="">ò</span> </td> <tr class=impl id=entity-ograve-legacy><td> <code title="">ograve</code> </td> <td> U+000F2 </td> <td> <span title="">ò</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ogt><td> <code title="">ogt;</code> </td> <td> U+029C1 </td> <td> <span class=glyph title="">⧁</span> </td> <tr id=entity-ohbar><td> <code title="">ohbar;</code> </td> <td> U+029B5 </td> <td> <span class=glyph title="">⦵</span> </td> <tr id=entity-ohm><td> <code title="">ohm;</code> </td> <td> U+003A9 </td> <td> <span class=glyph title="">Ω</span> </td> <tr id=entity-oint><td> <code title="">oint;</code> </td> <td> U+0222E </td> <td> <span class=glyph title="">∮</span> </td> <tr id=entity-olarr><td> <code title="">olarr;</code> </td> <td> U+021BA </td> <td> <span class=glyph title="">↺</span> </td> <tr id=entity-olcir><td> <code title="">olcir;</code> </td> <td> U+029BE </td> <td> <span class=glyph title="">⦾</span> </td> <tr id=entity-olcross><td> <code title="">olcross;</code> </td> <td> U+029BB </td> <td> <span class=glyph title="">⦻</span> </td> <tr id=entity-oline><td> <code title="">oline;</code> </td> <td> U+0203E </td> <td> <span class=glyph title="">‾</span> </td> <tr id=entity-olt><td> <code title="">olt;</code> </td> <td> U+029C0 </td> <td> <span class=glyph title="">⧀</span> </td> <tr id=entity-Omacr><td> <code title="">Omacr;</code> </td> <td> U+0014C </td> <td> <span class=glyph title="">Ō</span> </td> <tr id=entity-omacr><td> <code title="">omacr;</code> </td> <td> U+0014D </td> <td> <span class=glyph title="">ō</span> </td> <tr id=entity-Omega><td> <code title="">Omega;</code> </td> <td> U+003A9 </td> <td> <span class=glyph title="">Ω</span> </td> <tr id=entity-omega><td> <code title="">omega;</code> </td> <td> U+003C9 </td> <td> <span class=glyph title="">ω</span> </td> <tr id=entity-Omicron><td> <code title="">Omicron;</code> </td> <td> U+0039F </td> <td> <span class=glyph title="">Ο</span> </td> <tr id=entity-omicron><td> <code title="">omicron;</code> </td> <td> U+003BF </td> <td> <span class=glyph title="">ο</span> </td> <tr id=entity-omid><td> <code title="">omid;</code> </td> <td> U+029B6 </td> <td> <span class=glyph title="">⦶</span> </td> <tr id=entity-ominus><td> <code title="">ominus;</code> </td> <td> U+02296 </td> <td> <span class=glyph title="">⊖</span> </td> <tr id=entity-Oopf><td> <code title="">Oopf;</code> </td> <td> U+1D546 </td> <td> <span class=glyph title="">𝕆</span> </td> <tr id=entity-oopf><td> <code title="">oopf;</code> </td> <td> U+1D560 </td> <td> <span class=glyph title="">𝕠</span> </td> <tr id=entity-opar><td> <code title="">opar;</code> </td> <td> U+029B7 </td> <td> <span class=glyph title="">⦷</span> </td> <tr id=entity-OpenCurlyDoubleQuote><td> <code title="">OpenCurlyDoubleQuote;</code> </td> <td> U+0201C </td> <td> <span class=glyph title="">“</span> </td> <tr id=entity-OpenCurlyQuote><td> <code title="">OpenCurlyQuote;</code> </td> <td> U+02018 </td> <td> <span class=glyph title="">‘</span> </td> <tr id=entity-operp><td> <code title="">operp;</code> </td> <td> U+029B9 </td> <td> <span class=glyph title="">⦹</span> </td> <tr id=entity-oplus><td> <code title="">oplus;</code> </td> <td> U+02295 </td> <td> <span class=glyph title="">⊕</span> </td> <tr id=entity-Or><td> <code title="">Or;</code> </td> <td> U+02A54 </td> <td> <span class=glyph title="">⩔</span> </td> <tr id=entity-or><td> <code title="">or;</code> </td> <td> U+02228 </td> <td> <span class=glyph title="">∨</span> </td> <tr id=entity-orarr><td> <code title="">orarr;</code> </td> <td> U+021BB </td> <td> <span class=glyph title="">↻</span> </td> <tr id=entity-ord><td> <code title="">ord;</code> </td> <td> U+02A5D </td> <td> <span class=glyph title="">⩝</span> </td> <tr id=entity-order><td> <code title="">order;</code> </td> <td> U+02134 </td> <td> <span class=glyph title="">ℴ</span> </td> <tr id=entity-orderof><td> <code title="">orderof;</code> </td> <td> U+02134 </td> <td> <span class=glyph title="">ℴ</span> </td> <tr id=entity-ordf><td> <code title="">ordf;</code> </td> <td> U+000AA </td> <td> <span class=glyph title="">ª</span> </td> <tr class=impl id=entity-ordf-legacy><td> <code title="">ordf</code> </td> <td> U+000AA </td> <td> <span title="">ª</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ordm><td> <code title="">ordm;</code> </td> <td> U+000BA </td> <td> <span class=glyph title="">º</span> </td> <tr class=impl id=entity-ordm-legacy><td> <code title="">ordm</code> </td> <td> U+000BA </td> <td> <span title="">º</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-origof><td> <code title="">origof;</code> </td> <td> U+022B6 </td> <td> <span class=glyph title="">⊶</span> </td> <tr id=entity-oror><td> <code title="">oror;</code> </td> <td> U+02A56 </td> <td> <span class=glyph title="">⩖</span> </td> <tr id=entity-orslope><td> <code title="">orslope;</code> </td> <td> U+02A57 </td> <td> <span class=glyph title="">⩗</span> </td> <tr id=entity-orv><td> <code title="">orv;</code> </td> <td> U+02A5B </td> <td> <span class=glyph title="">⩛</span> </td> <tr id=entity-oS><td> <code title="">oS;</code> </td> <td> U+024C8 </td> <td> <span class=glyph title="">Ⓢ</span> </td> <tr id=entity-Oscr><td> <code title="">Oscr;</code> </td> <td> U+1D4AA </td> <td> <span class=glyph title="">𝒪</span> </td> <tr id=entity-oscr><td> <code title="">oscr;</code> </td> <td> U+02134 </td> <td> <span class=glyph title="">ℴ</span> </td> <tr id=entity-Oslash><td> <code title="">Oslash;</code> </td> <td> U+000D8 </td> <td> <span class=glyph title="">Ø</span> </td> <tr class=impl id=entity-Oslash-legacy><td> <code title="">Oslash</code> </td> <td> U+000D8 </td> <td> <span title="">Ø</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-oslash><td> <code title="">oslash;</code> </td> <td> U+000F8 </td> <td> <span class=glyph title="">ø</span> </td> <tr class=impl id=entity-oslash-legacy><td> <code title="">oslash</code> </td> <td> U+000F8 </td> <td> <span title="">ø</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-osol><td> <code title="">osol;</code> </td> <td> U+02298 </td> <td> <span class=glyph title="">⊘</span> </td> <tr id=entity-Otilde><td> <code title="">Otilde;</code> </td> <td> U+000D5 </td> <td> <span class=glyph title="">Õ</span> </td> <tr class=impl id=entity-Otilde-legacy><td> <code title="">Otilde</code> </td> <td> U+000D5 </td> <td> <span title="">Õ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-otilde><td> <code title="">otilde;</code> </td> <td> U+000F5 </td> <td> <span class=glyph title="">õ</span> </td> <tr class=impl id=entity-otilde-legacy><td> <code title="">otilde</code> </td> <td> U+000F5 </td> <td> <span title="">õ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Otimes><td> <code title="">Otimes;</code> </td> <td> U+02A37 </td> <td> <span class=glyph title="">⨷</span> </td> <tr id=entity-otimes><td> <code title="">otimes;</code> </td> <td> U+02297 </td> <td> <span class=glyph title="">⊗</span> </td> <tr id=entity-otimesas><td> <code title="">otimesas;</code> </td> <td> U+02A36 </td> <td> <span class=glyph title="">⨶</span> </td> <tr id=entity-Ouml><td> <code title="">Ouml;</code> </td> <td> U+000D6 </td> <td> <span class=glyph title="">Ö</span> </td> <tr class=impl id=entity-Ouml-legacy><td> <code title="">Ouml</code> </td> <td> U+000D6 </td> <td> <span title="">Ö</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ouml><td> <code title="">ouml;</code> </td> <td> U+000F6 </td> <td> <span class=glyph title="">ö</span> </td> <tr class=impl id=entity-ouml-legacy><td> <code title="">ouml</code> </td> <td> U+000F6 </td> <td> <span title="">ö</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ovbar><td> <code title="">ovbar;</code> </td> <td> U+0233D </td> <td> <span class=glyph title="">⌽</span> </td> <tr id=entity-OverBar><td> <code title="">OverBar;</code> </td> <td> U+0203E </td> <td> <span class=glyph title="">‾</span> </td> <tr id=entity-OverBrace><td> <code title="">OverBrace;</code> </td> <td> U+023DE </td> <td> <span class=glyph title="">⏞</span> </td> <tr id=entity-OverBracket><td> <code title="">OverBracket;</code> </td> <td> U+023B4 </td> <td> <span class=glyph title="">⎴</span> </td> <tr id=entity-OverParenthesis><td> <code title="">OverParenthesis;</code> </td> <td> U+023DC </td> <td> <span class=glyph title="">⏜</span> </td> <tr id=entity-par><td> <code title="">par;</code> </td> <td> U+02225 </td> <td> <span class=glyph title="">∥</span> </td> <tr id=entity-para><td> <code title="">para;</code> </td> <td> U+000B6 </td> <td> <span class=glyph title="">¶</span> </td> <tr class=impl id=entity-para-legacy><td> <code title="">para</code> </td> <td> U+000B6 </td> <td> <span title="">¶</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-parallel><td> <code title="">parallel;</code> </td> <td> U+02225 </td> <td> <span class=glyph title="">∥</span> </td> <tr id=entity-parsim><td> <code title="">parsim;</code> </td> <td> U+02AF3 </td> <td> <span class=glyph title="">⫳</span> </td> <tr id=entity-parsl><td> <code title="">parsl;</code> </td> <td> U+02AFD </td> <td> <span class=glyph title="">⫽</span> </td> <tr id=entity-part><td> <code title="">part;</code> </td> <td> U+02202 </td> <td> <span class=glyph title="">∂</span> </td> <tr id=entity-PartialD><td> <code title="">PartialD;</code> </td> <td> U+02202 </td> <td> <span class=glyph title="">∂</span> </td> <tr id=entity-Pcy><td> <code title="">Pcy;</code> </td> <td> U+0041F </td> <td> <span class=glyph title="">П</span> </td> <tr id=entity-pcy><td> <code title="">pcy;</code> </td> <td> U+0043F </td> <td> <span class=glyph title="">п</span> </td> <tr id=entity-percnt><td> <code title="">percnt;</code> </td> <td> U+00025 </td> <td> <span class=glyph title="">%</span> </td> <tr id=entity-period><td> <code title="">period;</code> </td> <td> U+0002E </td> <td> <span class=glyph title="">.</span> </td> <tr id=entity-permil><td> <code title="">permil;</code> </td> <td> U+02030 </td> <td> <span class=glyph title="">‰</span> </td> <tr id=entity-perp><td> <code title="">perp;</code> </td> <td> U+022A5 </td> <td> <span class=glyph title="">⊥</span> </td> <tr id=entity-pertenk><td> <code title="">pertenk;</code> </td> <td> U+02031 </td> <td> <span class=glyph title="">‱</span> </td> <tr id=entity-Pfr><td> <code title="">Pfr;</code> </td> <td> U+1D513 </td> <td> <span class=glyph title="">𝔓</span> </td> <tr id=entity-pfr><td> <code title="">pfr;</code> </td> <td> U+1D52D </td> <td> <span class=glyph title="">𝔭</span> </td> <tr id=entity-Phi><td> <code title="">Phi;</code> </td> <td> U+003A6 </td> <td> <span class=glyph title="">Φ</span> </td> <tr id=entity-phi><td> <code title="">phi;</code> </td> <td> U+003C6 </td> <td> <span class=glyph title="">φ</span> </td> <tr id=entity-phiv><td> <code title="">phiv;</code> </td> <td> U+003D5 </td> <td> <span class=glyph title="">ϕ</span> </td> <tr id=entity-phmmat><td> <code title="">phmmat;</code> </td> <td> U+02133 </td> <td> <span class=glyph title="">ℳ</span> </td> <tr id=entity-phone><td> <code title="">phone;</code> </td> <td> U+0260E </td> <td> <span class=glyph title="">☎</span> </td> <tr id=entity-Pi><td> <code title="">Pi;</code> </td> <td> U+003A0 </td> <td> <span class=glyph title="">Π</span> </td> <tr id=entity-pi><td> <code title="">pi;</code> </td> <td> U+003C0 </td> <td> <span class=glyph title="">π</span> </td> <tr id=entity-pitchfork><td> <code title="">pitchfork;</code> </td> <td> U+022D4 </td> <td> <span class=glyph title="">⋔</span> </td> <tr id=entity-piv><td> <code title="">piv;</code> </td> <td> U+003D6 </td> <td> <span class=glyph title="">ϖ</span> </td> <tr id=entity-planck><td> <code title="">planck;</code> </td> <td> U+0210F </td> <td> <span class=glyph title="">ℏ</span> </td> <tr id=entity-planckh><td> <code title="">planckh;</code> </td> <td> U+0210E </td> <td> <span class=glyph title="">ℎ</span> </td> <tr id=entity-plankv><td> <code title="">plankv;</code> </td> <td> U+0210F </td> <td> <span class=glyph title="">ℏ</span> </td> <tr id=entity-plus><td> <code title="">plus;</code> </td> <td> U+0002B </td> <td> <span class=glyph title="">+</span> </td> <tr id=entity-plusacir><td> <code title="">plusacir;</code> </td> <td> U+02A23 </td> <td> <span class=glyph title="">⨣</span> </td> <tr id=entity-plusb><td> <code title="">plusb;</code> </td> <td> U+0229E </td> <td> <span class=glyph title="">⊞</span> </td> <tr id=entity-pluscir><td> <code title="">pluscir;</code> </td> <td> U+02A22 </td> <td> <span class=glyph title="">⨢</span> </td> <tr id=entity-plusdo><td> <code title="">plusdo;</code> </td> <td> U+02214 </td> <td> <span class=glyph title="">∔</span> </td> <tr id=entity-plusdu><td> <code title="">plusdu;</code> </td> <td> U+02A25 </td> <td> <span class=glyph title="">⨥</span> </td> <tr id=entity-pluse><td> <code title="">pluse;</code> </td> <td> U+02A72 </td> <td> <span class=glyph title="">⩲</span> </td> <tr id=entity-PlusMinus><td> <code title="">PlusMinus;</code> </td> <td> U+000B1 </td> <td> <span class=glyph title="">±</span> </td> <tr id=entity-plusmn><td> <code title="">plusmn;</code> </td> <td> U+000B1 </td> <td> <span class=glyph title="">±</span> </td> <tr class=impl id=entity-plusmn-legacy><td> <code title="">plusmn</code> </td> <td> U+000B1 </td> <td> <span title="">±</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-plussim><td> <code title="">plussim;</code> </td> <td> U+02A26 </td> <td> <span class=glyph title="">⨦</span> </td> <tr id=entity-plustwo><td> <code title="">plustwo;</code> </td> <td> U+02A27 </td> <td> <span class=glyph title="">⨧</span> </td> <tr id=entity-pm><td> <code title="">pm;</code> </td> <td> U+000B1 </td> <td> <span class=glyph title="">±</span> </td> <tr id=entity-Poincareplane><td> <code title="">Poincareplane;</code> </td> <td> U+0210C </td> <td> <span class=glyph title="">ℌ</span> </td> <tr id=entity-pointint><td> <code title="">pointint;</code> </td> <td> U+02A15 </td> <td> <span class=glyph title="">⨕</span> </td> <tr id=entity-Popf><td> <code title="">Popf;</code> </td> <td> U+02119 </td> <td> <span class=glyph title="">ℙ</span> </td> <tr id=entity-popf><td> <code title="">popf;</code> </td> <td> U+1D561 </td> <td> <span class=glyph title="">𝕡</span> </td> <tr id=entity-pound><td> <code title="">pound;</code> </td> <td> U+000A3 </td> <td> <span class=glyph title="">£</span> </td> <tr class=impl id=entity-pound-legacy><td> <code title="">pound</code> </td> <td> U+000A3 </td> <td> <span title="">£</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Pr><td> <code title="">Pr;</code> </td> <td> U+02ABB </td> <td> <span class=glyph title="">⪻</span> </td> <tr id=entity-pr><td> <code title="">pr;</code> </td> <td> U+0227A </td> <td> <span class=glyph title="">≺</span> </td> <tr id=entity-prap><td> <code title="">prap;</code> </td> <td> U+02AB7 </td> <td> <span class=glyph title="">⪷</span> </td> <tr id=entity-prcue><td> <code title="">prcue;</code> </td> <td> U+0227C </td> <td> <span class=glyph title="">≼</span> </td> <tr id=entity-prE><td> <code title="">prE;</code> </td> <td> U+02AB3 </td> <td> <span class=glyph title="">⪳</span> </td> <tr id=entity-pre><td> <code title="">pre;</code> </td> <td> U+02AAF </td> <td> <span class=glyph title="">⪯</span> </td> <tr id=entity-prec><td> <code title="">prec;</code> </td> <td> U+0227A </td> <td> <span class=glyph title="">≺</span> </td> <tr id=entity-precapprox><td> <code title="">precapprox;</code> </td> <td> U+02AB7 </td> <td> <span class=glyph title="">⪷</span> </td> <tr id=entity-preccurlyeq><td> <code title="">preccurlyeq;</code> </td> <td> U+0227C </td> <td> <span class=glyph title="">≼</span> </td> <tr id=entity-Precedes><td> <code title="">Precedes;</code> </td> <td> U+0227A </td> <td> <span class=glyph title="">≺</span> </td> <tr id=entity-PrecedesEqual><td> <code title="">PrecedesEqual;</code> </td> <td> U+02AAF </td> <td> <span class=glyph title="">⪯</span> </td> <tr id=entity-PrecedesSlantEqual><td> <code title="">PrecedesSlantEqual;</code> </td> <td> U+0227C </td> <td> <span class=glyph title="">≼</span> </td> <tr id=entity-PrecedesTilde><td> <code title="">PrecedesTilde;</code> </td> <td> U+0227E </td> <td> <span class=glyph title="">≾</span> </td> <tr id=entity-preceq><td> <code title="">preceq;</code> </td> <td> U+02AAF </td> <td> <span class=glyph title="">⪯</span> </td> <tr id=entity-precnapprox><td> <code title="">precnapprox;</code> </td> <td> U+02AB9 </td> <td> <span class=glyph title="">⪹</span> </td> <tr id=entity-precneqq><td> <code title="">precneqq;</code> </td> <td> U+02AB5 </td> <td> <span class=glyph title="">⪵</span> </td> <tr id=entity-precnsim><td> <code title="">precnsim;</code> </td> <td> U+022E8 </td> <td> <span class=glyph title="">⋨</span> </td> <tr id=entity-precsim><td> <code title="">precsim;</code> </td> <td> U+0227E </td> <td> <span class=glyph title="">≾</span> </td> <tr id=entity-Prime><td> <code title="">Prime;</code> </td> <td> U+02033 </td> <td> <span class=glyph title="">″</span> </td> <tr id=entity-prime><td> <code title="">prime;</code> </td> <td> U+02032 </td> <td> <span class=glyph title="">′</span> </td> <tr id=entity-primes><td> <code title="">primes;</code> </td> <td> U+02119 </td> <td> <span class=glyph title="">ℙ</span> </td> <tr id=entity-prnap><td> <code title="">prnap;</code> </td> <td> U+02AB9 </td> <td> <span class=glyph title="">⪹</span> </td> <tr id=entity-prnE><td> <code title="">prnE;</code> </td> <td> U+02AB5 </td> <td> <span class=glyph title="">⪵</span> </td> <tr id=entity-prnsim><td> <code title="">prnsim;</code> </td> <td> U+022E8 </td> <td> <span class=glyph title="">⋨</span> </td> <tr id=entity-prod><td> <code title="">prod;</code> </td> <td> U+0220F </td> <td> <span class=glyph title="">∏</span> </td> <tr id=entity-Product><td> <code title="">Product;</code> </td> <td> U+0220F </td> <td> <span class=glyph title="">∏</span> </td> <tr id=entity-profalar><td> <code title="">profalar;</code> </td> <td> U+0232E </td> <td> <span class=glyph title="">⌮</span> </td> <tr id=entity-profline><td> <code title="">profline;</code> </td> <td> U+02312 </td> <td> <span class=glyph title="">⌒</span> </td> <tr id=entity-profsurf><td> <code title="">profsurf;</code> </td> <td> U+02313 </td> <td> <span class=glyph title="">⌓</span> </td> <tr id=entity-prop><td> <code title="">prop;</code> </td> <td> U+0221D </td> <td> <span class=glyph title="">∝</span> </td> <tr id=entity-Proportion><td> <code title="">Proportion;</code> </td> <td> U+02237 </td> <td> <span class=glyph title="">∷</span> </td> <tr id=entity-Proportional><td> <code title="">Proportional;</code> </td> <td> U+0221D </td> <td> <span class=glyph title="">∝</span> </td> <tr id=entity-propto><td> <code title="">propto;</code> </td> <td> U+0221D </td> <td> <span class=glyph title="">∝</span> </td> <tr id=entity-prsim><td> <code title="">prsim;</code> </td> <td> U+0227E </td> <td> <span class=glyph title="">≾</span> </td> <tr id=entity-prurel><td> <code title="">prurel;</code> </td> <td> U+022B0 </td> <td> <span class=glyph title="">⊰</span> </td> <tr id=entity-Pscr><td> <code title="">Pscr;</code> </td> <td> U+1D4AB </td> <td> <span class=glyph title="">𝒫</span> </td> <tr id=entity-pscr><td> <code title="">pscr;</code> </td> <td> U+1D4C5 </td> <td> <span class=glyph title="">𝓅</span> </td> <tr id=entity-Psi><td> <code title="">Psi;</code> </td> <td> U+003A8 </td> <td> <span class=glyph title="">Ψ</span> </td> <tr id=entity-psi><td> <code title="">psi;</code> </td> <td> U+003C8 </td> <td> <span class=glyph title="">ψ</span> </td> <tr id=entity-puncsp><td> <code title="">puncsp;</code> </td> <td> U+02008 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-Qfr><td> <code title="">Qfr;</code> </td> <td> U+1D514 </td> <td> <span class=glyph title="">𝔔</span> </td> <tr id=entity-qfr><td> <code title="">qfr;</code> </td> <td> U+1D52E </td> <td> <span class=glyph title="">𝔮</span> </td> <tr id=entity-qint><td> <code title="">qint;</code> </td> <td> U+02A0C </td> <td> <span class=glyph title="">⨌</span> </td> <tr id=entity-Qopf><td> <code title="">Qopf;</code> </td> <td> U+0211A </td> <td> <span class=glyph title="">ℚ</span> </td> <tr id=entity-qopf><td> <code title="">qopf;</code> </td> <td> U+1D562 </td> <td> <span class=glyph title="">𝕢</span> </td> <tr id=entity-qprime><td> <code title="">qprime;</code> </td> <td> U+02057 </td> <td> <span class=glyph title="">⁗</span> </td> <tr id=entity-Qscr><td> <code title="">Qscr;</code> </td> <td> U+1D4AC </td> <td> <span class=glyph title="">𝒬</span> </td> <tr id=entity-qscr><td> <code title="">qscr;</code> </td> <td> U+1D4C6 </td> <td> <span class=glyph title="">𝓆</span> </td> <tr id=entity-quaternions><td> <code title="">quaternions;</code> </td> <td> U+0210D </td> <td> <span class=glyph title="">ℍ</span> </td> <tr id=entity-quatint><td> <code title="">quatint;</code> </td> <td> U+02A16 </td> <td> <span class=glyph title="">⨖</span> </td> <tr id=entity-quest><td> <code title="">quest;</code> </td> <td> U+0003F </td> <td> <span class=glyph title="">?</span> </td> <tr id=entity-questeq><td> <code title="">questeq;</code> </td> <td> U+0225F </td> <td> <span class=glyph title="">≟</span> </td> <tr id=entity-QUOT><td> <code title="">QUOT;</code> </td> <td> U+00022 </td> <td> <span class=glyph title="">"</span> </td> <tr class=impl id=entity-QUOT-legacy><td> <code title="">QUOT</code> </td> <td> U+00022 </td> <td> <span title="">"</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-quot><td> <code title="">quot;</code> </td> <td> U+00022 </td> <td> <span class=glyph title="">"</span> </td> <tr class=impl id=entity-quot-legacy><td> <code title="">quot</code> </td> <td> U+00022 </td> <td> <span title="">"</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-rAarr><td> <code title="">rAarr;</code> </td> <td> U+021DB </td> <td> <span class=glyph title="">⇛</span> </td> <tr id=entity-race><td> <code title="">race;</code> </td> <td> U+0223D U+00331 </td> <td> <span class="glyph compound" title="">∽̱</span> </td> <tr id=entity-Racute><td> <code title="">Racute;</code> </td> <td> U+00154 </td> <td> <span class=glyph title="">Ŕ</span> </td> <tr id=entity-racute><td> <code title="">racute;</code> </td> <td> U+00155 </td> <td> <span class=glyph title="">ŕ</span> </td> <tr id=entity-radic><td> <code title="">radic;</code> </td> <td> U+0221A </td> <td> <span class=glyph title="">√</span> </td> <tr id=entity-raemptyv><td> <code title="">raemptyv;</code> </td> <td> U+029B3 </td> <td> <span class=glyph title="">⦳</span> </td> <tr id=entity-Rang><td> <code title="">Rang;</code> </td> <td> U+027EB </td> <td> <span class=glyph title="">⟫</span> </td> <tr id=entity-rang><td> <code title="">rang;</code> </td> <td> U+027E9 </td> <td> <span class=glyph title="">⟩</span> </td> <tr id=entity-rangd><td> <code title="">rangd;</code> </td> <td> U+02992 </td> <td> <span class=glyph title="">⦒</span> </td> <tr id=entity-range><td> <code title="">range;</code> </td> <td> U+029A5 </td> <td> <span class=glyph title="">⦥</span> </td> <tr id=entity-rangle><td> <code title="">rangle;</code> </td> <td> U+027E9 </td> <td> <span class=glyph title="">⟩</span> </td> <tr id=entity-raquo><td> <code title="">raquo;</code> </td> <td> U+000BB </td> <td> <span class=glyph title="">»</span> </td> <tr class=impl id=entity-raquo-legacy><td> <code title="">raquo</code> </td> <td> U+000BB </td> <td> <span title="">»</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Rarr><td> <code title="">Rarr;</code> </td> <td> U+021A0 </td> <td> <span class=glyph title="">↠</span> </td> <tr id=entity-rArr><td> <code title="">rArr;</code> </td> <td> U+021D2 </td> <td> <span class=glyph title="">⇒</span> </td> <tr id=entity-rarr><td> <code title="">rarr;</code> </td> <td> U+02192 </td> <td> <span class=glyph title="">→</span> </td> <tr id=entity-rarrap><td> <code title="">rarrap;</code> </td> <td> U+02975 </td> <td> <span class=glyph title="">⥵</span> </td> <tr id=entity-rarrb><td> <code title="">rarrb;</code> </td> <td> U+021E5 </td> <td> <span class=glyph title="">⇥</span> </td> <tr id=entity-rarrbfs><td> <code title="">rarrbfs;</code> </td> <td> U+02920 </td> <td> <span class=glyph title="">⤠</span> </td> <tr id=entity-rarrc><td> <code title="">rarrc;</code> </td> <td> U+02933 </td> <td> <span class=glyph title="">⤳</span> </td> <tr id=entity-rarrfs><td> <code title="">rarrfs;</code> </td> <td> U+0291E </td> <td> <span class=glyph title="">⤞</span> </td> <tr id=entity-rarrhk><td> <code title="">rarrhk;</code> </td> <td> U+021AA </td> <td> <span class=glyph title="">↪</span> </td> <tr id=entity-rarrlp><td> <code title="">rarrlp;</code> </td> <td> U+021AC </td> <td> <span class=glyph title="">↬</span> </td> <tr id=entity-rarrpl><td> <code title="">rarrpl;</code> </td> <td> U+02945 </td> <td> <span class=glyph title="">⥅</span> </td> <tr id=entity-rarrsim><td> <code title="">rarrsim;</code> </td> <td> U+02974 </td> <td> <span class=glyph title="">⥴</span> </td> <tr id=entity-Rarrtl><td> <code title="">Rarrtl;</code> </td> <td> U+02916 </td> <td> <span class=glyph title="">⤖</span> </td> <tr id=entity-rarrtl><td> <code title="">rarrtl;</code> </td> <td> U+021A3 </td> <td> <span class=glyph title="">↣</span> </td> <tr id=entity-rarrw><td> <code title="">rarrw;</code> </td> <td> U+0219D </td> <td> <span class=glyph title="">↝</span> </td> <tr id=entity-rAtail><td> <code title="">rAtail;</code> </td> <td> U+0291C </td> <td> <span class=glyph title="">⤜</span> </td> <tr id=entity-ratail><td> <code title="">ratail;</code> </td> <td> U+0291A </td> <td> <span class=glyph title="">⤚</span> </td> <tr id=entity-ratio><td> <code title="">ratio;</code> </td> <td> U+02236 </td> <td> <span class=glyph title="">∶</span> </td> <tr id=entity-rationals><td> <code title="">rationals;</code> </td> <td> U+0211A </td> <td> <span class=glyph title="">ℚ</span> </td> <tr id=entity-RBarr><td> <code title="">RBarr;</code> </td> <td> U+02910 </td> <td> <span class=glyph title="">⤐</span> </td> <tr id=entity-rBarr><td> <code title="">rBarr;</code> </td> <td> U+0290F </td> <td> <span class=glyph title="">⤏</span> </td> <tr id=entity-rbarr><td> <code title="">rbarr;</code> </td> <td> U+0290D </td> <td> <span class=glyph title="">⤍</span> </td> <tr id=entity-rbbrk><td> <code title="">rbbrk;</code> </td> <td> U+02773 </td> <td> <span class=glyph title="">❳</span> </td> <tr id=entity-rbrace><td> <code title="">rbrace;</code> </td> <td> U+0007D </td> <td> <span class=glyph title="">}</span> </td> <tr id=entity-rbrack><td> <code title="">rbrack;</code> </td> <td> U+0005D </td> <td> <span class=glyph title="">]</span> </td> <tr id=entity-rbrke><td> <code title="">rbrke;</code> </td> <td> U+0298C </td> <td> <span class=glyph title="">⦌</span> </td> <tr id=entity-rbrksld><td> <code title="">rbrksld;</code> </td> <td> U+0298E </td> <td> <span class=glyph title="">⦎</span> </td> <tr id=entity-rbrkslu><td> <code title="">rbrkslu;</code> </td> <td> U+02990 </td> <td> <span class=glyph title="">⦐</span> </td> <tr id=entity-Rcaron><td> <code title="">Rcaron;</code> </td> <td> U+00158 </td> <td> <span class=glyph title="">Ř</span> </td> <tr id=entity-rcaron><td> <code title="">rcaron;</code> </td> <td> U+00159 </td> <td> <span class=glyph title="">ř</span> </td> <tr id=entity-Rcedil><td> <code title="">Rcedil;</code> </td> <td> U+00156 </td> <td> <span class=glyph title="">Ŗ</span> </td> <tr id=entity-rcedil><td> <code title="">rcedil;</code> </td> <td> U+00157 </td> <td> <span class=glyph title="">ŗ</span> </td> <tr id=entity-rceil><td> <code title="">rceil;</code> </td> <td> U+02309 </td> <td> <span class=glyph title="">⌉</span> </td> <tr id=entity-rcub><td> <code title="">rcub;</code> </td> <td> U+0007D </td> <td> <span class=glyph title="">}</span> </td> <tr id=entity-Rcy><td> <code title="">Rcy;</code> </td> <td> U+00420 </td> <td> <span class=glyph title="">Р</span> </td> <tr id=entity-rcy><td> <code title="">rcy;</code> </td> <td> U+00440 </td> <td> <span class=glyph title="">р</span> </td> <tr id=entity-rdca><td> <code title="">rdca;</code> </td> <td> U+02937 </td> <td> <span class=glyph title="">⤷</span> </td> <tr id=entity-rdldhar><td> <code title="">rdldhar;</code> </td> <td> U+02969 </td> <td> <span class=glyph title="">⥩</span> </td> <tr id=entity-rdquo><td> <code title="">rdquo;</code> </td> <td> U+0201D </td> <td> <span class=glyph title="">”</span> </td> <tr id=entity-rdquor><td> <code title="">rdquor;</code> </td> <td> U+0201D </td> <td> <span class=glyph title="">”</span> </td> <tr id=entity-rdsh><td> <code title="">rdsh;</code> </td> <td> U+021B3 </td> <td> <span class=glyph title="">↳</span> </td> <tr id=entity-Re><td> <code title="">Re;</code> </td> <td> U+0211C </td> <td> <span class=glyph title="">ℜ</span> </td> <tr id=entity-real><td> <code title="">real;</code> </td> <td> U+0211C </td> <td> <span class=glyph title="">ℜ</span> </td> <tr id=entity-realine><td> <code title="">realine;</code> </td> <td> U+0211B </td> <td> <span class=glyph title="">ℛ</span> </td> <tr id=entity-realpart><td> <code title="">realpart;</code> </td> <td> U+0211C </td> <td> <span class=glyph title="">ℜ</span> </td> <tr id=entity-reals><td> <code title="">reals;</code> </td> <td> U+0211D </td> <td> <span class=glyph title="">ℝ</span> </td> <tr id=entity-rect><td> <code title="">rect;</code> </td> <td> U+025AD </td> <td> <span class=glyph title="">▭</span> </td> <tr id=entity-REG><td> <code title="">REG;</code> </td> <td> U+000AE </td> <td> <span class=glyph title="">®</span> </td> <tr class=impl id=entity-REG-legacy><td> <code title="">REG</code> </td> <td> U+000AE </td> <td> <span title="">®</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-reg><td> <code title="">reg;</code> </td> <td> U+000AE </td> <td> <span class=glyph title="">®</span> </td> <tr class=impl id=entity-reg-legacy><td> <code title="">reg</code> </td> <td> U+000AE </td> <td> <span title="">®</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ReverseElement><td> <code title="">ReverseElement;</code> </td> <td> U+0220B </td> <td> <span class=glyph title="">∋</span> </td> <tr id=entity-ReverseEquilibrium><td> <code title="">ReverseEquilibrium;</code> </td> <td> U+021CB </td> <td> <span class=glyph title="">⇋</span> </td> <tr id=entity-ReverseUpEquilibrium><td> <code title="">ReverseUpEquilibrium;</code> </td> <td> U+0296F </td> <td> <span class=glyph title="">⥯</span> </td> <tr id=entity-rfisht><td> <code title="">rfisht;</code> </td> <td> U+0297D </td> <td> <span class=glyph title="">⥽</span> </td> <tr id=entity-rfloor><td> <code title="">rfloor;</code> </td> <td> U+0230B </td> <td> <span class=glyph title="">⌋</span> </td> <tr id=entity-Rfr><td> <code title="">Rfr;</code> </td> <td> U+0211C </td> <td> <span class=glyph title="">ℜ</span> </td> <tr id=entity-rfr><td> <code title="">rfr;</code> </td> <td> U+1D52F </td> <td> <span class=glyph title="">𝔯</span> </td> <tr id=entity-rHar><td> <code title="">rHar;</code> </td> <td> U+02964 </td> <td> <span class=glyph title="">⥤</span> </td> <tr id=entity-rhard><td> <code title="">rhard;</code> </td> <td> U+021C1 </td> <td> <span class=glyph title="">⇁</span> </td> <tr id=entity-rharu><td> <code title="">rharu;</code> </td> <td> U+021C0 </td> <td> <span class=glyph title="">⇀</span> </td> <tr id=entity-rharul><td> <code title="">rharul;</code> </td> <td> U+0296C </td> <td> <span class=glyph title="">⥬</span> </td> <tr id=entity-Rho><td> <code title="">Rho;</code> </td> <td> U+003A1 </td> <td> <span class=glyph title="">Ρ</span> </td> <tr id=entity-rho><td> <code title="">rho;</code> </td> <td> U+003C1 </td> <td> <span class=glyph title="">ρ</span> </td> <tr id=entity-rhov><td> <code title="">rhov;</code> </td> <td> U+003F1 </td> <td> <span class=glyph title="">ϱ</span> </td> <tr id=entity-RightAngleBracket><td> <code title="">RightAngleBracket;</code> </td> <td> U+027E9 </td> <td> <span class=glyph title="">⟩</span> </td> <tr id=entity-RightArrow><td> <code title="">RightArrow;</code> </td> <td> U+02192 </td> <td> <span class=glyph title="">→</span> </td> <tr id=entity-Rightarrow><td> <code title="">Rightarrow;</code> </td> <td> U+021D2 </td> <td> <span class=glyph title="">⇒</span> </td> <tr id=entity-rightarrow><td> <code title="">rightarrow;</code> </td> <td> U+02192 </td> <td> <span class=glyph title="">→</span> </td> <tr id=entity-RightArrowBar><td> <code title="">RightArrowBar;</code> </td> <td> U+021E5 </td> <td> <span class=glyph title="">⇥</span> </td> <tr id=entity-RightArrowLeftArrow><td> <code title="">RightArrowLeftArrow;</code> </td> <td> U+021C4 </td> <td> <span class=glyph title="">⇄</span> </td> <tr id=entity-rightarrowtail><td> <code title="">rightarrowtail;</code> </td> <td> U+021A3 </td> <td> <span class=glyph title="">↣</span> </td> <tr id=entity-RightCeiling><td> <code title="">RightCeiling;</code> </td> <td> U+02309 </td> <td> <span class=glyph title="">⌉</span> </td> <tr id=entity-RightDoubleBracket><td> <code title="">RightDoubleBracket;</code> </td> <td> U+027E7 </td> <td> <span class=glyph title="">⟧</span> </td> <tr id=entity-RightDownTeeVector><td> <code title="">RightDownTeeVector;</code> </td> <td> U+0295D </td> <td> <span class=glyph title="">⥝</span> </td> <tr id=entity-RightDownVector><td> <code title="">RightDownVector;</code> </td> <td> U+021C2 </td> <td> <span class=glyph title="">⇂</span> </td> <tr id=entity-RightDownVectorBar><td> <code title="">RightDownVectorBar;</code> </td> <td> U+02955 </td> <td> <span class=glyph title="">⥕</span> </td> <tr id=entity-RightFloor><td> <code title="">RightFloor;</code> </td> <td> U+0230B </td> <td> <span class=glyph title="">⌋</span> </td> <tr id=entity-rightharpoondown><td> <code title="">rightharpoondown;</code> </td> <td> U+021C1 </td> <td> <span class=glyph title="">⇁</span> </td> <tr id=entity-rightharpoonup><td> <code title="">rightharpoonup;</code> </td> <td> U+021C0 </td> <td> <span class=glyph title="">⇀</span> </td> <tr id=entity-rightleftarrows><td> <code title="">rightleftarrows;</code> </td> <td> U+021C4 </td> <td> <span class=glyph title="">⇄</span> </td> <tr id=entity-rightleftharpoons><td> <code title="">rightleftharpoons;</code> </td> <td> U+021CC </td> <td> <span class=glyph title="">⇌</span> </td> <tr id=entity-rightrightarrows><td> <code title="">rightrightarrows;</code> </td> <td> U+021C9 </td> <td> <span class=glyph title="">⇉</span> </td> <tr id=entity-rightsquigarrow><td> <code title="">rightsquigarrow;</code> </td> <td> U+0219D </td> <td> <span class=glyph title="">↝</span> </td> <tr id=entity-RightTee><td> <code title="">RightTee;</code> </td> <td> U+022A2 </td> <td> <span class=glyph title="">⊢</span> </td> <tr id=entity-RightTeeArrow><td> <code title="">RightTeeArrow;</code> </td> <td> U+021A6 </td> <td> <span class=glyph title="">↦</span> </td> <tr id=entity-RightTeeVector><td> <code title="">RightTeeVector;</code> </td> <td> U+0295B </td> <td> <span class=glyph title="">⥛</span> </td> <tr id=entity-rightthreetimes><td> <code title="">rightthreetimes;</code> </td> <td> U+022CC </td> <td> <span class=glyph title="">⋌</span> </td> <tr id=entity-RightTriangle><td> <code title="">RightTriangle;</code> </td> <td> U+022B3 </td> <td> <span class=glyph title="">⊳</span> </td> <tr id=entity-RightTriangleBar><td> <code title="">RightTriangleBar;</code> </td> <td> U+029D0 </td> <td> <span class=glyph title="">⧐</span> </td> <tr id=entity-RightTriangleEqual><td> <code title="">RightTriangleEqual;</code> </td> <td> U+022B5 </td> <td> <span class=glyph title="">⊵</span> </td> <tr id=entity-RightUpDownVector><td> <code title="">RightUpDownVector;</code> </td> <td> U+0294F </td> <td> <span class=glyph title="">⥏</span> </td> <tr id=entity-RightUpTeeVector><td> <code title="">RightUpTeeVector;</code> </td> <td> U+0295C </td> <td> <span class=glyph title="">⥜</span> </td> <tr id=entity-RightUpVector><td> <code title="">RightUpVector;</code> </td> <td> U+021BE </td> <td> <span class=glyph title="">↾</span> </td> <tr id=entity-RightUpVectorBar><td> <code title="">RightUpVectorBar;</code> </td> <td> U+02954 </td> <td> <span class=glyph title="">⥔</span> </td> <tr id=entity-RightVector><td> <code title="">RightVector;</code> </td> <td> U+021C0 </td> <td> <span class=glyph title="">⇀</span> </td> <tr id=entity-RightVectorBar><td> <code title="">RightVectorBar;</code> </td> <td> U+02953 </td> <td> <span class=glyph title="">⥓</span> </td> <tr id=entity-ring><td> <code title="">ring;</code> </td> <td> U+002DA </td> <td> <span class=glyph title="">˚</span> </td> <tr id=entity-risingdotseq><td> <code title="">risingdotseq;</code> </td> <td> U+02253 </td> <td> <span class=glyph title="">≓</span> </td> <tr id=entity-rlarr><td> <code title="">rlarr;</code> </td> <td> U+021C4 </td> <td> <span class=glyph title="">⇄</span> </td> <tr id=entity-rlhar><td> <code title="">rlhar;</code> </td> <td> U+021CC </td> <td> <span class=glyph title="">⇌</span> </td> <tr id=entity-rlm><td> <code title="">rlm;</code> </td> <td> U+0200F </td> <td> <span class=glyph title="">‏</span> </td> <tr id=entity-rmoust><td> <code title="">rmoust;</code> </td> <td> U+023B1 </td> <td> <span class=glyph title="">⎱</span> </td> <tr id=entity-rmoustache><td> <code title="">rmoustache;</code> </td> <td> U+023B1 </td> <td> <span class=glyph title="">⎱</span> </td> <tr id=entity-rnmid><td> <code title="">rnmid;</code> </td> <td> U+02AEE </td> <td> <span class=glyph title="">⫮</span> </td> <tr id=entity-roang><td> <code title="">roang;</code> </td> <td> U+027ED </td> <td> <span class=glyph title="">⟭</span> </td> <tr id=entity-roarr><td> <code title="">roarr;</code> </td> <td> U+021FE </td> <td> <span class=glyph title="">⇾</span> </td> <tr id=entity-robrk><td> <code title="">robrk;</code> </td> <td> U+027E7 </td> <td> <span class=glyph title="">⟧</span> </td> <tr id=entity-ropar><td> <code title="">ropar;</code> </td> <td> U+02986 </td> <td> <span class=glyph title="">⦆</span> </td> <tr id=entity-Ropf><td> <code title="">Ropf;</code> </td> <td> U+0211D </td> <td> <span class=glyph title="">ℝ</span> </td> <tr id=entity-ropf><td> <code title="">ropf;</code> </td> <td> U+1D563 </td> <td> <span class=glyph title="">𝕣</span> </td> <tr id=entity-roplus><td> <code title="">roplus;</code> </td> <td> U+02A2E </td> <td> <span class=glyph title="">⨮</span> </td> <tr id=entity-rotimes><td> <code title="">rotimes;</code> </td> <td> U+02A35 </td> <td> <span class=glyph title="">⨵</span> </td> <tr id=entity-RoundImplies><td> <code title="">RoundImplies;</code> </td> <td> U+02970 </td> <td> <span class=glyph title="">⥰</span> </td> <tr id=entity-rpar><td> <code title="">rpar;</code> </td> <td> U+00029 </td> <td> <span class=glyph title="">)</span> </td> <tr id=entity-rpargt><td> <code title="">rpargt;</code> </td> <td> U+02994 </td> <td> <span class=glyph title="">⦔</span> </td> <tr id=entity-rppolint><td> <code title="">rppolint;</code> </td> <td> U+02A12 </td> <td> <span class=glyph title="">⨒</span> </td> <tr id=entity-rrarr><td> <code title="">rrarr;</code> </td> <td> U+021C9 </td> <td> <span class=glyph title="">⇉</span> </td> <tr id=entity-Rrightarrow><td> <code title="">Rrightarrow;</code> </td> <td> U+021DB </td> <td> <span class=glyph title="">⇛</span> </td> <tr id=entity-rsaquo><td> <code title="">rsaquo;</code> </td> <td> U+0203A </td> <td> <span class=glyph title="">›</span> </td> <tr id=entity-Rscr><td> <code title="">Rscr;</code> </td> <td> U+0211B </td> <td> <span class=glyph title="">ℛ</span> </td> <tr id=entity-rscr><td> <code title="">rscr;</code> </td> <td> U+1D4C7 </td> <td> <span class=glyph title="">𝓇</span> </td> <tr id=entity-Rsh><td> <code title="">Rsh;</code> </td> <td> U+021B1 </td> <td> <span class=glyph title="">↱</span> </td> <tr id=entity-rsh><td> <code title="">rsh;</code> </td> <td> U+021B1 </td> <td> <span class=glyph title="">↱</span> </td> <tr id=entity-rsqb><td> <code title="">rsqb;</code> </td> <td> U+0005D </td> <td> <span class=glyph title="">]</span> </td> <tr id=entity-rsquo><td> <code title="">rsquo;</code> </td> <td> U+02019 </td> <td> <span class=glyph title="">’</span> </td> <tr id=entity-rsquor><td> <code title="">rsquor;</code> </td> <td> U+02019 </td> <td> <span class=glyph title="">’</span> </td> <tr id=entity-rthree><td> <code title="">rthree;</code> </td> <td> U+022CC </td> <td> <span class=glyph title="">⋌</span> </td> <tr id=entity-rtimes><td> <code title="">rtimes;</code> </td> <td> U+022CA </td> <td> <span class=glyph title="">⋊</span> </td> <tr id=entity-rtri><td> <code title="">rtri;</code> </td> <td> U+025B9 </td> <td> <span class=glyph title="">▹</span> </td> <tr id=entity-rtrie><td> <code title="">rtrie;</code> </td> <td> U+022B5 </td> <td> <span class=glyph title="">⊵</span> </td> <tr id=entity-rtrif><td> <code title="">rtrif;</code> </td> <td> U+025B8 </td> <td> <span class=glyph title="">▸</span> </td> <tr id=entity-rtriltri><td> <code title="">rtriltri;</code> </td> <td> U+029CE </td> <td> <span class=glyph title="">⧎</span> </td> <tr id=entity-RuleDelayed><td> <code title="">RuleDelayed;</code> </td> <td> U+029F4 </td> <td> <span class=glyph title="">⧴</span> </td> <tr id=entity-ruluhar><td> <code title="">ruluhar;</code> </td> <td> U+02968 </td> <td> <span class=glyph title="">⥨</span> </td> <tr id=entity-rx><td> <code title="">rx;</code> </td> <td> U+0211E </td> <td> <span class=glyph title="">℞</span> </td> <tr id=entity-Sacute><td> <code title="">Sacute;</code> </td> <td> U+0015A </td> <td> <span class=glyph title="">Ś</span> </td> <tr id=entity-sacute><td> <code title="">sacute;</code> </td> <td> U+0015B </td> <td> <span class=glyph title="">ś</span> </td> <tr id=entity-sbquo><td> <code title="">sbquo;</code> </td> <td> U+0201A </td> <td> <span class=glyph title="">‚</span> </td> <tr id=entity-Sc><td> <code title="">Sc;</code> </td> <td> U+02ABC </td> <td> <span class=glyph title="">⪼</span> </td> <tr id=entity-sc><td> <code title="">sc;</code> </td> <td> U+0227B </td> <td> <span class=glyph title="">≻</span> </td> <tr id=entity-scap><td> <code title="">scap;</code> </td> <td> U+02AB8 </td> <td> <span class=glyph title="">⪸</span> </td> <tr id=entity-Scaron><td> <code title="">Scaron;</code> </td> <td> U+00160 </td> <td> <span class=glyph title="">Š</span> </td> <tr id=entity-scaron><td> <code title="">scaron;</code> </td> <td> U+00161 </td> <td> <span class=glyph title="">š</span> </td> <tr id=entity-sccue><td> <code title="">sccue;</code> </td> <td> U+0227D </td> <td> <span class=glyph title="">≽</span> </td> <tr id=entity-scE><td> <code title="">scE;</code> </td> <td> U+02AB4 </td> <td> <span class=glyph title="">⪴</span> </td> <tr id=entity-sce><td> <code title="">sce;</code> </td> <td> U+02AB0 </td> <td> <span class=glyph title="">⪰</span> </td> <tr id=entity-Scedil><td> <code title="">Scedil;</code> </td> <td> U+0015E </td> <td> <span class=glyph title="">Ş</span> </td> <tr id=entity-scedil><td> <code title="">scedil;</code> </td> <td> U+0015F </td> <td> <span class=glyph title="">ş</span> </td> <tr id=entity-Scirc><td> <code title="">Scirc;</code> </td> <td> U+0015C </td> <td> <span class=glyph title="">Ŝ</span> </td> <tr id=entity-scirc><td> <code title="">scirc;</code> </td> <td> U+0015D </td> <td> <span class=glyph title="">ŝ</span> </td> <tr id=entity-scnap><td> <code title="">scnap;</code> </td> <td> U+02ABA </td> <td> <span class=glyph title="">⪺</span> </td> <tr id=entity-scnE><td> <code title="">scnE;</code> </td> <td> U+02AB6 </td> <td> <span class=glyph title="">⪶</span> </td> <tr id=entity-scnsim><td> <code title="">scnsim;</code> </td> <td> U+022E9 </td> <td> <span class=glyph title="">⋩</span> </td> <tr id=entity-scpolint><td> <code title="">scpolint;</code> </td> <td> U+02A13 </td> <td> <span class=glyph title="">⨓</span> </td> <tr id=entity-scsim><td> <code title="">scsim;</code> </td> <td> U+0227F </td> <td> <span class=glyph title="">≿</span> </td> <tr id=entity-Scy><td> <code title="">Scy;</code> </td> <td> U+00421 </td> <td> <span class=glyph title="">С</span> </td> <tr id=entity-scy><td> <code title="">scy;</code> </td> <td> U+00441 </td> <td> <span class=glyph title="">с</span> </td> <tr id=entity-sdot><td> <code title="">sdot;</code> </td> <td> U+022C5 </td> <td> <span class=glyph title="">⋅</span> </td> <tr id=entity-sdotb><td> <code title="">sdotb;</code> </td> <td> U+022A1 </td> <td> <span class=glyph title="">⊡</span> </td> <tr id=entity-sdote><td> <code title="">sdote;</code> </td> <td> U+02A66 </td> <td> <span class=glyph title="">⩦</span> </td> <tr id=entity-searhk><td> <code title="">searhk;</code> </td> <td> U+02925 </td> <td> <span class=glyph title="">⤥</span> </td> <tr id=entity-seArr><td> <code title="">seArr;</code> </td> <td> U+021D8 </td> <td> <span class=glyph title="">⇘</span> </td> <tr id=entity-searr><td> <code title="">searr;</code> </td> <td> U+02198 </td> <td> <span class=glyph title="">↘</span> </td> <tr id=entity-searrow><td> <code title="">searrow;</code> </td> <td> U+02198 </td> <td> <span class=glyph title="">↘</span> </td> <tr id=entity-sect><td> <code title="">sect;</code> </td> <td> U+000A7 </td> <td> <span class=glyph title="">§</span> </td> <tr class=impl id=entity-sect-legacy><td> <code title="">sect</code> </td> <td> U+000A7 </td> <td> <span title="">§</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-semi><td> <code title="">semi;</code> </td> <td> U+0003B </td> <td> <span class=glyph title="">;</span> </td> <tr id=entity-seswar><td> <code title="">seswar;</code> </td> <td> U+02929 </td> <td> <span class=glyph title="">⤩</span> </td> <tr id=entity-setminus><td> <code title="">setminus;</code> </td> <td> U+02216 </td> <td> <span class=glyph title="">∖</span> </td> <tr id=entity-setmn><td> <code title="">setmn;</code> </td> <td> U+02216 </td> <td> <span class=glyph title="">∖</span> </td> <tr id=entity-sext><td> <code title="">sext;</code> </td> <td> U+02736 </td> <td> <span class=glyph title="">✶</span> </td> <tr id=entity-Sfr><td> <code title="">Sfr;</code> </td> <td> U+1D516 </td> <td> <span class=glyph title="">𝔖</span> </td> <tr id=entity-sfr><td> <code title="">sfr;</code> </td> <td> U+1D530 </td> <td> <span class=glyph title="">𝔰</span> </td> <tr id=entity-sfrown><td> <code title="">sfrown;</code> </td> <td> U+02322 </td> <td> <span class=glyph title="">⌢</span> </td> <tr id=entity-sharp><td> <code title="">sharp;</code> </td> <td> U+0266F </td> <td> <span class=glyph title="">♯</span> </td> <tr id=entity-SHCHcy><td> <code title="">SHCHcy;</code> </td> <td> U+00429 </td> <td> <span class=glyph title="">Щ</span> </td> <tr id=entity-shchcy><td> <code title="">shchcy;</code> </td> <td> U+00449 </td> <td> <span class=glyph title="">щ</span> </td> <tr id=entity-SHcy><td> <code title="">SHcy;</code> </td> <td> U+00428 </td> <td> <span class=glyph title="">Ш</span> </td> <tr id=entity-shcy><td> <code title="">shcy;</code> </td> <td> U+00448 </td> <td> <span class=glyph title="">ш</span> </td> <tr id=entity-ShortDownArrow><td> <code title="">ShortDownArrow;</code> </td> <td> U+02193 </td> <td> <span class=glyph title="">↓</span> </td> <tr id=entity-ShortLeftArrow><td> <code title="">ShortLeftArrow;</code> </td> <td> U+02190 </td> <td> <span class=glyph title="">←</span> </td> <tr id=entity-shortmid><td> <code title="">shortmid;</code> </td> <td> U+02223 </td> <td> <span class=glyph title="">∣</span> </td> <tr id=entity-shortparallel><td> <code title="">shortparallel;</code> </td> <td> U+02225 </td> <td> <span class=glyph title="">∥</span> </td> <tr id=entity-ShortRightArrow><td> <code title="">ShortRightArrow;</code> </td> <td> U+02192 </td> <td> <span class=glyph title="">→</span> </td> <tr id=entity-ShortUpArrow><td> <code title="">ShortUpArrow;</code> </td> <td> U+02191 </td> <td> <span class=glyph title="">↑</span> </td> <tr id=entity-shy><td> <code title="">shy;</code> </td> <td> U+000AD </td> <td> <span class=glyph title="">­</span> </td> <tr class=impl id=entity-shy-legacy><td> <code title="">shy</code> </td> <td> U+000AD </td> <td> <span title="">­</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Sigma><td> <code title="">Sigma;</code> </td> <td> U+003A3 </td> <td> <span class=glyph title="">Σ</span> </td> <tr id=entity-sigma><td> <code title="">sigma;</code> </td> <td> U+003C3 </td> <td> <span class=glyph title="">σ</span> </td> <tr id=entity-sigmaf><td> <code title="">sigmaf;</code> </td> <td> U+003C2 </td> <td> <span class=glyph title="">ς</span> </td> <tr id=entity-sigmav><td> <code title="">sigmav;</code> </td> <td> U+003C2 </td> <td> <span class=glyph title="">ς</span> </td> <tr id=entity-sim><td> <code title="">sim;</code> </td> <td> U+0223C </td> <td> <span class=glyph title="">∼</span> </td> <tr id=entity-simdot><td> <code title="">simdot;</code> </td> <td> U+02A6A </td> <td> <span class=glyph title="">⩪</span> </td> <tr id=entity-sime><td> <code title="">sime;</code> </td> <td> U+02243 </td> <td> <span class=glyph title="">≃</span> </td> <tr id=entity-simeq><td> <code title="">simeq;</code> </td> <td> U+02243 </td> <td> <span class=glyph title="">≃</span> </td> <tr id=entity-simg><td> <code title="">simg;</code> </td> <td> U+02A9E </td> <td> <span class=glyph title="">⪞</span> </td> <tr id=entity-simgE><td> <code title="">simgE;</code> </td> <td> U+02AA0 </td> <td> <span class=glyph title="">⪠</span> </td> <tr id=entity-siml><td> <code title="">siml;</code> </td> <td> U+02A9D </td> <td> <span class=glyph title="">⪝</span> </td> <tr id=entity-simlE><td> <code title="">simlE;</code> </td> <td> U+02A9F </td> <td> <span class=glyph title="">⪟</span> </td> <tr id=entity-simne><td> <code title="">simne;</code> </td> <td> U+02246 </td> <td> <span class=glyph title="">≆</span> </td> <tr id=entity-simplus><td> <code title="">simplus;</code> </td> <td> U+02A24 </td> <td> <span class=glyph title="">⨤</span> </td> <tr id=entity-simrarr><td> <code title="">simrarr;</code> </td> <td> U+02972 </td> <td> <span class=glyph title="">⥲</span> </td> <tr id=entity-slarr><td> <code title="">slarr;</code> </td> <td> U+02190 </td> <td> <span class=glyph title="">←</span> </td> <tr id=entity-SmallCircle><td> <code title="">SmallCircle;</code> </td> <td> U+02218 </td> <td> <span class=glyph title="">∘</span> </td> <tr id=entity-smallsetminus><td> <code title="">smallsetminus;</code> </td> <td> U+02216 </td> <td> <span class=glyph title="">∖</span> </td> <tr id=entity-smashp><td> <code title="">smashp;</code> </td> <td> U+02A33 </td> <td> <span class=glyph title="">⨳</span> </td> <tr id=entity-smeparsl><td> <code title="">smeparsl;</code> </td> <td> U+029E4 </td> <td> <span class=glyph title="">⧤</span> </td> <tr id=entity-smid><td> <code title="">smid;</code> </td> <td> U+02223 </td> <td> <span class=glyph title="">∣</span> </td> <tr id=entity-smile><td> <code title="">smile;</code> </td> <td> U+02323 </td> <td> <span class=glyph title="">⌣</span> </td> <tr id=entity-smt><td> <code title="">smt;</code> </td> <td> U+02AAA </td> <td> <span class=glyph title="">⪪</span> </td> <tr id=entity-smte><td> <code title="">smte;</code> </td> <td> U+02AAC </td> <td> <span class=glyph title="">⪬</span> </td> <tr id=entity-smtes><td> <code title="">smtes;</code> </td> <td> U+02AAC U+0FE00 </td> <td> <span class="glyph compound" title="">⪬︀</span> </td> <tr id=entity-SOFTcy><td> <code title="">SOFTcy;</code> </td> <td> U+0042C </td> <td> <span class=glyph title="">Ь</span> </td> <tr id=entity-softcy><td> <code title="">softcy;</code> </td> <td> U+0044C </td> <td> <span class=glyph title="">ь</span> </td> <tr id=entity-sol><td> <code title="">sol;</code> </td> <td> U+0002F </td> <td> <span class=glyph title="">/</span> </td> <tr id=entity-solb><td> <code title="">solb;</code> </td> <td> U+029C4 </td> <td> <span class=glyph title="">⧄</span> </td> <tr id=entity-solbar><td> <code title="">solbar;</code> </td> <td> U+0233F </td> <td> <span class=glyph title="">⌿</span> </td> <tr id=entity-Sopf><td> <code title="">Sopf;</code> </td> <td> U+1D54A </td> <td> <span class=glyph title="">𝕊</span> </td> <tr id=entity-sopf><td> <code title="">sopf;</code> </td> <td> U+1D564 </td> <td> <span class=glyph title="">𝕤</span> </td> <tr id=entity-spades><td> <code title="">spades;</code> </td> <td> U+02660 </td> <td> <span class=glyph title="">♠</span> </td> <tr id=entity-spadesuit><td> <code title="">spadesuit;</code> </td> <td> U+02660 </td> <td> <span class=glyph title="">♠</span> </td> <tr id=entity-spar><td> <code title="">spar;</code> </td> <td> U+02225 </td> <td> <span class=glyph title="">∥</span> </td> <tr id=entity-sqcap><td> <code title="">sqcap;</code> </td> <td> U+02293 </td> <td> <span class=glyph title="">⊓</span> </td> <tr id=entity-sqcaps><td> <code title="">sqcaps;</code> </td> <td> U+02293 U+0FE00 </td> <td> <span class="glyph compound" title="">⊓︀</span> </td> <tr id=entity-sqcup><td> <code title="">sqcup;</code> </td> <td> U+02294 </td> <td> <span class=glyph title="">⊔</span> </td> <tr id=entity-sqcups><td> <code title="">sqcups;</code> </td> <td> U+02294 U+0FE00 </td> <td> <span class="glyph compound" title="">⊔︀</span> </td> <tr id=entity-Sqrt><td> <code title="">Sqrt;</code> </td> <td> U+0221A </td> <td> <span class=glyph title="">√</span> </td> <tr id=entity-sqsub><td> <code title="">sqsub;</code> </td> <td> U+0228F </td> <td> <span class=glyph title="">⊏</span> </td> <tr id=entity-sqsube><td> <code title="">sqsube;</code> </td> <td> U+02291 </td> <td> <span class=glyph title="">⊑</span> </td> <tr id=entity-sqsubset><td> <code title="">sqsubset;</code> </td> <td> U+0228F </td> <td> <span class=glyph title="">⊏</span> </td> <tr id=entity-sqsubseteq><td> <code title="">sqsubseteq;</code> </td> <td> U+02291 </td> <td> <span class=glyph title="">⊑</span> </td> <tr id=entity-sqsup><td> <code title="">sqsup;</code> </td> <td> U+02290 </td> <td> <span class=glyph title="">⊐</span> </td> <tr id=entity-sqsupe><td> <code title="">sqsupe;</code> </td> <td> U+02292 </td> <td> <span class=glyph title="">⊒</span> </td> <tr id=entity-sqsupset><td> <code title="">sqsupset;</code> </td> <td> U+02290 </td> <td> <span class=glyph title="">⊐</span> </td> <tr id=entity-sqsupseteq><td> <code title="">sqsupseteq;</code> </td> <td> U+02292 </td> <td> <span class=glyph title="">⊒</span> </td> <tr id=entity-squ><td> <code title="">squ;</code> </td> <td> U+025A1 </td> <td> <span class=glyph title="">□</span> </td> <tr id=entity-Square><td> <code title="">Square;</code> </td> <td> U+025A1 </td> <td> <span class=glyph title="">□</span> </td> <tr id=entity-square><td> <code title="">square;</code> </td> <td> U+025A1 </td> <td> <span class=glyph title="">□</span> </td> <tr id=entity-SquareIntersection><td> <code title="">SquareIntersection;</code> </td> <td> U+02293 </td> <td> <span class=glyph title="">⊓</span> </td> <tr id=entity-SquareSubset><td> <code title="">SquareSubset;</code> </td> <td> U+0228F </td> <td> <span class=glyph title="">⊏</span> </td> <tr id=entity-SquareSubsetEqual><td> <code title="">SquareSubsetEqual;</code> </td> <td> U+02291 </td> <td> <span class=glyph title="">⊑</span> </td> <tr id=entity-SquareSuperset><td> <code title="">SquareSuperset;</code> </td> <td> U+02290 </td> <td> <span class=glyph title="">⊐</span> </td> <tr id=entity-SquareSupersetEqual><td> <code title="">SquareSupersetEqual;</code> </td> <td> U+02292 </td> <td> <span class=glyph title="">⊒</span> </td> <tr id=entity-SquareUnion><td> <code title="">SquareUnion;</code> </td> <td> U+02294 </td> <td> <span class=glyph title="">⊔</span> </td> <tr id=entity-squarf><td> <code title="">squarf;</code> </td> <td> U+025AA </td> <td> <span class=glyph title="">▪</span> </td> <tr id=entity-squf><td> <code title="">squf;</code> </td> <td> U+025AA </td> <td> <span class=glyph title="">▪</span> </td> <tr id=entity-srarr><td> <code title="">srarr;</code> </td> <td> U+02192 </td> <td> <span class=glyph title="">→</span> </td> <tr id=entity-Sscr><td> <code title="">Sscr;</code> </td> <td> U+1D4AE </td> <td> <span class=glyph title="">𝒮</span> </td> <tr id=entity-sscr><td> <code title="">sscr;</code> </td> <td> U+1D4C8 </td> <td> <span class=glyph title="">𝓈</span> </td> <tr id=entity-ssetmn><td> <code title="">ssetmn;</code> </td> <td> U+02216 </td> <td> <span class=glyph title="">∖</span> </td> <tr id=entity-ssmile><td> <code title="">ssmile;</code> </td> <td> U+02323 </td> <td> <span class=glyph title="">⌣</span> </td> <tr id=entity-sstarf><td> <code title="">sstarf;</code> </td> <td> U+022C6 </td> <td> <span class=glyph title="">⋆</span> </td> <tr id=entity-Star><td> <code title="">Star;</code> </td> <td> U+022C6 </td> <td> <span class=glyph title="">⋆</span> </td> <tr id=entity-star><td> <code title="">star;</code> </td> <td> U+02606 </td> <td> <span class=glyph title="">☆</span> </td> <tr id=entity-starf><td> <code title="">starf;</code> </td> <td> U+02605 </td> <td> <span class=glyph title="">★</span> </td> <tr id=entity-straightepsilon><td> <code title="">straightepsilon;</code> </td> <td> U+003F5 </td> <td> <span class=glyph title="">ϵ</span> </td> <tr id=entity-straightphi><td> <code title="">straightphi;</code> </td> <td> U+003D5 </td> <td> <span class=glyph title="">ϕ</span> </td> <tr id=entity-strns><td> <code title="">strns;</code> </td> <td> U+000AF </td> <td> <span class=glyph title="">¯</span> </td> <tr id=entity-Sub><td> <code title="">Sub;</code> </td> <td> U+022D0 </td> <td> <span class=glyph title="">⋐</span> </td> <tr id=entity-sub><td> <code title="">sub;</code> </td> <td> U+02282 </td> <td> <span class=glyph title="">⊂</span> </td> <tr id=entity-subdot><td> <code title="">subdot;</code> </td> <td> U+02ABD </td> <td> <span class=glyph title="">⪽</span> </td> <tr id=entity-subE><td> <code title="">subE;</code> </td> <td> U+02AC5 </td> <td> <span class=glyph title="">⫅</span> </td> <tr id=entity-sube><td> <code title="">sube;</code> </td> <td> U+02286 </td> <td> <span class=glyph title="">⊆</span> </td> <tr id=entity-subedot><td> <code title="">subedot;</code> </td> <td> U+02AC3 </td> <td> <span class=glyph title="">⫃</span> </td> <tr id=entity-submult><td> <code title="">submult;</code> </td> <td> U+02AC1 </td> <td> <span class=glyph title="">⫁</span> </td> <tr id=entity-subnE><td> <code title="">subnE;</code> </td> <td> U+02ACB </td> <td> <span class=glyph title="">⫋</span> </td> <tr id=entity-subne><td> <code title="">subne;</code> </td> <td> U+0228A </td> <td> <span class=glyph title="">⊊</span> </td> <tr id=entity-subplus><td> <code title="">subplus;</code> </td> <td> U+02ABF </td> <td> <span class=glyph title="">⪿</span> </td> <tr id=entity-subrarr><td> <code title="">subrarr;</code> </td> <td> U+02979 </td> <td> <span class=glyph title="">⥹</span> </td> <tr id=entity-Subset><td> <code title="">Subset;</code> </td> <td> U+022D0 </td> <td> <span class=glyph title="">⋐</span> </td> <tr id=entity-subset><td> <code title="">subset;</code> </td> <td> U+02282 </td> <td> <span class=glyph title="">⊂</span> </td> <tr id=entity-subseteq><td> <code title="">subseteq;</code> </td> <td> U+02286 </td> <td> <span class=glyph title="">⊆</span> </td> <tr id=entity-subseteqq><td> <code title="">subseteqq;</code> </td> <td> U+02AC5 </td> <td> <span class=glyph title="">⫅</span> </td> <tr id=entity-SubsetEqual><td> <code title="">SubsetEqual;</code> </td> <td> U+02286 </td> <td> <span class=glyph title="">⊆</span> </td> <tr id=entity-subsetneq><td> <code title="">subsetneq;</code> </td> <td> U+0228A </td> <td> <span class=glyph title="">⊊</span> </td> <tr id=entity-subsetneqq><td> <code title="">subsetneqq;</code> </td> <td> U+02ACB </td> <td> <span class=glyph title="">⫋</span> </td> <tr id=entity-subsim><td> <code title="">subsim;</code> </td> <td> U+02AC7 </td> <td> <span class=glyph title="">⫇</span> </td> <tr id=entity-subsub><td> <code title="">subsub;</code> </td> <td> U+02AD5 </td> <td> <span class=glyph title="">⫕</span> </td> <tr id=entity-subsup><td> <code title="">subsup;</code> </td> <td> U+02AD3 </td> <td> <span class=glyph title="">⫓</span> </td> <tr id=entity-succ><td> <code title="">succ;</code> </td> <td> U+0227B </td> <td> <span class=glyph title="">≻</span> </td> <tr id=entity-succapprox><td> <code title="">succapprox;</code> </td> <td> U+02AB8 </td> <td> <span class=glyph title="">⪸</span> </td> <tr id=entity-succcurlyeq><td> <code title="">succcurlyeq;</code> </td> <td> U+0227D </td> <td> <span class=glyph title="">≽</span> </td> <tr id=entity-Succeeds><td> <code title="">Succeeds;</code> </td> <td> U+0227B </td> <td> <span class=glyph title="">≻</span> </td> <tr id=entity-SucceedsEqual><td> <code title="">SucceedsEqual;</code> </td> <td> U+02AB0 </td> <td> <span class=glyph title="">⪰</span> </td> <tr id=entity-SucceedsSlantEqual><td> <code title="">SucceedsSlantEqual;</code> </td> <td> U+0227D </td> <td> <span class=glyph title="">≽</span> </td> <tr id=entity-SucceedsTilde><td> <code title="">SucceedsTilde;</code> </td> <td> U+0227F </td> <td> <span class=glyph title="">≿</span> </td> <tr id=entity-succeq><td> <code title="">succeq;</code> </td> <td> U+02AB0 </td> <td> <span class=glyph title="">⪰</span> </td> <tr id=entity-succnapprox><td> <code title="">succnapprox;</code> </td> <td> U+02ABA </td> <td> <span class=glyph title="">⪺</span> </td> <tr id=entity-succneqq><td> <code title="">succneqq;</code> </td> <td> U+02AB6 </td> <td> <span class=glyph title="">⪶</span> </td> <tr id=entity-succnsim><td> <code title="">succnsim;</code> </td> <td> U+022E9 </td> <td> <span class=glyph title="">⋩</span> </td> <tr id=entity-succsim><td> <code title="">succsim;</code> </td> <td> U+0227F </td> <td> <span class=glyph title="">≿</span> </td> <tr id=entity-SuchThat><td> <code title="">SuchThat;</code> </td> <td> U+0220B </td> <td> <span class=glyph title="">∋</span> </td> <tr id=entity-Sum><td> <code title="">Sum;</code> </td> <td> U+02211 </td> <td> <span class=glyph title="">∑</span> </td> <tr id=entity-sum><td> <code title="">sum;</code> </td> <td> U+02211 </td> <td> <span class=glyph title="">∑</span> </td> <tr id=entity-sung><td> <code title="">sung;</code> </td> <td> U+0266A </td> <td> <span class=glyph title="">♪</span> </td> <tr id=entity-Sup><td> <code title="">Sup;</code> </td> <td> U+022D1 </td> <td> <span class=glyph title="">⋑</span> </td> <tr id=entity-sup><td> <code title="">sup;</code> </td> <td> U+02283 </td> <td> <span class=glyph title="">⊃</span> </td> <tr id=entity-sup1><td> <code title="">sup1;</code> </td> <td> U+000B9 </td> <td> <span class=glyph title="">¹</span> </td> <tr class=impl id=entity-sup1-legacy><td> <code title="">sup1</code> </td> <td> U+000B9 </td> <td> <span title="">¹</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-sup2><td> <code title="">sup2;</code> </td> <td> U+000B2 </td> <td> <span class=glyph title="">²</span> </td> <tr class=impl id=entity-sup2-legacy><td> <code title="">sup2</code> </td> <td> U+000B2 </td> <td> <span title="">²</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-sup3><td> <code title="">sup3;</code> </td> <td> U+000B3 </td> <td> <span class=glyph title="">³</span> </td> <tr class=impl id=entity-sup3-legacy><td> <code title="">sup3</code> </td> <td> U+000B3 </td> <td> <span title="">³</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-supdot><td> <code title="">supdot;</code> </td> <td> U+02ABE </td> <td> <span class=glyph title="">⪾</span> </td> <tr id=entity-supdsub><td> <code title="">supdsub;</code> </td> <td> U+02AD8 </td> <td> <span class=glyph title="">⫘</span> </td> <tr id=entity-supE><td> <code title="">supE;</code> </td> <td> U+02AC6 </td> <td> <span class=glyph title="">⫆</span> </td> <tr id=entity-supe><td> <code title="">supe;</code> </td> <td> U+02287 </td> <td> <span class=glyph title="">⊇</span> </td> <tr id=entity-supedot><td> <code title="">supedot;</code> </td> <td> U+02AC4 </td> <td> <span class=glyph title="">⫄</span> </td> <tr id=entity-Superset><td> <code title="">Superset;</code> </td> <td> U+02283 </td> <td> <span class=glyph title="">⊃</span> </td> <tr id=entity-SupersetEqual><td> <code title="">SupersetEqual;</code> </td> <td> U+02287 </td> <td> <span class=glyph title="">⊇</span> </td> <tr id=entity-suphsol><td> <code title="">suphsol;</code> </td> <td> U+027C9 </td> <td> <span class=glyph title="">⟉</span> </td> <tr id=entity-suphsub><td> <code title="">suphsub;</code> </td> <td> U+02AD7 </td> <td> <span class=glyph title="">⫗</span> </td> <tr id=entity-suplarr><td> <code title="">suplarr;</code> </td> <td> U+0297B </td> <td> <span class=glyph title="">⥻</span> </td> <tr id=entity-supmult><td> <code title="">supmult;</code> </td> <td> U+02AC2 </td> <td> <span class=glyph title="">⫂</span> </td> <tr id=entity-supnE><td> <code title="">supnE;</code> </td> <td> U+02ACC </td> <td> <span class=glyph title="">⫌</span> </td> <tr id=entity-supne><td> <code title="">supne;</code> </td> <td> U+0228B </td> <td> <span class=glyph title="">⊋</span> </td> <tr id=entity-supplus><td> <code title="">supplus;</code> </td> <td> U+02AC0 </td> <td> <span class=glyph title="">⫀</span> </td> <tr id=entity-Supset><td> <code title="">Supset;</code> </td> <td> U+022D1 </td> <td> <span class=glyph title="">⋑</span> </td> <tr id=entity-supset><td> <code title="">supset;</code> </td> <td> U+02283 </td> <td> <span class=glyph title="">⊃</span> </td> <tr id=entity-supseteq><td> <code title="">supseteq;</code> </td> <td> U+02287 </td> <td> <span class=glyph title="">⊇</span> </td> <tr id=entity-supseteqq><td> <code title="">supseteqq;</code> </td> <td> U+02AC6 </td> <td> <span class=glyph title="">⫆</span> </td> <tr id=entity-supsetneq><td> <code title="">supsetneq;</code> </td> <td> U+0228B </td> <td> <span class=glyph title="">⊋</span> </td> <tr id=entity-supsetneqq><td> <code title="">supsetneqq;</code> </td> <td> U+02ACC </td> <td> <span class=glyph title="">⫌</span> </td> <tr id=entity-supsim><td> <code title="">supsim;</code> </td> <td> U+02AC8 </td> <td> <span class=glyph title="">⫈</span> </td> <tr id=entity-supsub><td> <code title="">supsub;</code> </td> <td> U+02AD4 </td> <td> <span class=glyph title="">⫔</span> </td> <tr id=entity-supsup><td> <code title="">supsup;</code> </td> <td> U+02AD6 </td> <td> <span class=glyph title="">⫖</span> </td> <tr id=entity-swarhk><td> <code title="">swarhk;</code> </td> <td> U+02926 </td> <td> <span class=glyph title="">⤦</span> </td> <tr id=entity-swArr><td> <code title="">swArr;</code> </td> <td> U+021D9 </td> <td> <span class=glyph title="">⇙</span> </td> <tr id=entity-swarr><td> <code title="">swarr;</code> </td> <td> U+02199 </td> <td> <span class=glyph title="">↙</span> </td> <tr id=entity-swarrow><td> <code title="">swarrow;</code> </td> <td> U+02199 </td> <td> <span class=glyph title="">↙</span> </td> <tr id=entity-swnwar><td> <code title="">swnwar;</code> </td> <td> U+0292A </td> <td> <span class=glyph title="">⤪</span> </td> <tr id=entity-szlig><td> <code title="">szlig;</code> </td> <td> U+000DF </td> <td> <span class=glyph title="">ß</span> </td> <tr class=impl id=entity-szlig-legacy><td> <code title="">szlig</code> </td> <td> U+000DF </td> <td> <span title="">ß</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Tab><td> <code title="">Tab;</code> </td> <td> U+00009 </td> <td> <span class="glyph control" title="">␉</span> </td> <tr id=entity-target><td> <code title="">target;</code> </td> <td> U+02316 </td> <td> <span class=glyph title="">⌖</span> </td> <tr id=entity-Tau><td> <code title="">Tau;</code> </td> <td> U+003A4 </td> <td> <span class=glyph title="">Τ</span> </td> <tr id=entity-tau><td> <code title="">tau;</code> </td> <td> U+003C4 </td> <td> <span class=glyph title="">τ</span> </td> <tr id=entity-tbrk><td> <code title="">tbrk;</code> </td> <td> U+023B4 </td> <td> <span class=glyph title="">⎴</span> </td> <tr id=entity-Tcaron><td> <code title="">Tcaron;</code> </td> <td> U+00164 </td> <td> <span class=glyph title="">Ť</span> </td> <tr id=entity-tcaron><td> <code title="">tcaron;</code> </td> <td> U+00165 </td> <td> <span class=glyph title="">ť</span> </td> <tr id=entity-Tcedil><td> <code title="">Tcedil;</code> </td> <td> U+00162 </td> <td> <span class=glyph title="">Ţ</span> </td> <tr id=entity-tcedil><td> <code title="">tcedil;</code> </td> <td> U+00163 </td> <td> <span class=glyph title="">ţ</span> </td> <tr id=entity-Tcy><td> <code title="">Tcy;</code> </td> <td> U+00422 </td> <td> <span class=glyph title="">Т</span> </td> <tr id=entity-tcy><td> <code title="">tcy;</code> </td> <td> U+00442 </td> <td> <span class=glyph title="">т</span> </td> <tr id=entity-tdot><td> <code title="">tdot;</code> </td> <td> U+020DB </td> <td> <span class="glyph composition" title="">◌⃛</span> </td> <tr id=entity-telrec><td> <code title="">telrec;</code> </td> <td> U+02315 </td> <td> <span class=glyph title="">⌕</span> </td> <tr id=entity-Tfr><td> <code title="">Tfr;</code> </td> <td> U+1D517 </td> <td> <span class=glyph title="">𝔗</span> </td> <tr id=entity-tfr><td> <code title="">tfr;</code> </td> <td> U+1D531 </td> <td> <span class=glyph title="">𝔱</span> </td> <tr id=entity-there4><td> <code title="">there4;</code> </td> <td> U+02234 </td> <td> <span class=glyph title="">∴</span> </td> <tr id=entity-Therefore><td> <code title="">Therefore;</code> </td> <td> U+02234 </td> <td> <span class=glyph title="">∴</span> </td> <tr id=entity-therefore><td> <code title="">therefore;</code> </td> <td> U+02234 </td> <td> <span class=glyph title="">∴</span> </td> <tr id=entity-Theta><td> <code title="">Theta;</code> </td> <td> U+00398 </td> <td> <span class=glyph title="">Θ</span> </td> <tr id=entity-theta><td> <code title="">theta;</code> </td> <td> U+003B8 </td> <td> <span class=glyph title="">θ</span> </td> <tr id=entity-thetasym><td> <code title="">thetasym;</code> </td> <td> U+003D1 </td> <td> <span class=glyph title="">ϑ</span> </td> <tr id=entity-thetav><td> <code title="">thetav;</code> </td> <td> U+003D1 </td> <td> <span class=glyph title="">ϑ</span> </td> <tr id=entity-thickapprox><td> <code title="">thickapprox;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-thicksim><td> <code title="">thicksim;</code> </td> <td> U+0223C </td> <td> <span class=glyph title="">∼</span> </td> <tr id=entity-ThickSpace><td> <code title="">ThickSpace;</code> </td> <td> U+0205F U+0200A </td> <td> <span class="glyph compound" title="">  </span> </td> <tr id=entity-thinsp><td> <code title="">thinsp;</code> </td> <td> U+02009 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-ThinSpace><td> <code title="">ThinSpace;</code> </td> <td> U+02009 </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-thkap><td> <code title="">thkap;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-thksim><td> <code title="">thksim;</code> </td> <td> U+0223C </td> <td> <span class=glyph title="">∼</span> </td> <tr id=entity-THORN><td> <code title="">THORN;</code> </td> <td> U+000DE </td> <td> <span class=glyph title="">Þ</span> </td> <tr class=impl id=entity-THORN-legacy><td> <code title="">THORN</code> </td> <td> U+000DE </td> <td> <span title="">Þ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-thorn><td> <code title="">thorn;</code> </td> <td> U+000FE </td> <td> <span class=glyph title="">þ</span> </td> <tr class=impl id=entity-thorn-legacy><td> <code title="">thorn</code> </td> <td> U+000FE </td> <td> <span title="">þ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Tilde><td> <code title="">Tilde;</code> </td> <td> U+0223C </td> <td> <span class=glyph title="">∼</span> </td> <tr id=entity-tilde><td> <code title="">tilde;</code> </td> <td> U+002DC </td> <td> <span class=glyph title="">˜</span> </td> <tr id=entity-TildeEqual><td> <code title="">TildeEqual;</code> </td> <td> U+02243 </td> <td> <span class=glyph title="">≃</span> </td> <tr id=entity-TildeFullEqual><td> <code title="">TildeFullEqual;</code> </td> <td> U+02245 </td> <td> <span class=glyph title="">≅</span> </td> <tr id=entity-TildeTilde><td> <code title="">TildeTilde;</code> </td> <td> U+02248 </td> <td> <span class=glyph title="">≈</span> </td> <tr id=entity-times><td> <code title="">times;</code> </td> <td> U+000D7 </td> <td> <span class=glyph title="">×</span> </td> <tr class=impl id=entity-times-legacy><td> <code title="">times</code> </td> <td> U+000D7 </td> <td> <span title="">×</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-timesb><td> <code title="">timesb;</code> </td> <td> U+022A0 </td> <td> <span class=glyph title="">⊠</span> </td> <tr id=entity-timesbar><td> <code title="">timesbar;</code> </td> <td> U+02A31 </td> <td> <span class=glyph title="">⨱</span> </td> <tr id=entity-timesd><td> <code title="">timesd;</code> </td> <td> U+02A30 </td> <td> <span class=glyph title="">⨰</span> </td> <tr id=entity-tint><td> <code title="">tint;</code> </td> <td> U+0222D </td> <td> <span class=glyph title="">∭</span> </td> <tr id=entity-toea><td> <code title="">toea;</code> </td> <td> U+02928 </td> <td> <span class=glyph title="">⤨</span> </td> <tr id=entity-top><td> <code title="">top;</code> </td> <td> U+022A4 </td> <td> <span class=glyph title="">⊤</span> </td> <tr id=entity-topbot><td> <code title="">topbot;</code> </td> <td> U+02336 </td> <td> <span class=glyph title="">⌶</span> </td> <tr id=entity-topcir><td> <code title="">topcir;</code> </td> <td> U+02AF1 </td> <td> <span class=glyph title="">⫱</span> </td> <tr id=entity-Topf><td> <code title="">Topf;</code> </td> <td> U+1D54B </td> <td> <span class=glyph title="">𝕋</span> </td> <tr id=entity-topf><td> <code title="">topf;</code> </td> <td> U+1D565 </td> <td> <span class=glyph title="">𝕥</span> </td> <tr id=entity-topfork><td> <code title="">topfork;</code> </td> <td> U+02ADA </td> <td> <span class=glyph title="">⫚</span> </td> <tr id=entity-tosa><td> <code title="">tosa;</code> </td> <td> U+02929 </td> <td> <span class=glyph title="">⤩</span> </td> <tr id=entity-tprime><td> <code title="">tprime;</code> </td> <td> U+02034 </td> <td> <span class=glyph title="">‴</span> </td> <tr id=entity-TRADE><td> <code title="">TRADE;</code> </td> <td> U+02122 </td> <td> <span class=glyph title="">™</span> </td> <tr id=entity-trade><td> <code title="">trade;</code> </td> <td> U+02122 </td> <td> <span class=glyph title="">™</span> </td> <tr id=entity-triangle><td> <code title="">triangle;</code> </td> <td> U+025B5 </td> <td> <span class=glyph title="">▵</span> </td> <tr id=entity-triangledown><td> <code title="">triangledown;</code> </td> <td> U+025BF </td> <td> <span class=glyph title="">▿</span> </td> <tr id=entity-triangleleft><td> <code title="">triangleleft;</code> </td> <td> U+025C3 </td> <td> <span class=glyph title="">◃</span> </td> <tr id=entity-trianglelefteq><td> <code title="">trianglelefteq;</code> </td> <td> U+022B4 </td> <td> <span class=glyph title="">⊴</span> </td> <tr id=entity-triangleq><td> <code title="">triangleq;</code> </td> <td> U+0225C </td> <td> <span class=glyph title="">≜</span> </td> <tr id=entity-triangleright><td> <code title="">triangleright;</code> </td> <td> U+025B9 </td> <td> <span class=glyph title="">▹</span> </td> <tr id=entity-trianglerighteq><td> <code title="">trianglerighteq;</code> </td> <td> U+022B5 </td> <td> <span class=glyph title="">⊵</span> </td> <tr id=entity-tridot><td> <code title="">tridot;</code> </td> <td> U+025EC </td> <td> <span class=glyph title="">◬</span> </td> <tr id=entity-trie><td> <code title="">trie;</code> </td> <td> U+0225C </td> <td> <span class=glyph title="">≜</span> </td> <tr id=entity-triminus><td> <code title="">triminus;</code> </td> <td> U+02A3A </td> <td> <span class=glyph title="">⨺</span> </td> <tr id=entity-TripleDot><td> <code title="">TripleDot;</code> </td> <td> U+020DB </td> <td> <span class="glyph composition" title="">◌⃛</span> </td> <tr id=entity-triplus><td> <code title="">triplus;</code> </td> <td> U+02A39 </td> <td> <span class=glyph title="">⨹</span> </td> <tr id=entity-trisb><td> <code title="">trisb;</code> </td> <td> U+029CD </td> <td> <span class=glyph title="">⧍</span> </td> <tr id=entity-tritime><td> <code title="">tritime;</code> </td> <td> U+02A3B </td> <td> <span class=glyph title="">⨻</span> </td> <tr id=entity-trpezium><td> <code title="">trpezium;</code> </td> <td> U+023E2 </td> <td> <span class=glyph title="">⏢</span> </td> <tr id=entity-Tscr><td> <code title="">Tscr;</code> </td> <td> U+1D4AF </td> <td> <span class=glyph title="">𝒯</span> </td> <tr id=entity-tscr><td> <code title="">tscr;</code> </td> <td> U+1D4C9 </td> <td> <span class=glyph title="">𝓉</span> </td> <tr id=entity-TScy><td> <code title="">TScy;</code> </td> <td> U+00426 </td> <td> <span class=glyph title="">Ц</span> </td> <tr id=entity-tscy><td> <code title="">tscy;</code> </td> <td> U+00446 </td> <td> <span class=glyph title="">ц</span> </td> <tr id=entity-TSHcy><td> <code title="">TSHcy;</code> </td> <td> U+0040B </td> <td> <span class=glyph title="">Ћ</span> </td> <tr id=entity-tshcy><td> <code title="">tshcy;</code> </td> <td> U+0045B </td> <td> <span class=glyph title="">ћ</span> </td> <tr id=entity-Tstrok><td> <code title="">Tstrok;</code> </td> <td> U+00166 </td> <td> <span class=glyph title="">Ŧ</span> </td> <tr id=entity-tstrok><td> <code title="">tstrok;</code> </td> <td> U+00167 </td> <td> <span class=glyph title="">ŧ</span> </td> <tr id=entity-twixt><td> <code title="">twixt;</code> </td> <td> U+0226C </td> <td> <span class=glyph title="">≬</span> </td> <tr id=entity-twoheadleftarrow><td> <code title="">twoheadleftarrow;</code> </td> <td> U+0219E </td> <td> <span class=glyph title="">↞</span> </td> <tr id=entity-twoheadrightarrow><td> <code title="">twoheadrightarrow;</code> </td> <td> U+021A0 </td> <td> <span class=glyph title="">↠</span> </td> <tr id=entity-Uacute><td> <code title="">Uacute;</code> </td> <td> U+000DA </td> <td> <span class=glyph title="">Ú</span> </td> <tr class=impl id=entity-Uacute-legacy><td> <code title="">Uacute</code> </td> <td> U+000DA </td> <td> <span title="">Ú</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-uacute><td> <code title="">uacute;</code> </td> <td> U+000FA </td> <td> <span class=glyph title="">ú</span> </td> <tr class=impl id=entity-uacute-legacy><td> <code title="">uacute</code> </td> <td> U+000FA </td> <td> <span title="">ú</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Uarr><td> <code title="">Uarr;</code> </td> <td> U+0219F </td> <td> <span class=glyph title="">↟</span> </td> <tr id=entity-uArr><td> <code title="">uArr;</code> </td> <td> U+021D1 </td> <td> <span class=glyph title="">⇑</span> </td> <tr id=entity-uarr><td> <code title="">uarr;</code> </td> <td> U+02191 </td> <td> <span class=glyph title="">↑</span> </td> <tr id=entity-Uarrocir><td> <code title="">Uarrocir;</code> </td> <td> U+02949 </td> <td> <span class=glyph title="">⥉</span> </td> <tr id=entity-Ubrcy><td> <code title="">Ubrcy;</code> </td> <td> U+0040E </td> <td> <span class=glyph title="">Ў</span> </td> <tr id=entity-ubrcy><td> <code title="">ubrcy;</code> </td> <td> U+0045E </td> <td> <span class=glyph title="">ў</span> </td> <tr id=entity-Ubreve><td> <code title="">Ubreve;</code> </td> <td> U+0016C </td> <td> <span class=glyph title="">Ŭ</span> </td> <tr id=entity-ubreve><td> <code title="">ubreve;</code> </td> <td> U+0016D </td> <td> <span class=glyph title="">ŭ</span> </td> <tr id=entity-Ucirc><td> <code title="">Ucirc;</code> </td> <td> U+000DB </td> <td> <span class=glyph title="">Û</span> </td> <tr class=impl id=entity-Ucirc-legacy><td> <code title="">Ucirc</code> </td> <td> U+000DB </td> <td> <span title="">Û</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ucirc><td> <code title="">ucirc;</code> </td> <td> U+000FB </td> <td> <span class=glyph title="">û</span> </td> <tr class=impl id=entity-ucirc-legacy><td> <code title="">ucirc</code> </td> <td> U+000FB </td> <td> <span title="">û</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Ucy><td> <code title="">Ucy;</code> </td> <td> U+00423 </td> <td> <span class=glyph title="">У</span> </td> <tr id=entity-ucy><td> <code title="">ucy;</code> </td> <td> U+00443 </td> <td> <span class=glyph title="">у</span> </td> <tr id=entity-udarr><td> <code title="">udarr;</code> </td> <td> U+021C5 </td> <td> <span class=glyph title="">⇅</span> </td> <tr id=entity-Udblac><td> <code title="">Udblac;</code> </td> <td> U+00170 </td> <td> <span class=glyph title="">Ű</span> </td> <tr id=entity-udblac><td> <code title="">udblac;</code> </td> <td> U+00171 </td> <td> <span class=glyph title="">ű</span> </td> <tr id=entity-udhar><td> <code title="">udhar;</code> </td> <td> U+0296E </td> <td> <span class=glyph title="">⥮</span> </td> <tr id=entity-ufisht><td> <code title="">ufisht;</code> </td> <td> U+0297E </td> <td> <span class=glyph title="">⥾</span> </td> <tr id=entity-Ufr><td> <code title="">Ufr;</code> </td> <td> U+1D518 </td> <td> <span class=glyph title="">𝔘</span> </td> <tr id=entity-ufr><td> <code title="">ufr;</code> </td> <td> U+1D532 </td> <td> <span class=glyph title="">𝔲</span> </td> <tr id=entity-Ugrave><td> <code title="">Ugrave;</code> </td> <td> U+000D9 </td> <td> <span class=glyph title="">Ù</span> </td> <tr class=impl id=entity-Ugrave-legacy><td> <code title="">Ugrave</code> </td> <td> U+000D9 </td> <td> <span title="">Ù</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-ugrave><td> <code title="">ugrave;</code> </td> <td> U+000F9 </td> <td> <span class=glyph title="">ù</span> </td> <tr class=impl id=entity-ugrave-legacy><td> <code title="">ugrave</code> </td> <td> U+000F9 </td> <td> <span title="">ù</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-uHar><td> <code title="">uHar;</code> </td> <td> U+02963 </td> <td> <span class=glyph title="">⥣</span> </td> <tr id=entity-uharl><td> <code title="">uharl;</code> </td> <td> U+021BF </td> <td> <span class=glyph title="">↿</span> </td> <tr id=entity-uharr><td> <code title="">uharr;</code> </td> <td> U+021BE </td> <td> <span class=glyph title="">↾</span> </td> <tr id=entity-uhblk><td> <code title="">uhblk;</code> </td> <td> U+02580 </td> <td> <span class=glyph title="">▀</span> </td> <tr id=entity-ulcorn><td> <code title="">ulcorn;</code> </td> <td> U+0231C </td> <td> <span class=glyph title="">⌜</span> </td> <tr id=entity-ulcorner><td> <code title="">ulcorner;</code> </td> <td> U+0231C </td> <td> <span class=glyph title="">⌜</span> </td> <tr id=entity-ulcrop><td> <code title="">ulcrop;</code> </td> <td> U+0230F </td> <td> <span class=glyph title="">⌏</span> </td> <tr id=entity-ultri><td> <code title="">ultri;</code> </td> <td> U+025F8 </td> <td> <span class=glyph title="">◸</span> </td> <tr id=entity-Umacr><td> <code title="">Umacr;</code> </td> <td> U+0016A </td> <td> <span class=glyph title="">Ū</span> </td> <tr id=entity-umacr><td> <code title="">umacr;</code> </td> <td> U+0016B </td> <td> <span class=glyph title="">ū</span> </td> <tr id=entity-uml><td> <code title="">uml;</code> </td> <td> U+000A8 </td> <td> <span class=glyph title="">¨</span> </td> <tr class=impl id=entity-uml-legacy><td> <code title="">uml</code> </td> <td> U+000A8 </td> <td> <span title="">¨</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-UnderBar><td> <code title="">UnderBar;</code> </td> <td> U+0005F </td> <td> <span class=glyph title="">_</span> </td> <tr id=entity-UnderBrace><td> <code title="">UnderBrace;</code> </td> <td> U+023DF </td> <td> <span class=glyph title="">⏟</span> </td> <tr id=entity-UnderBracket><td> <code title="">UnderBracket;</code> </td> <td> U+023B5 </td> <td> <span class=glyph title="">⎵</span> </td> <tr id=entity-UnderParenthesis><td> <code title="">UnderParenthesis;</code> </td> <td> U+023DD </td> <td> <span class=glyph title="">⏝</span> </td> <tr id=entity-Union><td> <code title="">Union;</code> </td> <td> U+022C3 </td> <td> <span class=glyph title="">⋃</span> </td> <tr id=entity-UnionPlus><td> <code title="">UnionPlus;</code> </td> <td> U+0228E </td> <td> <span class=glyph title="">⊎</span> </td> <tr id=entity-Uogon><td> <code title="">Uogon;</code> </td> <td> U+00172 </td> <td> <span class=glyph title="">Ų</span> </td> <tr id=entity-uogon><td> <code title="">uogon;</code> </td> <td> U+00173 </td> <td> <span class=glyph title="">ų</span> </td> <tr id=entity-Uopf><td> <code title="">Uopf;</code> </td> <td> U+1D54C </td> <td> <span class=glyph title="">𝕌</span> </td> <tr id=entity-uopf><td> <code title="">uopf;</code> </td> <td> U+1D566 </td> <td> <span class=glyph title="">𝕦</span> </td> <tr id=entity-UpArrow><td> <code title="">UpArrow;</code> </td> <td> U+02191 </td> <td> <span class=glyph title="">↑</span> </td> <tr id=entity-Uparrow><td> <code title="">Uparrow;</code> </td> <td> U+021D1 </td> <td> <span class=glyph title="">⇑</span> </td> <tr id=entity-uparrow><td> <code title="">uparrow;</code> </td> <td> U+02191 </td> <td> <span class=glyph title="">↑</span> </td> <tr id=entity-UpArrowBar><td> <code title="">UpArrowBar;</code> </td> <td> U+02912 </td> <td> <span class=glyph title="">⤒</span> </td> <tr id=entity-UpArrowDownArrow><td> <code title="">UpArrowDownArrow;</code> </td> <td> U+021C5 </td> <td> <span class=glyph title="">⇅</span> </td> <tr id=entity-UpDownArrow><td> <code title="">UpDownArrow;</code> </td> <td> U+02195 </td> <td> <span class=glyph title="">↕</span> </td> <tr id=entity-Updownarrow><td> <code title="">Updownarrow;</code> </td> <td> U+021D5 </td> <td> <span class=glyph title="">⇕</span> </td> <tr id=entity-updownarrow><td> <code title="">updownarrow;</code> </td> <td> U+02195 </td> <td> <span class=glyph title="">↕</span> </td> <tr id=entity-UpEquilibrium><td> <code title="">UpEquilibrium;</code> </td> <td> U+0296E </td> <td> <span class=glyph title="">⥮</span> </td> <tr id=entity-upharpoonleft><td> <code title="">upharpoonleft;</code> </td> <td> U+021BF </td> <td> <span class=glyph title="">↿</span> </td> <tr id=entity-upharpoonright><td> <code title="">upharpoonright;</code> </td> <td> U+021BE </td> <td> <span class=glyph title="">↾</span> </td> <tr id=entity-uplus><td> <code title="">uplus;</code> </td> <td> U+0228E </td> <td> <span class=glyph title="">⊎</span> </td> <tr id=entity-UpperLeftArrow><td> <code title="">UpperLeftArrow;</code> </td> <td> U+02196 </td> <td> <span class=glyph title="">↖</span> </td> <tr id=entity-UpperRightArrow><td> <code title="">UpperRightArrow;</code> </td> <td> U+02197 </td> <td> <span class=glyph title="">↗</span> </td> <tr id=entity-Upsi><td> <code title="">Upsi;</code> </td> <td> U+003D2 </td> <td> <span class=glyph title="">ϒ</span> </td> <tr id=entity-upsi><td> <code title="">upsi;</code> </td> <td> U+003C5 </td> <td> <span class=glyph title="">υ</span> </td> <tr id=entity-upsih><td> <code title="">upsih;</code> </td> <td> U+003D2 </td> <td> <span class=glyph title="">ϒ</span> </td> <tr id=entity-Upsilon><td> <code title="">Upsilon;</code> </td> <td> U+003A5 </td> <td> <span class=glyph title="">Υ</span> </td> <tr id=entity-upsilon><td> <code title="">upsilon;</code> </td> <td> U+003C5 </td> <td> <span class=glyph title="">υ</span> </td> <tr id=entity-UpTee><td> <code title="">UpTee;</code> </td> <td> U+022A5 </td> <td> <span class=glyph title="">⊥</span> </td> <tr id=entity-UpTeeArrow><td> <code title="">UpTeeArrow;</code> </td> <td> U+021A5 </td> <td> <span class=glyph title="">↥</span> </td> <tr id=entity-upuparrows><td> <code title="">upuparrows;</code> </td> <td> U+021C8 </td> <td> <span class=glyph title="">⇈</span> </td> <tr id=entity-urcorn><td> <code title="">urcorn;</code> </td> <td> U+0231D </td> <td> <span class=glyph title="">⌝</span> </td> <tr id=entity-urcorner><td> <code title="">urcorner;</code> </td> <td> U+0231D </td> <td> <span class=glyph title="">⌝</span> </td> <tr id=entity-urcrop><td> <code title="">urcrop;</code> </td> <td> U+0230E </td> <td> <span class=glyph title="">⌎</span> </td> <tr id=entity-Uring><td> <code title="">Uring;</code> </td> <td> U+0016E </td> <td> <span class=glyph title="">Ů</span> </td> <tr id=entity-uring><td> <code title="">uring;</code> </td> <td> U+0016F </td> <td> <span class=glyph title="">ů</span> </td> <tr id=entity-urtri><td> <code title="">urtri;</code> </td> <td> U+025F9 </td> <td> <span class=glyph title="">◹</span> </td> <tr id=entity-Uscr><td> <code title="">Uscr;</code> </td> <td> U+1D4B0 </td> <td> <span class=glyph title="">𝒰</span> </td> <tr id=entity-uscr><td> <code title="">uscr;</code> </td> <td> U+1D4CA </td> <td> <span class=glyph title="">𝓊</span> </td> <tr id=entity-utdot><td> <code title="">utdot;</code> </td> <td> U+022F0 </td> <td> <span class=glyph title="">⋰</span> </td> <tr id=entity-Utilde><td> <code title="">Utilde;</code> </td> <td> U+00168 </td> <td> <span class=glyph title="">Ũ</span> </td> <tr id=entity-utilde><td> <code title="">utilde;</code> </td> <td> U+00169 </td> <td> <span class=glyph title="">ũ</span> </td> <tr id=entity-utri><td> <code title="">utri;</code> </td> <td> U+025B5 </td> <td> <span class=glyph title="">▵</span> </td> <tr id=entity-utrif><td> <code title="">utrif;</code> </td> <td> U+025B4 </td> <td> <span class=glyph title="">▴</span> </td> <tr id=entity-uuarr><td> <code title="">uuarr;</code> </td> <td> U+021C8 </td> <td> <span class=glyph title="">⇈</span> </td> <tr id=entity-Uuml><td> <code title="">Uuml;</code> </td> <td> U+000DC </td> <td> <span class=glyph title="">Ü</span> </td> <tr class=impl id=entity-Uuml-legacy><td> <code title="">Uuml</code> </td> <td> U+000DC </td> <td> <span title="">Ü</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-uuml><td> <code title="">uuml;</code> </td> <td> U+000FC </td> <td> <span class=glyph title="">ü</span> </td> <tr class=impl id=entity-uuml-legacy><td> <code title="">uuml</code> </td> <td> U+000FC </td> <td> <span title="">ü</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-uwangle><td> <code title="">uwangle;</code> </td> <td> U+029A7 </td> <td> <span class=glyph title="">⦧</span> </td> <tr id=entity-vangrt><td> <code title="">vangrt;</code> </td> <td> U+0299C </td> <td> <span class=glyph title="">⦜</span> </td> <tr id=entity-varepsilon><td> <code title="">varepsilon;</code> </td> <td> U+003F5 </td> <td> <span class=glyph title="">ϵ</span> </td> <tr id=entity-varkappa><td> <code title="">varkappa;</code> </td> <td> U+003F0 </td> <td> <span class=glyph title="">ϰ</span> </td> <tr id=entity-varnothing><td> <code title="">varnothing;</code> </td> <td> U+02205 </td> <td> <span class=glyph title="">∅</span> </td> <tr id=entity-varphi><td> <code title="">varphi;</code> </td> <td> U+003D5 </td> <td> <span class=glyph title="">ϕ</span> </td> <tr id=entity-varpi><td> <code title="">varpi;</code> </td> <td> U+003D6 </td> <td> <span class=glyph title="">ϖ</span> </td> <tr id=entity-varpropto><td> <code title="">varpropto;</code> </td> <td> U+0221D </td> <td> <span class=glyph title="">∝</span> </td> <tr id=entity-vArr><td> <code title="">vArr;</code> </td> <td> U+021D5 </td> <td> <span class=glyph title="">⇕</span> </td> <tr id=entity-varr><td> <code title="">varr;</code> </td> <td> U+02195 </td> <td> <span class=glyph title="">↕</span> </td> <tr id=entity-varrho><td> <code title="">varrho;</code> </td> <td> U+003F1 </td> <td> <span class=glyph title="">ϱ</span> </td> <tr id=entity-varsigma><td> <code title="">varsigma;</code> </td> <td> U+003C2 </td> <td> <span class=glyph title="">ς</span> </td> <tr id=entity-varsubsetneq><td> <code title="">varsubsetneq;</code> </td> <td> U+0228A U+0FE00 </td> <td> <span class="glyph compound" title="">⊊︀</span> </td> <tr id=entity-varsubsetneqq><td> <code title="">varsubsetneqq;</code> </td> <td> U+02ACB U+0FE00 </td> <td> <span class="glyph compound" title="">⫋︀</span> </td> <tr id=entity-varsupsetneq><td> <code title="">varsupsetneq;</code> </td> <td> U+0228B U+0FE00 </td> <td> <span class="glyph compound" title="">⊋︀</span> </td> <tr id=entity-varsupsetneqq><td> <code title="">varsupsetneqq;</code> </td> <td> U+02ACC U+0FE00 </td> <td> <span class="glyph compound" title="">⫌︀</span> </td> <tr id=entity-vartheta><td> <code title="">vartheta;</code> </td> <td> U+003D1 </td> <td> <span class=glyph title="">ϑ</span> </td> <tr id=entity-vartriangleleft><td> <code title="">vartriangleleft;</code> </td> <td> U+022B2 </td> <td> <span class=glyph title="">⊲</span> </td> <tr id=entity-vartriangleright><td> <code title="">vartriangleright;</code> </td> <td> U+022B3 </td> <td> <span class=glyph title="">⊳</span> </td> <tr id=entity-Vbar><td> <code title="">Vbar;</code> </td> <td> U+02AEB </td> <td> <span class=glyph title="">⫫</span> </td> <tr id=entity-vBar><td> <code title="">vBar;</code> </td> <td> U+02AE8 </td> <td> <span class=glyph title="">⫨</span> </td> <tr id=entity-vBarv><td> <code title="">vBarv;</code> </td> <td> U+02AE9 </td> <td> <span class=glyph title="">⫩</span> </td> <tr id=entity-Vcy><td> <code title="">Vcy;</code> </td> <td> U+00412 </td> <td> <span class=glyph title="">В</span> </td> <tr id=entity-vcy><td> <code title="">vcy;</code> </td> <td> U+00432 </td> <td> <span class=glyph title="">в</span> </td> <tr id=entity-VDash><td> <code title="">VDash;</code> </td> <td> U+022AB </td> <td> <span class=glyph title="">⊫</span> </td> <tr id=entity-Vdash><td> <code title="">Vdash;</code> </td> <td> U+022A9 </td> <td> <span class=glyph title="">⊩</span> </td> <tr id=entity-vDash><td> <code title="">vDash;</code> </td> <td> U+022A8 </td> <td> <span class=glyph title="">⊨</span> </td> <tr id=entity-vdash><td> <code title="">vdash;</code> </td> <td> U+022A2 </td> <td> <span class=glyph title="">⊢</span> </td> <tr id=entity-Vdashl><td> <code title="">Vdashl;</code> </td> <td> U+02AE6 </td> <td> <span class=glyph title="">⫦</span> </td> <tr id=entity-Vee><td> <code title="">Vee;</code> </td> <td> U+022C1 </td> <td> <span class=glyph title="">⋁</span> </td> <tr id=entity-vee><td> <code title="">vee;</code> </td> <td> U+02228 </td> <td> <span class=glyph title="">∨</span> </td> <tr id=entity-veebar><td> <code title="">veebar;</code> </td> <td> U+022BB </td> <td> <span class=glyph title="">⊻</span> </td> <tr id=entity-veeeq><td> <code title="">veeeq;</code> </td> <td> U+0225A </td> <td> <span class=glyph title="">≚</span> </td> <tr id=entity-vellip><td> <code title="">vellip;</code> </td> <td> U+022EE </td> <td> <span class=glyph title="">⋮</span> </td> <tr id=entity-Verbar><td> <code title="">Verbar;</code> </td> <td> U+02016 </td> <td> <span class=glyph title="">‖</span> </td> <tr id=entity-verbar><td> <code title="">verbar;</code> </td> <td> U+0007C </td> <td> <span class=glyph title="">|</span> </td> <tr id=entity-Vert><td> <code title="">Vert;</code> </td> <td> U+02016 </td> <td> <span class=glyph title="">‖</span> </td> <tr id=entity-vert><td> <code title="">vert;</code> </td> <td> U+0007C </td> <td> <span class=glyph title="">|</span> </td> <tr id=entity-VerticalBar><td> <code title="">VerticalBar;</code> </td> <td> U+02223 </td> <td> <span class=glyph title="">∣</span> </td> <tr id=entity-VerticalLine><td> <code title="">VerticalLine;</code> </td> <td> U+0007C </td> <td> <span class=glyph title="">|</span> </td> <tr id=entity-VerticalSeparator><td> <code title="">VerticalSeparator;</code> </td> <td> U+02758 </td> <td> <span class=glyph title="">❘</span> </td> <tr id=entity-VerticalTilde><td> <code title="">VerticalTilde;</code> </td> <td> U+02240 </td> <td> <span class=glyph title="">≀</span> </td> <tr id=entity-VeryThinSpace><td> <code title="">VeryThinSpace;</code> </td> <td> U+0200A </td> <td> <span class=glyph title=""> </span> </td> <tr id=entity-Vfr><td> <code title="">Vfr;</code> </td> <td> U+1D519 </td> <td> <span class=glyph title="">𝔙</span> </td> <tr id=entity-vfr><td> <code title="">vfr;</code> </td> <td> U+1D533 </td> <td> <span class=glyph title="">𝔳</span> </td> <tr id=entity-vltri><td> <code title="">vltri;</code> </td> <td> U+022B2 </td> <td> <span class=glyph title="">⊲</span> </td> <tr id=entity-vnsub><td> <code title="">vnsub;</code> </td> <td> U+02282 U+020D2 </td> <td> <span class="glyph compound" title="">⊂⃒</span> </td> <tr id=entity-vnsup><td> <code title="">vnsup;</code> </td> <td> U+02283 U+020D2 </td> <td> <span class="glyph compound" title="">⊃⃒</span> </td> <tr id=entity-Vopf><td> <code title="">Vopf;</code> </td> <td> U+1D54D </td> <td> <span class=glyph title="">𝕍</span> </td> <tr id=entity-vopf><td> <code title="">vopf;</code> </td> <td> U+1D567 </td> <td> <span class=glyph title="">𝕧</span> </td> <tr id=entity-vprop><td> <code title="">vprop;</code> </td> <td> U+0221D </td> <td> <span class=glyph title="">∝</span> </td> <tr id=entity-vrtri><td> <code title="">vrtri;</code> </td> <td> U+022B3 </td> <td> <span class=glyph title="">⊳</span> </td> <tr id=entity-Vscr><td> <code title="">Vscr;</code> </td> <td> U+1D4B1 </td> <td> <span class=glyph title="">𝒱</span> </td> <tr id=entity-vscr><td> <code title="">vscr;</code> </td> <td> U+1D4CB </td> <td> <span class=glyph title="">𝓋</span> </td> <tr id=entity-vsubnE><td> <code title="">vsubnE;</code> </td> <td> U+02ACB U+0FE00 </td> <td> <span class="glyph compound" title="">⫋︀</span> </td> <tr id=entity-vsubne><td> <code title="">vsubne;</code> </td> <td> U+0228A U+0FE00 </td> <td> <span class="glyph compound" title="">⊊︀</span> </td> <tr id=entity-vsupnE><td> <code title="">vsupnE;</code> </td> <td> U+02ACC U+0FE00 </td> <td> <span class="glyph compound" title="">⫌︀</span> </td> <tr id=entity-vsupne><td> <code title="">vsupne;</code> </td> <td> U+0228B U+0FE00 </td> <td> <span class="glyph compound" title="">⊋︀</span> </td> <tr id=entity-Vvdash><td> <code title="">Vvdash;</code> </td> <td> U+022AA </td> <td> <span class=glyph title="">⊪</span> </td> <tr id=entity-vzigzag><td> <code title="">vzigzag;</code> </td> <td> U+0299A </td> <td> <span class=glyph title="">⦚</span> </td> <tr id=entity-Wcirc><td> <code title="">Wcirc;</code> </td> <td> U+00174 </td> <td> <span class=glyph title="">Ŵ</span> </td> <tr id=entity-wcirc><td> <code title="">wcirc;</code> </td> <td> U+00175 </td> <td> <span class=glyph title="">ŵ</span> </td> <tr id=entity-wedbar><td> <code title="">wedbar;</code> </td> <td> U+02A5F </td> <td> <span class=glyph title="">⩟</span> </td> <tr id=entity-Wedge><td> <code title="">Wedge;</code> </td> <td> U+022C0 </td> <td> <span class=glyph title="">⋀</span> </td> <tr id=entity-wedge><td> <code title="">wedge;</code> </td> <td> U+02227 </td> <td> <span class=glyph title="">∧</span> </td> <tr id=entity-wedgeq><td> <code title="">wedgeq;</code> </td> <td> U+02259 </td> <td> <span class=glyph title="">≙</span> </td> <tr id=entity-weierp><td> <code title="">weierp;</code> </td> <td> U+02118 </td> <td> <span class=glyph title="">℘</span> </td> <tr id=entity-Wfr><td> <code title="">Wfr;</code> </td> <td> U+1D51A </td> <td> <span class=glyph title="">𝔚</span> </td> <tr id=entity-wfr><td> <code title="">wfr;</code> </td> <td> U+1D534 </td> <td> <span class=glyph title="">𝔴</span> </td> <tr id=entity-Wopf><td> <code title="">Wopf;</code> </td> <td> U+1D54E </td> <td> <span class=glyph title="">𝕎</span> </td> <tr id=entity-wopf><td> <code title="">wopf;</code> </td> <td> U+1D568 </td> <td> <span class=glyph title="">𝕨</span> </td> <tr id=entity-wp><td> <code title="">wp;</code> </td> <td> U+02118 </td> <td> <span class=glyph title="">℘</span> </td> <tr id=entity-wr><td> <code title="">wr;</code> </td> <td> U+02240 </td> <td> <span class=glyph title="">≀</span> </td> <tr id=entity-wreath><td> <code title="">wreath;</code> </td> <td> U+02240 </td> <td> <span class=glyph title="">≀</span> </td> <tr id=entity-Wscr><td> <code title="">Wscr;</code> </td> <td> U+1D4B2 </td> <td> <span class=glyph title="">𝒲</span> </td> <tr id=entity-wscr><td> <code title="">wscr;</code> </td> <td> U+1D4CC </td> <td> <span class=glyph title="">𝓌</span> </td> <tr id=entity-xcap><td> <code title="">xcap;</code> </td> <td> U+022C2 </td> <td> <span class=glyph title="">⋂</span> </td> <tr id=entity-xcirc><td> <code title="">xcirc;</code> </td> <td> U+025EF </td> <td> <span class=glyph title="">◯</span> </td> <tr id=entity-xcup><td> <code title="">xcup;</code> </td> <td> U+022C3 </td> <td> <span class=glyph title="">⋃</span> </td> <tr id=entity-xdtri><td> <code title="">xdtri;</code> </td> <td> U+025BD </td> <td> <span class=glyph title="">▽</span> </td> <tr id=entity-Xfr><td> <code title="">Xfr;</code> </td> <td> U+1D51B </td> <td> <span class=glyph title="">𝔛</span> </td> <tr id=entity-xfr><td> <code title="">xfr;</code> </td> <td> U+1D535 </td> <td> <span class=glyph title="">𝔵</span> </td> <tr id=entity-xhArr><td> <code title="">xhArr;</code> </td> <td> U+027FA </td> <td> <span class=glyph title="">⟺</span> </td> <tr id=entity-xharr><td> <code title="">xharr;</code> </td> <td> U+027F7 </td> <td> <span class=glyph title="">⟷</span> </td> <tr id=entity-Xi><td> <code title="">Xi;</code> </td> <td> U+0039E </td> <td> <span class=glyph title="">Ξ</span> </td> <tr id=entity-xi><td> <code title="">xi;</code> </td> <td> U+003BE </td> <td> <span class=glyph title="">ξ</span> </td> <tr id=entity-xlArr><td> <code title="">xlArr;</code> </td> <td> U+027F8 </td> <td> <span class=glyph title="">⟸</span> </td> <tr id=entity-xlarr><td> <code title="">xlarr;</code> </td> <td> U+027F5 </td> <td> <span class=glyph title="">⟵</span> </td> <tr id=entity-xmap><td> <code title="">xmap;</code> </td> <td> U+027FC </td> <td> <span class=glyph title="">⟼</span> </td> <tr id=entity-xnis><td> <code title="">xnis;</code> </td> <td> U+022FB </td> <td> <span class=glyph title="">⋻</span> </td> <tr id=entity-xodot><td> <code title="">xodot;</code> </td> <td> U+02A00 </td> <td> <span class=glyph title="">⨀</span> </td> <tr id=entity-Xopf><td> <code title="">Xopf;</code> </td> <td> U+1D54F </td> <td> <span class=glyph title="">𝕏</span> </td> <tr id=entity-xopf><td> <code title="">xopf;</code> </td> <td> U+1D569 </td> <td> <span class=glyph title="">𝕩</span> </td> <tr id=entity-xoplus><td> <code title="">xoplus;</code> </td> <td> U+02A01 </td> <td> <span class=glyph title="">⨁</span> </td> <tr id=entity-xotime><td> <code title="">xotime;</code> </td> <td> U+02A02 </td> <td> <span class=glyph title="">⨂</span> </td> <tr id=entity-xrArr><td> <code title="">xrArr;</code> </td> <td> U+027F9 </td> <td> <span class=glyph title="">⟹</span> </td> <tr id=entity-xrarr><td> <code title="">xrarr;</code> </td> <td> U+027F6 </td> <td> <span class=glyph title="">⟶</span> </td> <tr id=entity-Xscr><td> <code title="">Xscr;</code> </td> <td> U+1D4B3 </td> <td> <span class=glyph title="">𝒳</span> </td> <tr id=entity-xscr><td> <code title="">xscr;</code> </td> <td> U+1D4CD </td> <td> <span class=glyph title="">𝓍</span> </td> <tr id=entity-xsqcup><td> <code title="">xsqcup;</code> </td> <td> U+02A06 </td> <td> <span class=glyph title="">⨆</span> </td> <tr id=entity-xuplus><td> <code title="">xuplus;</code> </td> <td> U+02A04 </td> <td> <span class=glyph title="">⨄</span> </td> <tr id=entity-xutri><td> <code title="">xutri;</code> </td> <td> U+025B3 </td> <td> <span class=glyph title="">△</span> </td> <tr id=entity-xvee><td> <code title="">xvee;</code> </td> <td> U+022C1 </td> <td> <span class=glyph title="">⋁</span> </td> <tr id=entity-xwedge><td> <code title="">xwedge;</code> </td> <td> U+022C0 </td> <td> <span class=glyph title="">⋀</span> </td> <tr id=entity-Yacute><td> <code title="">Yacute;</code> </td> <td> U+000DD </td> <td> <span class=glyph title="">Ý</span> </td> <tr class=impl id=entity-Yacute-legacy><td> <code title="">Yacute</code> </td> <td> U+000DD </td> <td> <span title="">Ý</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-yacute><td> <code title="">yacute;</code> </td> <td> U+000FD </td> <td> <span class=glyph title="">ý</span> </td> <tr class=impl id=entity-yacute-legacy><td> <code title="">yacute</code> </td> <td> U+000FD </td> <td> <span title="">ý</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-YAcy><td> <code title="">YAcy;</code> </td> <td> U+0042F </td> <td> <span class=glyph title="">Я</span> </td> <tr id=entity-yacy><td> <code title="">yacy;</code> </td> <td> U+0044F </td> <td> <span class=glyph title="">я</span> </td> <tr id=entity-Ycirc><td> <code title="">Ycirc;</code> </td> <td> U+00176 </td> <td> <span class=glyph title="">Ŷ</span> </td> <tr id=entity-ycirc><td> <code title="">ycirc;</code> </td> <td> U+00177 </td> <td> <span class=glyph title="">ŷ</span> </td> <tr id=entity-Ycy><td> <code title="">Ycy;</code> </td> <td> U+0042B </td> <td> <span class=glyph title="">Ы</span> </td> <tr id=entity-ycy><td> <code title="">ycy;</code> </td> <td> U+0044B </td> <td> <span class=glyph title="">ы</span> </td> <tr id=entity-yen><td> <code title="">yen;</code> </td> <td> U+000A5 </td> <td> <span class=glyph title="">¥</span> </td> <tr class=impl id=entity-yen-legacy><td> <code title="">yen</code> </td> <td> U+000A5 </td> <td> <span title="">¥</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Yfr><td> <code title="">Yfr;</code> </td> <td> U+1D51C </td> <td> <span class=glyph title="">𝔜</span> </td> <tr id=entity-yfr><td> <code title="">yfr;</code> </td> <td> U+1D536 </td> <td> <span class=glyph title="">𝔶</span> </td> <tr id=entity-YIcy><td> <code title="">YIcy;</code> </td> <td> U+00407 </td> <td> <span class=glyph title="">Ї</span> </td> <tr id=entity-yicy><td> <code title="">yicy;</code> </td> <td> U+00457 </td> <td> <span class=glyph title="">ї</span> </td> <tr id=entity-Yopf><td> <code title="">Yopf;</code> </td> <td> U+1D550 </td> <td> <span class=glyph title="">𝕐</span> </td> <tr id=entity-yopf><td> <code title="">yopf;</code> </td> <td> U+1D56A </td> <td> <span class=glyph title="">𝕪</span> </td> <tr id=entity-Yscr><td> <code title="">Yscr;</code> </td> <td> U+1D4B4 </td> <td> <span class=glyph title="">𝒴</span> </td> <tr id=entity-yscr><td> <code title="">yscr;</code> </td> <td> U+1D4CE </td> <td> <span class=glyph title="">𝓎</span> </td> <tr id=entity-YUcy><td> <code title="">YUcy;</code> </td> <td> U+0042E </td> <td> <span class=glyph title="">Ю</span> </td> <tr id=entity-yucy><td> <code title="">yucy;</code> </td> <td> U+0044E </td> <td> <span class=glyph title="">ю</span> </td> <tr id=entity-Yuml><td> <code title="">Yuml;</code> </td> <td> U+00178 </td> <td> <span class=glyph title="">Ÿ</span> </td> <tr id=entity-yuml><td> <code title="">yuml;</code> </td> <td> U+000FF </td> <td> <span class=glyph title="">ÿ</span> </td> <tr class=impl id=entity-yuml-legacy><td> <code title="">yuml</code> </td> <td> U+000FF </td> <td> <span title="">ÿ</span> </td> </tr><!-- (invalid entity with missing semicolon for legacy support only) --><tr id=entity-Zacute><td> <code title="">Zacute;</code> </td> <td> U+00179 </td> <td> <span class=glyph title="">Ź</span> </td> <tr id=entity-zacute><td> <code title="">zacute;</code> </td> <td> U+0017A </td> <td> <span class=glyph title="">ź</span> </td> <tr id=entity-Zcaron><td> <code title="">Zcaron;</code> </td> <td> U+0017D </td> <td> <span class=glyph title="">Ž</span> </td> <tr id=entity-zcaron><td> <code title="">zcaron;</code> </td> <td> U+0017E </td> <td> <span class=glyph title="">ž</span> </td> <tr id=entity-Zcy><td> <code title="">Zcy;</code> </td> <td> U+00417 </td> <td> <span class=glyph title="">З</span> </td> <tr id=entity-zcy><td> <code title="">zcy;</code> </td> <td> U+00437 </td> <td> <span class=glyph title="">з</span> </td> <tr id=entity-Zdot><td> <code title="">Zdot;</code> </td> <td> U+0017B </td> <td> <span class=glyph title="">Ż</span> </td> <tr id=entity-zdot><td> <code title="">zdot;</code> </td> <td> U+0017C </td> <td> <span class=glyph title="">ż</span> </td> <tr id=entity-zeetrf><td> <code title="">zeetrf;</code> </td> <td> U+02128 </td> <td> <span class=glyph title="">ℨ</span> </td> <tr id=entity-ZeroWidthSpace><td> <code title="">ZeroWidthSpace;</code> </td> <td> U+0200B </td> <td> <span class=glyph title="">​</span> </td> <tr id=entity-Zeta><td> <code title="">Zeta;</code> </td> <td> U+00396 </td> <td> <span class=glyph title="">Ζ</span> </td> <tr id=entity-zeta><td> <code title="">zeta;</code> </td> <td> U+003B6 </td> <td> <span class=glyph title="">ζ</span> </td> <tr id=entity-Zfr><td> <code title="">Zfr;</code> </td> <td> U+02128 </td> <td> <span class=glyph title="">ℨ</span> </td> <tr id=entity-zfr><td> <code title="">zfr;</code> </td> <td> U+1D537 </td> <td> <span class=glyph title="">𝔷</span> </td> <tr id=entity-ZHcy><td> <code title="">ZHcy;</code> </td> <td> U+00416 </td> <td> <span class=glyph title="">Ж</span> </td> <tr id=entity-zhcy><td> <code title="">zhcy;</code> </td> <td> U+00436 </td> <td> <span class=glyph title="">ж</span> </td> <tr id=entity-zigrarr><td> <code title="">zigrarr;</code> </td> <td> U+021DD </td> <td> <span class=glyph title="">⇝</span> </td> <tr id=entity-Zopf><td> <code title="">Zopf;</code> </td> <td> U+02124 </td> <td> <span class=glyph title="">ℤ</span> </td> <tr id=entity-zopf><td> <code title="">zopf;</code> </td> <td> U+1D56B </td> <td> <span class=glyph title="">𝕫</span> </td> <tr id=entity-Zscr><td> <code title="">Zscr;</code> </td> <td> U+1D4B5 </td> <td> <span class=glyph title="">𝒵</span> </td> <tr id=entity-zscr><td> <code title="">zscr;</code> </td> <td> U+1D4CF </td> <td> <span class=glyph title="">𝓏</span> </td> <tr id=entity-zwj><td> <code title="">zwj;</code> </td> <td> U+0200D </td> <td> <span class=glyph title="">‍</span> </td> <tr id=entity-zwnj><td> <code title="">zwnj;</code> </td> <td> U+0200C </td> <td> <span class=glyph title="">‌</span> </td> </table><!-- If we want to add character references, Almorca suggests: > I would add &sub1; (character U+2081), &sub2; > (character U+2082) and &sub3; (character U+2083). They > would are the equivalent to ¹, ², and ³. See also: http://www.w3.org/2003/entities/ --></div> <p><i>The glyphs displayed above are non-normative. Refer to the Unicode specifications for formal definitions of the characters listed above.</i></p> <h2 id=the-xhtml-syntax><span class=secno>14 </span><dfn id=xhtml>The XHTML syntax</dfn></h2> <p class=note>This section only describes the rules for XML resources. Rules for <code><a href=#text/html>text/html</a></code> resources are discussed in the section above entitled "<a href=#syntax>The HTML syntax</a>".</p> <div class=impl> <h3 id=writing-xhtml-documents><span class=secno>14.1 </span>Writing XHTML documents</h3> </div> <p>The syntax for using HTML with XML, whether in XHTML documents or embedded in other XML documents, 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 format 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 entity references for characters in XHTML documents is unsafe if they are defined in an external file (except for <code title="">&lt;</code>, <code title="">&gt;</code>, <code title="">&amp;</code>, <code title="">&quot;</code> and <code title="">&apos;</code>).</p> <div class=impl> <h3 id=parsing-xhtml-documents><span class=secno>14.2 </span>Parsing XHTML documents</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>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><a href=#document>Document</a></code> object.</p> <p>An <a href=#xml-parser>XML parser</a> is either associated with a <code><a href=#document>Document</a></code> object when it is created, or creates one implicitly.</p> <p>This <code><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 DOM Core specification. DOM mutation events must not fire for the operations that the <a href=#xml-parser>XML parser</a> performs on the <code><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. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a> <a href=#refsDOMCORE>[DOMCORE]</a> <a href=#refsDOMEVENTS>[DOMEVENTS]</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>stack of open elements</a>.</p> <p class=note>This is used by the <code><a href=#the-object-element>object</a></code> element to avoid instantiating plugins before the <code><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%2BPCFFTlRJVFkgcGVyY250ICImI3gyNTsiPjwhRU5USVRZIGFtcCAiJiN4MjY7Ij48IUVOVElUWSBBTVAgIiYjeDI2OyI%2BPCFFTlRJVFkgYXBvcyAiJiN4Mjc7Ij48IUVOVElUWSBscGFyICImI3gyODsiPjwhRU5USVRZIHJwYXIgIiYjeDI5OyI%2BPCFFTlRJVFkgYXN0ICImI3gyQTsiPjwhRU5USVRZIG1pZGFzdCAiJiN4MkE7Ij48IUVOVElUWSBwbHVzICImI3gyQjsiPjwhRU5USVRZIGNvbW1hICImI3gyQzsiPjwhRU5USVRZIHBlcmlvZCAiJiN4MkU7Ij48IUVOVElUWSBzb2wgIiYjeDJGOyI%2BPCFFTlRJVFkgY29sb24gIiYjeDNBOyI%2BPCFFTlRJVFkgc2VtaSAiJiN4M0I7Ij48IUVOVElUWSBsdCAiJiN4M0M7Ij48IUVOVElUWSBMVCAiJiN4M0M7Ij48IUVOVElUWSBudmx0ICImI3gzQzsmI3gyMEQyOyI%2BPCFFTlRJVFkgZXF1YWxzICImI3gzRDsiPjwhRU5USVRZIGJuZSAiJiN4M0Q7JiN4MjBFNTsiPjwhRU5USVRZIGd0ICImI3gzRTsiPjwhRU5USVRZIEdUICImI3gzRTsiPjwhRU5USVRZIG52Z3QgIiYjeDNFOyYjeDIwRDI7Ij48IUVOVElUWSBxdWVzdCAiJiN4M0Y7Ij48IUVOVElUWSBjb21tYXQgIiYjeDQwOyI%2BPCFFTlRJVFkgbHNxYiAiJiN4NUI7Ij48IUVOVElUWSBsYnJhY2sgIiYjeDVCOyI%2BPCFFTlRJVFkgYnNvbCAiJiN4NUM7Ij48IUVOVElUWSByc3FiICImI3g1RDsiPjwhRU5USVRZIHJicmFjayAiJiN4NUQ7Ij48IUVOVElUWSBIYXQgIiYjeDVFOyI%2BPCFFTlRJVFkgbG93YmFyICImI3g1RjsiPjwhRU5USVRZIFVuZGVyQmFyICImI3g1RjsiPjwhRU5USVRZIGdyYXZlICImI3g2MDsiPjwhRU5USVRZIERpYWNyaXRpY2FsR3JhdmUgIiYjeDYwOyI%2BPCFFTlRJVFkgZmpsaWcgIiYjeDY2OyYjeDZBOyI%2BPCFFTlRJVFkgbGN1YiAiJiN4N0I7Ij48IUVOVElUWSBsYnJhY2UgIiYjeDdCOyI%2BPCFFTlRJVFkgdmVyYmFyICImI3g3QzsiPjwhRU5USVRZIHZlcnQgIiYjeDdDOyI%2BPCFFTlRJVFkgVmVydGljYWxMaW5lICImI3g3QzsiPjwhRU5USVRZIHJjdWIgIiYjeDdEOyI%2BPCFFTlRJVFkgcmJyYWNlICImI3g3RDsiPjwhRU5USVRZIG5ic3AgIiYjeEEwOyI%2BPCFFTlRJVFkgTm9uQnJlYWtpbmdTcGFjZSAiJiN4QTA7Ij48IUVOVElUWSBpZXhjbCAiJiN4QTE7Ij48IUVOVElUWSBjZW50ICImI3hBMjsiPjwhRU5USVRZIHBvdW5kICImI3hBMzsiPjwhRU5USVRZIGN1cnJlbiAiJiN4QTQ7Ij48IUVOVElUWSB5ZW4gIiYjeEE1OyI%2BPCFFTlRJVFkgYnJ2YmFyICImI3hBNjsiPjwhRU5USVRZIHNlY3QgIiYjeEE3OyI%2BPCFFTlRJVFkgRG90ICImI3hBODsiPjwhRU5USVRZIGRpZSAiJiN4QTg7Ij48IUVOVElUWSBEb3VibGVEb3QgIiYjeEE4OyI%2BPCFFTlRJVFkgdW1sICImI3hBODsiPjwhRU5USVRZIGNvcHkgIiYjeEE5OyI%2BPCFFTlRJVFkgQ09QWSAiJiN4QTk7Ij48IUVOVElUWSBvcmRmICImI3hBQTsiPjwhRU5USVRZIGxhcXVvICImI3hBQjsiPjwhRU5USVRZIG5vdCAiJiN4QUM7Ij48IUVOVElUWSBzaHkgIiYjeEFEOyI%2BPCFFTlRJVFkgcmVnICImI3hBRTsiPjwhRU5USVRZIGNpcmNsZWRSICImI3hBRTsiPjwhRU5USVRZIFJFRyAiJiN4QUU7Ij48IUVOVElUWSBtYWNyICImI3hBRjsiPjwhRU5USVRZIHN0cm5zICImI3hBRjsiPjwhRU5USVRZIGRlZyAiJiN4QjA7Ij48IUVOVElUWSBwbHVzbW4gIiYjeEIxOyI%2BPCFFTlRJVFkgcG0gIiYjeEIxOyI%2BPCFFTlRJVFkgUGx1c01pbnVzICImI3hCMTsiPjwhRU5USVRZIHN1cDIgIiYjeEIyOyI%2BPCFFTlRJVFkgc3VwMyAiJiN4QjM7Ij48IUVOVElUWSBhY3V0ZSAiJiN4QjQ7Ij48IUVOVElUWSBEaWFjcml0aWNhbEFjdXRlICImI3hCNDsiPjwhRU5USVRZIG1pY3JvICImI3hCNTsiPjwhRU5USVRZIHBhcmEgIiYjeEI2OyI%2BPCFFTlRJVFkgbWlkZG90ICImI3hCNzsiPjwhRU5USVRZIGNlbnRlcmRvdCAiJiN4Qjc7Ij48IUVOVElUWSBDZW50ZXJEb3QgIiYjeEI3OyI%2BPCFFTlRJVFkgY2VkaWwgIiYjeEI4OyI%2BPCFFTlRJVFkgQ2VkaWxsYSAiJiN4Qjg7Ij48IUVOVElUWSBzdXAxICImI3hCOTsiPjwhRU5USVRZIG9yZG0gIiYjeEJBOyI%2BPCFFTlRJVFkgcmFxdW8gIiYjeEJCOyI%2BPCFFTlRJVFkgZnJhYzE0ICImI3hCQzsiPjwhRU5USVRZIGZyYWMxMiAiJiN4QkQ7Ij48IUVOVElUWSBoYWxmICImI3hCRDsiPjwhRU5USVRZIGZyYWMzNCAiJiN4QkU7Ij48IUVOVElUWSBpcXVlc3QgIiYjeEJGOyI%2BPCFFTlRJVFkgQWdyYXZlICImI3hDMDsiPjwhRU5USVRZIEFhY3V0ZSAiJiN4QzE7Ij48IUVOVElUWSBBY2lyYyAiJiN4QzI7Ij48IUVOVElUWSBBdGlsZGUgIiYjeEMzOyI%2BPCFFTlRJVFkgQXVtbCAiJiN4QzQ7Ij48IUVOVElUWSBBcmluZyAiJiN4QzU7Ij48IUVOVElUWSBhbmdzdCAiJiN4QzU7Ij48IUVOVElUWSBBRWxpZyAiJiN4QzY7Ij48IUVOVElUWSBDY2VkaWwgIiYjeEM3OyI%2BPCFFTlRJVFkgRWdyYXZlICImI3hDODsiPjwhRU5USVRZIEVhY3V0ZSAiJiN4Qzk7Ij48IUVOVElUWSBFY2lyYyAiJiN4Q0E7Ij48IUVOVElUWSBFdW1sICImI3hDQjsiPjwhRU5USVRZIElncmF2ZSAiJiN4Q0M7Ij48IUVOVElUWSBJYWN1dGUgIiYjeENEOyI%2BPCFFTlRJVFkgSWNpcmMgIiYjeENFOyI%2BPCFFTlRJVFkgSXVtbCAiJiN4Q0Y7Ij48IUVOVElUWSBFVEggIiYjeEQwOyI%2BPCFFTlRJVFkgTnRpbGRlICImI3hEMTsiPjwhRU5USVRZIE9ncmF2ZSAiJiN4RDI7Ij48IUVOVElUWSBPYWN1dGUgIiYjeEQzOyI%2BPCFFTlRJVFkgT2NpcmMgIiYjeEQ0OyI%2BPCFFTlRJVFkgT3RpbGRlICImI3hENTsiPjwhRU5USVRZIE91bWwgIiYjeEQ2OyI%2BPCFFTlRJVFkgdGltZXMgIiYjeEQ3OyI%2BPCFFTlRJVFkgT3NsYXNoICImI3hEODsiPjwhRU5USVRZIFVncmF2ZSAiJiN4RDk7Ij48IUVOVElUWSBVYWN1dGUgIiYjeERBOyI%2BPCFFTlRJVFkgVWNpcmMgIiYjeERCOyI%2BPCFFTlRJVFkgVXVtbCAiJiN4REM7Ij48IUVOVElUWSBZYWN1dGUgIiYjeEREOyI%2BPCFFTlRJVFkgVEhPUk4gIiYjeERFOyI%2BPCFFTlRJVFkgc3psaWcgIiYjeERGOyI%2BPCFFTlRJVFkgYWdyYXZlICImI3hFMDsiPjwhRU5USVRZIGFhY3V0ZSAiJiN4RTE7Ij48IUVOVElUWSBhY2lyYyAiJiN4RTI7Ij48IUVOVElUWSBhdGlsZGUgIiYjeEUzOyI%2BPCFFTlRJVFkgYXVtbCAiJiN4RTQ7Ij48IUVOVElUWSBhcmluZyAiJiN4RTU7Ij48IUVOVElUWSBhZWxpZyAiJiN4RTY7Ij48IUVOVElUWSBjY2VkaWwgIiYjeEU3OyI%2BPCFFTlRJVFkgZWdyYXZlICImI3hFODsiPjwhRU5USVRZIGVhY3V0ZSAiJiN4RTk7Ij48IUVOVElUWSBlY2lyYyAiJiN4RUE7Ij48IUVOVElUWSBldW1sICImI3hFQjsiPjwhRU5USVRZIGlncmF2ZSAiJiN4RUM7Ij48IUVOVElUWSBpYWN1dGUgIiYjeEVEOyI%2BPCFFTlRJVFkgaWNpcmMgIiYjeEVFOyI%2BPCFFTlRJVFkgaXVtbCAiJiN4RUY7Ij48IUVOVElUWSBldGggIiYjeEYwOyI%2BPCFFTlRJVFkgbnRpbGRlICImI3hGMTsiPjwhRU5USVRZIG9ncmF2ZSAiJiN4RjI7Ij48IUVOVElUWSBvYWN1dGUgIiYjeEYzOyI%2BPCFFTlRJVFkgb2NpcmMgIiYjeEY0OyI%2BPCFFTlRJVFkgb3RpbGRlICImI3hGNTsiPjwhRU5USVRZIG91bWwgIiYjeEY2OyI%2BPCFFTlRJVFkgZGl2aWRlICImI3hGNzsiPjwhRU5USVRZIGRpdiAiJiN4Rjc7Ij48IUVOVElUWSBvc2xhc2ggIiYjeEY4OyI%2BPCFFTlRJVFkgdWdyYXZlICImI3hGOTsiPjwhRU5USVRZIHVhY3V0ZSAiJiN4RkE7Ij48IUVOVElUWSB1Y2lyYyAiJiN4RkI7Ij48IUVOVElUWSB1dW1sICImI3hGQzsiPjwhRU5USVRZIHlhY3V0ZSAiJiN4RkQ7Ij48IUVOVElUWSB0aG9ybiAiJiN4RkU7Ij48IUVOVElUWSB5dW1sICImI3hGRjsiPjwhRU5USVRZIEFtYWNyICImI3gxMDA7Ij48IUVOVElUWSBhbWFjciAiJiN4MTAxOyI%2BPCFFTlRJVFkgQWJyZXZlICImI3gxMDI7Ij48IUVOVElUWSBhYnJldmUgIiYjeDEwMzsiPjwhRU5USVRZIEFvZ29uICImI3gxMDQ7Ij48IUVOVElUWSBhb2dvbiAiJiN4MTA1OyI%2BPCFFTlRJVFkgQ2FjdXRlICImI3gxMDY7Ij48IUVOVElUWSBjYWN1dGUgIiYjeDEwNzsiPjwhRU5USVRZIENjaXJjICImI3gxMDg7Ij48IUVOVElUWSBjY2lyYyAiJiN4MTA5OyI%2BPCFFTlRJVFkgQ2RvdCAiJiN4MTBBOyI%2BPCFFTlRJVFkgY2RvdCAiJiN4MTBCOyI%2BPCFFTlRJVFkgQ2Nhcm9uICImI3gxMEM7Ij48IUVOVElUWSBjY2Fyb24gIiYjeDEwRDsiPjwhRU5USVRZIERjYXJvbiAiJiN4MTBFOyI%2BPCFFTlRJVFkgZGNhcm9uICImI3gxMEY7Ij48IUVOVElUWSBEc3Ryb2sgIiYjeDExMDsiPjwhRU5USVRZIGRzdHJvayAiJiN4MTExOyI%2BPCFFTlRJVFkgRW1hY3IgIiYjeDExMjsiPjwhRU5USVRZIGVtYWNyICImI3gxMTM7Ij48IUVOVElUWSBFZG90ICImI3gxMTY7Ij48IUVOVElUWSBlZG90ICImI3gxMTc7Ij48IUVOVElUWSBFb2dvbiAiJiN4MTE4OyI%2BPCFFTlRJVFkgZW9nb24gIiYjeDExOTsiPjwhRU5USVRZIEVjYXJvbiAiJiN4MTFBOyI%2BPCFFTlRJVFkgZWNhcm9uICImI3gxMUI7Ij48IUVOVElUWSBHY2lyYyAiJiN4MTFDOyI%2BPCFFTlRJVFkgZ2NpcmMgIiYjeDExRDsiPjwhRU5USVRZIEdicmV2ZSAiJiN4MTFFOyI%2BPCFFTlRJVFkgZ2JyZXZlICImI3gxMUY7Ij48IUVOVElUWSBHZG90ICImI3gxMjA7Ij48IUVOVElUWSBnZG90ICImI3gxMjE7Ij48IUVOVElUWSBHY2VkaWwgIiYjeDEyMjsiPjwhRU5USVRZIEhjaXJjICImI3gxMjQ7Ij48IUVOVElUWSBoY2lyYyAiJiN4MTI1OyI%2BPCFFTlRJVFkgSHN0cm9rICImI3gxMjY7Ij48IUVOVElUWSBoc3Ryb2sgIiYjeDEyNzsiPjwhRU5USVRZIEl0aWxkZSAiJiN4MTI4OyI%2BPCFFTlRJVFkgaXRpbGRlICImI3gxMjk7Ij48IUVOVElUWSBJbWFjciAiJiN4MTJBOyI%2BPCFFTlRJVFkgaW1hY3IgIiYjeDEyQjsiPjwhRU5USVRZIElvZ29uICImI3gxMkU7Ij48IUVOVElUWSBpb2dvbiAiJiN4MTJGOyI%2BPCFFTlRJVFkgSWRvdCAiJiN4MTMwOyI%2BPCFFTlRJVFkgaW1hdGggIiYjeDEzMTsiPjwhRU5USVRZIGlub2RvdCAiJiN4MTMxOyI%2BPCFFTlRJVFkgSUpsaWcgIiYjeDEzMjsiPjwhRU5USVRZIGlqbGlnICImI3gxMzM7Ij48IUVOVElUWSBKY2lyYyAiJiN4MTM0OyI%2BPCFFTlRJVFkgamNpcmMgIiYjeDEzNTsiPjwhRU5USVRZIEtjZWRpbCAiJiN4MTM2OyI%2BPCFFTlRJVFkga2NlZGlsICImI3gxMzc7Ij48IUVOVElUWSBrZ3JlZW4gIiYjeDEzODsiPjwhRU5USVRZIExhY3V0ZSAiJiN4MTM5OyI%2BPCFFTlRJVFkgbGFjdXRlICImI3gxM0E7Ij48IUVOVElUWSBMY2VkaWwgIiYjeDEzQjsiPjwhRU5USVRZIGxjZWRpbCAiJiN4MTNDOyI%2BPCFFTlRJVFkgTGNhcm9uICImI3gxM0Q7Ij48IUVOVElUWSBsY2Fyb24gIiYjeDEzRTsiPjwhRU5USVRZIExtaWRvdCAiJiN4MTNGOyI%2BPCFFTlRJVFkgbG1pZG90ICImI3gxNDA7Ij48IUVOVElUWSBMc3Ryb2sgIiYjeDE0MTsiPjwhRU5USVRZIGxzdHJvayAiJiN4MTQyOyI%2BPCFFTlRJVFkgTmFjdXRlICImI3gxNDM7Ij48IUVOVElUWSBuYWN1dGUgIiYjeDE0NDsiPjwhRU5USVRZIE5jZWRpbCAiJiN4MTQ1OyI%2BPCFFTlRJVFkgbmNlZGlsICImI3gxNDY7Ij48IUVOVElUWSBOY2Fyb24gIiYjeDE0NzsiPjwhRU5USVRZIG5jYXJvbiAiJiN4MTQ4OyI%2BPCFFTlRJVFkgbmFwb3MgIiYjeDE0OTsiPjwhRU5USVRZIEVORyAiJiN4MTRBOyI%2BPCFFTlRJVFkgZW5nICImI3gxNEI7Ij48IUVOVElUWSBPbWFjciAiJiN4MTRDOyI%2BPCFFTlRJVFkgb21hY3IgIiYjeDE0RDsiPjwhRU5USVRZIE9kYmxhYyAiJiN4MTUwOyI%2BPCFFTlRJVFkgb2RibGFjICImI3gxNTE7Ij48IUVOVElUWSBPRWxpZyAiJiN4MTUyOyI%2BPCFFTlRJVFkgb2VsaWcgIiYjeDE1MzsiPjwhRU5USVRZIFJhY3V0ZSAiJiN4MTU0OyI%2BPCFFTlRJVFkgcmFjdXRlICImI3gxNTU7Ij48IUVOVElUWSBSY2VkaWwgIiYjeDE1NjsiPjwhRU5USVRZIHJjZWRpbCAiJiN4MTU3OyI%2BPCFFTlRJVFkgUmNhcm9uICImI3gxNTg7Ij48IUVOVElUWSByY2Fyb24gIiYjeDE1OTsiPjwhRU5USVRZIFNhY3V0ZSAiJiN4MTVBOyI%2BPCFFTlRJVFkgc2FjdXRlICImI3gxNUI7Ij48IUVOVElUWSBTY2lyYyAiJiN4MTVDOyI%2BPCFFTlRJVFkgc2NpcmMgIiYjeDE1RDsiPjwhRU5USVRZIFNjZWRpbCAiJiN4MTVFOyI%2BPCFFTlRJVFkgc2NlZGlsICImI3gxNUY7Ij48IUVOVElUWSBTY2Fyb24gIiYjeDE2MDsiPjwhRU5USVRZIHNjYXJvbiAiJiN4MTYxOyI%2BPCFFTlRJVFkgVGNlZGlsICImI3gxNjI7Ij48IUVOVElUWSB0Y2VkaWwgIiYjeDE2MzsiPjwhRU5USVRZIFRjYXJvbiAiJiN4MTY0OyI%2BPCFFTlRJVFkgdGNhcm9uICImI3gxNjU7Ij48IUVOVElUWSBUc3Ryb2sgIiYjeDE2NjsiPjwhRU5USVRZIHRzdHJvayAiJiN4MTY3OyI%2BPCFFTlRJVFkgVXRpbGRlICImI3gxNjg7Ij48IUVOVElUWSB1dGlsZGUgIiYjeDE2OTsiPjwhRU5USVRZIFVtYWNyICImI3gxNkE7Ij48IUVOVElUWSB1bWFjciAiJiN4MTZCOyI%2BPCFFTlRJVFkgVWJyZXZlICImI3gxNkM7Ij48IUVOVElUWSB1YnJldmUgIiYjeDE2RDsiPjwhRU5USVRZIFVyaW5nICImI3gxNkU7Ij48IUVOVElUWSB1cmluZyAiJiN4MTZGOyI%2BPCFFTlRJVFkgVWRibGFjICImI3gxNzA7Ij48IUVOVElUWSB1ZGJsYWMgIiYjeDE3MTsiPjwhRU5USVRZIFVvZ29uICImI3gxNzI7Ij48IUVOVElUWSB1b2dvbiAiJiN4MTczOyI%2BPCFFTlRJVFkgV2NpcmMgIiYjeDE3NDsiPjwhRU5USVRZIHdjaXJjICImI3gxNzU7Ij48IUVOVElUWSBZY2lyYyAiJiN4MTc2OyI%2BPCFFTlRJVFkgeWNpcmMgIiYjeDE3NzsiPjwhRU5USVRZIFl1bWwgIiYjeDE3ODsiPjwhRU5USVRZIFphY3V0ZSAiJiN4MTc5OyI%2BPCFFTlRJVFkgemFjdXRlICImI3gxN0E7Ij48IUVOVElUWSBaZG90ICImI3gxN0I7Ij48IUVOVElUWSB6ZG90ICImI3gxN0M7Ij48IUVOVElUWSBaY2Fyb24gIiYjeDE3RDsiPjwhRU5USVRZIHpjYXJvbiAiJiN4MTdFOyI%2BPCFFTlRJVFkgZm5vZiAiJiN4MTkyOyI%2BPCFFTlRJVFkgaW1wZWQgIiYjeDFCNTsiPjwhRU5USVRZIGdhY3V0ZSAiJiN4MUY1OyI%2BPCFFTlRJVFkgam1hdGggIiYjeDIzNzsiPjwhRU5USVRZIGNpcmMgIiYjeDJDNjsiPjwhRU5USVRZIGNhcm9uICImI3gyQzc7Ij48IUVOVElUWSBIYWNlayAiJiN4MkM3OyI%2BPCFFTlRJVFkgYnJldmUgIiYjeDJEODsiPjwhRU5USVRZIEJyZXZlICImI3gyRDg7Ij48IUVOVElUWSBkb3QgIiYjeDJEOTsiPjwhRU5USVRZIERpYWNyaXRpY2FsRG90ICImI3gyRDk7Ij48IUVOVElUWSByaW5nICImI3gyREE7Ij48IUVOVElUWSBvZ29uICImI3gyREI7Ij48IUVOVElUWSB0aWxkZSAiJiN4MkRDOyI%2BPCFFTlRJVFkgRGlhY3JpdGljYWxUaWxkZSAiJiN4MkRDOyI%2BPCFFTlRJVFkgZGJsYWMgIiYjeDJERDsiPjwhRU5USVRZIERpYWNyaXRpY2FsRG91YmxlQWN1dGUgIiYjeDJERDsiPjwhRU5USVRZIERvd25CcmV2ZSAiJiN4MzExOyI%2BPCFFTlRJVFkgQWxwaGEgIiYjeDM5MTsiPjwhRU5USVRZIEJldGEgIiYjeDM5MjsiPjwhRU5USVRZIEdhbW1hICImI3gzOTM7Ij48IUVOVElUWSBEZWx0YSAiJiN4Mzk0OyI%2BPCFFTlRJVFkgRXBzaWxvbiAiJiN4Mzk1OyI%2BPCFFTlRJVFkgWmV0YSAiJiN4Mzk2OyI%2BPCFFTlRJVFkgRXRhICImI3gzOTc7Ij48IUVOVElUWSBUaGV0YSAiJiN4Mzk4OyI%2BPCFFTlRJVFkgSW90YSAiJiN4Mzk5OyI%2BPCFFTlRJVFkgS2FwcGEgIiYjeDM5QTsiPjwhRU5USVRZIExhbWJkYSAiJiN4MzlCOyI%2BPCFFTlRJVFkgTXUgIiYjeDM5QzsiPjwhRU5USVRZIE51ICImI3gzOUQ7Ij48IUVOVElUWSBYaSAiJiN4MzlFOyI%2BPCFFTlRJVFkgT21pY3JvbiAiJiN4MzlGOyI%2BPCFFTlRJVFkgUGkgIiYjeDNBMDsiPjwhRU5USVRZIFJobyAiJiN4M0ExOyI%2BPCFFTlRJVFkgU2lnbWEgIiYjeDNBMzsiPjwhRU5USVRZIFRhdSAiJiN4M0E0OyI%2BPCFFTlRJVFkgVXBzaWxvbiAiJiN4M0E1OyI%2BPCFFTlRJVFkgUGhpICImI3gzQTY7Ij48IUVOVElUWSBDaGkgIiYjeDNBNzsiPjwhRU5USVRZIFBzaSAiJiN4M0E4OyI%2BPCFFTlRJVFkgT21lZ2EgIiYjeDNBOTsiPjwhRU5USVRZIG9obSAiJiN4M0E5OyI%2BPCFFTlRJVFkgYWxwaGEgIiYjeDNCMTsiPjwhRU5USVRZIGJldGEgIiYjeDNCMjsiPjwhRU5USVRZIGdhbW1hICImI3gzQjM7Ij48IUVOVElUWSBkZWx0YSAiJiN4M0I0OyI%2BPCFFTlRJVFkgZXBzaSAiJiN4M0I1OyI%2BPCFFTlRJVFkgZXBzaWxvbiAiJiN4M0I1OyI%2BPCFFTlRJVFkgemV0YSAiJiN4M0I2OyI%2BPCFFTlRJVFkgZXRhICImI3gzQjc7Ij48IUVOVElUWSB0aGV0YSAiJiN4M0I4OyI%2BPCFFTlRJVFkgaW90YSAiJiN4M0I5OyI%2BPCFFTlRJVFkga2FwcGEgIiYjeDNCQTsiPjwhRU5USVRZIGxhbWJkYSAiJiN4M0JCOyI%2BPCFFTlRJVFkgbXUgIiYjeDNCQzsiPjwhRU5USVRZIG51ICImI3gzQkQ7Ij48IUVOVElUWSB4aSAiJiN4M0JFOyI%2BPCFFTlRJVFkgb21pY3JvbiAiJiN4M0JGOyI%2BPCFFTlRJVFkgcGkgIiYjeDNDMDsiPjwhRU5USVRZIHJobyAiJiN4M0MxOyI%2BPCFFTlRJVFkgc2lnbWF2ICImI3gzQzI7Ij48IUVOVElUWSB2YXJzaWdtYSAiJiN4M0MyOyI%2BPCFFTlRJVFkgc2lnbWFmICImI3gzQzI7Ij48IUVOVElUWSBzaWdtYSAiJiN4M0MzOyI%2BPCFFTlRJVFkgdGF1ICImI3gzQzQ7Ij48IUVOVElUWSB1cHNpICImI3gzQzU7Ij48IUVOVElUWSB1cHNpbG9uICImI3gzQzU7Ij48IUVOVElUWSBwaGkgIiYjeDNDNjsiPjwhRU5USVRZIGNoaSAiJiN4M0M3OyI%2BPCFFTlRJVFkgcHNpICImI3gzQzg7Ij48IUVOVElUWSBvbWVnYSAiJiN4M0M5OyI%2BPCFFTlRJVFkgdGhldGF2ICImI3gzRDE7Ij48IUVOVElUWSB2YXJ0aGV0YSAiJiN4M0QxOyI%2BPCFFTlRJVFkgdGhldGFzeW0gIiYjeDNEMTsiPjwhRU5USVRZIFVwc2kgIiYjeDNEMjsiPjwhRU5USVRZIHVwc2loICImI3gzRDI7Ij48IUVOVElUWSBzdHJhaWdodHBoaSAiJiN4M0Q1OyI%2BPCFFTlRJVFkgcGhpdiAiJiN4M0Q1OyI%2BPCFFTlRJVFkgdmFycGhpICImI3gzRDU7Ij48IUVOVElUWSBwaXYgIiYjeDNENjsiPjwhRU5USVRZIHZhcnBpICImI3gzRDY7Ij48IUVOVElUWSBHYW1tYWQgIiYjeDNEQzsiPjwhRU5USVRZIGdhbW1hZCAiJiN4M0REOyI%2BPCFFTlRJVFkgZGlnYW1tYSAiJiN4M0REOyI%2BPCFFTlRJVFkga2FwcGF2ICImI3gzRjA7Ij48IUVOVElUWSB2YXJrYXBwYSAiJiN4M0YwOyI%2BPCFFTlRJVFkgcmhvdiAiJiN4M0YxOyI%2BPCFFTlRJVFkgdmFycmhvICImI3gzRjE7Ij48IUVOVElUWSBlcHNpdiAiJiN4M0Y1OyI%2BPCFFTlRJVFkgc3RyYWlnaHRlcHNpbG9uICImI3gzRjU7Ij48IUVOVElUWSB2YXJlcHNpbG9uICImI3gzRjU7Ij48IUVOVElUWSBiZXBzaSAiJiN4M0Y2OyI%2BPCFFTlRJVFkgYmFja2Vwc2lsb24gIiYjeDNGNjsiPjwhRU5USVRZIElPY3kgIiYjeDQwMTsiPjwhRU5USVRZIERKY3kgIiYjeDQwMjsiPjwhRU5USVRZIEdKY3kgIiYjeDQwMzsiPjwhRU5USVRZIEp1a2N5ICImI3g0MDQ7Ij48IUVOVElUWSBEU2N5ICImI3g0MDU7Ij48IUVOVElUWSBJdWtjeSAiJiN4NDA2OyI%2BPCFFTlRJVFkgWUljeSAiJiN4NDA3OyI%2BPCFFTlRJVFkgSnNlcmN5ICImI3g0MDg7Ij48IUVOVElUWSBMSmN5ICImI3g0MDk7Ij48IUVOVElUWSBOSmN5ICImI3g0MEE7Ij48IUVOVElUWSBUU0hjeSAiJiN4NDBCOyI%2BPCFFTlRJVFkgS0pjeSAiJiN4NDBDOyI%2BPCFFTlRJVFkgVWJyY3kgIiYjeDQwRTsiPjwhRU5USVRZIERaY3kgIiYjeDQwRjsiPjwhRU5USVRZIEFjeSAiJiN4NDEwOyI%2BPCFFTlRJVFkgQmN5ICImI3g0MTE7Ij48IUVOVElUWSBWY3kgIiYjeDQxMjsiPjwhRU5USVRZIEdjeSAiJiN4NDEzOyI%2BPCFFTlRJVFkgRGN5ICImI3g0MTQ7Ij48IUVOVElUWSBJRWN5ICImI3g0MTU7Ij48IUVOVElUWSBaSGN5ICImI3g0MTY7Ij48IUVOVElUWSBaY3kgIiYjeDQxNzsiPjwhRU5USVRZIEljeSAiJiN4NDE4OyI%2BPCFFTlRJVFkgSmN5ICImI3g0MTk7Ij48IUVOVElUWSBLY3kgIiYjeDQxQTsiPjwhRU5USVRZIExjeSAiJiN4NDFCOyI%2BPCFFTlRJVFkgTWN5ICImI3g0MUM7Ij48IUVOVElUWSBOY3kgIiYjeDQxRDsiPjwhRU5USVRZIE9jeSAiJiN4NDFFOyI%2BPCFFTlRJVFkgUGN5ICImI3g0MUY7Ij48IUVOVElUWSBSY3kgIiYjeDQyMDsiPjwhRU5USVRZIFNjeSAiJiN4NDIxOyI%2BPCFFTlRJVFkgVGN5ICImI3g0MjI7Ij48IUVOVElUWSBVY3kgIiYjeDQyMzsiPjwhRU5USVRZIEZjeSAiJiN4NDI0OyI%2BPCFFTlRJVFkgS0hjeSAiJiN4NDI1OyI%2BPCFFTlRJVFkgVFNjeSAiJiN4NDI2OyI%2BPCFFTlRJVFkgQ0hjeSAiJiN4NDI3OyI%2BPCFFTlRJVFkgU0hjeSAiJiN4NDI4OyI%2BPCFFTlRJVFkgU0hDSGN5ICImI3g0Mjk7Ij48IUVOVElUWSBIQVJEY3kgIiYjeDQyQTsiPjwhRU5USVRZIFljeSAiJiN4NDJCOyI%2BPCFFTlRJVFkgU09GVGN5ICImI3g0MkM7Ij48IUVOVElUWSBFY3kgIiYjeDQyRDsiPjwhRU5USVRZIFlVY3kgIiYjeDQyRTsiPjwhRU5USVRZIFlBY3kgIiYjeDQyRjsiPjwhRU5USVRZIGFjeSAiJiN4NDMwOyI%2BPCFFTlRJVFkgYmN5ICImI3g0MzE7Ij48IUVOVElUWSB2Y3kgIiYjeDQzMjsiPjwhRU5USVRZIGdjeSAiJiN4NDMzOyI%2BPCFFTlRJVFkgZGN5ICImI3g0MzQ7Ij48IUVOVElUWSBpZWN5ICImI3g0MzU7Ij48IUVOVElUWSB6aGN5ICImI3g0MzY7Ij48IUVOVElUWSB6Y3kgIiYjeDQzNzsiPjwhRU5USVRZIGljeSAiJiN4NDM4OyI%2BPCFFTlRJVFkgamN5ICImI3g0Mzk7Ij48IUVOVElUWSBrY3kgIiYjeDQzQTsiPjwhRU5USVRZIGxjeSAiJiN4NDNCOyI%2BPCFFTlRJVFkgbWN5ICImI3g0M0M7Ij48IUVOVElUWSBuY3kgIiYjeDQzRDsiPjwhRU5USVRZIG9jeSAiJiN4NDNFOyI%2BPCFFTlRJVFkgcGN5ICImI3g0M0Y7Ij48IUVOVElUWSByY3kgIiYjeDQ0MDsiPjwhRU5USVRZIHNjeSAiJiN4NDQxOyI%2BPCFFTlRJVFkgdGN5ICImI3g0NDI7Ij48IUVOVElUWSB1Y3kgIiYjeDQ0MzsiPjwhRU5USVRZIGZjeSAiJiN4NDQ0OyI%2BPCFFTlRJVFkga2hjeSAiJiN4NDQ1OyI%2BPCFFTlRJVFkgdHNjeSAiJiN4NDQ2OyI%2BPCFFTlRJVFkgY2hjeSAiJiN4NDQ3OyI%2BPCFFTlRJVFkgc2hjeSAiJiN4NDQ4OyI%2BPCFFTlRJVFkgc2hjaGN5ICImI3g0NDk7Ij48IUVOVElUWSBoYXJkY3kgIiYjeDQ0QTsiPjwhRU5USVRZIHljeSAiJiN4NDRCOyI%2BPCFFTlRJVFkgc29mdGN5ICImI3g0NEM7Ij48IUVOVElUWSBlY3kgIiYjeDQ0RDsiPjwhRU5USVRZIHl1Y3kgIiYjeDQ0RTsiPjwhRU5USVRZIHlhY3kgIiYjeDQ0RjsiPjwhRU5USVRZIGlvY3kgIiYjeDQ1MTsiPjwhRU5USVRZIGRqY3kgIiYjeDQ1MjsiPjwhRU5USVRZIGdqY3kgIiYjeDQ1MzsiPjwhRU5USVRZIGp1a2N5ICImI3g0NTQ7Ij48IUVOVElUWSBkc2N5ICImI3g0NTU7Ij48IUVOVElUWSBpdWtjeSAiJiN4NDU2OyI%2BPCFFTlRJVFkgeWljeSAiJiN4NDU3OyI%2BPCFFTlRJVFkganNlcmN5ICImI3g0NTg7Ij48IUVOVElUWSBsamN5ICImI3g0NTk7Ij48IUVOVElUWSBuamN5ICImI3g0NUE7Ij48IUVOVElUWSB0c2hjeSAiJiN4NDVCOyI%2BPCFFTlRJVFkga2pjeSAiJiN4NDVDOyI%2BPCFFTlRJVFkgdWJyY3kgIiYjeDQ1RTsiPjwhRU5USVRZIGR6Y3kgIiYjeDQ1RjsiPjwhRU5USVRZIGVuc3AgIiYjeDIwMDI7Ij48IUVOVElUWSBlbXNwICImI3gyMDAzOyI%2BPCFFTlRJVFkgZW1zcDEzICImI3gyMDA0OyI%2BPCFFTlRJVFkgZW1zcDE0ICImI3gyMDA1OyI%2BPCFFTlRJVFkgbnVtc3AgIiYjeDIwMDc7Ij48IUVOVElUWSBwdW5jc3AgIiYjeDIwMDg7Ij48IUVOVElUWSB0aGluc3AgIiYjeDIwMDk7Ij48IUVOVElUWSBUaGluU3BhY2UgIiYjeDIwMDk7Ij48IUVOVElUWSBoYWlyc3AgIiYjeDIwMEE7Ij48IUVOVElUWSBWZXJ5VGhpblNwYWNlICImI3gyMDBBOyI%2BPCFFTlRJVFkgWmVyb1dpZHRoU3BhY2UgIiYjeDIwMEI7Ij48IUVOVElUWSBOZWdhdGl2ZVZlcnlUaGluU3BhY2UgIiYjeDIwMEI7Ij48IUVOVElUWSBOZWdhdGl2ZVRoaW5TcGFjZSAiJiN4MjAwQjsiPjwhRU5USVRZIE5lZ2F0aXZlTWVkaXVtU3BhY2UgIiYjeDIwMEI7Ij48IUVOVElUWSBOZWdhdGl2ZVRoaWNrU3BhY2UgIiYjeDIwMEI7Ij48IUVOVElUWSB6d25qICImI3gyMDBDOyI%2BPCFFTlRJVFkgendqICImI3gyMDBEOyI%2BPCFFTlRJVFkgbHJtICImI3gyMDBFOyI%2BPCFFTlRJVFkgcmxtICImI3gyMDBGOyI%2BPCFFTlRJVFkgaHlwaGVuICImI3gyMDEwOyI%2BPCFFTlRJVFkgZGFzaCAiJiN4MjAxMDsiPjwhRU5USVRZIG5kYXNoICImI3gyMDEzOyI%2BPCFFTlRJVFkgbWRhc2ggIiYjeDIwMTQ7Ij48IUVOVElUWSBob3JiYXIgIiYjeDIwMTU7Ij48IUVOVElUWSBWZXJiYXIgIiYjeDIwMTY7Ij48IUVOVElUWSBWZXJ0ICImI3gyMDE2OyI%2BPCFFTlRJVFkgbHNxdW8gIiYjeDIwMTg7Ij48IUVOVElUWSBPcGVuQ3VybHlRdW90ZSAiJiN4MjAxODsiPjwhRU5USVRZIHJzcXVvICImI3gyMDE5OyI%2BPCFFTlRJVFkgcnNxdW9yICImI3gyMDE5OyI%2BPCFFTlRJVFkgQ2xvc2VDdXJseVF1b3RlICImI3gyMDE5OyI%2BPCFFTlRJVFkgbHNxdW9yICImI3gyMDFBOyI%2BPCFFTlRJVFkgc2JxdW8gIiYjeDIwMUE7Ij48IUVOVElUWSBsZHF1byAiJiN4MjAxQzsiPjwhRU5USVRZIE9wZW5DdXJseURvdWJsZVF1b3RlICImI3gyMDFDOyI%2BPCFFTlRJVFkgcmRxdW8gIiYjeDIwMUQ7Ij48IUVOVElUWSByZHF1b3IgIiYjeDIwMUQ7Ij48IUVOVElUWSBDbG9zZUN1cmx5RG91YmxlUXVvdGUgIiYjeDIwMUQ7Ij48IUVOVElUWSBsZHF1b3IgIiYjeDIwMUU7Ij48IUVOVElUWSBiZHF1byAiJiN4MjAxRTsiPjwhRU5USVRZIGRhZ2dlciAiJiN4MjAyMDsiPjwhRU5USVRZIERhZ2dlciAiJiN4MjAyMTsiPjwhRU5USVRZIGRkYWdnZXIgIiYjeDIwMjE7Ij48IUVOVElUWSBidWxsICImI3gyMDIyOyI%2BPCFFTlRJVFkgYnVsbGV0ICImI3gyMDIyOyI%2BPCFFTlRJVFkgbmxkciAiJiN4MjAyNTsiPjwhRU5USVRZIGhlbGxpcCAiJiN4MjAyNjsiPjwhRU5USVRZIG1sZHIgIiYjeDIwMjY7Ij48IUVOVElUWSBwZXJtaWwgIiYjeDIwMzA7Ij48IUVOVElUWSBwZXJ0ZW5rICImI3gyMDMxOyI%2BPCFFTlRJVFkgcHJpbWUgIiYjeDIwMzI7Ij48IUVOVElUWSBQcmltZSAiJiN4MjAzMzsiPjwhRU5USVRZIHRwcmltZSAiJiN4MjAzNDsiPjwhRU5USVRZIGJwcmltZSAiJiN4MjAzNTsiPjwhRU5USVRZIGJhY2twcmltZSAiJiN4MjAzNTsiPjwhRU5USVRZIGxzYXF1byAiJiN4MjAzOTsiPjwhRU5USVRZIHJzYXF1byAiJiN4MjAzQTsiPjwhRU5USVRZIG9saW5lICImI3gyMDNFOyI%2BPCFFTlRJVFkgT3ZlckJhciAiJiN4MjAzRTsiPjwhRU5USVRZIGNhcmV0ICImI3gyMDQxOyI%2BPCFFTlRJVFkgaHlidWxsICImI3gyMDQzOyI%2BPCFFTlRJVFkgZnJhc2wgIiYjeDIwNDQ7Ij48IUVOVElUWSBic2VtaSAiJiN4MjA0RjsiPjwhRU5USVRZIHFwcmltZSAiJiN4MjA1NzsiPjwhRU5USVRZIE1lZGl1bVNwYWNlICImI3gyMDVGOyI%2BPCFFTlRJVFkgVGhpY2tTcGFjZSAiJiN4MjA1RjsmI3gyMDBBOyI%2BPCFFTlRJVFkgTm9CcmVhayAiJiN4MjA2MDsiPjwhRU5USVRZIEFwcGx5RnVuY3Rpb24gIiYjeDIwNjE7Ij48IUVOVElUWSBhZiAiJiN4MjA2MTsiPjwhRU5USVRZIEludmlzaWJsZVRpbWVzICImI3gyMDYyOyI%2BPCFFTlRJVFkgaXQgIiYjeDIwNjI7Ij48IUVOVElUWSBJbnZpc2libGVDb21tYSAiJiN4MjA2MzsiPjwhRU5USVRZIGljICImI3gyMDYzOyI%2BPCFFTlRJVFkgZXVybyAiJiN4MjBBQzsiPjwhRU5USVRZIHRkb3QgIiYjeDIwREI7Ij48IUVOVElUWSBUcmlwbGVEb3QgIiYjeDIwREI7Ij48IUVOVElUWSBEb3REb3QgIiYjeDIwREM7Ij48IUVOVElUWSBDb3BmICImI3gyMTAyOyI%2BPCFFTlRJVFkgY29tcGxleGVzICImI3gyMTAyOyI%2BPCFFTlRJVFkgaW5jYXJlICImI3gyMTA1OyI%2BPCFFTlRJVFkgZ3NjciAiJiN4MjEwQTsiPjwhRU5USVRZIGhhbWlsdCAiJiN4MjEwQjsiPjwhRU5USVRZIEhpbGJlcnRTcGFjZSAiJiN4MjEwQjsiPjwhRU5USVRZIEhzY3IgIiYjeDIxMEI7Ij48IUVOVElUWSBIZnIgIiYjeDIxMEM7Ij48IUVOVElUWSBQb2luY2FyZXBsYW5lICImI3gyMTBDOyI%2BPCFFTlRJVFkgcXVhdGVybmlvbnMgIiYjeDIxMEQ7Ij48IUVOVElUWSBIb3BmICImI3gyMTBEOyI%2BPCFFTlRJVFkgcGxhbmNraCAiJiN4MjEwRTsiPjwhRU5USVRZIHBsYW5jayAiJiN4MjEwRjsiPjwhRU5USVRZIGhiYXIgIiYjeDIxMEY7Ij48IUVOVElUWSBwbGFua3YgIiYjeDIxMEY7Ij48IUVOVElUWSBoc2xhc2ggIiYjeDIxMEY7Ij48IUVOVElUWSBJc2NyICImI3gyMTEwOyI%2BPCFFTlRJVFkgaW1hZ2xpbmUgIiYjeDIxMTA7Ij48IUVOVElUWSBpbWFnZSAiJiN4MjExMTsiPjwhRU5USVRZIEltICImI3gyMTExOyI%2BPCFFTlRJVFkgaW1hZ3BhcnQgIiYjeDIxMTE7Ij48IUVOVElUWSBJZnIgIiYjeDIxMTE7Ij48IUVOVElUWSBMc2NyICImI3gyMTEyOyI%2BPCFFTlRJVFkgbGFncmFuICImI3gyMTEyOyI%2BPCFFTlRJVFkgTGFwbGFjZXRyZiAiJiN4MjExMjsiPjwhRU5USVRZIGVsbCAiJiN4MjExMzsiPjwhRU5USVRZIE5vcGYgIiYjeDIxMTU7Ij48IUVOVElUWSBuYXR1cmFscyAiJiN4MjExNTsiPjwhRU5USVRZIG51bWVybyAiJiN4MjExNjsiPjwhRU5USVRZIGNvcHlzciAiJiN4MjExNzsiPjwhRU5USVRZIHdlaWVycCAiJiN4MjExODsiPjwhRU5USVRZIHdwICImI3gyMTE4OyI%2BPCFFTlRJVFkgUG9wZiAiJiN4MjExOTsiPjwhRU5USVRZIHByaW1lcyAiJiN4MjExOTsiPjwhRU5USVRZIHJhdGlvbmFscyAiJiN4MjExQTsiPjwhRU5USVRZIFFvcGYgIiYjeDIxMUE7Ij48IUVOVElUWSBSc2NyICImI3gyMTFCOyI%2BPCFFTlRJVFkgcmVhbGluZSAiJiN4MjExQjsiPjwhRU5USVRZIHJlYWwgIiYjeDIxMUM7Ij48IUVOVElUWSBSZSAiJiN4MjExQzsiPjwhRU5USVRZIHJlYWxwYXJ0ICImI3gyMTFDOyI%2BPCFFTlRJVFkgUmZyICImI3gyMTFDOyI%2BPCFFTlRJVFkgcmVhbHMgIiYjeDIxMUQ7Ij48IUVOVElUWSBSb3BmICImI3gyMTFEOyI%2BPCFFTlRJVFkgcnggIiYjeDIxMUU7Ij48IUVOVElUWSB0cmFkZSAiJiN4MjEyMjsiPjwhRU5USVRZIFRSQURFICImI3gyMTIyOyI%2BPCFFTlRJVFkgaW50ZWdlcnMgIiYjeDIxMjQ7Ij48IUVOVElUWSBab3BmICImI3gyMTI0OyI%2BPCFFTlRJVFkgbWhvICImI3gyMTI3OyI%2BPCFFTlRJVFkgWmZyICImI3gyMTI4OyI%2BPCFFTlRJVFkgemVldHJmICImI3gyMTI4OyI%2BPCFFTlRJVFkgaWlvdGEgIiYjeDIxMjk7Ij48IUVOVElUWSBiZXJub3UgIiYjeDIxMkM7Ij48IUVOVElUWSBCZXJub3VsbGlzICImI3gyMTJDOyI%2BPCFFTlRJVFkgQnNjciAiJiN4MjEyQzsiPjwhRU5USVRZIENmciAiJiN4MjEyRDsiPjwhRU5USVRZIENheWxleXMgIiYjeDIxMkQ7Ij48IUVOVElUWSBlc2NyICImI3gyMTJGOyI%2BPCFFTlRJVFkgRXNjciAiJiN4MjEzMDsiPjwhRU5USVRZIGV4cGVjdGF0aW9uICImI3gyMTMwOyI%2BPCFFTlRJVFkgRnNjciAiJiN4MjEzMTsiPjwhRU5USVRZIEZvdXJpZXJ0cmYgIiYjeDIxMzE7Ij48IUVOVElUWSBwaG1tYXQgIiYjeDIxMzM7Ij48IUVOVElUWSBNZWxsaW50cmYgIiYjeDIxMzM7Ij48IUVOVElUWSBNc2NyICImI3gyMTMzOyI%2BPCFFTlRJVFkgb3JkZXIgIiYjeDIxMzQ7Ij48IUVOVElUWSBvcmRlcm9mICImI3gyMTM0OyI%2BPCFFTlRJVFkgb3NjciAiJiN4MjEzNDsiPjwhRU5USVRZIGFsZWZzeW0gIiYjeDIxMzU7Ij48IUVOVElUWSBhbGVwaCAiJiN4MjEzNTsiPjwhRU5USVRZIGJldGggIiYjeDIxMzY7Ij48IUVOVElUWSBnaW1lbCAiJiN4MjEzNzsiPjwhRU5USVRZIGRhbGV0aCAiJiN4MjEzODsiPjwhRU5USVRZIENhcGl0YWxEaWZmZXJlbnRpYWxEICImI3gyMTQ1OyI%2BPCFFTlRJVFkgREQgIiYjeDIxNDU7Ij48IUVOVElUWSBEaWZmZXJlbnRpYWxEICImI3gyMTQ2OyI%2BPCFFTlRJVFkgZGQgIiYjeDIxNDY7Ij48IUVOVElUWSBFeHBvbmVudGlhbEUgIiYjeDIxNDc7Ij48IUVOVElUWSBleHBvbmVudGlhbGUgIiYjeDIxNDc7Ij48IUVOVElUWSBlZSAiJiN4MjE0NzsiPjwhRU5USVRZIEltYWdpbmFyeUkgIiYjeDIxNDg7Ij48IUVOVElUWSBpaSAiJiN4MjE0ODsiPjwhRU5USVRZIGZyYWMxMyAiJiN4MjE1MzsiPjwhRU5USVRZIGZyYWMyMyAiJiN4MjE1NDsiPjwhRU5USVRZIGZyYWMxNSAiJiN4MjE1NTsiPjwhRU5USVRZIGZyYWMyNSAiJiN4MjE1NjsiPjwhRU5USVRZIGZyYWMzNSAiJiN4MjE1NzsiPjwhRU5USVRZIGZyYWM0NSAiJiN4MjE1ODsiPjwhRU5USVRZIGZyYWMxNiAiJiN4MjE1OTsiPjwhRU5USVRZIGZyYWM1NiAiJiN4MjE1QTsiPjwhRU5USVRZIGZyYWMxOCAiJiN4MjE1QjsiPjwhRU5USVRZIGZyYWMzOCAiJiN4MjE1QzsiPjwhRU5USVRZIGZyYWM1OCAiJiN4MjE1RDsiPjwhRU5USVRZIGZyYWM3OCAiJiN4MjE1RTsiPjwhRU5USVRZIGxhcnIgIiYjeDIxOTA7Ij48IUVOVElUWSBsZWZ0YXJyb3cgIiYjeDIxOTA7Ij48IUVOVElUWSBMZWZ0QXJyb3cgIiYjeDIxOTA7Ij48IUVOVElUWSBzbGFyciAiJiN4MjE5MDsiPjwhRU5USVRZIFNob3J0TGVmdEFycm93ICImI3gyMTkwOyI%2BPCFFTlRJVFkgdWFyciAiJiN4MjE5MTsiPjwhRU5USVRZIHVwYXJyb3cgIiYjeDIxOTE7Ij48IUVOVElUWSBVcEFycm93ICImI3gyMTkxOyI%2BPCFFTlRJVFkgU2hvcnRVcEFycm93ICImI3gyMTkxOyI%2BPCFFTlRJVFkgcmFyciAiJiN4MjE5MjsiPjwhRU5USVRZIHJpZ2h0YXJyb3cgIiYjeDIxOTI7Ij48IUVOVElUWSBSaWdodEFycm93ICImI3gyMTkyOyI%2BPCFFTlRJVFkgc3JhcnIgIiYjeDIxOTI7Ij48IUVOVElUWSBTaG9ydFJpZ2h0QXJyb3cgIiYjeDIxOTI7Ij48IUVOVElUWSBkYXJyICImI3gyMTkzOyI%2BPCFFTlRJVFkgZG93bmFycm93ICImI3gyMTkzOyI%2BPCFFTlRJVFkgRG93bkFycm93ICImI3gyMTkzOyI%2BPCFFTlRJVFkgU2hvcnREb3duQXJyb3cgIiYjeDIxOTM7Ij48IUVOVElUWSBoYXJyICImI3gyMTk0OyI%2BPCFFTlRJVFkgbGVmdHJpZ2h0YXJyb3cgIiYjeDIxOTQ7Ij48IUVOVElUWSBMZWZ0UmlnaHRBcnJvdyAiJiN4MjE5NDsiPjwhRU5USVRZIHZhcnIgIiYjeDIxOTU7Ij48IUVOVElUWSB1cGRvd25hcnJvdyAiJiN4MjE5NTsiPjwhRU5USVRZIFVwRG93bkFycm93ICImI3gyMTk1OyI%2BPCFFTlRJVFkgbndhcnIgIiYjeDIxOTY7Ij48IUVOVElUWSBVcHBlckxlZnRBcnJvdyAiJiN4MjE5NjsiPjwhRU5USVRZIG53YXJyb3cgIiYjeDIxOTY7Ij48IUVOVElUWSBuZWFyciAiJiN4MjE5NzsiPjwhRU5USVRZIFVwcGVyUmlnaHRBcnJvdyAiJiN4MjE5NzsiPjwhRU5USVRZIG5lYXJyb3cgIiYjeDIxOTc7Ij48IUVOVElUWSBzZWFyciAiJiN4MjE5ODsiPjwhRU5USVRZIHNlYXJyb3cgIiYjeDIxOTg7Ij48IUVOVElUWSBMb3dlclJpZ2h0QXJyb3cgIiYjeDIxOTg7Ij48IUVOVElUWSBzd2FyciAiJiN4MjE5OTsiPjwhRU5USVRZIHN3YXJyb3cgIiYjeDIxOTk7Ij48IUVOVElUWSBMb3dlckxlZnRBcnJvdyAiJiN4MjE5OTsiPjwhRU5USVRZIG5sYXJyICImI3gyMTlBOyI%2BPCFFTlRJVFkgbmxlZnRhcnJvdyAiJiN4MjE5QTsiPjwhRU5USVRZIG5yYXJyICImI3gyMTlCOyI%2BPCFFTlRJVFkgbnJpZ2h0YXJyb3cgIiYjeDIxOUI7Ij48IUVOVElUWSByYXJydyAiJiN4MjE5RDsiPjwhRU5USVRZIHJpZ2h0c3F1aWdhcnJvdyAiJiN4MjE5RDsiPjwhRU5USVRZIG5yYXJydyAiJiN4MjE5RDsmI3gzMzg7Ij48IUVOVElUWSBMYXJyICImI3gyMTlFOyI%2BPCFFTlRJVFkgdHdvaGVhZGxlZnRhcnJvdyAiJiN4MjE5RTsiPjwhRU5USVRZIFVhcnIgIiYjeDIxOUY7Ij48IUVOVElUWSBSYXJyICImI3gyMUEwOyI%2BPCFFTlRJVFkgdHdvaGVhZHJpZ2h0YXJyb3cgIiYjeDIxQTA7Ij48IUVOVElUWSBEYXJyICImI3gyMUExOyI%2BPCFFTlRJVFkgbGFycnRsICImI3gyMUEyOyI%2BPCFFTlRJVFkgbGVmdGFycm93dGFpbCAiJiN4MjFBMjsiPjwhRU5USVRZIHJhcnJ0bCAiJiN4MjFBMzsiPjwhRU5USVRZIHJpZ2h0YXJyb3d0YWlsICImI3gyMUEzOyI%2BPCFFTlRJVFkgTGVmdFRlZUFycm93ICImI3gyMUE0OyI%2BPCFFTlRJVFkgbWFwc3RvbGVmdCAiJiN4MjFBNDsiPjwhRU5USVRZIFVwVGVlQXJyb3cgIiYjeDIxQTU7Ij48IUVOVElUWSBtYXBzdG91cCAiJiN4MjFBNTsiPjwhRU5USVRZIG1hcCAiJiN4MjFBNjsiPjwhRU5USVRZIFJpZ2h0VGVlQXJyb3cgIiYjeDIxQTY7Ij48IUVOVElUWSBtYXBzdG8gIiYjeDIxQTY7Ij48IUVOVElUWSBEb3duVGVlQXJyb3cgIiYjeDIxQTc7Ij48IUVOVElUWSBtYXBzdG9kb3duICImI3gyMUE3OyI%2BPCFFTlRJVFkgbGFycmhrICImI3gyMUE5OyI%2BPCFFTlRJVFkgaG9va2xlZnRhcnJvdyAiJiN4MjFBOTsiPjwhRU5USVRZIHJhcnJoayAiJiN4MjFBQTsiPjwhRU5USVRZIGhvb2tyaWdodGFycm93ICImI3gyMUFBOyI%2BPCFFTlRJVFkgbGFycmxwICImI3gyMUFCOyI%2BPCFFTlRJVFkgbG9vcGFycm93bGVmdCAiJiN4MjFBQjsiPjwhRU5USVRZIHJhcnJscCAiJiN4MjFBQzsiPjwhRU5USVRZIGxvb3BhcnJvd3JpZ2h0ICImI3gyMUFDOyI%2BPCFFTlRJVFkgaGFycncgIiYjeDIxQUQ7Ij48IUVOVElUWSBsZWZ0cmlnaHRzcXVpZ2Fycm93ICImI3gyMUFEOyI%2BPCFFTlRJVFkgbmhhcnIgIiYjeDIxQUU7Ij48IUVOVElUWSBubGVmdHJpZ2h0YXJyb3cgIiYjeDIxQUU7Ij48IUVOVElUWSBsc2ggIiYjeDIxQjA7Ij48IUVOVElUWSBMc2ggIiYjeDIxQjA7Ij48IUVOVElUWSByc2ggIiYjeDIxQjE7Ij48IUVOVElUWSBSc2ggIiYjeDIxQjE7Ij48IUVOVElUWSBsZHNoICImI3gyMUIyOyI%2BPCFFTlRJVFkgcmRzaCAiJiN4MjFCMzsiPjwhRU5USVRZIGNyYXJyICImI3gyMUI1OyI%2BPCFFTlRJVFkgY3VsYXJyICImI3gyMUI2OyI%2BPCFFTlRJVFkgY3VydmVhcnJvd2xlZnQgIiYjeDIxQjY7Ij48IUVOVElUWSBjdXJhcnIgIiYjeDIxQjc7Ij48IUVOVElUWSBjdXJ2ZWFycm93cmlnaHQgIiYjeDIxQjc7Ij48IUVOVElUWSBvbGFyciAiJiN4MjFCQTsiPjwhRU5USVRZIGNpcmNsZWFycm93bGVmdCAiJiN4MjFCQTsiPjwhRU5USVRZIG9yYXJyICImI3gyMUJCOyI%2BPCFFTlRJVFkgY2lyY2xlYXJyb3dyaWdodCAiJiN4MjFCQjsiPjwhRU5USVRZIGxoYXJ1ICImI3gyMUJDOyI%2BPCFFTlRJVFkgTGVmdFZlY3RvciAiJiN4MjFCQzsiPjwhRU5USVRZIGxlZnRoYXJwb29udXAgIiYjeDIxQkM7Ij48IUVOVElUWSBsaGFyZCAiJiN4MjFCRDsiPjwhRU5USVRZIGxlZnRoYXJwb29uZG93biAiJiN4MjFCRDsiPjwhRU5USVRZIERvd25MZWZ0VmVjdG9yICImI3gyMUJEOyI%2BPCFFTlRJVFkgdWhhcnIgIiYjeDIxQkU7Ij48IUVOVElUWSB1cGhhcnBvb25yaWdodCAiJiN4MjFCRTsiPjwhRU5USVRZIFJpZ2h0VXBWZWN0b3IgIiYjeDIxQkU7Ij48IUVOVElUWSB1aGFybCAiJiN4MjFCRjsiPjwhRU5USVRZIHVwaGFycG9vbmxlZnQgIiYjeDIxQkY7Ij48IUVOVElUWSBMZWZ0VXBWZWN0b3IgIiYjeDIxQkY7Ij48IUVOVElUWSByaGFydSAiJiN4MjFDMDsiPjwhRU5USVRZIFJpZ2h0VmVjdG9yICImI3gyMUMwOyI%2BPCFFTlRJVFkgcmlnaHRoYXJwb29udXAgIiYjeDIxQzA7Ij48IUVOVElUWSByaGFyZCAiJiN4MjFDMTsiPjwhRU5USVRZIHJpZ2h0aGFycG9vbmRvd24gIiYjeDIxQzE7Ij48IUVOVElUWSBEb3duUmlnaHRWZWN0b3IgIiYjeDIxQzE7Ij48IUVOVElUWSBkaGFyciAiJiN4MjFDMjsiPjwhRU5USVRZIFJpZ2h0RG93blZlY3RvciAiJiN4MjFDMjsiPjwhRU5USVRZIGRvd25oYXJwb29ucmlnaHQgIiYjeDIxQzI7Ij48IUVOVElUWSBkaGFybCAiJiN4MjFDMzsiPjwhRU5USVRZIExlZnREb3duVmVjdG9yICImI3gyMUMzOyI%2BPCFFTlRJVFkgZG93bmhhcnBvb25sZWZ0ICImI3gyMUMzOyI%2BPCFFTlRJVFkgcmxhcnIgIiYjeDIxQzQ7Ij48IUVOVElUWSByaWdodGxlZnRhcnJvd3MgIiYjeDIxQzQ7Ij48IUVOVElUWSBSaWdodEFycm93TGVmdEFycm93ICImI3gyMUM0OyI%2BPCFFTlRJVFkgdWRhcnIgIiYjeDIxQzU7Ij48IUVOVElUWSBVcEFycm93RG93bkFycm93ICImI3gyMUM1OyI%2BPCFFTlRJVFkgbHJhcnIgIiYjeDIxQzY7Ij48IUVOVElUWSBsZWZ0cmlnaHRhcnJvd3MgIiYjeDIxQzY7Ij48IUVOVElUWSBMZWZ0QXJyb3dSaWdodEFycm93ICImI3gyMUM2OyI%2BPCFFTlRJVFkgbGxhcnIgIiYjeDIxQzc7Ij48IUVOVElUWSBsZWZ0bGVmdGFycm93cyAiJiN4MjFDNzsiPjwhRU5USVRZIHV1YXJyICImI3gyMUM4OyI%2BPCFFTlRJVFkgdXB1cGFycm93cyAiJiN4MjFDODsiPjwhRU5USVRZIHJyYXJyICImI3gyMUM5OyI%2BPCFFTlRJVFkgcmlnaHRyaWdodGFycm93cyAiJiN4MjFDOTsiPjwhRU5USVRZIGRkYXJyICImI3gyMUNBOyI%2BPCFFTlRJVFkgZG93bmRvd25hcnJvd3MgIiYjeDIxQ0E7Ij48IUVOVElUWSBscmhhciAiJiN4MjFDQjsiPjwhRU5USVRZIFJldmVyc2VFcXVpbGlicml1bSAiJiN4MjFDQjsiPjwhRU5USVRZIGxlZnRyaWdodGhhcnBvb25zICImI3gyMUNCOyI%2BPCFFTlRJVFkgcmxoYXIgIiYjeDIxQ0M7Ij48IUVOVElUWSByaWdodGxlZnRoYXJwb29ucyAiJiN4MjFDQzsiPjwhRU5USVRZIEVxdWlsaWJyaXVtICImI3gyMUNDOyI%2BPCFFTlRJVFkgbmxBcnIgIiYjeDIxQ0Q7Ij48IUVOVElUWSBuTGVmdGFycm93ICImI3gyMUNEOyI%2BPCFFTlRJVFkgbmhBcnIgIiYjeDIxQ0U7Ij48IUVOVElUWSBuTGVmdHJpZ2h0YXJyb3cgIiYjeDIxQ0U7Ij48IUVOVElUWSBuckFyciAiJiN4MjFDRjsiPjwhRU5USVRZIG5SaWdodGFycm93ICImI3gyMUNGOyI%2BPCFFTlRJVFkgbEFyciAiJiN4MjFEMDsiPjwhRU5USVRZIExlZnRhcnJvdyAiJiN4MjFEMDsiPjwhRU5USVRZIERvdWJsZUxlZnRBcnJvdyAiJiN4MjFEMDsiPjwhRU5USVRZIHVBcnIgIiYjeDIxRDE7Ij48IUVOVElUWSBVcGFycm93ICImI3gyMUQxOyI%2BPCFFTlRJVFkgRG91YmxlVXBBcnJvdyAiJiN4MjFEMTsiPjwhRU5USVRZIHJBcnIgIiYjeDIxRDI7Ij48IUVOVElUWSBSaWdodGFycm93ICImI3gyMUQyOyI%2BPCFFTlRJVFkgSW1wbGllcyAiJiN4MjFEMjsiPjwhRU5USVRZIERvdWJsZVJpZ2h0QXJyb3cgIiYjeDIxRDI7Ij48IUVOVElUWSBkQXJyICImI3gyMUQzOyI%2BPCFFTlRJVFkgRG93bmFycm93ICImI3gyMUQzOyI%2BPCFFTlRJVFkgRG91YmxlRG93bkFycm93ICImI3gyMUQzOyI%2BPCFFTlRJVFkgaEFyciAiJiN4MjFENDsiPjwhRU5USVRZIExlZnRyaWdodGFycm93ICImI3gyMUQ0OyI%2BPCFFTlRJVFkgRG91YmxlTGVmdFJpZ2h0QXJyb3cgIiYjeDIxRDQ7Ij48IUVOVElUWSBpZmYgIiYjeDIxRDQ7Ij48IUVOVElUWSB2QXJyICImI3gyMUQ1OyI%2BPCFFTlRJVFkgVXBkb3duYXJyb3cgIiYjeDIxRDU7Ij48IUVOVElUWSBEb3VibGVVcERvd25BcnJvdyAiJiN4MjFENTsiPjwhRU5USVRZIG53QXJyICImI3gyMUQ2OyI%2BPCFFTlRJVFkgbmVBcnIgIiYjeDIxRDc7Ij48IUVOVElUWSBzZUFyciAiJiN4MjFEODsiPjwhRU5USVRZIHN3QXJyICImI3gyMUQ5OyI%2BPCFFTlRJVFkgbEFhcnIgIiYjeDIxREE7Ij48IUVOVElUWSBMbGVmdGFycm93ICImI3gyMURBOyI%2BPCFFTlRJVFkgckFhcnIgIiYjeDIxREI7Ij48IUVOVElUWSBScmlnaHRhcnJvdyAiJiN4MjFEQjsiPjwhRU5USVRZIHppZ3JhcnIgIiYjeDIxREQ7Ij48IUVOVElUWSBsYXJyYiAiJiN4MjFFNDsiPjwhRU5USVRZIExlZnRBcnJvd0JhciAiJiN4MjFFNDsiPjwhRU5USVRZIHJhcnJiICImI3gyMUU1OyI%2BPCFFTlRJVFkgUmlnaHRBcnJvd0JhciAiJiN4MjFFNTsiPjwhRU5USVRZIGR1YXJyICImI3gyMUY1OyI%2BPCFFTlRJVFkgRG93bkFycm93VXBBcnJvdyAiJiN4MjFGNTsiPjwhRU5USVRZIGxvYXJyICImI3gyMUZEOyI%2BPCFFTlRJVFkgcm9hcnIgIiYjeDIxRkU7Ij48IUVOVElUWSBob2FyciAiJiN4MjFGRjsiPjwhRU5USVRZIGZvcmFsbCAiJiN4MjIwMDsiPjwhRU5USVRZIEZvckFsbCAiJiN4MjIwMDsiPjwhRU5USVRZIGNvbXAgIiYjeDIyMDE7Ij48IUVOVElUWSBjb21wbGVtZW50ICImI3gyMjAxOyI%2BPCFFTlRJVFkgcGFydCAiJiN4MjIwMjsiPjwhRU5USVRZIFBhcnRpYWxEICImI3gyMjAyOyI%2BPCFFTlRJVFkgbnBhcnQgIiYjeDIyMDI7JiN4MzM4OyI%2BPCFFTlRJVFkgZXhpc3QgIiYjeDIyMDM7Ij48IUVOVElUWSBFeGlzdHMgIiYjeDIyMDM7Ij48IUVOVElUWSBuZXhpc3QgIiYjeDIyMDQ7Ij48IUVOVElUWSBOb3RFeGlzdHMgIiYjeDIyMDQ7Ij48IUVOVElUWSBuZXhpc3RzICImI3gyMjA0OyI%2BPCFFTlRJVFkgZW1wdHkgIiYjeDIyMDU7Ij48IUVOVElUWSBlbXB0eXNldCAiJiN4MjIwNTsiPjwhRU5USVRZIGVtcHR5diAiJiN4MjIwNTsiPjwhRU5USVRZIHZhcm5vdGhpbmcgIiYjeDIyMDU7Ij48IUVOVElUWSBuYWJsYSAiJiN4MjIwNzsiPjwhRU5USVRZIERlbCAiJiN4MjIwNzsiPjwhRU5USVRZIGlzaW4gIiYjeDIyMDg7Ij48IUVOVElUWSBpc2ludiAiJiN4MjIwODsiPjwhRU5USVRZIEVsZW1lbnQgIiYjeDIyMDg7Ij48IUVOVElUWSBpbiAiJiN4MjIwODsiPjwhRU5USVRZIG5vdGluICImI3gyMjA5OyI%2BPCFFTlRJVFkgTm90RWxlbWVudCAiJiN4MjIwOTsiPjwhRU5USVRZIG5vdGludmEgIiYjeDIyMDk7Ij48IUVOVElUWSBuaXYgIiYjeDIyMEI7Ij48IUVOVElUWSBSZXZlcnNlRWxlbWVudCAiJiN4MjIwQjsiPjwhRU5USVRZIG5pICImI3gyMjBCOyI%2BPCFFTlRJVFkgU3VjaFRoYXQgIiYjeDIyMEI7Ij48IUVOVElUWSBub3RuaSAiJiN4MjIwQzsiPjwhRU5USVRZIG5vdG5pdmEgIiYjeDIyMEM7Ij48IUVOVElUWSBOb3RSZXZlcnNlRWxlbWVudCAiJiN4MjIwQzsiPjwhRU5USVRZIHByb2QgIiYjeDIyMEY7Ij48IUVOVElUWSBQcm9kdWN0ICImI3gyMjBGOyI%2BPCFFTlRJVFkgY29wcm9kICImI3gyMjEwOyI%2BPCFFTlRJVFkgQ29wcm9kdWN0ICImI3gyMjEwOyI%2BPCFFTlRJVFkgc3VtICImI3gyMjExOyI%2BPCFFTlRJVFkgU3VtICImI3gyMjExOyI%2BPCFFTlRJVFkgbWludXMgIiYjeDIyMTI7Ij48IUVOVElUWSBtbnBsdXMgIiYjeDIyMTM7Ij48IUVOVElUWSBtcCAiJiN4MjIxMzsiPjwhRU5USVRZIE1pbnVzUGx1cyAiJiN4MjIxMzsiPjwhRU5USVRZIHBsdXNkbyAiJiN4MjIxNDsiPjwhRU5USVRZIGRvdHBsdXMgIiYjeDIyMTQ7Ij48IUVOVElUWSBzZXRtbiAiJiN4MjIxNjsiPjwhRU5USVRZIHNldG1pbnVzICImI3gyMjE2OyI%2BPCFFTlRJVFkgQmFja3NsYXNoICImI3gyMjE2OyI%2BPCFFTlRJVFkgc3NldG1uICImI3gyMjE2OyI%2BPCFFTlRJVFkgc21hbGxzZXRtaW51cyAiJiN4MjIxNjsiPjwhRU5USVRZIGxvd2FzdCAiJiN4MjIxNzsiPjwhRU5USVRZIGNvbXBmbiAiJiN4MjIxODsiPjwhRU5USVRZIFNtYWxsQ2lyY2xlICImI3gyMjE4OyI%2BPCFFTlRJVFkgcmFkaWMgIiYjeDIyMUE7Ij48IUVOVElUWSBTcXJ0ICImI3gyMjFBOyI%2BPCFFTlRJVFkgcHJvcCAiJiN4MjIxRDsiPjwhRU5USVRZIHByb3B0byAiJiN4MjIxRDsiPjwhRU5USVRZIFByb3BvcnRpb25hbCAiJiN4MjIxRDsiPjwhRU5USVRZIHZwcm9wICImI3gyMjFEOyI%2BPCFFTlRJVFkgdmFycHJvcHRvICImI3gyMjFEOyI%2BPCFFTlRJVFkgaW5maW4gIiYjeDIyMUU7Ij48IUVOVElUWSBhbmdydCAiJiN4MjIxRjsiPjwhRU5USVRZIGFuZyAiJiN4MjIyMDsiPjwhRU5USVRZIGFuZ2xlICImI3gyMjIwOyI%2BPCFFTlRJVFkgbmFuZyAiJiN4MjIyMDsmI3gyMEQyOyI%2BPCFFTlRJVFkgYW5nbXNkICImI3gyMjIxOyI%2BPCFFTlRJVFkgbWVhc3VyZWRhbmdsZSAiJiN4MjIyMTsiPjwhRU5USVRZIGFuZ3NwaCAiJiN4MjIyMjsiPjwhRU5USVRZIG1pZCAiJiN4MjIyMzsiPjwhRU5USVRZIFZlcnRpY2FsQmFyICImI3gyMjIzOyI%2BPCFFTlRJVFkgc21pZCAiJiN4MjIyMzsiPjwhRU5USVRZIHNob3J0bWlkICImI3gyMjIzOyI%2BPCFFTlRJVFkgbm1pZCAiJiN4MjIyNDsiPjwhRU5USVRZIE5vdFZlcnRpY2FsQmFyICImI3gyMjI0OyI%2BPCFFTlRJVFkgbnNtaWQgIiYjeDIyMjQ7Ij48IUVOVElUWSBuc2hvcnRtaWQgIiYjeDIyMjQ7Ij48IUVOVElUWSBwYXIgIiYjeDIyMjU7Ij48IUVOVElUWSBwYXJhbGxlbCAiJiN4MjIyNTsiPjwhRU5USVRZIERvdWJsZVZlcnRpY2FsQmFyICImI3gyMjI1OyI%2BPCFFTlRJVFkgc3BhciAiJiN4MjIyNTsiPjwhRU5USVRZIHNob3J0cGFyYWxsZWwgIiYjeDIyMjU7Ij48IUVOVElUWSBucGFyICImI3gyMjI2OyI%2BPCFFTlRJVFkgbnBhcmFsbGVsICImI3gyMjI2OyI%2BPCFFTlRJVFkgTm90RG91YmxlVmVydGljYWxCYXIgIiYjeDIyMjY7Ij48IUVOVElUWSBuc3BhciAiJiN4MjIyNjsiPjwhRU5USVRZIG5zaG9ydHBhcmFsbGVsICImI3gyMjI2OyI%2BPCFFTlRJVFkgYW5kICImI3gyMjI3OyI%2BPCFFTlRJVFkgd2VkZ2UgIiYjeDIyMjc7Ij48IUVOVElUWSBvciAiJiN4MjIyODsiPjwhRU5USVRZIHZlZSAiJiN4MjIyODsiPjwhRU5USVRZIGNhcCAiJiN4MjIyOTsiPjwhRU5USVRZIGNhcHMgIiYjeDIyMjk7JiN4RkUwMDsiPjwhRU5USVRZIGN1cCAiJiN4MjIyQTsiPjwhRU5USVRZIGN1cHMgIiYjeDIyMkE7JiN4RkUwMDsiPjwhRU5USVRZIGludCAiJiN4MjIyQjsiPjwhRU5USVRZIEludGVncmFsICImI3gyMjJCOyI%2BPCFFTlRJVFkgSW50ICImI3gyMjJDOyI%2BPCFFTlRJVFkgdGludCAiJiN4MjIyRDsiPjwhRU5USVRZIGlpaW50ICImI3gyMjJEOyI%2BPCFFTlRJVFkgY29uaW50ICImI3gyMjJFOyI%2BPCFFTlRJVFkgb2ludCAiJiN4MjIyRTsiPjwhRU5USVRZIENvbnRvdXJJbnRlZ3JhbCAiJiN4MjIyRTsiPjwhRU5USVRZIENvbmludCAiJiN4MjIyRjsiPjwhRU5USVRZIERvdWJsZUNvbnRvdXJJbnRlZ3JhbCAiJiN4MjIyRjsiPjwhRU5USVRZIENjb25pbnQgIiYjeDIyMzA7Ij48IUVOVElUWSBjd2ludCAiJiN4MjIzMTsiPjwhRU5USVRZIGN3Y29uaW50ICImI3gyMjMyOyI%2BPCFFTlRJVFkgQ2xvY2t3aXNlQ29udG91ckludGVncmFsICImI3gyMjMyOyI%2BPCFFTlRJVFkgYXdjb25pbnQgIiYjeDIyMzM7Ij48IUVOVElUWSBDb3VudGVyQ2xvY2t3aXNlQ29udG91ckludGVncmFsICImI3gyMjMzOyI%2BPCFFTlRJVFkgdGhlcmU0ICImI3gyMjM0OyI%2BPCFFTlRJVFkgdGhlcmVmb3JlICImI3gyMjM0OyI%2BPCFFTlRJVFkgVGhlcmVmb3JlICImI3gyMjM0OyI%2BPCFFTlRJVFkgYmVjYXVzICImI3gyMjM1OyI%2BPCFFTlRJVFkgYmVjYXVzZSAiJiN4MjIzNTsiPjwhRU5USVRZIEJlY2F1c2UgIiYjeDIyMzU7Ij48IUVOVElUWSByYXRpbyAiJiN4MjIzNjsiPjwhRU5USVRZIENvbG9uICImI3gyMjM3OyI%2BPCFFTlRJVFkgUHJvcG9ydGlvbiAiJiN4MjIzNzsiPjwhRU5USVRZIG1pbnVzZCAiJiN4MjIzODsiPjwhRU5USVRZIGRvdG1pbnVzICImI3gyMjM4OyI%2BPCFFTlRJVFkgbUREb3QgIiYjeDIyM0E7Ij48IUVOVElUWSBob210aHQgIiYjeDIyM0I7Ij48IUVOVElUWSBzaW0gIiYjeDIyM0M7Ij48IUVOVElUWSBUaWxkZSAiJiN4MjIzQzsiPjwhRU5USVRZIHRoa3NpbSAiJiN4MjIzQzsiPjwhRU5USVRZIHRoaWNrc2ltICImI3gyMjNDOyI%2BPCFFTlRJVFkgbnZzaW0gIiYjeDIyM0M7JiN4MjBEMjsiPjwhRU5USVRZIGJzaW0gIiYjeDIyM0Q7Ij48IUVOVElUWSBiYWNrc2ltICImI3gyMjNEOyI%2BPCFFTlRJVFkgcmFjZSAiJiN4MjIzRDsmI3gzMzE7Ij48IUVOVElUWSBhYyAiJiN4MjIzRTsiPjwhRU5USVRZIG1zdHBvcyAiJiN4MjIzRTsiPjwhRU5USVRZIGFjRSAiJiN4MjIzRTsmI3gzMzM7Ij48IUVOVElUWSBhY2QgIiYjeDIyM0Y7Ij48IUVOVElUWSB3cmVhdGggIiYjeDIyNDA7Ij48IUVOVElUWSBWZXJ0aWNhbFRpbGRlICImI3gyMjQwOyI%2BPCFFTlRJVFkgd3IgIiYjeDIyNDA7Ij48IUVOVElUWSBuc2ltICImI3gyMjQxOyI%2BPCFFTlRJVFkgTm90VGlsZGUgIiYjeDIyNDE7Ij48IUVOVElUWSBlc2ltICImI3gyMjQyOyI%2BPCFFTlRJVFkgRXF1YWxUaWxkZSAiJiN4MjI0MjsiPjwhRU5USVRZIGVxc2ltICImI3gyMjQyOyI%2BPCFFTlRJVFkgTm90RXF1YWxUaWxkZSAiJiN4MjI0MjsmI3gzMzg7Ij48IUVOVElUWSBuZXNpbSAiJiN4MjI0MjsmI3gzMzg7Ij48IUVOVElUWSBzaW1lICImI3gyMjQzOyI%2BPCFFTlRJVFkgVGlsZGVFcXVhbCAiJiN4MjI0MzsiPjwhRU5USVRZIHNpbWVxICImI3gyMjQzOyI%2BPCFFTlRJVFkgbnNpbWUgIiYjeDIyNDQ7Ij48IUVOVElUWSBuc2ltZXEgIiYjeDIyNDQ7Ij48IUVOVElUWSBOb3RUaWxkZUVxdWFsICImI3gyMjQ0OyI%2BPCFFTlRJVFkgY29uZyAiJiN4MjI0NTsiPjwhRU5USVRZIFRpbGRlRnVsbEVxdWFsICImI3gyMjQ1OyI%2BPCFFTlRJVFkgc2ltbmUgIiYjeDIyNDY7Ij48IUVOVElUWSBuY29uZyAiJiN4MjI0NzsiPjwhRU5USVRZIE5vdFRpbGRlRnVsbEVxdWFsICImI3gyMjQ3OyI%2BPCFFTlRJVFkgYXN5bXAgIiYjeDIyNDg7Ij48IUVOVElUWSBhcCAiJiN4MjI0ODsiPjwhRU5USVRZIFRpbGRlVGlsZGUgIiYjeDIyNDg7Ij48IUVOVElUWSBhcHByb3ggIiYjeDIyNDg7Ij48IUVOVElUWSB0aGthcCAiJiN4MjI0ODsiPjwhRU5USVRZIHRoaWNrYXBwcm94ICImI3gyMjQ4OyI%2BPCFFTlRJVFkgbmFwICImI3gyMjQ5OyI%2BPCFFTlRJVFkgTm90VGlsZGVUaWxkZSAiJiN4MjI0OTsiPjwhRU5USVRZIG5hcHByb3ggIiYjeDIyNDk7Ij48IUVOVElUWSBhcGUgIiYjeDIyNEE7Ij48IUVOVElUWSBhcHByb3hlcSAiJiN4MjI0QTsiPjwhRU5USVRZIGFwaWQgIiYjeDIyNEI7Ij48IUVOVElUWSBuYXBpZCAiJiN4MjI0QjsmI3gzMzg7Ij48IUVOVElUWSBiY29uZyAiJiN4MjI0QzsiPjwhRU5USVRZIGJhY2tjb25nICImI3gyMjRDOyI%2BPCFFTlRJVFkgYXN5bXBlcSAiJiN4MjI0RDsiPjwhRU5USVRZIEN1cENhcCAiJiN4MjI0RDsiPjwhRU5USVRZIG52YXAgIiYjeDIyNEQ7JiN4MjBEMjsiPjwhRU5USVRZIGJ1bXAgIiYjeDIyNEU7Ij48IUVOVElUWSBIdW1wRG93bkh1bXAgIiYjeDIyNEU7Ij48IUVOVElUWSBCdW1wZXEgIiYjeDIyNEU7Ij48IUVOVElUWSBOb3RIdW1wRG93bkh1bXAgIiYjeDIyNEU7JiN4MzM4OyI%2BPCFFTlRJVFkgbmJ1bXAgIiYjeDIyNEU7JiN4MzM4OyI%2BPCFFTlRJVFkgYnVtcGUgIiYjeDIyNEY7Ij48IUVOVElUWSBIdW1wRXF1YWwgIiYjeDIyNEY7Ij48IUVOVElUWSBidW1wZXEgIiYjeDIyNEY7Ij48IUVOVElUWSBuYnVtcGUgIiYjeDIyNEY7JiN4MzM4OyI%2BPCFFTlRJVFkgTm90SHVtcEVxdWFsICImI3gyMjRGOyYjeDMzODsiPjwhRU5USVRZIGVzZG90ICImI3gyMjUwOyI%2BPCFFTlRJVFkgRG90RXF1YWwgIiYjeDIyNTA7Ij48IUVOVElUWSBkb3RlcSAiJiN4MjI1MDsiPjwhRU5USVRZIG5lZG90ICImI3gyMjUwOyYjeDMzODsiPjwhRU5USVRZIGVEb3QgIiYjeDIyNTE7Ij48IUVOVElUWSBkb3RlcWRvdCAiJiN4MjI1MTsiPjwhRU5USVRZIGVmRG90ICImI3gyMjUyOyI%2BPCFFTlRJVFkgZmFsbGluZ2RvdHNlcSAiJiN4MjI1MjsiPjwhRU5USVRZIGVyRG90ICImI3gyMjUzOyI%2BPCFFTlRJVFkgcmlzaW5nZG90c2VxICImI3gyMjUzOyI%2BPCFFTlRJVFkgY29sb25lICImI3gyMjU0OyI%2BPCFFTlRJVFkgY29sb25lcSAiJiN4MjI1NDsiPjwhRU5USVRZIEFzc2lnbiAiJiN4MjI1NDsiPjwhRU5USVRZIGVjb2xvbiAiJiN4MjI1NTsiPjwhRU5USVRZIGVxY29sb24gIiYjeDIyNTU7Ij48IUVOVElUWSBlY2lyICImI3gyMjU2OyI%2BPCFFTlRJVFkgZXFjaXJjICImI3gyMjU2OyI%2BPCFFTlRJVFkgY2lyZSAiJiN4MjI1NzsiPjwhRU5USVRZIGNpcmNlcSAiJiN4MjI1NzsiPjwhRU5USVRZIHdlZGdlcSAiJiN4MjI1OTsiPjwhRU5USVRZIHZlZWVxICImI3gyMjVBOyI%2BPCFFTlRJVFkgdHJpZSAiJiN4MjI1QzsiPjwhRU5USVRZIHRyaWFuZ2xlcSAiJiN4MjI1QzsiPjwhRU5USVRZIGVxdWVzdCAiJiN4MjI1RjsiPjwhRU5USVRZIHF1ZXN0ZXEgIiYjeDIyNUY7Ij48IUVOVElUWSBuZSAiJiN4MjI2MDsiPjwhRU5USVRZIE5vdEVxdWFsICImI3gyMjYwOyI%2BPCFFTlRJVFkgZXF1aXYgIiYjeDIyNjE7Ij48IUVOVElUWSBDb25ncnVlbnQgIiYjeDIyNjE7Ij48IUVOVElUWSBibmVxdWl2ICImI3gyMjYxOyYjeDIwRTU7Ij48IUVOVElUWSBuZXF1aXYgIiYjeDIyNjI7Ij48IUVOVElUWSBOb3RDb25ncnVlbnQgIiYjeDIyNjI7Ij48IUVOVElUWSBsZSAiJiN4MjI2NDsiPjwhRU5USVRZIGxlcSAiJiN4MjI2NDsiPjwhRU5USVRZIG52bGUgIiYjeDIyNjQ7JiN4MjBEMjsiPjwhRU5USVRZIGdlICImI3gyMjY1OyI%2BPCFFTlRJVFkgR3JlYXRlckVxdWFsICImI3gyMjY1OyI%2BPCFFTlRJVFkgZ2VxICImI3gyMjY1OyI%2BPCFFTlRJVFkgbnZnZSAiJiN4MjI2NTsmI3gyMEQyOyI%2BPCFFTlRJVFkgbEUgIiYjeDIyNjY7Ij48IUVOVElUWSBMZXNzRnVsbEVxdWFsICImI3gyMjY2OyI%2BPCFFTlRJVFkgbGVxcSAiJiN4MjI2NjsiPjwhRU5USVRZIG5sRSAiJiN4MjI2NjsmI3gzMzg7Ij48IUVOVElUWSBubGVxcSAiJiN4MjI2NjsmI3gzMzg7Ij48IUVOVElUWSBnRSAiJiN4MjI2NzsiPjwhRU5USVRZIEdyZWF0ZXJGdWxsRXF1YWwgIiYjeDIyNjc7Ij48IUVOVElUWSBnZXFxICImI3gyMjY3OyI%2BPCFFTlRJVFkgbmdFICImI3gyMjY3OyYjeDMzODsiPjwhRU5USVRZIG5nZXFxICImI3gyMjY3OyYjeDMzODsiPjwhRU5USVRZIE5vdEdyZWF0ZXJGdWxsRXF1YWwgIiYjeDIyNjc7JiN4MzM4OyI%2BPCFFTlRJVFkgbG5FICImI3gyMjY4OyI%2BPCFFTlRJVFkgbG5lcXEgIiYjeDIyNjg7Ij48IUVOVElUWSBsdm5FICImI3gyMjY4OyYjeEZFMDA7Ij48IUVOVElUWSBsdmVydG5lcXEgIiYjeDIyNjg7JiN4RkUwMDsiPjwhRU5USVRZIGduRSAiJiN4MjI2OTsiPjwhRU5USVRZIGduZXFxICImI3gyMjY5OyI%2BPCFFTlRJVFkgZ3ZuRSAiJiN4MjI2OTsmI3hGRTAwOyI%2BPCFFTlRJVFkgZ3ZlcnRuZXFxICImI3gyMjY5OyYjeEZFMDA7Ij48IUVOVElUWSBMdCAiJiN4MjI2QTsiPjwhRU5USVRZIE5lc3RlZExlc3NMZXNzICImI3gyMjZBOyI%2BPCFFTlRJVFkgbGwgIiYjeDIyNkE7Ij48IUVOVElUWSBuTHR2ICImI3gyMjZBOyYjeDMzODsiPjwhRU5USVRZIE5vdExlc3NMZXNzICImI3gyMjZBOyYjeDMzODsiPjwhRU5USVRZIG5MdCAiJiN4MjI2QTsmI3gyMEQyOyI%2BPCFFTlRJVFkgR3QgIiYjeDIyNkI7Ij48IUVOVElUWSBOZXN0ZWRHcmVhdGVyR3JlYXRlciAiJiN4MjI2QjsiPjwhRU5USVRZIGdnICImI3gyMjZCOyI%2BPCFFTlRJVFkgbkd0diAiJiN4MjI2QjsmI3gzMzg7Ij48IUVOVElUWSBOb3RHcmVhdGVyR3JlYXRlciAiJiN4MjI2QjsmI3gzMzg7Ij48IUVOVElUWSBuR3QgIiYjeDIyNkI7JiN4MjBEMjsiPjwhRU5USVRZIHR3aXh0ICImI3gyMjZDOyI%2BPCFFTlRJVFkgYmV0d2VlbiAiJiN4MjI2QzsiPjwhRU5USVRZIE5vdEN1cENhcCAiJiN4MjI2RDsiPjwhRU5USVRZIG5sdCAiJiN4MjI2RTsiPjwhRU5USVRZIE5vdExlc3MgIiYjeDIyNkU7Ij48IUVOVElUWSBubGVzcyAiJiN4MjI2RTsiPjwhRU5USVRZIG5ndCAiJiN4MjI2RjsiPjwhRU5USVRZIE5vdEdyZWF0ZXIgIiYjeDIyNkY7Ij48IUVOVElUWSBuZ3RyICImI3gyMjZGOyI%2BPCFFTlRJVFkgbmxlICImI3gyMjcwOyI%2BPCFFTlRJVFkgTm90TGVzc0VxdWFsICImI3gyMjcwOyI%2BPCFFTlRJVFkgbmxlcSAiJiN4MjI3MDsiPjwhRU5USVRZIG5nZSAiJiN4MjI3MTsiPjwhRU5USVRZIE5vdEdyZWF0ZXJFcXVhbCAiJiN4MjI3MTsiPjwhRU5USVRZIG5nZXEgIiYjeDIyNzE7Ij48IUVOVElUWSBsc2ltICImI3gyMjcyOyI%2BPCFFTlRJVFkgTGVzc1RpbGRlICImI3gyMjcyOyI%2BPCFFTlRJVFkgbGVzc3NpbSAiJiN4MjI3MjsiPjwhRU5USVRZIGdzaW0gIiYjeDIyNzM7Ij48IUVOVElUWSBndHJzaW0gIiYjeDIyNzM7Ij48IUVOVElUWSBHcmVhdGVyVGlsZGUgIiYjeDIyNzM7Ij48IUVOVElUWSBubHNpbSAiJiN4MjI3NDsiPjwhRU5USVRZIE5vdExlc3NUaWxkZSAiJiN4MjI3NDsiPjwhRU5USVRZIG5nc2ltICImI3gyMjc1OyI%2BPCFFTlRJVFkgTm90R3JlYXRlclRpbGRlICImI3gyMjc1OyI%2BPCFFTlRJVFkgbGcgIiYjeDIyNzY7Ij48IUVOVElUWSBsZXNzZ3RyICImI3gyMjc2OyI%2BPCFFTlRJVFkgTGVzc0dyZWF0ZXIgIiYjeDIyNzY7Ij48IUVOVElUWSBnbCAiJiN4MjI3NzsiPjwhRU5USVRZIGd0cmxlc3MgIiYjeDIyNzc7Ij48IUVOVElUWSBHcmVhdGVyTGVzcyAiJiN4MjI3NzsiPjwhRU5USVRZIG50bGcgIiYjeDIyNzg7Ij48IUVOVElUWSBOb3RMZXNzR3JlYXRlciAiJiN4MjI3ODsiPjwhRU5USVRZIG50Z2wgIiYjeDIyNzk7Ij48IUVOVElUWSBOb3RHcmVhdGVyTGVzcyAiJiN4MjI3OTsiPjwhRU5USVRZIHByICImI3gyMjdBOyI%2BPCFFTlRJVFkgUHJlY2VkZXMgIiYjeDIyN0E7Ij48IUVOVElUWSBwcmVjICImI3gyMjdBOyI%2BPCFFTlRJVFkgc2MgIiYjeDIyN0I7Ij48IUVOVElUWSBTdWNjZWVkcyAiJiN4MjI3QjsiPjwhRU5USVRZIHN1Y2MgIiYjeDIyN0I7Ij48IUVOVElUWSBwcmN1ZSAiJiN4MjI3QzsiPjwhRU5USVRZIFByZWNlZGVzU2xhbnRFcXVhbCAiJiN4MjI3QzsiPjwhRU5USVRZIHByZWNjdXJseWVxICImI3gyMjdDOyI%2BPCFFTlRJVFkgc2NjdWUgIiYjeDIyN0Q7Ij48IUVOVElUWSBTdWNjZWVkc1NsYW50RXF1YWwgIiYjeDIyN0Q7Ij48IUVOVElUWSBzdWNjY3VybHllcSAiJiN4MjI3RDsiPjwhRU5USVRZIHByc2ltICImI3gyMjdFOyI%2BPCFFTlRJVFkgcHJlY3NpbSAiJiN4MjI3RTsiPjwhRU5USVRZIFByZWNlZGVzVGlsZGUgIiYjeDIyN0U7Ij48IUVOVElUWSBzY3NpbSAiJiN4MjI3RjsiPjwhRU5USVRZIHN1Y2NzaW0gIiYjeDIyN0Y7Ij48IUVOVElUWSBTdWNjZWVkc1RpbGRlICImI3gyMjdGOyI%2BPCFFTlRJVFkgTm90U3VjY2VlZHNUaWxkZSAiJiN4MjI3RjsmI3gzMzg7Ij48IUVOVElUWSBucHIgIiYjeDIyODA7Ij48IUVOVElUWSBucHJlYyAiJiN4MjI4MDsiPjwhRU5USVRZIE5vdFByZWNlZGVzICImI3gyMjgwOyI%2BPCFFTlRJVFkgbnNjICImI3gyMjgxOyI%2BPCFFTlRJVFkgbnN1Y2MgIiYjeDIyODE7Ij48IUVOVElUWSBOb3RTdWNjZWVkcyAiJiN4MjI4MTsiPjwhRU5USVRZIHN1YiAiJiN4MjI4MjsiPjwhRU5USVRZIHN1YnNldCAiJiN4MjI4MjsiPjwhRU5USVRZIHZuc3ViICImI3gyMjgyOyYjeDIwRDI7Ij48IUVOVElUWSBuc3Vic2V0ICImI3gyMjgyOyYjeDIwRDI7Ij48IUVOVElUWSBOb3RTdWJzZXQgIiYjeDIyODI7JiN4MjBEMjsiPjwhRU5USVRZIHN1cCAiJiN4MjI4MzsiPjwhRU5USVRZIHN1cHNldCAiJiN4MjI4MzsiPjwhRU5USVRZIFN1cGVyc2V0ICImI3gyMjgzOyI%2BPCFFTlRJVFkgdm5zdXAgIiYjeDIyODM7JiN4MjBEMjsiPjwhRU5USVRZIG5zdXBzZXQgIiYjeDIyODM7JiN4MjBEMjsiPjwhRU5USVRZIE5vdFN1cGVyc2V0ICImI3gyMjgzOyYjeDIwRDI7Ij48IUVOVElUWSBuc3ViICImI3gyMjg0OyI%2BPCFFTlRJVFkgbnN1cCAiJiN4MjI4NTsiPjwhRU5USVRZIHN1YmUgIiYjeDIyODY7Ij48IUVOVElUWSBTdWJzZXRFcXVhbCAiJiN4MjI4NjsiPjwhRU5USVRZIHN1YnNldGVxICImI3gyMjg2OyI%2BPCFFTlRJVFkgc3VwZSAiJiN4MjI4NzsiPjwhRU5USVRZIHN1cHNldGVxICImI3gyMjg3OyI%2BPCFFTlRJVFkgU3VwZXJzZXRFcXVhbCAiJiN4MjI4NzsiPjwhRU5USVRZIG5zdWJlICImI3gyMjg4OyI%2BPCFFTlRJVFkgbnN1YnNldGVxICImI3gyMjg4OyI%2BPCFFTlRJVFkgTm90U3Vic2V0RXF1YWwgIiYjeDIyODg7Ij48IUVOVElUWSBuc3VwZSAiJiN4MjI4OTsiPjwhRU5USVRZIG5zdXBzZXRlcSAiJiN4MjI4OTsiPjwhRU5USVRZIE5vdFN1cGVyc2V0RXF1YWwgIiYjeDIyODk7Ij48IUVOVElUWSBzdWJuZSAiJiN4MjI4QTsiPjwhRU5USVRZIHN1YnNldG5lcSAiJiN4MjI4QTsiPjwhRU5USVRZIHZzdWJuZSAiJiN4MjI4QTsmI3hGRTAwOyI%2BPCFFTlRJVFkgdmFyc3Vic2V0bmVxICImI3gyMjhBOyYjeEZFMDA7Ij48IUVOVElUWSBzdXBuZSAiJiN4MjI4QjsiPjwhRU5USVRZIHN1cHNldG5lcSAiJiN4MjI4QjsiPjwhRU5USVRZIHZzdXBuZSAiJiN4MjI4QjsmI3hGRTAwOyI%2BPCFFTlRJVFkgdmFyc3Vwc2V0bmVxICImI3gyMjhCOyYjeEZFMDA7Ij48IUVOVElUWSBjdXBkb3QgIiYjeDIyOEQ7Ij48IUVOVElUWSB1cGx1cyAiJiN4MjI4RTsiPjwhRU5USVRZIFVuaW9uUGx1cyAiJiN4MjI4RTsiPjwhRU5USVRZIHNxc3ViICImI3gyMjhGOyI%2BPCFFTlRJVFkgU3F1YXJlU3Vic2V0ICImI3gyMjhGOyI%2BPCFFTlRJVFkgc3FzdWJzZXQgIiYjeDIyOEY7Ij48IUVOVElUWSBOb3RTcXVhcmVTdWJzZXQgIiYjeDIyOEY7JiN4MzM4OyI%2BPCFFTlRJVFkgc3FzdXAgIiYjeDIyOTA7Ij48IUVOVElUWSBTcXVhcmVTdXBlcnNldCAiJiN4MjI5MDsiPjwhRU5USVRZIHNxc3Vwc2V0ICImI3gyMjkwOyI%2BPCFFTlRJVFkgTm90U3F1YXJlU3VwZXJzZXQgIiYjeDIyOTA7JiN4MzM4OyI%2BPCFFTlRJVFkgc3FzdWJlICImI3gyMjkxOyI%2BPCFFTlRJVFkgU3F1YXJlU3Vic2V0RXF1YWwgIiYjeDIyOTE7Ij48IUVOVElUWSBzcXN1YnNldGVxICImI3gyMjkxOyI%2BPCFFTlRJVFkgc3FzdXBlICImI3gyMjkyOyI%2BPCFFTlRJVFkgU3F1YXJlU3VwZXJzZXRFcXVhbCAiJiN4MjI5MjsiPjwhRU5USVRZIHNxc3Vwc2V0ZXEgIiYjeDIyOTI7Ij48IUVOVElUWSBzcWNhcCAiJiN4MjI5MzsiPjwhRU5USVRZIFNxdWFyZUludGVyc2VjdGlvbiAiJiN4MjI5MzsiPjwhRU5USVRZIHNxY2FwcyAiJiN4MjI5MzsmI3hGRTAwOyI%2BPCFFTlRJVFkgc3FjdXAgIiYjeDIyOTQ7Ij48IUVOVElUWSBTcXVhcmVVbmlvbiAiJiN4MjI5NDsiPjwhRU5USVRZIHNxY3VwcyAiJiN4MjI5NDsmI3hGRTAwOyI%2BPCFFTlRJVFkgb3BsdXMgIiYjeDIyOTU7Ij48IUVOVElUWSBDaXJjbGVQbHVzICImI3gyMjk1OyI%2BPCFFTlRJVFkgb21pbnVzICImI3gyMjk2OyI%2BPCFFTlRJVFkgQ2lyY2xlTWludXMgIiYjeDIyOTY7Ij48IUVOVElUWSBvdGltZXMgIiYjeDIyOTc7Ij48IUVOVElUWSBDaXJjbGVUaW1lcyAiJiN4MjI5NzsiPjwhRU5USVRZIG9zb2wgIiYjeDIyOTg7Ij48IUVOVElUWSBvZG90ICImI3gyMjk5OyI%2BPCFFTlRJVFkgQ2lyY2xlRG90ICImI3gyMjk5OyI%2BPCFFTlRJVFkgb2NpciAiJiN4MjI5QTsiPjwhRU5USVRZIGNpcmNsZWRjaXJjICImI3gyMjlBOyI%2BPCFFTlRJVFkgb2FzdCAiJiN4MjI5QjsiPjwhRU5USVRZIGNpcmNsZWRhc3QgIiYjeDIyOUI7Ij48IUVOVElUWSBvZGFzaCAiJiN4MjI5RDsiPjwhRU5USVRZIGNpcmNsZWRkYXNoICImI3gyMjlEOyI%2BPCFFTlRJVFkgcGx1c2IgIiYjeDIyOUU7Ij48IUVOVElUWSBib3hwbHVzICImI3gyMjlFOyI%2BPCFFTlRJVFkgbWludXNiICImI3gyMjlGOyI%2BPCFFTlRJVFkgYm94bWludXMgIiYjeDIyOUY7Ij48IUVOVElUWSB0aW1lc2IgIiYjeDIyQTA7Ij48IUVOVElUWSBib3h0aW1lcyAiJiN4MjJBMDsiPjwhRU5USVRZIHNkb3RiICImI3gyMkExOyI%2BPCFFTlRJVFkgZG90c3F1YXJlICImI3gyMkExOyI%2BPCFFTlRJVFkgdmRhc2ggIiYjeDIyQTI7Ij48IUVOVElUWSBSaWdodFRlZSAiJiN4MjJBMjsiPjwhRU5USVRZIGRhc2h2ICImI3gyMkEzOyI%2BPCFFTlRJVFkgTGVmdFRlZSAiJiN4MjJBMzsiPjwhRU5USVRZIHRvcCAiJiN4MjJBNDsiPjwhRU5USVRZIERvd25UZWUgIiYjeDIyQTQ7Ij48IUVOVElUWSBib3R0b20gIiYjeDIyQTU7Ij48IUVOVElUWSBib3QgIiYjeDIyQTU7Ij48IUVOVElUWSBwZXJwICImI3gyMkE1OyI%2BPCFFTlRJVFkgVXBUZWUgIiYjeDIyQTU7Ij48IUVOVElUWSBtb2RlbHMgIiYjeDIyQTc7Ij48IUVOVElUWSB2RGFzaCAiJiN4MjJBODsiPjwhRU5USVRZIERvdWJsZVJpZ2h0VGVlICImI3gyMkE4OyI%2BPCFFTlRJVFkgVmRhc2ggIiYjeDIyQTk7Ij48IUVOVElUWSBWdmRhc2ggIiYjeDIyQUE7Ij48IUVOVElUWSBWRGFzaCAiJiN4MjJBQjsiPjwhRU5USVRZIG52ZGFzaCAiJiN4MjJBQzsiPjwhRU5USVRZIG52RGFzaCAiJiN4MjJBRDsiPjwhRU5USVRZIG5WZGFzaCAiJiN4MjJBRTsiPjwhRU5USVRZIG5WRGFzaCAiJiN4MjJBRjsiPjwhRU5USVRZIHBydXJlbCAiJiN4MjJCMDsiPjwhRU5USVRZIHZsdHJpICImI3gyMkIyOyI%2BPCFFTlRJVFkgdmFydHJpYW5nbGVsZWZ0ICImI3gyMkIyOyI%2BPCFFTlRJVFkgTGVmdFRyaWFuZ2xlICImI3gyMkIyOyI%2BPCFFTlRJVFkgdnJ0cmkgIiYjeDIyQjM7Ij48IUVOVElUWSB2YXJ0cmlhbmdsZXJpZ2h0ICImI3gyMkIzOyI%2BPCFFTlRJVFkgUmlnaHRUcmlhbmdsZSAiJiN4MjJCMzsiPjwhRU5USVRZIGx0cmllICImI3gyMkI0OyI%2BPCFFTlRJVFkgdHJpYW5nbGVsZWZ0ZXEgIiYjeDIyQjQ7Ij48IUVOVElUWSBMZWZ0VHJpYW5nbGVFcXVhbCAiJiN4MjJCNDsiPjwhRU5USVRZIG52bHRyaWUgIiYjeDIyQjQ7JiN4MjBEMjsiPjwhRU5USVRZIHJ0cmllICImI3gyMkI1OyI%2BPCFFTlRJVFkgdHJpYW5nbGVyaWdodGVxICImI3gyMkI1OyI%2BPCFFTlRJVFkgUmlnaHRUcmlhbmdsZUVxdWFsICImI3gyMkI1OyI%2BPCFFTlRJVFkgbnZydHJpZSAiJiN4MjJCNTsmI3gyMEQyOyI%2BPCFFTlRJVFkgb3JpZ29mICImI3gyMkI2OyI%2BPCFFTlRJVFkgaW1vZiAiJiN4MjJCNzsiPjwhRU5USVRZIG11bWFwICImI3gyMkI4OyI%2BPCFFTlRJVFkgbXVsdGltYXAgIiYjeDIyQjg7Ij48IUVOVElUWSBoZXJjb24gIiYjeDIyQjk7Ij48IUVOVElUWSBpbnRjYWwgIiYjeDIyQkE7Ij48IUVOVElUWSBpbnRlcmNhbCAiJiN4MjJCQTsiPjwhRU5USVRZIHZlZWJhciAiJiN4MjJCQjsiPjwhRU5USVRZIGJhcnZlZSAiJiN4MjJCRDsiPjwhRU5USVRZIGFuZ3J0dmIgIiYjeDIyQkU7Ij48IUVOVElUWSBscnRyaSAiJiN4MjJCRjsiPjwhRU5USVRZIHh3ZWRnZSAiJiN4MjJDMDsiPjwhRU5USVRZIFdlZGdlICImI3gyMkMwOyI%2BPCFFTlRJVFkgYmlnd2VkZ2UgIiYjeDIyQzA7Ij48IUVOVElUWSB4dmVlICImI3gyMkMxOyI%2BPCFFTlRJVFkgVmVlICImI3gyMkMxOyI%2BPCFFTlRJVFkgYmlndmVlICImI3gyMkMxOyI%2BPCFFTlRJVFkgeGNhcCAiJiN4MjJDMjsiPjwhRU5USVRZIEludGVyc2VjdGlvbiAiJiN4MjJDMjsiPjwhRU5USVRZIGJpZ2NhcCAiJiN4MjJDMjsiPjwhRU5USVRZIHhjdXAgIiYjeDIyQzM7Ij48IUVOVElUWSBVbmlvbiAiJiN4MjJDMzsiPjwhRU5USVRZIGJpZ2N1cCAiJiN4MjJDMzsiPjwhRU5USVRZIGRpYW0gIiYjeDIyQzQ7Ij48IUVOVElUWSBkaWFtb25kICImI3gyMkM0OyI%2BPCFFTlRJVFkgRGlhbW9uZCAiJiN4MjJDNDsiPjwhRU5USVRZIHNkb3QgIiYjeDIyQzU7Ij48IUVOVElUWSBzc3RhcmYgIiYjeDIyQzY7Ij48IUVOVElUWSBTdGFyICImI3gyMkM2OyI%2BPCFFTlRJVFkgZGl2b254ICImI3gyMkM3OyI%2BPCFFTlRJVFkgZGl2aWRlb250aW1lcyAiJiN4MjJDNzsiPjwhRU5USVRZIGJvd3RpZSAiJiN4MjJDODsiPjwhRU5USVRZIGx0aW1lcyAiJiN4MjJDOTsiPjwhRU5USVRZIHJ0aW1lcyAiJiN4MjJDQTsiPjwhRU5USVRZIGx0aHJlZSAiJiN4MjJDQjsiPjwhRU5USVRZIGxlZnR0aHJlZXRpbWVzICImI3gyMkNCOyI%2BPCFFTlRJVFkgcnRocmVlICImI3gyMkNDOyI%2BPCFFTlRJVFkgcmlnaHR0aHJlZXRpbWVzICImI3gyMkNDOyI%2BPCFFTlRJVFkgYnNpbWUgIiYjeDIyQ0Q7Ij48IUVOVElUWSBiYWNrc2ltZXEgIiYjeDIyQ0Q7Ij48IUVOVElUWSBjdXZlZSAiJiN4MjJDRTsiPjwhRU5USVRZIGN1cmx5dmVlICImI3gyMkNFOyI%2BPCFFTlRJVFkgY3V3ZWQgIiYjeDIyQ0Y7Ij48IUVOVElUWSBjdXJseXdlZGdlICImI3gyMkNGOyI%2BPCFFTlRJVFkgU3ViICImI3gyMkQwOyI%2BPCFFTlRJVFkgU3Vic2V0ICImI3gyMkQwOyI%2BPCFFTlRJVFkgU3VwICImI3gyMkQxOyI%2BPCFFTlRJVFkgU3Vwc2V0ICImI3gyMkQxOyI%2BPCFFTlRJVFkgQ2FwICImI3gyMkQyOyI%2BPCFFTlRJVFkgQ3VwICImI3gyMkQzOyI%2BPCFFTlRJVFkgZm9yayAiJiN4MjJENDsiPjwhRU5USVRZIHBpdGNoZm9yayAiJiN4MjJENDsiPjwhRU5USVRZIGVwYXIgIiYjeDIyRDU7Ij48IUVOVElUWSBsdGRvdCAiJiN4MjJENjsiPjwhRU5USVRZIGxlc3Nkb3QgIiYjeDIyRDY7Ij48IUVOVElUWSBndGRvdCAiJiN4MjJENzsiPjwhRU5USVRZIGd0cmRvdCAiJiN4MjJENzsiPjwhRU5USVRZIExsICImI3gyMkQ4OyI%2BPCFFTlRJVFkgbkxsICImI3gyMkQ4OyYjeDMzODsiPjwhRU5USVRZIEdnICImI3gyMkQ5OyI%2BPCFFTlRJVFkgZ2dnICImI3gyMkQ5OyI%2BPCFFTlRJVFkgbkdnICImI3gyMkQ5OyYjeDMzODsiPjwhRU5USVRZIGxlZyAiJiN4MjJEQTsiPjwhRU5USVRZIExlc3NFcXVhbEdyZWF0ZXIgIiYjeDIyREE7Ij48IUVOVElUWSBsZXNzZXFndHIgIiYjeDIyREE7Ij48IUVOVElUWSBsZXNnICImI3gyMkRBOyYjeEZFMDA7Ij48IUVOVElUWSBnZWwgIiYjeDIyREI7Ij48IUVOVElUWSBndHJlcWxlc3MgIiYjeDIyREI7Ij48IUVOVElUWSBHcmVhdGVyRXF1YWxMZXNzICImI3gyMkRCOyI%2BPCFFTlRJVFkgZ2VzbCAiJiN4MjJEQjsmI3hGRTAwOyI%2BPCFFTlRJVFkgY3VlcHIgIiYjeDIyREU7Ij48IUVOVElUWSBjdXJseWVxcHJlYyAiJiN4MjJERTsiPjwhRU5USVRZIGN1ZXNjICImI3gyMkRGOyI%2BPCFFTlRJVFkgY3VybHllcXN1Y2MgIiYjeDIyREY7Ij48IUVOVElUWSBucHJjdWUgIiYjeDIyRTA7Ij48IUVOVElUWSBOb3RQcmVjZWRlc1NsYW50RXF1YWwgIiYjeDIyRTA7Ij48IUVOVElUWSBuc2NjdWUgIiYjeDIyRTE7Ij48IUVOVElUWSBOb3RTdWNjZWVkc1NsYW50RXF1YWwgIiYjeDIyRTE7Ij48IUVOVElUWSBuc3FzdWJlICImI3gyMkUyOyI%2BPCFFTlRJVFkgTm90U3F1YXJlU3Vic2V0RXF1YWwgIiYjeDIyRTI7Ij48IUVOVElUWSBuc3FzdXBlICImI3gyMkUzOyI%2BPCFFTlRJVFkgTm90U3F1YXJlU3VwZXJzZXRFcXVhbCAiJiN4MjJFMzsiPjwhRU5USVRZIGxuc2ltICImI3gyMkU2OyI%2BPCFFTlRJVFkgZ25zaW0gIiYjeDIyRTc7Ij48IUVOVElUWSBwcm5zaW0gIiYjeDIyRTg7Ij48IUVOVElUWSBwcmVjbnNpbSAiJiN4MjJFODsiPjwhRU5USVRZIHNjbnNpbSAiJiN4MjJFOTsiPjwhRU5USVRZIHN1Y2Nuc2ltICImI3gyMkU5OyI%2BPCFFTlRJVFkgbmx0cmkgIiYjeDIyRUE7Ij48IUVOVElUWSBudHJpYW5nbGVsZWZ0ICImI3gyMkVBOyI%2BPCFFTlRJVFkgTm90TGVmdFRyaWFuZ2xlICImI3gyMkVBOyI%2BPCFFTlRJVFkgbnJ0cmkgIiYjeDIyRUI7Ij48IUVOVElUWSBudHJpYW5nbGVyaWdodCAiJiN4MjJFQjsiPjwhRU5USVRZIE5vdFJpZ2h0VHJpYW5nbGUgIiYjeDIyRUI7Ij48IUVOVElUWSBubHRyaWUgIiYjeDIyRUM7Ij48IUVOVElUWSBudHJpYW5nbGVsZWZ0ZXEgIiYjeDIyRUM7Ij48IUVOVElUWSBOb3RMZWZ0VHJpYW5nbGVFcXVhbCAiJiN4MjJFQzsiPjwhRU5USVRZIG5ydHJpZSAiJiN4MjJFRDsiPjwhRU5USVRZIG50cmlhbmdsZXJpZ2h0ZXEgIiYjeDIyRUQ7Ij48IUVOVElUWSBOb3RSaWdodFRyaWFuZ2xlRXF1YWwgIiYjeDIyRUQ7Ij48IUVOVElUWSB2ZWxsaXAgIiYjeDIyRUU7Ij48IUVOVElUWSBjdGRvdCAiJiN4MjJFRjsiPjwhRU5USVRZIHV0ZG90ICImI3gyMkYwOyI%2BPCFFTlRJVFkgZHRkb3QgIiYjeDIyRjE7Ij48IUVOVElUWSBkaXNpbiAiJiN4MjJGMjsiPjwhRU5USVRZIGlzaW5zdiAiJiN4MjJGMzsiPjwhRU5USVRZIGlzaW5zICImI3gyMkY0OyI%2BPCFFTlRJVFkgaXNpbmRvdCAiJiN4MjJGNTsiPjwhRU5USVRZIG5vdGluZG90ICImI3gyMkY1OyYjeDMzODsiPjwhRU5USVRZIG5vdGludmMgIiYjeDIyRjY7Ij48IUVOVElUWSBub3RpbnZiICImI3gyMkY3OyI%2BPCFFTlRJVFkgaXNpbkUgIiYjeDIyRjk7Ij48IUVOVElUWSBub3RpbkUgIiYjeDIyRjk7JiN4MzM4OyI%2BPCFFTlRJVFkgbmlzZCAiJiN4MjJGQTsiPjwhRU5USVRZIHhuaXMgIiYjeDIyRkI7Ij48IUVOVElUWSBuaXMgIiYjeDIyRkM7Ij48IUVOVElUWSBub3RuaXZjICImI3gyMkZEOyI%2BPCFFTlRJVFkgbm90bml2YiAiJiN4MjJGRTsiPjwhRU5USVRZIGJhcndlZCAiJiN4MjMwNTsiPjwhRU5USVRZIGJhcndlZGdlICImI3gyMzA1OyI%2BPCFFTlRJVFkgQmFyd2VkICImI3gyMzA2OyI%2BPCFFTlRJVFkgZG91YmxlYmFyd2VkZ2UgIiYjeDIzMDY7Ij48IUVOVElUWSBsY2VpbCAiJiN4MjMwODsiPjwhRU5USVRZIExlZnRDZWlsaW5nICImI3gyMzA4OyI%2BPCFFTlRJVFkgcmNlaWwgIiYjeDIzMDk7Ij48IUVOVElUWSBSaWdodENlaWxpbmcgIiYjeDIzMDk7Ij48IUVOVElUWSBsZmxvb3IgIiYjeDIzMEE7Ij48IUVOVElUWSBMZWZ0Rmxvb3IgIiYjeDIzMEE7Ij48IUVOVElUWSByZmxvb3IgIiYjeDIzMEI7Ij48IUVOVElUWSBSaWdodEZsb29yICImI3gyMzBCOyI%2BPCFFTlRJVFkgZHJjcm9wICImI3gyMzBDOyI%2BPCFFTlRJVFkgZGxjcm9wICImI3gyMzBEOyI%2BPCFFTlRJVFkgdXJjcm9wICImI3gyMzBFOyI%2BPCFFTlRJVFkgdWxjcm9wICImI3gyMzBGOyI%2BPCFFTlRJVFkgYm5vdCAiJiN4MjMxMDsiPjwhRU5USVRZIHByb2ZsaW5lICImI3gyMzEyOyI%2BPCFFTlRJVFkgcHJvZnN1cmYgIiYjeDIzMTM7Ij48IUVOVElUWSB0ZWxyZWMgIiYjeDIzMTU7Ij48IUVOVElUWSB0YXJnZXQgIiYjeDIzMTY7Ij48IUVOVElUWSB1bGNvcm4gIiYjeDIzMUM7Ij48IUVOVElUWSB1bGNvcm5lciAiJiN4MjMxQzsiPjwhRU5USVRZIHVyY29ybiAiJiN4MjMxRDsiPjwhRU5USVRZIHVyY29ybmVyICImI3gyMzFEOyI%2BPCFFTlRJVFkgZGxjb3JuICImI3gyMzFFOyI%2BPCFFTlRJVFkgbGxjb3JuZXIgIiYjeDIzMUU7Ij48IUVOVElUWSBkcmNvcm4gIiYjeDIzMUY7Ij48IUVOVElUWSBscmNvcm5lciAiJiN4MjMxRjsiPjwhRU5USVRZIGZyb3duICImI3gyMzIyOyI%2BPCFFTlRJVFkgc2Zyb3duICImI3gyMzIyOyI%2BPCFFTlRJVFkgc21pbGUgIiYjeDIzMjM7Ij48IUVOVElUWSBzc21pbGUgIiYjeDIzMjM7Ij48IUVOVElUWSBjeWxjdHkgIiYjeDIzMkQ7Ij48IUVOVElUWSBwcm9mYWxhciAiJiN4MjMyRTsiPjwhRU5USVRZIHRvcGJvdCAiJiN4MjMzNjsiPjwhRU5USVRZIG92YmFyICImI3gyMzNEOyI%2BPCFFTlRJVFkgc29sYmFyICImI3gyMzNGOyI%2BPCFFTlRJVFkgYW5nemFyciAiJiN4MjM3QzsiPjwhRU5USVRZIGxtb3VzdCAiJiN4MjNCMDsiPjwhRU5USVRZIGxtb3VzdGFjaGUgIiYjeDIzQjA7Ij48IUVOVElUWSBybW91c3QgIiYjeDIzQjE7Ij48IUVOVElUWSBybW91c3RhY2hlICImI3gyM0IxOyI%2BPCFFTlRJVFkgdGJyayAiJiN4MjNCNDsiPjwhRU5USVRZIE92ZXJCcmFja2V0ICImI3gyM0I0OyI%2BPCFFTlRJVFkgYmJyayAiJiN4MjNCNTsiPjwhRU5USVRZIFVuZGVyQnJhY2tldCAiJiN4MjNCNTsiPjwhRU5USVRZIGJicmt0YnJrICImI3gyM0I2OyI%2BPCFFTlRJVFkgT3ZlclBhcmVudGhlc2lzICImI3gyM0RDOyI%2BPCFFTlRJVFkgVW5kZXJQYXJlbnRoZXNpcyAiJiN4MjNERDsiPjwhRU5USVRZIE92ZXJCcmFjZSAiJiN4MjNERTsiPjwhRU5USVRZIFVuZGVyQnJhY2UgIiYjeDIzREY7Ij48IUVOVElUWSB0cnBleml1bSAiJiN4MjNFMjsiPjwhRU5USVRZIGVsaW50ZXJzICImI3gyM0U3OyI%2BPCFFTlRJVFkgYmxhbmsgIiYjeDI0MjM7Ij48IUVOVElUWSBvUyAiJiN4MjRDODsiPjwhRU5USVRZIGNpcmNsZWRTICImI3gyNEM4OyI%2BPCFFTlRJVFkgYm94aCAiJiN4MjUwMDsiPjwhRU5USVRZIEhvcml6b250YWxMaW5lICImI3gyNTAwOyI%2BPCFFTlRJVFkgYm94diAiJiN4MjUwMjsiPjwhRU5USVRZIGJveGRyICImI3gyNTBDOyI%2BPCFFTlRJVFkgYm94ZGwgIiYjeDI1MTA7Ij48IUVOVElUWSBib3h1ciAiJiN4MjUxNDsiPjwhRU5USVRZIGJveHVsICImI3gyNTE4OyI%2BPCFFTlRJVFkgYm94dnIgIiYjeDI1MUM7Ij48IUVOVElUWSBib3h2bCAiJiN4MjUyNDsiPjwhRU5USVRZIGJveGhkICImI3gyNTJDOyI%2BPCFFTlRJVFkgYm94aHUgIiYjeDI1MzQ7Ij48IUVOVElUWSBib3h2aCAiJiN4MjUzQzsiPjwhRU5USVRZIGJveEggIiYjeDI1NTA7Ij48IUVOVElUWSBib3hWICImI3gyNTUxOyI%2BPCFFTlRJVFkgYm94ZFIgIiYjeDI1NTI7Ij48IUVOVElUWSBib3hEciAiJiN4MjU1MzsiPjwhRU5USVRZIGJveERSICImI3gyNTU0OyI%2BPCFFTlRJVFkgYm94ZEwgIiYjeDI1NTU7Ij48IUVOVElUWSBib3hEbCAiJiN4MjU1NjsiPjwhRU5USVRZIGJveERMICImI3gyNTU3OyI%2BPCFFTlRJVFkgYm94dVIgIiYjeDI1NTg7Ij48IUVOVElUWSBib3hVciAiJiN4MjU1OTsiPjwhRU5USVRZIGJveFVSICImI3gyNTVBOyI%2BPCFFTlRJVFkgYm94dUwgIiYjeDI1NUI7Ij48IUVOVElUWSBib3hVbCAiJiN4MjU1QzsiPjwhRU5USVRZIGJveFVMICImI3gyNTVEOyI%2BPCFFTlRJVFkgYm94dlIgIiYjeDI1NUU7Ij48IUVOVElUWSBib3hWciAiJiN4MjU1RjsiPjwhRU5USVRZIGJveFZSICImI3gyNTYwOyI%2BPCFFTlRJVFkgYm94dkwgIiYjeDI1NjE7Ij48IUVOVElUWSBib3hWbCAiJiN4MjU2MjsiPjwhRU5USVRZIGJveFZMICImI3gyNTYzOyI%2BPCFFTlRJVFkgYm94SGQgIiYjeDI1NjQ7Ij48IUVOVElUWSBib3hoRCAiJiN4MjU2NTsiPjwhRU5USVRZIGJveEhEICImI3gyNTY2OyI%2BPCFFTlRJVFkgYm94SHUgIiYjeDI1Njc7Ij48IUVOVElUWSBib3hoVSAiJiN4MjU2ODsiPjwhRU5USVRZIGJveEhVICImI3gyNTY5OyI%2BPCFFTlRJVFkgYm94dkggIiYjeDI1NkE7Ij48IUVOVElUWSBib3hWaCAiJiN4MjU2QjsiPjwhRU5USVRZIGJveFZIICImI3gyNTZDOyI%2BPCFFTlRJVFkgdWhibGsgIiYjeDI1ODA7Ij48IUVOVElUWSBsaGJsayAiJiN4MjU4NDsiPjwhRU5USVRZIGJsb2NrICImI3gyNTg4OyI%2BPCFFTlRJVFkgYmxrMTQgIiYjeDI1OTE7Ij48IUVOVElUWSBibGsxMiAiJiN4MjU5MjsiPjwhRU5USVRZIGJsazM0ICImI3gyNTkzOyI%2BPCFFTlRJVFkgc3F1ICImI3gyNUExOyI%2BPCFFTlRJVFkgc3F1YXJlICImI3gyNUExOyI%2BPCFFTlRJVFkgU3F1YXJlICImI3gyNUExOyI%2BPCFFTlRJVFkgc3F1ZiAiJiN4MjVBQTsiPjwhRU5USVRZIHNxdWFyZiAiJiN4MjVBQTsiPjwhRU5USVRZIGJsYWNrc3F1YXJlICImI3gyNUFBOyI%2BPCFFTlRJVFkgRmlsbGVkVmVyeVNtYWxsU3F1YXJlICImI3gyNUFBOyI%2BPCFFTlRJVFkgRW1wdHlWZXJ5U21hbGxTcXVhcmUgIiYjeDI1QUI7Ij48IUVOVElUWSByZWN0ICImI3gyNUFEOyI%2BPCFFTlRJVFkgbWFya2VyICImI3gyNUFFOyI%2BPCFFTlRJVFkgZmx0bnMgIiYjeDI1QjE7Ij48IUVOVElUWSB4dXRyaSAiJiN4MjVCMzsiPjwhRU5USVRZIGJpZ3RyaWFuZ2xldXAgIiYjeDI1QjM7Ij48IUVOVElUWSB1dHJpZiAiJiN4MjVCNDsiPjwhRU5USVRZIGJsYWNrdHJpYW5nbGUgIiYjeDI1QjQ7Ij48IUVOVElUWSB1dHJpICImI3gyNUI1OyI%2BPCFFTlRJVFkgdHJpYW5nbGUgIiYjeDI1QjU7Ij48IUVOVElUWSBydHJpZiAiJiN4MjVCODsiPjwhRU5USVRZIGJsYWNrdHJpYW5nbGVyaWdodCAiJiN4MjVCODsiPjwhRU5USVRZIHJ0cmkgIiYjeDI1Qjk7Ij48IUVOVElUWSB0cmlhbmdsZXJpZ2h0ICImI3gyNUI5OyI%2BPCFFTlRJVFkgeGR0cmkgIiYjeDI1QkQ7Ij48IUVOVElUWSBiaWd0cmlhbmdsZWRvd24gIiYjeDI1QkQ7Ij48IUVOVElUWSBkdHJpZiAiJiN4MjVCRTsiPjwhRU5USVRZIGJsYWNrdHJpYW5nbGVkb3duICImI3gyNUJFOyI%2BPCFFTlRJVFkgZHRyaSAiJiN4MjVCRjsiPjwhRU5USVRZIHRyaWFuZ2xlZG93biAiJiN4MjVCRjsiPjwhRU5USVRZIGx0cmlmICImI3gyNUMyOyI%2BPCFFTlRJVFkgYmxhY2t0cmlhbmdsZWxlZnQgIiYjeDI1QzI7Ij48IUVOVElUWSBsdHJpICImI3gyNUMzOyI%2BPCFFTlRJVFkgdHJpYW5nbGVsZWZ0ICImI3gyNUMzOyI%2BPCFFTlRJVFkgbG96ICImI3gyNUNBOyI%2BPCFFTlRJVFkgbG96ZW5nZSAiJiN4MjVDQTsiPjwhRU5USVRZIGNpciAiJiN4MjVDQjsiPjwhRU5USVRZIHRyaWRvdCAiJiN4MjVFQzsiPjwhRU5USVRZIHhjaXJjICImI3gyNUVGOyI%2BPCFFTlRJVFkgYmlnY2lyYyAiJiN4MjVFRjsiPjwhRU5USVRZIHVsdHJpICImI3gyNUY4OyI%2BPCFFTlRJVFkgdXJ0cmkgIiYjeDI1Rjk7Ij48IUVOVElUWSBsbHRyaSAiJiN4MjVGQTsiPjwhRU5USVRZIEVtcHR5U21hbGxTcXVhcmUgIiYjeDI1RkI7Ij48IUVOVElUWSBGaWxsZWRTbWFsbFNxdWFyZSAiJiN4MjVGQzsiPjwhRU5USVRZIHN0YXJmICImI3gyNjA1OyI%2BPCFFTlRJVFkgYmlnc3RhciAiJiN4MjYwNTsiPjwhRU5USVRZIHN0YXIgIiYjeDI2MDY7Ij48IUVOVElUWSBwaG9uZSAiJiN4MjYwRTsiPjwhRU5USVRZIGZlbWFsZSAiJiN4MjY0MDsiPjwhRU5USVRZIG1hbGUgIiYjeDI2NDI7Ij48IUVOVElUWSBzcGFkZXMgIiYjeDI2NjA7Ij48IUVOVElUWSBzcGFkZXN1aXQgIiYjeDI2NjA7Ij48IUVOVElUWSBjbHVicyAiJiN4MjY2MzsiPjwhRU5USVRZIGNsdWJzdWl0ICImI3gyNjYzOyI%2BPCFFTlRJVFkgaGVhcnRzICImI3gyNjY1OyI%2BPCFFTlRJVFkgaGVhcnRzdWl0ICImI3gyNjY1OyI%2BPCFFTlRJVFkgZGlhbXMgIiYjeDI2NjY7Ij48IUVOVElUWSBkaWFtb25kc3VpdCAiJiN4MjY2NjsiPjwhRU5USVRZIHN1bmcgIiYjeDI2NkE7Ij48IUVOVElUWSBmbGF0ICImI3gyNjZEOyI%2BPCFFTlRJVFkgbmF0dXIgIiYjeDI2NkU7Ij48IUVOVElUWSBuYXR1cmFsICImI3gyNjZFOyI%2BPCFFTlRJVFkgc2hhcnAgIiYjeDI2NkY7Ij48IUVOVElUWSBjaGVjayAiJiN4MjcxMzsiPjwhRU5USVRZIGNoZWNrbWFyayAiJiN4MjcxMzsiPjwhRU5USVRZIGNyb3NzICImI3gyNzE3OyI%2BPCFFTlRJVFkgbWFsdCAiJiN4MjcyMDsiPjwhRU5USVRZIG1hbHRlc2UgIiYjeDI3MjA7Ij48IUVOVElUWSBzZXh0ICImI3gyNzM2OyI%2BPCFFTlRJVFkgVmVydGljYWxTZXBhcmF0b3IgIiYjeDI3NTg7Ij48IUVOVElUWSBsYmJyayAiJiN4Mjc3MjsiPjwhRU5USVRZIHJiYnJrICImI3gyNzczOyI%2BPCFFTlRJVFkgYnNvbGhzdWIgIiYjeDI3Qzg7Ij48IUVOVElUWSBzdXBoc29sICImI3gyN0M5OyI%2BPCFFTlRJVFkgbG9icmsgIiYjeDI3RTY7Ij48IUVOVElUWSBMZWZ0RG91YmxlQnJhY2tldCAiJiN4MjdFNjsiPjwhRU5USVRZIHJvYnJrICImI3gyN0U3OyI%2BPCFFTlRJVFkgUmlnaHREb3VibGVCcmFja2V0ICImI3gyN0U3OyI%2BPCFFTlRJVFkgbGFuZyAiJiN4MjdFODsiPjwhRU5USVRZIExlZnRBbmdsZUJyYWNrZXQgIiYjeDI3RTg7Ij48IUVOVElUWSBsYW5nbGUgIiYjeDI3RTg7Ij48IUVOVElUWSByYW5nICImI3gyN0U5OyI%2BPCFFTlRJVFkgUmlnaHRBbmdsZUJyYWNrZXQgIiYjeDI3RTk7Ij48IUVOVElUWSByYW5nbGUgIiYjeDI3RTk7Ij48IUVOVElUWSBMYW5nICImI3gyN0VBOyI%2BPCFFTlRJVFkgUmFuZyAiJiN4MjdFQjsiPjwhRU5USVRZIGxvYW5nICImI3gyN0VDOyI%2BPCFFTlRJVFkgcm9hbmcgIiYjeDI3RUQ7Ij48IUVOVElUWSB4bGFyciAiJiN4MjdGNTsiPjwhRU5USVRZIGxvbmdsZWZ0YXJyb3cgIiYjeDI3RjU7Ij48IUVOVElUWSBMb25nTGVmdEFycm93ICImI3gyN0Y1OyI%2BPCFFTlRJVFkgeHJhcnIgIiYjeDI3RjY7Ij48IUVOVElUWSBsb25ncmlnaHRhcnJvdyAiJiN4MjdGNjsiPjwhRU5USVRZIExvbmdSaWdodEFycm93ICImI3gyN0Y2OyI%2BPCFFTlRJVFkgeGhhcnIgIiYjeDI3Rjc7Ij48IUVOVElUWSBsb25nbGVmdHJpZ2h0YXJyb3cgIiYjeDI3Rjc7Ij48IUVOVElUWSBMb25nTGVmdFJpZ2h0QXJyb3cgIiYjeDI3Rjc7Ij48IUVOVElUWSB4bEFyciAiJiN4MjdGODsiPjwhRU5USVRZIExvbmdsZWZ0YXJyb3cgIiYjeDI3Rjg7Ij48IUVOVElUWSBEb3VibGVMb25nTGVmdEFycm93ICImI3gyN0Y4OyI%2BPCFFTlRJVFkgeHJBcnIgIiYjeDI3Rjk7Ij48IUVOVElUWSBMb25ncmlnaHRhcnJvdyAiJiN4MjdGOTsiPjwhRU5USVRZIERvdWJsZUxvbmdSaWdodEFycm93ICImI3gyN0Y5OyI%2BPCFFTlRJVFkgeGhBcnIgIiYjeDI3RkE7Ij48IUVOVElUWSBMb25nbGVmdHJpZ2h0YXJyb3cgIiYjeDI3RkE7Ij48IUVOVElUWSBEb3VibGVMb25nTGVmdFJpZ2h0QXJyb3cgIiYjeDI3RkE7Ij48IUVOVElUWSB4bWFwICImI3gyN0ZDOyI%2BPCFFTlRJVFkgbG9uZ21hcHN0byAiJiN4MjdGQzsiPjwhRU5USVRZIGR6aWdyYXJyICImI3gyN0ZGOyI%2BPCFFTlRJVFkgbnZsQXJyICImI3gyOTAyOyI%2BPCFFTlRJVFkgbnZyQXJyICImI3gyOTAzOyI%2BPCFFTlRJVFkgbnZIYXJyICImI3gyOTA0OyI%2BPCFFTlRJVFkgTWFwICImI3gyOTA1OyI%2BPCFFTlRJVFkgbGJhcnIgIiYjeDI5MEM7Ij48IUVOVElUWSByYmFyciAiJiN4MjkwRDsiPjwhRU5USVRZIGJrYXJvdyAiJiN4MjkwRDsiPjwhRU5USVRZIGxCYXJyICImI3gyOTBFOyI%2BPCFFTlRJVFkgckJhcnIgIiYjeDI5MEY7Ij48IUVOVElUWSBkYmthcm93ICImI3gyOTBGOyI%2BPCFFTlRJVFkgUkJhcnIgIiYjeDI5MTA7Ij48IUVOVElUWSBkcmJrYXJvdyAiJiN4MjkxMDsiPjwhRU5USVRZIEREb3RyYWhkICImI3gyOTExOyI%2BPCFFTlRJVFkgVXBBcnJvd0JhciAiJiN4MjkxMjsiPjwhRU5USVRZIERvd25BcnJvd0JhciAiJiN4MjkxMzsiPjwhRU5USVRZIFJhcnJ0bCAiJiN4MjkxNjsiPjwhRU5USVRZIGxhdGFpbCAiJiN4MjkxOTsiPjwhRU5USVRZIHJhdGFpbCAiJiN4MjkxQTsiPjwhRU5USVRZIGxBdGFpbCAiJiN4MjkxQjsiPjwhRU5USVRZIHJBdGFpbCAiJiN4MjkxQzsiPjwhRU5USVRZIGxhcnJmcyAiJiN4MjkxRDsiPjwhRU5USVRZIHJhcnJmcyAiJiN4MjkxRTsiPjwhRU5USVRZIGxhcnJiZnMgIiYjeDI5MUY7Ij48IUVOVElUWSByYXJyYmZzICImI3gyOTIwOyI%2BPCFFTlRJVFkgbndhcmhrICImI3gyOTIzOyI%2BPCFFTlRJVFkgbmVhcmhrICImI3gyOTI0OyI%2BPCFFTlRJVFkgc2VhcmhrICImI3gyOTI1OyI%2BPCFFTlRJVFkgaGtzZWFyb3cgIiYjeDI5MjU7Ij48IUVOVElUWSBzd2FyaGsgIiYjeDI5MjY7Ij48IUVOVElUWSBoa3N3YXJvdyAiJiN4MjkyNjsiPjwhRU5USVRZIG53bmVhciAiJiN4MjkyNzsiPjwhRU5USVRZIG5lc2VhciAiJiN4MjkyODsiPjwhRU5USVRZIHRvZWEgIiYjeDI5Mjg7Ij48IUVOVElUWSBzZXN3YXIgIiYjeDI5Mjk7Ij48IUVOVElUWSB0b3NhICImI3gyOTI5OyI%2BPCFFTlRJVFkgc3dud2FyICImI3gyOTJBOyI%2BPCFFTlRJVFkgcmFycmMgIiYjeDI5MzM7Ij48IUVOVElUWSBucmFycmMgIiYjeDI5MzM7JiN4MzM4OyI%2BPCFFTlRJVFkgY3VkYXJyciAiJiN4MjkzNTsiPjwhRU5USVRZIGxkY2EgIiYjeDI5MzY7Ij48IUVOVElUWSByZGNhICImI3gyOTM3OyI%2BPCFFTlRJVFkgY3VkYXJybCAiJiN4MjkzODsiPjwhRU5USVRZIGxhcnJwbCAiJiN4MjkzOTsiPjwhRU5USVRZIGN1cmFycm0gIiYjeDI5M0M7Ij48IUVOVElUWSBjdWxhcnJwICImI3gyOTNEOyI%2BPCFFTlRJVFkgcmFycnBsICImI3gyOTQ1OyI%2BPCFFTlRJVFkgaGFycmNpciAiJiN4Mjk0ODsiPjwhRU5USVRZIFVhcnJvY2lyICImI3gyOTQ5OyI%2BPCFFTlRJVFkgbHVyZHNoYXIgIiYjeDI5NEE7Ij48IUVOVElUWSBsZHJ1c2hhciAiJiN4Mjk0QjsiPjwhRU5USVRZIExlZnRSaWdodFZlY3RvciAiJiN4Mjk0RTsiPjwhRU5USVRZIFJpZ2h0VXBEb3duVmVjdG9yICImI3gyOTRGOyI%2BPCFFTlRJVFkgRG93bkxlZnRSaWdodFZlY3RvciAiJiN4Mjk1MDsiPjwhRU5USVRZIExlZnRVcERvd25WZWN0b3IgIiYjeDI5NTE7Ij48IUVOVElUWSBMZWZ0VmVjdG9yQmFyICImI3gyOTUyOyI%2BPCFFTlRJVFkgUmlnaHRWZWN0b3JCYXIgIiYjeDI5NTM7Ij48IUVOVElUWSBSaWdodFVwVmVjdG9yQmFyICImI3gyOTU0OyI%2BPCFFTlRJVFkgUmlnaHREb3duVmVjdG9yQmFyICImI3gyOTU1OyI%2BPCFFTlRJVFkgRG93bkxlZnRWZWN0b3JCYXIgIiYjeDI5NTY7Ij48IUVOVElUWSBEb3duUmlnaHRWZWN0b3JCYXIgIiYjeDI5NTc7Ij48IUVOVElUWSBMZWZ0VXBWZWN0b3JCYXIgIiYjeDI5NTg7Ij48IUVOVElUWSBMZWZ0RG93blZlY3RvckJhciAiJiN4Mjk1OTsiPjwhRU5USVRZIExlZnRUZWVWZWN0b3IgIiYjeDI5NUE7Ij48IUVOVElUWSBSaWdodFRlZVZlY3RvciAiJiN4Mjk1QjsiPjwhRU5USVRZIFJpZ2h0VXBUZWVWZWN0b3IgIiYjeDI5NUM7Ij48IUVOVElUWSBSaWdodERvd25UZWVWZWN0b3IgIiYjeDI5NUQ7Ij48IUVOVElUWSBEb3duTGVmdFRlZVZlY3RvciAiJiN4Mjk1RTsiPjwhRU5USVRZIERvd25SaWdodFRlZVZlY3RvciAiJiN4Mjk1RjsiPjwhRU5USVRZIExlZnRVcFRlZVZlY3RvciAiJiN4Mjk2MDsiPjwhRU5USVRZIExlZnREb3duVGVlVmVjdG9yICImI3gyOTYxOyI%2BPCFFTlRJVFkgbEhhciAiJiN4Mjk2MjsiPjwhRU5USVRZIHVIYXIgIiYjeDI5NjM7Ij48IUVOVElUWSBySGFyICImI3gyOTY0OyI%2BPCFFTlRJVFkgZEhhciAiJiN4Mjk2NTsiPjwhRU5USVRZIGx1cnVoYXIgIiYjeDI5NjY7Ij48IUVOVElUWSBsZHJkaGFyICImI3gyOTY3OyI%2BPCFFTlRJVFkgcnVsdWhhciAiJiN4Mjk2ODsiPjwhRU5USVRZIHJkbGRoYXIgIiYjeDI5Njk7Ij48IUVOVElUWSBsaGFydWwgIiYjeDI5NkE7Ij48IUVOVElUWSBsbGhhcmQgIiYjeDI5NkI7Ij48IUVOVElUWSByaGFydWwgIiYjeDI5NkM7Ij48IUVOVElUWSBscmhhcmQgIiYjeDI5NkQ7Ij48IUVOVElUWSB1ZGhhciAiJiN4Mjk2RTsiPjwhRU5USVRZIFVwRXF1aWxpYnJpdW0gIiYjeDI5NkU7Ij48IUVOVElUWSBkdWhhciAiJiN4Mjk2RjsiPjwhRU5USVRZIFJldmVyc2VVcEVxdWlsaWJyaXVtICImI3gyOTZGOyI%2BPCFFTlRJVFkgUm91bmRJbXBsaWVzICImI3gyOTcwOyI%2BPCFFTlRJVFkgZXJhcnIgIiYjeDI5NzE7Ij48IUVOVElUWSBzaW1yYXJyICImI3gyOTcyOyI%2BPCFFTlRJVFkgbGFycnNpbSAiJiN4Mjk3MzsiPjwhRU5USVRZIHJhcnJzaW0gIiYjeDI5NzQ7Ij48IUVOVElUWSByYXJyYXAgIiYjeDI5NzU7Ij48IUVOVElUWSBsdGxhcnIgIiYjeDI5NzY7Ij48IUVOVElUWSBndHJhcnIgIiYjeDI5Nzg7Ij48IUVOVElUWSBzdWJyYXJyICImI3gyOTc5OyI%2BPCFFTlRJVFkgc3VwbGFyciAiJiN4Mjk3QjsiPjwhRU5USVRZIGxmaXNodCAiJiN4Mjk3QzsiPjwhRU5USVRZIHJmaXNodCAiJiN4Mjk3RDsiPjwhRU5USVRZIHVmaXNodCAiJiN4Mjk3RTsiPjwhRU5USVRZIGRmaXNodCAiJiN4Mjk3RjsiPjwhRU5USVRZIGxvcGFyICImI3gyOTg1OyI%2BPCFFTlRJVFkgcm9wYXIgIiYjeDI5ODY7Ij48IUVOVElUWSBsYnJrZSAiJiN4Mjk4QjsiPjwhRU5USVRZIHJicmtlICImI3gyOThDOyI%2BPCFFTlRJVFkgbGJya3NsdSAiJiN4Mjk4RDsiPjwhRU5USVRZIHJicmtzbGQgIiYjeDI5OEU7Ij48IUVOVElUWSBsYnJrc2xkICImI3gyOThGOyI%2BPCFFTlRJVFkgcmJya3NsdSAiJiN4Mjk5MDsiPjwhRU5USVRZIGxhbmdkICImI3gyOTkxOyI%2BPCFFTlRJVFkgcmFuZ2QgIiYjeDI5OTI7Ij48IUVOVElUWSBscGFybHQgIiYjeDI5OTM7Ij48IUVOVElUWSBycGFyZ3QgIiYjeDI5OTQ7Ij48IUVOVElUWSBndGxQYXIgIiYjeDI5OTU7Ij48IUVOVElUWSBsdHJQYXIgIiYjeDI5OTY7Ij48IUVOVElUWSB2emlnemFnICImI3gyOTlBOyI%2BPCFFTlRJVFkgdmFuZ3J0ICImI3gyOTlDOyI%2BPCFFTlRJVFkgYW5ncnR2YmQgIiYjeDI5OUQ7Ij48IUVOVElUWSBhbmdlICImI3gyOUE0OyI%2BPCFFTlRJVFkgcmFuZ2UgIiYjeDI5QTU7Ij48IUVOVElUWSBkd2FuZ2xlICImI3gyOUE2OyI%2BPCFFTlRJVFkgdXdhbmdsZSAiJiN4MjlBNzsiPjwhRU5USVRZIGFuZ21zZGFhICImI3gyOUE4OyI%2BPCFFTlRJVFkgYW5nbXNkYWIgIiYjeDI5QTk7Ij48IUVOVElUWSBhbmdtc2RhYyAiJiN4MjlBQTsiPjwhRU5USVRZIGFuZ21zZGFkICImI3gyOUFCOyI%2BPCFFTlRJVFkgYW5nbXNkYWUgIiYjeDI5QUM7Ij48IUVOVElUWSBhbmdtc2RhZiAiJiN4MjlBRDsiPjwhRU5USVRZIGFuZ21zZGFnICImI3gyOUFFOyI%2BPCFFTlRJVFkgYW5nbXNkYWggIiYjeDI5QUY7Ij48IUVOVElUWSBiZW1wdHl2ICImI3gyOUIwOyI%2BPCFFTlRJVFkgZGVtcHR5diAiJiN4MjlCMTsiPjwhRU5USVRZIGNlbXB0eXYgIiYjeDI5QjI7Ij48IUVOVElUWSByYWVtcHR5diAiJiN4MjlCMzsiPjwhRU5USVRZIGxhZW1wdHl2ICImI3gyOUI0OyI%2BPCFFTlRJVFkgb2hiYXIgIiYjeDI5QjU7Ij48IUVOVElUWSBvbWlkICImI3gyOUI2OyI%2BPCFFTlRJVFkgb3BhciAiJiN4MjlCNzsiPjwhRU5USVRZIG9wZXJwICImI3gyOUI5OyI%2BPCFFTlRJVFkgb2xjcm9zcyAiJiN4MjlCQjsiPjwhRU5USVRZIG9kc29sZCAiJiN4MjlCQzsiPjwhRU5USVRZIG9sY2lyICImI3gyOUJFOyI%2BPCFFTlRJVFkgb2ZjaXIgIiYjeDI5QkY7Ij48IUVOVElUWSBvbHQgIiYjeDI5QzA7Ij48IUVOVElUWSBvZ3QgIiYjeDI5QzE7Ij48IUVOVElUWSBjaXJzY2lyICImI3gyOUMyOyI%2BPCFFTlRJVFkgY2lyRSAiJiN4MjlDMzsiPjwhRU5USVRZIHNvbGIgIiYjeDI5QzQ7Ij48IUVOVElUWSBic29sYiAiJiN4MjlDNTsiPjwhRU5USVRZIGJveGJveCAiJiN4MjlDOTsiPjwhRU5USVRZIHRyaXNiICImI3gyOUNEOyI%2BPCFFTlRJVFkgcnRyaWx0cmkgIiYjeDI5Q0U7Ij48IUVOVElUWSBMZWZ0VHJpYW5nbGVCYXIgIiYjeDI5Q0Y7Ij48IUVOVElUWSBOb3RMZWZ0VHJpYW5nbGVCYXIgIiYjeDI5Q0Y7JiN4MzM4OyI%2BPCFFTlRJVFkgUmlnaHRUcmlhbmdsZUJhciAiJiN4MjlEMDsiPjwhRU5USVRZIE5vdFJpZ2h0VHJpYW5nbGVCYXIgIiYjeDI5RDA7JiN4MzM4OyI%2BPCFFTlRJVFkgaWluZmluICImI3gyOURDOyI%2BPCFFTlRJVFkgaW5maW50aWUgIiYjeDI5REQ7Ij48IUVOVElUWSBudmluZmluICImI3gyOURFOyI%2BPCFFTlRJVFkgZXBhcnNsICImI3gyOUUzOyI%2BPCFFTlRJVFkgc21lcGFyc2wgIiYjeDI5RTQ7Ij48IUVOVElUWSBlcXZwYXJzbCAiJiN4MjlFNTsiPjwhRU5USVRZIGxvemYgIiYjeDI5RUI7Ij48IUVOVElUWSBibGFja2xvemVuZ2UgIiYjeDI5RUI7Ij48IUVOVElUWSBSdWxlRGVsYXllZCAiJiN4MjlGNDsiPjwhRU5USVRZIGRzb2wgIiYjeDI5RjY7Ij48IUVOVElUWSB4b2RvdCAiJiN4MkEwMDsiPjwhRU5USVRZIGJpZ29kb3QgIiYjeDJBMDA7Ij48IUVOVElUWSB4b3BsdXMgIiYjeDJBMDE7Ij48IUVOVElUWSBiaWdvcGx1cyAiJiN4MkEwMTsiPjwhRU5USVRZIHhvdGltZSAiJiN4MkEwMjsiPjwhRU5USVRZIGJpZ290aW1lcyAiJiN4MkEwMjsiPjwhRU5USVRZIHh1cGx1cyAiJiN4MkEwNDsiPjwhRU5USVRZIGJpZ3VwbHVzICImI3gyQTA0OyI%2BPCFFTlRJVFkgeHNxY3VwICImI3gyQTA2OyI%2BPCFFTlRJVFkgYmlnc3FjdXAgIiYjeDJBMDY7Ij48IUVOVElUWSBxaW50ICImI3gyQTBDOyI%2BPCFFTlRJVFkgaWlpaW50ICImI3gyQTBDOyI%2BPCFFTlRJVFkgZnBhcnRpbnQgIiYjeDJBMEQ7Ij48IUVOVElUWSBjaXJmbmludCAiJiN4MkExMDsiPjwhRU5USVRZIGF3aW50ICImI3gyQTExOyI%2BPCFFTlRJVFkgcnBwb2xpbnQgIiYjeDJBMTI7Ij48IUVOVElUWSBzY3BvbGludCAiJiN4MkExMzsiPjwhRU5USVRZIG5wb2xpbnQgIiYjeDJBMTQ7Ij48IUVOVElUWSBwb2ludGludCAiJiN4MkExNTsiPjwhRU5USVRZIHF1YXRpbnQgIiYjeDJBMTY7Ij48IUVOVElUWSBpbnRsYXJoayAiJiN4MkExNzsiPjwhRU5USVRZIHBsdXNjaXIgIiYjeDJBMjI7Ij48IUVOVElUWSBwbHVzYWNpciAiJiN4MkEyMzsiPjwhRU5USVRZIHNpbXBsdXMgIiYjeDJBMjQ7Ij48IUVOVElUWSBwbHVzZHUgIiYjeDJBMjU7Ij48IUVOVElUWSBwbHVzc2ltICImI3gyQTI2OyI%2BPCFFTlRJVFkgcGx1c3R3byAiJiN4MkEyNzsiPjwhRU5USVRZIG1jb21tYSAiJiN4MkEyOTsiPjwhRU5USVRZIG1pbnVzZHUgIiYjeDJBMkE7Ij48IUVOVElUWSBsb3BsdXMgIiYjeDJBMkQ7Ij48IUVOVElUWSByb3BsdXMgIiYjeDJBMkU7Ij48IUVOVElUWSBDcm9zcyAiJiN4MkEyRjsiPjwhRU5USVRZIHRpbWVzZCAiJiN4MkEzMDsiPjwhRU5USVRZIHRpbWVzYmFyICImI3gyQTMxOyI%2BPCFFTlRJVFkgc21hc2hwICImI3gyQTMzOyI%2BPCFFTlRJVFkgbG90aW1lcyAiJiN4MkEzNDsiPjwhRU5USVRZIHJvdGltZXMgIiYjeDJBMzU7Ij48IUVOVElUWSBvdGltZXNhcyAiJiN4MkEzNjsiPjwhRU5USVRZIE90aW1lcyAiJiN4MkEzNzsiPjwhRU5USVRZIG9kaXYgIiYjeDJBMzg7Ij48IUVOVElUWSB0cmlwbHVzICImI3gyQTM5OyI%2BPCFFTlRJVFkgdHJpbWludXMgIiYjeDJBM0E7Ij48IUVOVElUWSB0cml0aW1lICImI3gyQTNCOyI%2BPCFFTlRJVFkgaXByb2QgIiYjeDJBM0M7Ij48IUVOVElUWSBpbnRwcm9kICImI3gyQTNDOyI%2BPCFFTlRJVFkgYW1hbGcgIiYjeDJBM0Y7Ij48IUVOVElUWSBjYXBkb3QgIiYjeDJBNDA7Ij48IUVOVElUWSBuY3VwICImI3gyQTQyOyI%2BPCFFTlRJVFkgbmNhcCAiJiN4MkE0MzsiPjwhRU5USVRZIGNhcGFuZCAiJiN4MkE0NDsiPjwhRU5USVRZIGN1cG9yICImI3gyQTQ1OyI%2BPCFFTlRJVFkgY3VwY2FwICImI3gyQTQ2OyI%2BPCFFTlRJVFkgY2FwY3VwICImI3gyQTQ3OyI%2BPCFFTlRJVFkgY3VwYnJjYXAgIiYjeDJBNDg7Ij48IUVOVElUWSBjYXBicmN1cCAiJiN4MkE0OTsiPjwhRU5USVRZIGN1cGN1cCAiJiN4MkE0QTsiPjwhRU5USVRZIGNhcGNhcCAiJiN4MkE0QjsiPjwhRU5USVRZIGNjdXBzICImI3gyQTRDOyI%2BPCFFTlRJVFkgY2NhcHMgIiYjeDJBNEQ7Ij48IUVOVElUWSBjY3Vwc3NtICImI3gyQTUwOyI%2BPCFFTlRJVFkgQW5kICImI3gyQTUzOyI%2BPCFFTlRJVFkgT3IgIiYjeDJBNTQ7Ij48IUVOVElUWSBhbmRhbmQgIiYjeDJBNTU7Ij48IUVOVElUWSBvcm9yICImI3gyQTU2OyI%2BPCFFTlRJVFkgb3JzbG9wZSAiJiN4MkE1NzsiPjwhRU5USVRZIGFuZHNsb3BlICImI3gyQTU4OyI%2BPCFFTlRJVFkgYW5kdiAiJiN4MkE1QTsiPjwhRU5USVRZIG9ydiAiJiN4MkE1QjsiPjwhRU5USVRZIGFuZGQgIiYjeDJBNUM7Ij48IUVOVElUWSBvcmQgIiYjeDJBNUQ7Ij48IUVOVElUWSB3ZWRiYXIgIiYjeDJBNUY7Ij48IUVOVElUWSBzZG90ZSAiJiN4MkE2NjsiPjwhRU5USVRZIHNpbWRvdCAiJiN4MkE2QTsiPjwhRU5USVRZIGNvbmdkb3QgIiYjeDJBNkQ7Ij48IUVOVElUWSBuY29uZ2RvdCAiJiN4MkE2RDsmI3gzMzg7Ij48IUVOVElUWSBlYXN0ZXIgIiYjeDJBNkU7Ij48IUVOVElUWSBhcGFjaXIgIiYjeDJBNkY7Ij48IUVOVElUWSBhcEUgIiYjeDJBNzA7Ij48IUVOVElUWSBuYXBFICImI3gyQTcwOyYjeDMzODsiPjwhRU5USVRZIGVwbHVzICImI3gyQTcxOyI%2BPCFFTlRJVFkgcGx1c2UgIiYjeDJBNzI7Ij48IUVOVElUWSBFc2ltICImI3gyQTczOyI%2BPCFFTlRJVFkgQ29sb25lICImI3gyQTc0OyI%2BPCFFTlRJVFkgRXF1YWwgIiYjeDJBNzU7Ij48IUVOVElUWSBlRERvdCAiJiN4MkE3NzsiPjwhRU5USVRZIGRkb3RzZXEgIiYjeDJBNzc7Ij48IUVOVElUWSBlcXVpdkREICImI3gyQTc4OyI%2BPCFFTlRJVFkgbHRjaXIgIiYjeDJBNzk7Ij48IUVOVElUWSBndGNpciAiJiN4MkE3QTsiPjwhRU5USVRZIGx0cXVlc3QgIiYjeDJBN0I7Ij48IUVOVElUWSBndHF1ZXN0ICImI3gyQTdDOyI%2BPCFFTlRJVFkgbGVzICImI3gyQTdEOyI%2BPCFFTlRJVFkgTGVzc1NsYW50RXF1YWwgIiYjeDJBN0Q7Ij48IUVOVElUWSBsZXFzbGFudCAiJiN4MkE3RDsiPjwhRU5USVRZIG5sZXMgIiYjeDJBN0Q7JiN4MzM4OyI%2BPCFFTlRJVFkgTm90TGVzc1NsYW50RXF1YWwgIiYjeDJBN0Q7JiN4MzM4OyI%2BPCFFTlRJVFkgbmxlcXNsYW50ICImI3gyQTdEOyYjeDMzODsiPjwhRU5USVRZIGdlcyAiJiN4MkE3RTsiPjwhRU5USVRZIEdyZWF0ZXJTbGFudEVxdWFsICImI3gyQTdFOyI%2BPCFFTlRJVFkgZ2Vxc2xhbnQgIiYjeDJBN0U7Ij48IUVOVElUWSBuZ2VzICImI3gyQTdFOyYjeDMzODsiPjwhRU5USVRZIE5vdEdyZWF0ZXJTbGFudEVxdWFsICImI3gyQTdFOyYjeDMzODsiPjwhRU5USVRZIG5nZXFzbGFudCAiJiN4MkE3RTsmI3gzMzg7Ij48IUVOVElUWSBsZXNkb3QgIiYjeDJBN0Y7Ij48IUVOVElUWSBnZXNkb3QgIiYjeDJBODA7Ij48IUVOVElUWSBsZXNkb3RvICImI3gyQTgxOyI%2BPCFFTlRJVFkgZ2VzZG90byAiJiN4MkE4MjsiPjwhRU5USVRZIGxlc2RvdG9yICImI3gyQTgzOyI%2BPCFFTlRJVFkgZ2VzZG90b2wgIiYjeDJBODQ7Ij48IUVOVElUWSBsYXAgIiYjeDJBODU7Ij48IUVOVElUWSBsZXNzYXBwcm94ICImI3gyQTg1OyI%2BPCFFTlRJVFkgZ2FwICImI3gyQTg2OyI%2BPCFFTlRJVFkgZ3RyYXBwcm94ICImI3gyQTg2OyI%2BPCFFTlRJVFkgbG5lICImI3gyQTg3OyI%2BPCFFTlRJVFkgbG5lcSAiJiN4MkE4NzsiPjwhRU5USVRZIGduZSAiJiN4MkE4ODsiPjwhRU5USVRZIGduZXEgIiYjeDJBODg7Ij48IUVOVElUWSBsbmFwICImI3gyQTg5OyI%2BPCFFTlRJVFkgbG5hcHByb3ggIiYjeDJBODk7Ij48IUVOVElUWSBnbmFwICImI3gyQThBOyI%2BPCFFTlRJVFkgZ25hcHByb3ggIiYjeDJBOEE7Ij48IUVOVElUWSBsRWcgIiYjeDJBOEI7Ij48IUVOVElUWSBsZXNzZXFxZ3RyICImI3gyQThCOyI%2BPCFFTlRJVFkgZ0VsICImI3gyQThDOyI%2BPCFFTlRJVFkgZ3RyZXFxbGVzcyAiJiN4MkE4QzsiPjwhRU5USVRZIGxzaW1lICImI3gyQThEOyI%2BPCFFTlRJVFkgZ3NpbWUgIiYjeDJBOEU7Ij48IUVOVElUWSBsc2ltZyAiJiN4MkE4RjsiPjwhRU5USVRZIGdzaW1sICImI3gyQTkwOyI%2BPCFFTlRJVFkgbGdFICImI3gyQTkxOyI%2BPCFFTlRJVFkgZ2xFICImI3gyQTkyOyI%2BPCFFTlRJVFkgbGVzZ2VzICImI3gyQTkzOyI%2BPCFFTlRJVFkgZ2VzbGVzICImI3gyQTk0OyI%2BPCFFTlRJVFkgZWxzICImI3gyQTk1OyI%2BPCFFTlRJVFkgZXFzbGFudGxlc3MgIiYjeDJBOTU7Ij48IUVOVElUWSBlZ3MgIiYjeDJBOTY7Ij48IUVOVElUWSBlcXNsYW50Z3RyICImI3gyQTk2OyI%2BPCFFTlRJVFkgZWxzZG90ICImI3gyQTk3OyI%2BPCFFTlRJVFkgZWdzZG90ICImI3gyQTk4OyI%2BPCFFTlRJVFkgZWwgIiYjeDJBOTk7Ij48IUVOVElUWSBlZyAiJiN4MkE5QTsiPjwhRU5USVRZIHNpbWwgIiYjeDJBOUQ7Ij48IUVOVElUWSBzaW1nICImI3gyQTlFOyI%2BPCFFTlRJVFkgc2ltbEUgIiYjeDJBOUY7Ij48IUVOVElUWSBzaW1nRSAiJiN4MkFBMDsiPjwhRU5USVRZIExlc3NMZXNzICImI3gyQUExOyI%2BPCFFTlRJVFkgTm90TmVzdGVkTGVzc0xlc3MgIiYjeDJBQTE7JiN4MzM4OyI%2BPCFFTlRJVFkgR3JlYXRlckdyZWF0ZXIgIiYjeDJBQTI7Ij48IUVOVElUWSBOb3ROZXN0ZWRHcmVhdGVyR3JlYXRlciAiJiN4MkFBMjsmI3gzMzg7Ij48IUVOVElUWSBnbGogIiYjeDJBQTQ7Ij48IUVOVElUWSBnbGEgIiYjeDJBQTU7Ij48IUVOVElUWSBsdGNjICImI3gyQUE2OyI%2BPCFFTlRJVFkgZ3RjYyAiJiN4MkFBNzsiPjwhRU5USVRZIGxlc2NjICImI3gyQUE4OyI%2BPCFFTlRJVFkgZ2VzY2MgIiYjeDJBQTk7Ij48IUVOVElUWSBzbXQgIiYjeDJBQUE7Ij48IUVOVElUWSBsYXQgIiYjeDJBQUI7Ij48IUVOVElUWSBzbXRlICImI3gyQUFDOyI%2BPCFFTlRJVFkgc210ZXMgIiYjeDJBQUM7JiN4RkUwMDsiPjwhRU5USVRZIGxhdGUgIiYjeDJBQUQ7Ij48IUVOVElUWSBsYXRlcyAiJiN4MkFBRDsmI3hGRTAwOyI%2BPCFFTlRJVFkgYnVtcEUgIiYjeDJBQUU7Ij48IUVOVElUWSBwcmUgIiYjeDJBQUY7Ij48IUVOVElUWSBwcmVjZXEgIiYjeDJBQUY7Ij48IUVOVElUWSBQcmVjZWRlc0VxdWFsICImI3gyQUFGOyI%2BPCFFTlRJVFkgbnByZSAiJiN4MkFBRjsmI3gzMzg7Ij48IUVOVElUWSBucHJlY2VxICImI3gyQUFGOyYjeDMzODsiPjwhRU5USVRZIE5vdFByZWNlZGVzRXF1YWwgIiYjeDJBQUY7JiN4MzM4OyI%2BPCFFTlRJVFkgc2NlICImI3gyQUIwOyI%2BPCFFTlRJVFkgc3VjY2VxICImI3gyQUIwOyI%2BPCFFTlRJVFkgU3VjY2VlZHNFcXVhbCAiJiN4MkFCMDsiPjwhRU5USVRZIG5zY2UgIiYjeDJBQjA7JiN4MzM4OyI%2BPCFFTlRJVFkgbnN1Y2NlcSAiJiN4MkFCMDsmI3gzMzg7Ij48IUVOVElUWSBOb3RTdWNjZWVkc0VxdWFsICImI3gyQUIwOyYjeDMzODsiPjwhRU5USVRZIHByRSAiJiN4MkFCMzsiPjwhRU5USVRZIHNjRSAiJiN4MkFCNDsiPjwhRU5USVRZIHBybkUgIiYjeDJBQjU7Ij48IUVOVElUWSBwcmVjbmVxcSAiJiN4MkFCNTsiPjwhRU5USVRZIHNjbkUgIiYjeDJBQjY7Ij48IUVOVElUWSBzdWNjbmVxcSAiJiN4MkFCNjsiPjwhRU5USVRZIHByYXAgIiYjeDJBQjc7Ij48IUVOVElUWSBwcmVjYXBwcm94ICImI3gyQUI3OyI%2BPCFFTlRJVFkgc2NhcCAiJiN4MkFCODsiPjwhRU5USVRZIHN1Y2NhcHByb3ggIiYjeDJBQjg7Ij48IUVOVElUWSBwcm5hcCAiJiN4MkFCOTsiPjwhRU5USVRZIHByZWNuYXBwcm94ICImI3gyQUI5OyI%2BPCFFTlRJVFkgc2NuYXAgIiYjeDJBQkE7Ij48IUVOVElUWSBzdWNjbmFwcHJveCAiJiN4MkFCQTsiPjwhRU5USVRZIFByICImI3gyQUJCOyI%2BPCFFTlRJVFkgU2MgIiYjeDJBQkM7Ij48IUVOVElUWSBzdWJkb3QgIiYjeDJBQkQ7Ij48IUVOVElUWSBzdXBkb3QgIiYjeDJBQkU7Ij48IUVOVElUWSBzdWJwbHVzICImI3gyQUJGOyI%2BPCFFTlRJVFkgc3VwcGx1cyAiJiN4MkFDMDsiPjwhRU5USVRZIHN1Ym11bHQgIiYjeDJBQzE7Ij48IUVOVElUWSBzdXBtdWx0ICImI3gyQUMyOyI%2BPCFFTlRJVFkgc3ViZWRvdCAiJiN4MkFDMzsiPjwhRU5USVRZIHN1cGVkb3QgIiYjeDJBQzQ7Ij48IUVOVElUWSBzdWJFICImI3gyQUM1OyI%2BPCFFTlRJVFkgc3Vic2V0ZXFxICImI3gyQUM1OyI%2BPCFFTlRJVFkgbnN1YkUgIiYjeDJBQzU7JiN4MzM4OyI%2BPCFFTlRJVFkgbnN1YnNldGVxcSAiJiN4MkFDNTsmI3gzMzg7Ij48IUVOVElUWSBzdXBFICImI3gyQUM2OyI%2BPCFFTlRJVFkgc3Vwc2V0ZXFxICImI3gyQUM2OyI%2BPCFFTlRJVFkgbnN1cEUgIiYjeDJBQzY7JiN4MzM4OyI%2BPCFFTlRJVFkgbnN1cHNldGVxcSAiJiN4MkFDNjsmI3gzMzg7Ij48IUVOVElUWSBzdWJzaW0gIiYjeDJBQzc7Ij48IUVOVElUWSBzdXBzaW0gIiYjeDJBQzg7Ij48IUVOVElUWSBzdWJuRSAiJiN4MkFDQjsiPjwhRU5USVRZIHN1YnNldG5lcXEgIiYjeDJBQ0I7Ij48IUVOVElUWSB2c3VibkUgIiYjeDJBQ0I7JiN4RkUwMDsiPjwhRU5USVRZIHZhcnN1YnNldG5lcXEgIiYjeDJBQ0I7JiN4RkUwMDsiPjwhRU5USVRZIHN1cG5FICImI3gyQUNDOyI%2BPCFFTlRJVFkgc3Vwc2V0bmVxcSAiJiN4MkFDQzsiPjwhRU5USVRZIHZzdXBuRSAiJiN4MkFDQzsmI3hGRTAwOyI%2BPCFFTlRJVFkgdmFyc3Vwc2V0bmVxcSAiJiN4MkFDQzsmI3hGRTAwOyI%2BPCFFTlRJVFkgY3N1YiAiJiN4MkFDRjsiPjwhRU5USVRZIGNzdXAgIiYjeDJBRDA7Ij48IUVOVElUWSBjc3ViZSAiJiN4MkFEMTsiPjwhRU5USVRZIGNzdXBlICImI3gyQUQyOyI%2BPCFFTlRJVFkgc3Vic3VwICImI3gyQUQzOyI%2BPCFFTlRJVFkgc3Vwc3ViICImI3gyQUQ0OyI%2BPCFFTlRJVFkgc3Vic3ViICImI3gyQUQ1OyI%2BPCFFTlRJVFkgc3Vwc3VwICImI3gyQUQ2OyI%2BPCFFTlRJVFkgc3VwaHN1YiAiJiN4MkFENzsiPjwhRU5USVRZIHN1cGRzdWIgIiYjeDJBRDg7Ij48IUVOVElUWSBmb3JrdiAiJiN4MkFEOTsiPjwhRU5USVRZIHRvcGZvcmsgIiYjeDJBREE7Ij48IUVOVElUWSBtbGNwICImI3gyQURCOyI%2BPCFFTlRJVFkgRGFzaHYgIiYjeDJBRTQ7Ij48IUVOVElUWSBEb3VibGVMZWZ0VGVlICImI3gyQUU0OyI%2BPCFFTlRJVFkgVmRhc2hsICImI3gyQUU2OyI%2BPCFFTlRJVFkgQmFydiAiJiN4MkFFNzsiPjwhRU5USVRZIHZCYXIgIiYjeDJBRTg7Ij48IUVOVElUWSB2QmFydiAiJiN4MkFFOTsiPjwhRU5USVRZIFZiYXIgIiYjeDJBRUI7Ij48IUVOVElUWSBOb3QgIiYjeDJBRUM7Ij48IUVOVElUWSBiTm90ICImI3gyQUVEOyI%2BPCFFTlRJVFkgcm5taWQgIiYjeDJBRUU7Ij48IUVOVElUWSBjaXJtaWQgIiYjeDJBRUY7Ij48IUVOVElUWSBtaWRjaXIgIiYjeDJBRjA7Ij48IUVOVElUWSB0b3BjaXIgIiYjeDJBRjE7Ij48IUVOVElUWSBuaHBhciAiJiN4MkFGMjsiPjwhRU5USVRZIHBhcnNpbSAiJiN4MkFGMzsiPjwhRU5USVRZIHBhcnNsICImI3gyQUZEOyI%2BPCFFTlRJVFkgbnBhcnNsICImI3gyQUZEOyYjeDIwRTU7Ij48IUVOVElUWSBmZmxpZyAiJiN4RkIwMDsiPjwhRU5USVRZIGZpbGlnICImI3hGQjAxOyI%2BPCFFTlRJVFkgZmxsaWcgIiYjeEZCMDI7Ij48IUVOVElUWSBmZmlsaWcgIiYjeEZCMDM7Ij48IUVOVElUWSBmZmxsaWcgIiYjeEZCMDQ7Ij48IUVOVElUWSBBc2NyICImI3gxRDQ5QzsiPjwhRU5USVRZIENzY3IgIiYjeDFENDlFOyI%2BPCFFTlRJVFkgRHNjciAiJiN4MUQ0OUY7Ij48IUVOVElUWSBHc2NyICImI3gxRDRBMjsiPjwhRU5USVRZIEpzY3IgIiYjeDFENEE1OyI%2BPCFFTlRJVFkgS3NjciAiJiN4MUQ0QTY7Ij48IUVOVElUWSBOc2NyICImI3gxRDRBOTsiPjwhRU5USVRZIE9zY3IgIiYjeDFENEFBOyI%2BPCFFTlRJVFkgUHNjciAiJiN4MUQ0QUI7Ij48IUVOVElUWSBRc2NyICImI3gxRDRBQzsiPjwhRU5USVRZIFNzY3IgIiYjeDFENEFFOyI%2BPCFFTlRJVFkgVHNjciAiJiN4MUQ0QUY7Ij48IUVOVElUWSBVc2NyICImI3gxRDRCMDsiPjwhRU5USVRZIFZzY3IgIiYjeDFENEIxOyI%2BPCFFTlRJVFkgV3NjciAiJiN4MUQ0QjI7Ij48IUVOVElUWSBYc2NyICImI3gxRDRCMzsiPjwhRU5USVRZIFlzY3IgIiYjeDFENEI0OyI%2BPCFFTlRJVFkgWnNjciAiJiN4MUQ0QjU7Ij48IUVOVElUWSBhc2NyICImI3gxRDRCNjsiPjwhRU5USVRZIGJzY3IgIiYjeDFENEI3OyI%2BPCFFTlRJVFkgY3NjciAiJiN4MUQ0Qjg7Ij48IUVOVElUWSBkc2NyICImI3gxRDRCOTsiPjwhRU5USVRZIGZzY3IgIiYjeDFENEJCOyI%2BPCFFTlRJVFkgaHNjciAiJiN4MUQ0QkQ7Ij48IUVOVElUWSBpc2NyICImI3gxRDRCRTsiPjwhRU5USVRZIGpzY3IgIiYjeDFENEJGOyI%2BPCFFTlRJVFkga3NjciAiJiN4MUQ0QzA7Ij48IUVOVElUWSBsc2NyICImI3gxRDRDMTsiPjwhRU5USVRZIG1zY3IgIiYjeDFENEMyOyI%2BPCFFTlRJVFkgbnNjciAiJiN4MUQ0QzM7Ij48IUVOVElUWSBwc2NyICImI3gxRDRDNTsiPjwhRU5USVRZIHFzY3IgIiYjeDFENEM2OyI%2BPCFFTlRJVFkgcnNjciAiJiN4MUQ0Qzc7Ij48IUVOVElUWSBzc2NyICImI3gxRDRDODsiPjwhRU5USVRZIHRzY3IgIiYjeDFENEM5OyI%2BPCFFTlRJVFkgdXNjciAiJiN4MUQ0Q0E7Ij48IUVOVElUWSB2c2NyICImI3gxRDRDQjsiPjwhRU5USVRZIHdzY3IgIiYjeDFENENDOyI%2BPCFFTlRJVFkgeHNjciAiJiN4MUQ0Q0Q7Ij48IUVOVElUWSB5c2NyICImI3gxRDRDRTsiPjwhRU5USVRZIHpzY3IgIiYjeDFENENGOyI%2BPCFFTlRJVFkgQWZyICImI3gxRDUwNDsiPjwhRU5USVRZIEJmciAiJiN4MUQ1MDU7Ij48IUVOVElUWSBEZnIgIiYjeDFENTA3OyI%2BPCFFTlRJVFkgRWZyICImI3gxRDUwODsiPjwhRU5USVRZIEZmciAiJiN4MUQ1MDk7Ij48IUVOVElUWSBHZnIgIiYjeDFENTBBOyI%2BPCFFTlRJVFkgSmZyICImI3gxRDUwRDsiPjwhRU5USVRZIEtmciAiJiN4MUQ1MEU7Ij48IUVOVElUWSBMZnIgIiYjeDFENTBGOyI%2BPCFFTlRJVFkgTWZyICImI3gxRDUxMDsiPjwhRU5USVRZIE5mciAiJiN4MUQ1MTE7Ij48IUVOVElUWSBPZnIgIiYjeDFENTEyOyI%2BPCFFTlRJVFkgUGZyICImI3gxRDUxMzsiPjwhRU5USVRZIFFmciAiJiN4MUQ1MTQ7Ij48IUVOVElUWSBTZnIgIiYjeDFENTE2OyI%2BPCFFTlRJVFkgVGZyICImI3gxRDUxNzsiPjwhRU5USVRZIFVmciAiJiN4MUQ1MTg7Ij48IUVOVElUWSBWZnIgIiYjeDFENTE5OyI%2BPCFFTlRJVFkgV2ZyICImI3gxRDUxQTsiPjwhRU5USVRZIFhmciAiJiN4MUQ1MUI7Ij48IUVOVElUWSBZZnIgIiYjeDFENTFDOyI%2BPCFFTlRJVFkgYWZyICImI3gxRDUxRTsiPjwhRU5USVRZIGJmciAiJiN4MUQ1MUY7Ij48IUVOVElUWSBjZnIgIiYjeDFENTIwOyI%2BPCFFTlRJVFkgZGZyICImI3gxRDUyMTsiPjwhRU5USVRZIGVmciAiJiN4MUQ1MjI7Ij48IUVOVElUWSBmZnIgIiYjeDFENTIzOyI%2BPCFFTlRJVFkgZ2ZyICImI3gxRDUyNDsiPjwhRU5USVRZIGhmciAiJiN4MUQ1MjU7Ij48IUVOVElUWSBpZnIgIiYjeDFENTI2OyI%2BPCFFTlRJVFkgamZyICImI3gxRDUyNzsiPjwhRU5USVRZIGtmciAiJiN4MUQ1Mjg7Ij48IUVOVElUWSBsZnIgIiYjeDFENTI5OyI%2BPCFFTlRJVFkgbWZyICImI3gxRDUyQTsiPjwhRU5USVRZIG5mciAiJiN4MUQ1MkI7Ij48IUVOVElUWSBvZnIgIiYjeDFENTJDOyI%2BPCFFTlRJVFkgcGZyICImI3gxRDUyRDsiPjwhRU5USVRZIHFmciAiJiN4MUQ1MkU7Ij48IUVOVElUWSByZnIgIiYjeDFENTJGOyI%2BPCFFTlRJVFkgc2ZyICImI3gxRDUzMDsiPjwhRU5USVRZIHRmciAiJiN4MUQ1MzE7Ij48IUVOVElUWSB1ZnIgIiYjeDFENTMyOyI%2BPCFFTlRJVFkgdmZyICImI3gxRDUzMzsiPjwhRU5USVRZIHdmciAiJiN4MUQ1MzQ7Ij48IUVOVElUWSB4ZnIgIiYjeDFENTM1OyI%2BPCFFTlRJVFkgeWZyICImI3gxRDUzNjsiPjwhRU5USVRZIHpmciAiJiN4MUQ1Mzc7Ij48IUVOVElUWSBBb3BmICImI3gxRDUzODsiPjwhRU5USVRZIEJvcGYgIiYjeDFENTM5OyI%2BPCFFTlRJVFkgRG9wZiAiJiN4MUQ1M0I7Ij48IUVOVElUWSBFb3BmICImI3gxRDUzQzsiPjwhRU5USVRZIEZvcGYgIiYjeDFENTNEOyI%2BPCFFTlRJVFkgR29wZiAiJiN4MUQ1M0U7Ij48IUVOVElUWSBJb3BmICImI3gxRDU0MDsiPjwhRU5USVRZIEpvcGYgIiYjeDFENTQxOyI%2BPCFFTlRJVFkgS29wZiAiJiN4MUQ1NDI7Ij48IUVOVElUWSBMb3BmICImI3gxRDU0MzsiPjwhRU5USVRZIE1vcGYgIiYjeDFENTQ0OyI%2BPCFFTlRJVFkgT29wZiAiJiN4MUQ1NDY7Ij48IUVOVElUWSBTb3BmICImI3gxRDU0QTsiPjwhRU5USVRZIFRvcGYgIiYjeDFENTRCOyI%2BPCFFTlRJVFkgVW9wZiAiJiN4MUQ1NEM7Ij48IUVOVElUWSBWb3BmICImI3gxRDU0RDsiPjwhRU5USVRZIFdvcGYgIiYjeDFENTRFOyI%2BPCFFTlRJVFkgWG9wZiAiJiN4MUQ1NEY7Ij48IUVOVElUWSBZb3BmICImI3gxRDU1MDsiPjwhRU5USVRZIGFvcGYgIiYjeDFENTUyOyI%2BPCFFTlRJVFkgYm9wZiAiJiN4MUQ1NTM7Ij48IUVOVElUWSBjb3BmICImI3gxRDU1NDsiPjwhRU5USVRZIGRvcGYgIiYjeDFENTU1OyI%2BPCFFTlRJVFkgZW9wZiAiJiN4MUQ1NTY7Ij48IUVOVElUWSBmb3BmICImI3gxRDU1NzsiPjwhRU5USVRZIGdvcGYgIiYjeDFENTU4OyI%2BPCFFTlRJVFkgaG9wZiAiJiN4MUQ1NTk7Ij48IUVOVElUWSBpb3BmICImI3gxRDU1QTsiPjwhRU5USVRZIGpvcGYgIiYjeDFENTVCOyI%2BPCFFTlRJVFkga29wZiAiJiN4MUQ1NUM7Ij48IUVOVElUWSBsb3BmICImI3gxRDU1RDsiPjwhRU5USVRZIG1vcGYgIiYjeDFENTVFOyI%2BPCFFTlRJVFkgbm9wZiAiJiN4MUQ1NUY7Ij48IUVOVElUWSBvb3BmICImI3gxRDU2MDsiPjwhRU5USVRZIHBvcGYgIiYjeDFENTYxOyI%2BPCFFTlRJVFkgcW9wZiAiJiN4MUQ1NjI7Ij48IUVOVElUWSByb3BmICImI3gxRDU2MzsiPjwhRU5USVRZIHNvcGYgIiYjeDFENTY0OyI%2BPCFFTlRJVFkgdG9wZiAiJiN4MUQ1NjU7Ij48IUVOVElUWSB1b3BmICImI3gxRDU2NjsiPjwhRU5USVRZIHZvcGYgIiYjeDFENTY3OyI%2BPCFFTlRJVFkgd29wZiAiJiN4MUQ1Njg7Ij48IUVOVElUWSB4b3BmICImI3gxRDU2OTsiPjwhRU5USVRZIHlvcGYgIiYjeDFENTZBOyI%2BPCFFTlRJVFkgem9wZiAiJiN4MUQ1NkI7Ij4%3D>the URL given by this link</a>. (This URL is a DTD containing the entity reference declarations for the names listed in the <a href=#named-character-references>named character references</a> section.)</p> <ul class=brief><li><code title="">-//W3C//DTD XHTML 1.0 Transitional//EN</code></li> <li><code title="">-//W3C//DTD XHTML 1.1//EN</code></li> <li><code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code></li> <li><code title="">-//W3C//DTD XHTML 1.0 Frameset//EN</code></li> <li><code title="">-//W3C//DTD XHTML Basic 1.0//EN</code></li> <li><code title="">-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN</code></li> <li><code title="">-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN</code></li> <li><code title="">-//W3C//DTD MathML 2.0//EN</code></li> <li><code title="">-//WAPFORUM//DTD XHTML Mobile 1.0//EN</code></li> </ul><p>Furthermore, user agents should attempt to retrieve the above external entity's content when one of the above public identifiers is used, and should not attempt to retrieve any other external entity's content.</p> <p class=note>This is not strictly a <a href=#willful-violation title="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 id=scriptTagXML>When an <a href=#xml-parser>XML parser</a> creates a <code><a href=#the-script-element>script</a></code> element, it must be marked as being <a href=#parser-inserted>"parser-inserted"</a> and its <a href=#force-async>"force-async"</a> flag must be unset. If the parser was originally created for the <a href=#xml-fragment-parsing-algorithm>XML fragment parsing algorithm</a>, then the element must be marked as <a href=#already-started>"already started"</a> also. When the element's end tag is parsed, the user agent must <a href=#provide-a-stable-state>provide a stable state</a>, and then <a href=#prepare-a-script title="prepare a script">prepare</a> the <code><a href=#the-script-element>script</a></code> element. If this causes there to be a <a href=#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>XML parser</a>, such that the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke it.</li> <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the parser's <code><a href=#document>Document</a></code> <a href=#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>pending parsing-blocking script</a>'s <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is set.</li> <li><p>Unblock this instance of the <a href=#xml-parser>XML parser</a>, such that <a href=#concept-task title=concept-task>tasks</a> that invoke it can again be run.</li> <li><p><a href=#execute-the-script-block title="execute the script block">Execute</a> the <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>.</li> <li><p>There is no longer a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>.</li> </ol><p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not available for <a href=#xml-documents>XML documents</a>, much of the complexity in the <a href=#html-parser>HTML parser</a> is not needed in the <a href=#xml-parser>XML parser</a>.</p> <p>Certain algorithms in this specification <dfn id=feed-the-parser title="feed the parser">spoon-feed the parser</dfn> characters one string at a time. In such cases, the <a href=#xml-parser>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>XML parser</a> reaches the end of its input, it must <a href=#stop-parsing>stop parsing</a>, following the same rules as the <a href=#html-parser>HTML parser</a>. An <a href=#xml-parser>XML parser</a> can also be <a href=#abort-a-parser title="abort a parser">aborted</a>, which must again by done in the same way as for an <a href=#html-parser>HTML parser</a>.</p> <p>For the purposes of conformance checkers, if a resource is determined to be in <a href=#the-xhtml-syntax>the XHTML syntax</a>, then it is an <a href=#xml-documents title="XML documents">XML document</a>.</p> <h3 id=serializing-xhtml-fragments><span class=secno>14.3 </span>Serializing XHTML fragments</h3> <p>The <dfn id=xml-fragment-serialization-algorithm>XML fragment serialization algorithm</dfn> for a <code><a href=#document>Document</a></code> or <code><a href=#element>Element</a></code> node either returns a fragment of XML that represents that node or throws an exception.</p> <p>For <code><a href=#document>Document</a></code>s, the algorithm must return a string in the form of a <a href=http://www.w3.org/TR/xml/#sec-well-formed>document entity</a>, if none of the error cases below apply.</p> <p>For <code><a href=#element>Element</a></code>s, the algorithm must return a string in the form of an <a href=http://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 child nodes, in <a href=#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, character references, and CDATA sections to represent <a href=#text-node title="text node">text nodes</a> in the DOM (and indeed might be forced to use representations that don't match the DOM's, e.g. if a <code><a href=#cdatasection>CDATASection</a></code> node contains the string "<code title="">]]></code>").</p> <p>For <code><a href=#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.<!-- because otherwise round-tripping might break since it'll pick up the surrounding default ns when setting --> (This doesn't apply in the <code><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 <code><a href=#invalidstateerror>InvalidStateError</a></code> exception instead of returning a string:</p> <ul><li>A <code><a href=#document>Document</a></code> node with no child element nodes.</li> <li>A <code><a href=#documenttype>DocumentType</a></code> node that has an external subset public identifier that contains characters that are not matched by the XML <code title="">PubidChar</code> production. <a href=#refsXML>[XML]</a></li> <li>A <code><a href=#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 title="">Char</code> production. <a href=#refsXML>[XML]</a></li> <li>A node with a <!--prefix or--> local name containing a U+003A COLON (:).</li> <!--(prefixes can get adjusted, so this isn't an excuse) --> <li>A node with a <!--prefix or--> local name that does not match the XML <code title="">Name</code> production. <a href=#refsXML>[XML]</a></li> <!--(again, prefixes can get adjusted, so this isn't an excuse) --> <li>An <code><a href=#attr>Attr</a></code> node with no namespace whose local name is the lowercase string "<code title="">xmlns</code>". <a href=#refsXMLNS>[XMLNS]</a></li> <li>An <code><a href=#element>Element</a></code> node with two or more attributes with the same local name and namespace.</li> <li>An <code><a href=#attr>Attr</a></code> node, <code><a href=#text>Text</a></code> node, <code><a href=#cdatasection>CDATASection</a></code> node, <code><a href=#comment-0>Comment</a></code> node, or <code><a href=#processinginstruction>ProcessingInstruction</a></code> node whose data contains characters that are not matched by the XML <code title="">Char</code> production. <a href=#refsXML>[XML]</a></li> <!--<li>A <code>CDATASection</code> node whose data contains the string "<code title="">]]></code>".</li> (these can be split)--> <li>A <code><a href=#comment-0>Comment</a></code> node whose data contains two adjacent U+002D HYPHEN-MINUS characters (-) or ends with such a character.</li> <li>A <code><a href=#processinginstruction>ProcessingInstruction</a></code> node whose target name is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">xml</code>".</li> <li>A <code><a href=#processinginstruction>ProcessingInstruction</a></code> node whose target name contains a U+003A COLON (:).</li> <li>A <code><a href=#processinginstruction>ProcessingInstruction</a></code> node whose data contains the string "<code title="">?></code>".</li> </ul><p class=note>These are the only ways to make a DOM unserializable. The DOM enforces all the other XML constraints; for example, trying to append two elements to a <code><a href=#document>Document</a></code> node will throw a <code><a href=#hierarchyrequesterror>HierarchyRequestError</a></code> exception.</p> <h3 id=parsing-xhtml-fragments><span class=secno>14.4 </span>Parsing XHTML fragments</h3> <p>The <dfn id=xml-fragment-parsing-algorithm>XML fragment parsing algorithm</dfn> either returns a <code><a href=#document>Document</a></code> or throws a <code><a href=#syntaxerror>SyntaxError</a></code> exception. Given a string <var title="">input</var> and an optional context element <var title=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>XML parser</a>.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, <a href=#feed-the-parser>feed the parser</a> just created the string corresponding to the start tag of that 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 Core <code title="">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 Core <code title="">isDefaultNamespace()</code> method on the element would return true.</p> <p class=note>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, no <code title="">DOCTYPE</code> is passed to the parser, and therefore no external subset is referenced, and therefore no entities will be recognized.</p> </li> <li> <p><a href=#feed-the-parser>Feed the parser</a> just created the string <var title="">input</var>.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, <a href=#feed-the-parser>feed the parser</a> just created the string corresponding to the end tag of that element.</p> </li> <li> <p>If there is an XML well-formedness or XML namespace well-formedness error, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps.</p> </li> <li> <p>If there is a <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element, then return the child nodes of the root element of the resulting <code><a href=#document>Document</a></code>, in <a href=#tree-order>tree order</a>.</p> <p>Otherwise, return the children of the <code><a href=#document>Document</a></code> object, in <a href=#tree-order>tree order</a>.</p> </li> </ol></div> <div class=impl> <h2 id=rendering><span class=secno>15 </span>Rendering</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, RFC2119 terms have 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 the RFC2119-defined term "must".</i></p> <h3 id=introduction-17><span class=secno>15.1 </span>Introduction</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 <dfn id=represents>represents</dfn>, 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 implementors 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 is <a href=#in-a-document>in a <code>Document</code></a>, either its parent node is itself <a href=#being-rendered>being rendered</a> or it is the <code><a href=#document>Document</a></code> node, and it is not explicitly excluded from the rendering using either:</p> <ul class=brief><li>the CSS 'display' property's 'none' value, or</li> <li>the 'visibility' property's 'collapse' value unless it is being treated as equivalent to the 'hidden' value, or</li> <li>some equivalent in other styling languages.</li> </ul><p class=note>Just being off-screen does not mean the element is not <a href=#being-rendered>being rendered</a>. The presence of the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute normally means the element is not <a href=#being-rendered>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 'display', 'unicode-bidi', and 'direction' properties.</p> <h3 id=the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>15.2 </span>The CSS user agent style sheet and presentational hints</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>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> <p>Some of the rules regarding left and right margins are given here as appropriate for elements whose 'direction' property is 'ltr', and are expected to be flipped around on elements whose 'direction' property is 'rtl'. These are marked "<dfn id=ltr-specific>LTR-specific</dfn>".</p> <p class=note>These markings only affect the handling of attribute <em>values</em>, not attribute names or element names.</p> <hr><p>When the text below says that an attribute <var title="">attribute</var> on an element <var title="">element</var> <dfn id=maps-to-the-pixel-length-property>maps to the pixel length property</dfn> (or properties) <var title="">properties</var>, it means that if <var title="">element</var> has an attribute <var title="">attribute</var> set, and parsing that attribute's value using the <a href=#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 title="presentational hints">presentational hint</a> for <var title="">properties</var>.</p> <p>When the text below says that an attribute <var title="">attribute</var> on an element <var title="">element</var> <dfn id=maps-to-the-dimension-property>maps to the dimension property</dfn> (or properties) <var title="">properties</var>, it means that if <var title="">element</var> has an attribute <var title="">attribute</var> set, and parsing that attribute's value using the <a href=#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 title="presentational hints">presentational hint</a> for <var title="">properties</var>, with the value given as a pixel length if the dimension was an integer, 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 'margin-left' and 'margin-right' properties computing to a value other than 'auto', that are over-constrained and that have one of those two margins with a used value forced to a greater value, and that do not themselves have an applicable <code title=attr-align>align</code> attribute. When multiple elements are to <a href=#align-descendants title="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 used values of their left and right margins be set accordingly.</p> <h3 id=non-replaced-elements><span class=secno>15.3 </span>Non-replaced elements</h3> <h4 id=hidden-elements><span class=secno>15.3.1 </span>Hidden elements</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); [hidden], area, base, basefont, command, datalist, head, input[type=hidden i], link, menu[type=context i], meta, noembed, noframes, param, rp, script, source, style, track, title { display: none; }</pre> <p>The user agent is expected to force the 'display' property of <code><a href=#the-noscript-element>noscript</a></code> elements for whom <a href=#concept-n-script title=concept-n-script>scripting is enabled</a> to compute to 'none', irrespective of CSS rules.</p> <h4 id=the-page><span class=secno>15.3.2 </span>The page</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); html, body { display: block; }</pre> <p>For each property in the table below, given a <code><a href=#the-body-element>body</a></code> element, the first attribute that exists <a href=#maps-to-the-pixel-length-property>maps to the pixel length property</a> on the <code><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>'margin-top' <td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-marginheight><a href=#attr-body-marginheight>marginheight</a></code> attribute <tr><td>The <code><a href=#the-body-element>body</a></code> element's <a href=#container-frame-element>container frame element</a>'s <code title=attr-iframe-marginheight><a href=#attr-iframe-marginheight>marginheight</a></code> attribute <tr><td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-topmargin>topmargin</code> attribute <tbody><tr><td rowspan=3>'margin-right' <td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-marginwidth><a href=#attr-body-marginwidth>marginwidth</a></code> attribute <tr><td>The <code><a href=#the-body-element>body</a></code> element's <a href=#container-frame-element>container frame element</a>'s <code title=attr-iframe-marginwidth><a href=#attr-iframe-marginwidth>marginwidth</a></code> attribute <tr><td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-rightmargin>rightmargin</code> attribute <tbody><tr><td rowspan=3>'margin-bottom' <td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-marginheight><a href=#attr-body-marginheight>marginheight</a></code> attribute <tr><td>The <code><a href=#the-body-element>body</a></code> element's <a href=#container-frame-element>container frame element</a>'s <code title=attr-iframe-marginheight><a href=#attr-iframe-marginheight>marginheight</a></code> attribute <tr><td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-bottommargin>bottommargin</code> attribute <tbody><tr><td rowspan=3>'margin-left' <td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-marginwidth><a href=#attr-body-marginwidth>marginwidth</a></code> attribute <tr><td>The <code><a href=#the-body-element>body</a></code> element's <a href=#container-frame-element>container frame element</a>'s <code title=attr-iframe-marginwidth><a href=#attr-iframe-marginwidth>marginwidth</a></code> attribute <tr><td><code><a href=#the-body-element>body</a></code> element's <code title=attr-body-leftmargin>leftmargin</code> attribute </table><p>If the <code><a href=#the-body-element>body</a></code> element's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> is a <a href=#nested-browsing-context>nested browsing context</a>, and the <a href=#browsing-context-container>browsing context container</a> of that <a href=#nested-browsing-context>nested browsing context</a> is a <code><a href=#frame>frame</a></code> or <code><a href=#the-iframe-element>iframe</a></code> element, then the <dfn id=container-frame-element>container frame element</dfn> of the <code><a href=#the-body-element>body</a></code> element is that <code><a href=#frame>frame</a></code> or <code><a href=#the-iframe-element>iframe</a></code> element. Otherwise, there is no <a href=#container-frame-element>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=#origin>origin</a>) using, for example, an <code><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 the <code><a href=#document>Document</a></code> has a <a href=#root-element>root element</a>, and the <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> is a <a href=#nested-browsing-context>nested browsing context</a>, and the <a href=#browsing-context-container>browsing context container</a> of that <a href=#nested-browsing-context>nested browsing context</a> is a <code><a href=#frame>frame</a></code> or <code><a href=#the-iframe-element>iframe</a></code> element, and that element has a <code title=attr-frames-scrolling>scrolling</code> attribute, then the user agent is expected to compare the value of the attribute in an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> manner to the values in the first column of the following table, and if one of them matches, then the user agent is expected to treat that attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> for the aforementioned root element's 'overflow' property, setting it to the value given in the corresponding cell on the same row in the second column:</p> <table><thead><tr><th> Attribute value <th> 'overflow' value <tbody><tr><td><code title="">on</code> <td>'scroll' <tr><td><code title="">scroll</code> <td>'scroll' <tr><td><code title="">yes</code> <td>'scroll' <tr><td><code title="">off</code> <td>'hidden' <tr><td><code title="">noscroll</code> <td>'hidden' <tr><td><code title="">no</code> <td>'hidden' <tr><td><code title="">auto</code> <td>'auto' </table><hr><p>When a <code><a href=#document>Document</a></code> is in <a href=#quirks-mode>quirks mode</a>, vertical margins on <a href=#html-elements>HTML elements</a> at the top or bottom of <code><a href=#the-body-element>body</a></code> elements are expected to be collapsed to zero.</p> <hr><p>When a <code><a href=#the-body-element>body</a></code> element has a <code title=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=#resolve-a-url title="resolve a url">resolved</a> relative to the element, and if this is successful, the user agent is expected to treat the attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> setting the element's 'background-image' property to the resulting <a href=#absolute-url>absolute URL</a>.</p> <p>When a <code><a href=#the-body-element>body</a></code> element has a <code title="">bgcolor</code> attribute set, the new value is expected to be parsed using the <a href=#rules-for-parsing-a-legacy-color-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 title="presentational hints">presentational hint</a> setting the element's 'background-color' property to the resulting color.</p> <p>When a <code><a href=#the-body-element>body</a></code> element has a <code title=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-color-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 title="presentational hints">presentational hint</a> setting the element's 'color' property to the resulting color.</p> <p>When a <code><a href=#the-body-element>body</a></code> element has a <code title=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-color-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 title="presentational hints">presentational hint</a> setting the 'color' property of any element in the <code><a href=#document>Document</a></code> matching the ':link' pseudo-class to the resulting color.</p> <p>When a <code><a href=#the-body-element>body</a></code> element has a <code title=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-color-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 title="presentational hints">presentational hint</a> setting the 'color' property of any element in the <code><a href=#document>Document</a></code> matching the ':visited' pseudo-class to the resulting color.</p> <p>When a <code><a href=#the-body-element>body</a></code> element has a <code title=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-color-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 title="presentational hints">presentational hint</a> setting the 'color' property of any element in the <code><a href=#document>Document</a></code> matching the ':active' pseudo-class and either the ':link' pseudo-class or the ':visited' pseudo-class to the resulting color.</p> <h4 id=flow-content-1><span class=secno>15.3.3 </span>Flow content</h4> <!-- del, ins, and map are inline. --> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); address, blockquote, center, div, figure, figcaption, footer, form, header, hr, legend, listing, p, plaintext, pre, summary, xmp { display: block; unicode-bidi: isolate; } blockquote, figure, listing, p, plaintext, pre, xmp { margin-top: 1em; margin-bottom: 1em; } blockquote, figure { margin-left: 40px; margin-right: 40px; } address { font-style: italic; } listing, plaintext, pre, xmp { font-family: monospace; white-space: pre; }</pre> <p>The following rules are also expected to apply, as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); pre[wrap] { white-space: pre-wrap; }</pre> <p>In <a href=#quirks-mode>quirks mode</a>, the following rules are also expected to apply:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); form { margin-bottom: 1em; }</pre> <hr><p>The <code><a href=#center>center</a></code> element, and the <code><a href=#the-div-element>div</a></code> element when it has an <code title=attr-div-align><a href=#attr-div-align>align</a></code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for either the string "<code title="">center</code>" or the string "<code title="">middle</code>", are expected to center text within themselves, as if they had their 'text-align' property set to 'center' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the center.</p> <p>The <code><a href=#the-div-element>div</a></code> element, when it has an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">left</code>", is expected to left-align text within itself, as if it had its 'text-align' property set to 'left' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the left.</p> <p>The <code><a href=#the-div-element>div</a></code> element, when it has an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">right</code>", is expected to right-align text within itself, as if it had its 'text-align' property set to 'right' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the right.</p> <p>The <code><a href=#the-div-element>div</a></code> element, when it has an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">justify</code>", is expected to full-justify text within itself, as if it had its 'text-align' property set to 'justify' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the left.</p> <h4 id=phrasing-content-1><span class=secno>15.3.4 </span>Phrasing content</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); cite, dfn, em, i, var { font-style: italic; } b, strong { font-weight: bold; } code, kbd, samp, tt { font-family: monospace; } big { font-size: larger; } small { font-size: smaller; } sub { vertical-align: sub; } sup { vertical-align: super; } sub, sup { line-height: normal; font-size: smaller; } ruby { display: ruby; } rt { display: ruby-text; } :link { color: #0000EE; } :visited { color: #551A8B; } :link, :visited { text-decoration: underline; } a:link[rel~=help], a:visited[rel~=help], area:link[rel~=help], area:visited[rel~=help] { cursor: help; } :focus { outline: auto; } mark { background: yellow; color: black; } /* this color is just a suggestion and can be changed based on implementation feedback */ abbr[title], acronym[title] { text-decoration: dotted underline; }<!-- CSS3 http://dev.w3.org/csswg/css3-text/#text-decoration-style --> ins, u { text-decoration: underline; } del, s, strike { text-decoration: line-through; } blink { text-decoration: blink; } q::before { content: open-quote; } q::after { content: close-quote; } br { content: '\A'; white-space: pre; } nobr { white-space: nowrap; }</pre> <p>The following rules are also expected to apply, as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); br[clear=left i] { clear: left; } br[clear=right i] { clear: right; } br[clear=all i], br[clear=both i] { clear: both; }</pre> <p>For the purposes of the CSS ruby model, runs of children of <code><a href=#the-ruby-element>ruby</a></code> elements that are not <code><a href=#the-rt-element>rt</a></code> or <code><a href=#the-rp-element>rp</a></code> elements are expected to be wrapped in anonymous boxes whose 'display' property has the value 'ruby-base'. <a href=#refsCSSRUBY>[CSSRUBY]</a></p> <p>User agents that do not support correct ruby rendering are expected to render parentheses around the text of <code><a href=#the-rt-element>rt</a></code> elements in the absence of <code><a href=#the-rp-element>rp</a></code> elements.</p> <p class=critical>It is highly likely that the style rules above will be dramatically expanded in the near future to include suggested quote style rules for a variety of languages.</p> <hr><p>User agents are expected to support the 'clear' property on inline elements (in order to render <code><a href=#the-br-element>br</a></code> elements with <code title=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 CSS2.1.</p> <!-- section 9.5.2 of CSS2.1 --> <p>The <code><a href=#the-wbr-element>wbr</a></code> element is expected to override the 'white-space' property and always provide a line-breaking opportunity.</p> <p>The initial value for the 'color' property is expected to be black. The initial value for the 'background-color' property is expected to be 'transparent'. The canvas' background is expected to be white.</p> <hr><p>When a <code><a href=#font>font</a></code> element has a <code title=attr-font-color>color</code> attribute, its value is expected to be parsed using the <a href=#rules-for-parsing-a-legacy-color-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 title="presentational hints">presentational hint</a> setting the element's 'color' property to the resulting color.</p> <p>When a <code><a href=#font>font</a></code> element has a <code title=attr-font-face>face</code> attribute, the user agent is expected to treat the attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> setting the element's 'font-family' property to the attribute's value.</p> <!-- (Apparently only IE supports this?) (Note: if you add this back, make sure to define which of 'size' vs 'pointsize' wins.) <p>When a <code>font</code> element has a <code title="attr-font-pointsize">pointsize</code> attribute, the user agent is expected to parse that attribute's value using the <span>rules for parsing non-negative integers</span>, and if this doesn't generate an error, then the user agent is expected to use the parsed value as a <em>point</em> length for a <span title="presentational hints">presentational hint</span> for the 'font-size' property on the element.</p> --> <p>When a <code><a href=#font>font</a></code> element has a <code title=attr-font-size>size</code> attribute, the user agent is expected to use the following steps to treat the attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> setting the element's 'font-size' property:</p> <ol><li><p>Let <var title="">input</var> be the attribute's value.</li> <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the string.</li> <li><p><a href=#skip-whitespace>Skip whitespace</a>.</li> <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, there is no <a href=#presentational-hints title="presentational hints">presentational hint</a>. Abort these steps.</li> <li><p>If the character at <var title="">position</var> is a U+002B PLUS SIGN character (+), then let <var title="">mode</var> be <i>relative-plus</i>, and advance <var title="">position</var> to the next character. Otherwise, if the character at <var title="">position</var> is a U+002D HYPHEN-MINUS character (-), then let <var title="">mode</var> be <i>relative-minus</i>, and advance <var title="">position</var> to the next character. Otherwise, let <var title="">mode</var> be <i>absolute</i>.</li> <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let the resulting sequence be <var title="">digits</var>.</li> <li><p>If <var title="">digits</var> is the empty string, there is no <a href=#presentational-hints title="presentational hints">presentational hint</a>. Abort these steps.</li> <li><p>Interpret <var title="">digits</var> as a base-ten integer. Let <var title="">value</var> be the resulting number.</li> <li> <!-- basefont support would go here, but we removed it --> <p>If <var title="">mode</var> is <i>relative-plus</i>, then increment <var title="">value</var> by 3. If <var title="">mode</var> is <i>relative-minus</i>, then let <var title="">value</var> be the result of subtracting <var title="">value</var> from 3.</p> </li> <li><p>If <var title="">value</var> is greater than 7, let it be 7.</li> <li><p>If <var title="">value</var> is less than 1, let it be 1.</li> <li> <p>Set 'font-size' to the keyword corresponding to the value of <var title="">value</var> according to the following table:</p> <table><thead><tr><th><var title="">value</var> <th>'font-size' keyword <th>Notes <tbody><tr><td>1 <td>xx-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>x<!---->xx-large <td><i>see below</i> </table><p>The 'x<!---->xx-large' value is a non-CSS value used here to indicate a font size 50% larger than 'xx-large'.</p> </li> </ol><h4 id=bidirectional-text><span class=secno>15.3.5 </span>Bidirectional text</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); :dir(ltr) { direction: ltr; } :dir(rtl) { direction: rtl; } [dir] { unicode-bidi: embed; } bdi, bdi[dir], output, output[dir], [dir=auto i] { unicode-bidi: isolate; } bdo, bdo[dir] { unicode-bidi: bidi-override; } bdo[dir=auto i] { unicode-bidi: bidi-override isolate; } textarea[dir=auto i], pre[dir=auto i] { unicode-bidi: plaintext; }</pre> <h4 id=quotes><span class=secno>15.3.6 </span>Quotes</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 title="">delimiter</code> blocks, with fallback handled as specified in the CLDR documentation.</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); :root { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(af) { quotes: '\201c' '\201d' '\2018' '\201d'; } /* “ ” ‘ ” */ :lang(agq) { quotes: '\0027' '\0027' '\201e' '\201d'; } /* ' ' „ ” */ :lang(ak) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(am) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(ar) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(asa) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(az) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(bas) { quotes: '\00ab' '\00bb' '\201c' '\201e'; } /* « » “ „ */ :lang(be) { quotes: '\201e' '\201d' '\00ab' '\00bb'; } /* „ ” « » */ :lang(bem) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(bez) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(bg) { quotes: '\201e' '\201c' '\2018' '\2019'; } /* „ “ ‘ ’ */ :lang(bm) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(bn) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(brx) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(bs) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(ca) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(cgg) { quotes: '\0027' '\0027' '\201c' '\201e'; } /* ' ' “ „ */ :lang(chr) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(cs) { quotes: '\201e' '\201c' '\201a' '\2018'; } /* „ “ ‚ ‘ */ :lang(cy) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(da) { quotes: '\201d' '\201d' '\201d' '\201d'; } /* ” ” ” ” */ :lang(dav) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(de) { quotes: '\201e' '\201c' '\201a' '\2018'; } /* „ “ ‚ ‘ */ :lang(de-CH) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(dje) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(dua) { quotes: '\00ab' '\00bb' '\0027' '\0027'; } /* « » ' ' */ :lang(dyo) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(dz) { quotes: '\0022' '\0022' '\0027' '\0027'; } /* " " ' ' */ :lang(ebu) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(ee) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(el) { quotes: '\00ab' '\00bb' '\2018' '\2019'; } /* « » ‘ ’ */ :lang(el-POLYTON) { quotes: '\00ab' '\00bb' '\201b' '\2019'; } /* « » ‛ ’ */ :lang(en) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(en-GB) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(es) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(et) { quotes: '\201e' '\201c' '\201e' '\201c'; } /* „ “ „ “ */ :lang(eu) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ewo) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(fa) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(ff) { quotes: '\201e' '\201d' '\0027' '\0027'; } /* „ ” ' ' */ :lang(fi) { quotes: '\201d' '\201d' '\2019' '\2019'; } /* ” ” ’ ’ */ :lang(fil) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(fo) { quotes: '\201d' '\201d' '\2019' '\2019'; } /* ” ” ’ ’ */ :lang(fr) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(fr-CH) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(fur) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(gaa) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(gd) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(gl) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(gsw) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(gu) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(guz) { quotes: '\0027' '\2018' '\201c' '\201c'; } /* ' ‘ “ “ */ :lang(ha) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(he) { quotes: '\201c' '\201d' '\0022' '\0022'; } /* “ ” " " */ :lang(hi) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(hr) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(hu) { quotes: '\201e' '\201d' '\201e' '\201d'; } /* „ ” „ ” */ :lang(ia) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(id) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ig) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(is) { quotes: '\201e' '\201c' '\201a' '\2018'; } /* „ “ ‚ ‘ */ :lang(it) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(it-CH) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(ja) { quotes: '\300c' '\300d' '\300e' '\300f'; } /* 「 」 『 』 */ :lang(jmc) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(ka) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(kab) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(kam) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(kde) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(kea) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(khq) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(ki) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(kl) { quotes: '\00bb' '\00ab' '\203a' '\2039'; } /* » « › ‹ */ :lang(kln) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(km) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(kn) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ko) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(ksb) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(ksf) { quotes: '\0027' '\0027' '\00ab' '\00bb'; } /* ' ' « » */ :lang(ksh) { quotes: '\201e' '\201c' '\201a' '\2018'; } /* „ “ ‚ ‘ */ :lang(lag) { quotes: '\201d' '\201d' '\0027' '\0027'; } /* ” ” ' ' */ :lang(lg) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(ln) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(lo) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(lt) { quotes: '\201e' '\201c' '\201e' '\201c'; } /* „ “ „ “ */ :lang(lu) { quotes: '\2018' '\2018' '\201c' '\201c'; } /* ‘ ‘ “ “ */ :lang(luo) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(luy) { quotes: '\0027' '\0027' '\201e' '\201c'; } /* ' ' „ “ */ :lang(lv) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(mas) { quotes: '\0027' '\0027' '\201d' '\201c'; } /* ' ' ” “ */ :lang(mer) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(mfe) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(mg) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(ml) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(mn) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(mr) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(ms) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(mt) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(mua) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(my) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(naq) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(nb) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(nd) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(nds) { quotes: '\201e' '\201c' '\201a' '\2018'; } /* „ “ ‚ ‘ */ :lang(ne) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(nl) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(nmg) { quotes: '\201c' '\201e' '\00ab' '\00bb'; } /* “ „ « » */ :lang(nn) { quotes: '\00ab' '\00bb' '\201c' '\201d'; } /* « » “ ” */ :lang(nr) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(nso) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(nus) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(nyn) { quotes: '\0027' '\0027' '\201c' '\201e'; } /* ' ' “ „ */ :lang(pa) { quotes: '\0027' '\0027' '\0022' '\0022'; } /* ' ' " " */ :lang(pl) { quotes: '\2018' '\2019' '\201e' '\201d'; } /* ‘ ’ „ ” */ :lang(pt) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(rm) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(rn) { quotes: '\0027' '\0027' '\201d' '\201d'; } /* ' ' ” ” */ :lang(ro) { quotes: '\201e' '\201d' '\00ab' '\00bb'; } /* „ ” « » */ :lang(rof) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(ru) { quotes: '\00ab' '\00bb' '\201e' '\201c'; } /* « » „ “ */ :lang(rw) { quotes: '\2018' '\2019' '\00ab' '\00bb'; } /* ‘ ’ « » */ :lang(rwk) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(saq) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(sbp) { quotes: '\0027' '\0027' '\201c' '\201d'; } /* ' ' “ ” */ :lang(se) { quotes: '\201d' '\201d' '\2019' '\2019'; } /* ” ” ’ ’ */ :lang(seh) { quotes: '\0027' '\0027' '\0027' '\0027'; } /* ' ' ' ' */ :lang(ses) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(sg) { quotes: '\00ab' '\00bb' '\201c' '\2019'; } /* « » “ ’ */ :lang(shi) { quotes: '\00ab' '\00bb' '\201e' '\201d'; } /* « » „ ” */ :lang(shi-Tfng) { quotes: '\00ab' '\00bb' '\201e' '\201d'; } /* « » „ ” */ :lang(sk) { quotes: '\201a' '\2018' '\201e' '\201c'; } /* ‚ ‘ „ “ */ :lang(sl) { quotes: '\00bb' '\00ab' '\201e' '\201c'; } /* » « „ “ */ :lang(sn) { quotes: '\0027' '\0027' '\201d' '\201d'; } /* ' ' ” ” */ :lang(so) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(sr) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ss) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(st) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(sv) { quotes: '\201d' '\201d' '\2019' '\2019'; } /* ” ” ’ ’ */ :lang(sw) { quotes: '\0027' '\0027' '\0027' '\0027'; } /* ' ' ' ' */ :lang(swc) { quotes: '\0027' '\0027' '\201d' '\201c'; } /* ' ' ” “ */ :lang(ta) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(te) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(teo) { quotes: '\0027' '\2019' '\201c' '\201d'; } /* ' ’ “ ” */ :lang(tg) { quotes: '\00ab' '\00bb' '\00ab' '\201e'; } /* « » « „ */ :lang(th) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ti-ER) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(tn) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(to) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(tr) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(trv) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(ts) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(twq) { quotes: '\201c' '\201d' '\00ab' '\00bb'; } /* “ ” « » */ :lang(tzm) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(uk) { quotes: '\00ab' '\00bb' '\201e' '\201c'; } /* « » „ “ */ :lang(ur) { quotes: '\0022' '\0022' '\0027' '\0027'; } /* " " ' ' */ :lang(vai) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(vai-Latn) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(ve) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(vi) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(vun) { quotes: '\0027' '\0027' '\201c' '\201c'; } /* ' ' “ “ */ :lang(wae) { quotes: '\00ab' '\00bb' '\2039' '\203a'; } /* « » ‹ › */ :lang(xh) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ :lang(xog) { quotes: '\0027' '\0027' '\201c' '\201e'; } /* ' ' “ „ */ :lang(yav) { quotes: '\00ab' '\00bb' '\00ab' '\00bb'; } /* « » « » */ :lang(yo) { quotes: '\0027' '\0027' '\0027' '\0027'; } /* ' ' ' ' */ :lang(zh) { quotes: '\201c' '\201d' '\2018' '\2019'; } /* “ ” ‘ ’ */ :lang(zh-Hant) { quotes: '\300c' '\300d' '\300e' '\300f'; } /* 「 」 『 』 */ :lang(zu) { quotes: '\2018' '\2019' '\201c' '\201d'; } /* ‘ ’ “ ” */ </pre> <h4 id=sections-and-headings><span class=secno>15.3.7 </span>Sections and headings</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); article, aside, h1, h2, h3, h4, h5, h6, hgroup, nav, section { display: block; unicode-bidi: isolate; } h1 { margin-top: 0.67em; margin-bottom: 0.67em; font-size: 2.00em; font-weight: bold; } h2 { margin-top: 0.83em; margin-bottom: 0.83em; font-size: 1.50em; font-weight: bold; } h3 { margin-top: 1.00em; margin-bottom: 1.00em; font-size: 1.17em; font-weight: bold; } h4 { margin-top: 1.33em; margin-bottom: 1.33em; font-size: 1.00em; font-weight: bold; } h5 { margin-top: 1.67em; margin-bottom: 1.67em; font-size: 0.83em; font-weight: bold; } h6 { margin-top: 2.33em; margin-bottom: 2.33em; font-size: 0.67em; font-weight: bold; }</pre> <p>The <code><a href=#the-article-element>article</a></code>, <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-nav-element>nav</a></code>, and <code><a href=#the-section-element>section</a></code> elements are expected to affect the margins and font size of <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> elements, based on the nesting depth. If <var title="">x</var> is a selector that matches elements that are either <code><a href=#the-article-element>article</a></code>, <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-nav-element>nav</a></code>, or <code><a href=#the-section-element>section</a></code> elements, then the following rules capture what is expected:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); <var title="">x</var> h1 { margin-top: 0.83em; margin-bottom: 0.83em; font-size: 1.50em; } <var title="">x</var> <var title="">x</var> h1 { margin-top: 1.00em; margin-bottom: 1.00em; font-size: 1.17em; } <var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { margin-top: 1.33em; margin-bottom: 1.33em; font-size: 1.00em; } <var title="">x</var> <var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { margin-top: 1.67em; margin-bottom: 1.67em; font-size: 0.83em; } <var title="">x</var> <var title="">x</var> <var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { margin-top: 2.33em; margin-bottom: 2.33em; font-size: 0.67em; }</pre> <h4 id=lists><span class=secno>15.3.8 </span>Lists</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); dir, dd, dl, dt, menu, ol, ul { display: block; unicode-bidi: isolate; } li { display: list-item; unicode-bidi: isolate; } dir, dl, menu, ol, ul { margin-top: 1em; margin-bottom: 1em; } dir dir, dir dl, dir menu, dir ol, dir ul, dl dir, dl dl, dl menu, dl ol, dl ul, menu dir, menu dl, menu menu, menu ol, menu ul, ol dir, ol dl, ol menu, ol ol, ol ul, ul dir, ul dl, ul menu, ul ol, ul ul { margin-top: 0; margin-bottom: 0; } dd { margin-left: 40px; } /* <a href=#ltr-specific>LTR-specific</a>: use 'margin-right' for rtl elements */ dir, menu, ol, ul { padding-left: 40px; } /* <a href=#ltr-specific>LTR-specific</a>: use 'padding-right' for rtl elements */ ol { list-style-type: decimal; } dir, menu, ul { list-style-type: disc; } dir dl, dir menu, dir ul, menu dl, menu menu, menu ul, ol dl, ol menu, ol ul, ul dl, ul menu, ul ul { list-style-type: circle; } dir dir dl, dir dir menu, dir dir ul, dir menu dl, dir menu menu, dir menu ul, dir ol dl, dir ol menu, dir ol ul, dir ul dl, dir ul menu, dir ul ul, menu dir dl, menu dir menu, menu dir ul, menu menu dl, menu menu menu, menu menu ul, menu ol dl, menu ol menu, menu ol ul, menu ul dl, menu ul menu, menu ul ul, ol dir dl, ol dir menu, ol dir ul, ol menu dl, ol menu menu, ol menu ul, ol ol dl, ol ol menu, ol ol ul, ol ul dl, ol ul menu, ol ul ul, ul dir dl, ul dir menu, ul dir ul, ul menu dl, ul menu menu, ul menu ul, ul ol dl, ul ol menu, ul ol ul, ul ul dl, ul ul menu, ul ul ul { list-style-type: square; }</pre> <p id=decohints>The following rules are also expected to apply, as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); ol[type=1], li[type=1] { list-style-type: decimal; } ol[type=a], li[type=a] { list-style-type: lower-alpha; } ol[type=A], li[type=A] { list-style-type: upper-alpha; } ol[type=i], li[type=i] { list-style-type: lower-roman; } ol[type=I], li[type=I] { list-style-type: upper-roman; } ul[type=disc i], li[type=disc i] { list-style-type: disc; } ul[type=circle i], li[type=circle i] { list-style-type: circle; } ul[type=square i], li[type=square i] { list-style-type: square; }</pre> <p>When rendering <code><a href=#the-li-element>li</a></code> elements, user agents are expected to use the <a href=#ordinal-value>ordinal value</a> of the <code><a href=#the-li-element>li</a></code> element to render the counter in the list item marker.</p> <h4 id=tables><span class=secno>15.3.9 </span>Tables</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); table { display: table; unicode-bidi: isolate; } caption { display: table-caption; unicode-bidi: isolate; } colgroup, colgroup[hidden] { display: table-column-group; unicode-bidi: isolate; } col, col[hidden] { display: table-column; unicode-bidi: isolate; } thead, thead[hidden] { display: table-header-group; unicode-bidi: isolate; } tbody, tbody[hidden] { display: table-row-group; unicode-bidi: isolate; } tfoot, tfoot[hidden] { display: table-footer-group; unicode-bidi: isolate; } tr, tr[hidden] { display: table-row; unicode-bidi: isolate; } td, th, td[hidden], th[hidden] { display: table-cell; unicode-bidi: isolate; } colgroup[hidden], col[hidden], thead[hidden], tbody[hidden], tfoot[hidden], tr[hidden], td[hidden], th[hidden] { visibility: collapse; } table { border-spacing: 2px; border-collapse: separate; text-indent: initial; } td, th { padding: 1px; } th { font-weight: bold; } thead, tbody, tfoot, table > tr { vertical-align: middle; } tr, td, th { vertical-align: inherit; } table, td, th { border-color: gray; } thead, tbody, tfoot, tr { border-color: inherit; } table[rules=none i], table[rules=groups i], table[rules=rows i], table[rules=cols i], table[rules=all i], table[frame=void i], table[frame=above i], table[frame=below i], table[frame=hsides i], table[frame=lhs i], table[frame=rhs i], table[frame=vsides i], table[frame=box i], table[frame=border i], table[rules=none i] > tr > td, table[rules=none i] > tr > th, table[rules=groups i] > tr > td, table[rules=groups i] > tr > th, table[rules=rows i] > tr > td, table[rules=rows i] > tr > th, table[rules=cols i] > tr > td, table[rules=cols i] > tr > th, table[rules=all i] > tr > td, table[rules=all i] > tr > th, table[rules=none i] > thead > tr > td, table[rules=none i] > thead > tr > th, table[rules=groups i] > thead > tr > td, table[rules=groups i] > thead > tr > th, table[rules=rows i] > thead > tr > td, table[rules=rows i] > thead > tr > th, table[rules=cols i] > thead > tr > td, table[rules=cols i] > thead > tr > th, table[rules=all i] > thead > tr > td, table[rules=all i] > thead > tr > th, table[rules=none i] > tbody > tr > td, table[rules=none i] > tbody > tr > th, table[rules=groups i] > tbody > tr > td, table[rules=groups i] > tbody > tr > th, table[rules=rows i] > tbody > tr > td, table[rules=rows i] > tbody > tr > th, table[rules=cols i] > tbody > tr > td, table[rules=cols i] > tbody > tr > th, table[rules=all i] > tbody > tr > td, table[rules=all i] > tbody > tr > th, table[rules=none i] > tfoot > tr > td, table[rules=none i] > tfoot > tr > th, table[rules=groups i] > tfoot > tr > td, table[rules=groups i] > tfoot > tr > th, table[rules=rows i] > tfoot > tr > td, table[rules=rows i] > tfoot > tr > th, table[rules=cols i] > tfoot > tr > td, table[rules=cols i] > tfoot > tr > th, table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th { border-color: black; }</pre> <p>The following rules are also expected to apply, as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); table[align=left i] { float: left; } table[align=right i] { float: right; } table[align=center i], table[align=abscenter i], table[align=absmiddle i], table[align=middle i] { margin-left: auto; margin-right: auto; } thead[align=absmiddle i], tbody[align=absmiddle i], tfoot[align=absmiddle i], tr[align=absmiddle i], td[align=absmiddle i], th[align=absmiddle i] { text-align: center; } caption[align=bottom i] { caption-side: bottom; } p[align=left i], h1[align=left i], h2[align=left i], h3[align=left i], h4[align=left i], h5[align=left i], h6[align=left i] { text-align: left; } p[align=right i], h1[align=right i], h2[align=right i], h3[align=right i], h4[align=right i], h5[align=right i], h6[align=right i] { text-align: right; } p[align=center i], h1[align=center i], h2[align=center i], h3[align=center i], h4[align=center i], h5[align=center i], h6[align=center i] { text-align: center; } p[align=justify i], h1[align=justify i], h2[align=justify i], h3[align=justify i], h4[align=justify i], h5[align=justify i], h6[align=justify i] { text-align: justify; } thead[valign=top i], tbody[valign=top i], tfoot[valign=top i], tr[valign=top i], td[valign=top i], th[valign=top i] { vertical-align: top; } thead[valign=middle i], tbody[valign=middle i], tfoot[valign=middle i], tr[valign=middle i], td[valign=middle i], th[valign=middle i] { vertical-align: middle; } thead[valign=bottom i], tbody[valign=bottom i], tfoot[valign=bottom i], tr[valign=bottom i], td[valign=bottom i], th[valign=bottom i] { vertical-align: bottom; } thead[valign=baseline i], tbody[valign=baseline i], tfoot[valign=baseline i], tr[valign=baseline i], td[valign=baseline i], th[valign=baseline i] { vertical-align: baseline; } td[nowrap], th[nowrap] { white-space: nowrap; } table[rules=none i], table[rules=groups i], table[rules=rows i], table[rules=cols i], table[rules=all i] { border-style: hidden; border-collapse: collapse; } table[border] { border-style: outset; } /* <a href=#magic-border-selector>only if border is not equivalent to zero</a> */ table[frame=void i] { border-style: hidden; } table[frame=above i] { border-style: outset hidden hidden hidden; } table[frame=below i] { border-style: hidden hidden outset hidden; } table[frame=hsides i] { border-style: outset hidden outset hidden; } table[frame=lhs i] { border-style: hidden hidden hidden outset; } table[frame=rhs i] { border-style: hidden outset hidden hidden; } table[frame=vsides i] { border-style: hidden outset; } table[frame=box i], table[frame=border i] { border-style: outset; } table[border] > tr > td, table[border] > tr > th, table[border] > thead > tr > td, table[border] > thead > tr > th, table[border] > tbody > tr > td, table[border] > tbody > tr > th, table[border] > tfoot > tr > td, table[border] > tfoot > tr > th { /* <a href=#magic-border-selector>only if border is not equivalent to zero</a> */ border-width: 1px; border-style: inset; } table[rules=none i] > tr > td, table[rules=none i] > tr > th, table[rules=none i] > thead > tr > td, table[rules=none i] > thead > tr > th, table[rules=none i] > tbody > tr > td, table[rules=none i] > tbody > tr > th, table[rules=none i] > tfoot > tr > td, table[rules=none i] > tfoot > tr > th, table[rules=groups i] > tr > td, table[rules=groups i] > tr > th, table[rules=groups i] > thead > tr > td, table[rules=groups i] > thead > tr > th, table[rules=groups i] > tbody > tr > td, table[rules=groups i] > tbody > tr > th, table[rules=groups i] > tfoot > tr > td, table[rules=groups i] > tfoot > tr > th, table[rules=rows i] > tr > td, table[rules=rows i] > tr > th, table[rules=rows i] > thead > tr > td, table[rules=rows i] > thead > tr > th, table[rules=rows i] > tbody > tr > td, table[rules=rows i] > tbody > tr > th, table[rules=rows i] > tfoot > tr > td, table[rules=rows i] > tfoot > tr > th { border-width: 1px; border-style: none; } table[rules=cols i] > tr > td, table[rules=cols i] > tr > th, table[rules=cols i] > thead > tr > td, table[rules=cols i] > thead > tr > th, table[rules=cols i] > tbody > tr > td, table[rules=cols i] > tbody > tr > th, table[rules=cols i] > tfoot > tr > td, table[rules=cols i] > tfoot > tr > th { border-width: 1px; border-style: none solid; } table[rules=all i] > tr > td, table[rules=all i] > tr > th, table[rules=all i] > thead > tr > td, table[rules=all i] > thead > tr > th, table[rules=all i] > tbody > tr > td, table[rules=all i] > tbody > tr > th, table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th { border-width: 1px; border-style: solid; } table[rules=groups i] > colgroup { border-left-width: 1px; border-left-style: solid; border-right-width: 1px; border-right-style: solid; } table[rules=groups i] > thead, table[rules=groups i] > tbody, table[rules=groups i] > tfoot { border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; } table[rules=rows i] > tr, table[rules=rows i] > thead > tr, table[rules=rows i] > tbody > tr, table[rules=rows i] > tfoot > tr { border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; }</pre> <!-- Demos that the above (and prose below) must explain: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1191 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1194 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1195 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1196 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1197 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1199 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1200 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1201 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1209 --> <p>In <a href=#quirks-mode>quirks mode</a>, the following rules are also expected to apply:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); table { font-weight: initial; font-style: initial; font-variant: initial; font-size: initial; line-height: initial; white-space: initial; text-align: initial; }</pre> <hr><p>For the purposes of the CSS table model, the <code><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 title=attr-col-span><a href=#attr-col-span>span</a></code> attribute <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">specifies</a>.</p> <p>For the purposes of the CSS table model, the <code><a href=#the-colgroup-element>colgroup</a></code> element, if it contains no <code><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 title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">specifies</a>.</p> <p>For the purposes of the CSS table model, the <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code> and <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code> attributes on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements are expected to <a href=#rules-for-parsing-non-negative-integers title="rules for parsing non-negative integers">provide</a> the <i>special knowledge</i> regarding cells spanning rows and columns.</p> <p>In <a href=#html-documents>HTML documents</a>, the user agent is expected to force the 'display' property of <code><a href=#the-form-element>form</a></code> elements that are children of <code><a href=#the-table-element>table</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, or <code><a href=#the-tr-element>tr</a></code> elements to compute to 'none', irrespective of CSS rules.</p> <hr><p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-cellspacing><a href=#attr-table-cellspacing>cellspacing</a></code> attribute <a href=#maps-to-the-pixel-length-property>maps to the pixel length property</a> 'border-spacing' on the element.</p> <p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-cellpadding><a href=#attr-table-cellpadding>cellpadding</a></code> attribute <a href=#maps-to-the-pixel-length-property title="maps to the pixel length property">maps to the pixel length properties</a> 'padding-top', 'padding-right', 'padding-bottom', and 'padding-left' of any <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements that have corresponding <a href=#concept-cell title=concept-cell>cells</a> in the <a href=#concept-table title=concept-table>table</a> corresponding to the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-hspace>hspace</code> attribute <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-left' and 'margin-right' on the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-vspace>vspace</code> attribute <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-top' and 'margin-bottom' on the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-height>height</code> attribute <a href=#maps-to-the-dimension-property>maps to the dimension property</a> 'height' on the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-width><a href=#attr-table-width>width</a></code> attribute <a href=#maps-to-the-dimension-property>maps to the dimension property</a> 'width' on the <code><a href=#the-table-element>table</a></code> element.</p> <p>The <code><a href=#the-col-element>col</a></code> element's <code title=attr-col-width><a href=#attr-col-width>width</a></code> attribute <a href=#maps-to-the-dimension-property>maps to the dimension property</a> 'width' on the <code><a href=#the-col-element>col</a></code> element.</p> <p>The <code><a href=#the-tr-element>tr</a></code> element's <code title=attr-tr-height>height</code> attribute <a href=#maps-to-the-dimension-property>maps to the dimension property</a> 'height' on the <code><a href=#the-tr-element>tr</a></code> element.</p> <p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements' <code title=attr-tdth-height><a href=#attr-tdth-height>height</a></code> attributes <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension property</a> 'height' on the element.</p> <p>The <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements' <code title=attr-tdth-width><a href=#attr-tdth-width>width</a></code> attributes <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension property</a> 'width' on the element.</p> <p>When a <code><a href=#document>Document</a></code> is in <a href=#quirks-mode>quirks mode</a>, vertical margins on <a href=#html-elements>HTML elements</a> at the top or bottom of <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> elements are expected to be collapsed to zero.</p> <hr><p>The <code><a href=#the-caption-element>caption</a></code> element unless specified otherwise below, and the <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, and <code><a href=#the-th-element>th</a></code> elements when they have an <code title=attr-div-align><a href=#attr-div-align>align</a></code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for either the string "<code title="">center</code>" or the string "<code title="">middle</code>", are expected to center text within themselves, as if they had their 'text-align' property set to 'center' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the center.</p> <p>The <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, and <code><a href=#the-th-element>th</a></code> elements, when they have an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">left</code>", are expected to left-align text within themselves, as if they had their 'text-align' property set to 'left' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the left.</p> <p>The <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, and <code><a href=#the-th-element>th</a></code> elements, when they have an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">right</code>", are expected to right-align text within themselves, as if they had their 'text-align' property set to 'right' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the right.</p> <p>The <code><a href=#the-caption-element>caption</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, and <code><a href=#the-th-element>th</a></code> elements, when they have an <code title=attr-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">justify</code>", are expected to full-justify text within themselves, as if they had their 'text-align' property set to 'justify' in a <a href=#presentational-hints title="presentational hints">presentational hint</a>, and to <a href=#align-descendants>align descendants</a> to the left.</p> <p>User agents are expected to have a rule in their user agent stylesheet that matches <code><a href=#the-th-element>th</a></code> elements that have a parent node whose computed value for the 'text-align' property is its initial value, whose declaration block consists of just a single declaration that sets the 'text-align' property to the value 'center'.</p> <!-- q.v. '-moz-center-or-inherit' --> <hr><p>When a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, or <code><a href=#the-th-element>th</a></code> element has a <code title=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=#resolve-a-url title="resolve a url">resolved</a> relative to the element, and if this is successful, the user agent is expected to treat the attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> setting the element's 'background-image' property to the resulting <a href=#absolute-url>absolute URL</a>.</p> <p>When a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, or <code><a href=#the-th-element>th</a></code> element has a <code title="">bgcolor</code> attribute set, the new value is expected to be parsed using the <a href=#rules-for-parsing-a-legacy-color-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 title="presentational hints">presentational hint</a> setting the element's 'background-color' property to the resulting color.</p> <p>When a <code><a href=#the-table-element>table</a></code> element has a <code title=attr-table-bordercolor>bordercolor</code> attribute, its value is expected to be parsed using the <a href=#rules-for-parsing-a-legacy-color-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 title="presentational hints">presentational hint</a> setting the element's 'border-top-color', 'border-right-color', 'border-bottom-color', and 'border-right-color' properties to the resulting color.</p> <hr><p>The <code><a href=#the-table-element>table</a></code> element's <code title=attr-table-border><a href=#attr-table-border>border</a></code> attribute <a href=#maps-to-the-pixel-length-property title="maps to the pixel length property">maps to the pixel length properties</a> 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width' on the element. If the attribute is present but parsing the attribute's value using the <a href=#rules-for-parsing-non-negative-integers>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 title=attr-table-border><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>rules for parsing non-negative integers</a>, is also found to have a value other than zero or to generate an error.</p> <h4 id=form-controls><span class=secno>15.3.10 </span>Form controls</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input, select, option, optgroup, button, textarea, keygen { text-indent: initial; } textarea { white-space: pre-wrap; } </pre> <p>In <a href=#quirks-mode>quirks mode</a>, the following rules are also expected to apply:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input { box-sizing: border-box; }</pre> <p>Each kind of form control is also given a specific default binding, as described in subsequent sections, which implements the look and feel of the control.</p> <h4 id=the-hr-element-0><span class=secno>15.3.11 </span>The <code><a href=#the-hr-element>hr</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); hr { color: gray; border-style: inset; border-width: 1px; margin: 0.5em auto; }</pre> <p>The following rules are also expected to apply, as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); hr[align=left] { margin-left: 0; margin-right: auto; } hr[align=right] { margin-left: auto; margin-right: 0; } hr[align=center] { margin-left: auto; margin-right: auto; } hr[color], hr[noshade] { border-style: solid; }</pre> <p>If an <code><a href=#the-hr-element>hr</a></code> element has either a <code title=attr-hr-color><a href=#attr-hr-color>color</a></code> attribute or a <code title=attr-hr-noshade><a href=#attr-hr-noshade>noshade</a></code> attribute, and furthermore also has a <code title=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>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>presentational hints</a> for the properties 'border-top-width', 'border-right-width', 'border-bottom-width', and 'border-left-width' on the element.</p> <p>Otherwise, if an <code><a href=#the-hr-element>hr</a></code> element has neither a <code title=attr-hr-color><a href=#attr-hr-color>color</a></code> attribute nor a <code title=attr-hr-noshade><a href=#attr-hr-noshade>noshade</a></code> attribute, but does have a <code title=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>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 title="presentational hints">presentational hint</a> setting the element's 'border-bottom-width' 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>presentational hints</a> for the 'height' property on the element.</p> <p>The <code title=attr-hr-width><a href=#attr-hr-width>width</a></code> attribute on an <code><a href=#the-hr-element>hr</a></code> element <a href=#maps-to-the-dimension-property>maps to the dimension property</a> 'width' on the element.</p> <p>When an <code><a href=#the-hr-element>hr</a></code> element has a <code title=attr-hr-color><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-color-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 title="presentational hints">presentational hint</a> setting the element's 'color' property to the resulting color.</p> <h4 id=the-fieldset-element-0><span class=secno>15.3.12 </span>The <code><a href=#the-fieldset-element>fieldset</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); fieldset { margin-left: 2px; margin-right: 2px; border: groove 2px ThreeDFace; padding: 0.35em 0.625em 0.75em; }</pre> <p>The <code><a href=#the-fieldset-element>fieldset</a></code> element is expected to establish a new block formatting context.</p> <p>If the <code><a href=#the-fieldset-element>fieldset</a></code> element has a child that matches the conditions in the list below, then the first such child is the <code><a href=#the-fieldset-element>fieldset</a></code> element's <dfn id=rendered-legend>rendered legend</dfn>:</p> <ul class=brief><li>The child is a <code><a href=#the-legend-element>legend</a></code> element.</li> <li>The child is not out-of-flow (e.g. not absolutely positioned or floated).</li> <li>The child is generating a box (e.g. it is not 'display:none').</li> </ul><p>A <code><a href=#the-fieldset-element>fieldset</a></code> element's <a href=#rendered-legend>rendered legend</a>, if any, is expected to be rendered over the top border edge of the <code><a href=#the-fieldset-element>fieldset</a></code> element as a 'block' box (overriding any explicit 'display' value). In the absence of an explicit width, the box should shrink-wrap. If the <code><a href=#the-legend-element>legend</a></code> element in question has an <code title=attr-legend-align><a href=#attr-legend-align>align</a></code> attribute, and its value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for one of the strings in the first column of the following table, then the <code><a href=#the-legend-element>legend</a></code> is expected to be rendered horizontally aligned over the border edge in the position given in the corresponding cell on the same row in the second column. If the attribute is absent or has a value that doesn't match any of the cases in the table, then the position is expected to be on the right if the 'direction' property on this element has a computed value of 'rtl', and on the left otherwise.</p> <table><thead><tr><th>Attribute value <th>Alignment position <tbody><tr><td><code title="">left</code> <td>On the left <tr><td><code title="">right</code> <td>On the right <tr><td><code title="">center</code> <td>In the middle </table><h3 id=replaced-elements><span class=secno>15.4 </span>Replaced elements</h3> <h4 id=embedded-content-2><span class=secno>15.4.1 </span>Embedded content</h4> <p>The <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, and <code><a href=#the-video-element>video</a></code> elements are expected to be treated as replaced elements.</p> <p>A <code><a href=#the-canvas-element>canvas</a></code> element that <a href=#represents>represents</a> <a href=#embedded-content>embedded content</a> is expected to be treated as a replaced element. Other <code><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><a href=#the-object-element>object</a></code> element that <a href=#represents>represents</a> an image, plugin, or <a href=#nested-browsing-context>nested browsing context</a> is expected to be treated as a replaced element. Other <code><a href=#the-object-element>object</a></code> elements are expected to be treated as ordinary elements in the rendering model.</p> <p>An <code><a href=#the-applet-element>applet</a></code> element that <a href=#represents>represents</a> a <a href=#plugin>plugin</a> is expected to be treated as a replaced element. Other <code><a href=#the-applet-element>applet</a></code> elements are expected to be treated as ordinary elements in the rendering model.</p> <p>The <code><a href=#the-audio-element>audio</a></code> element, when it is <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface</a>, is expected to be treated as a replaced element about one line high, as wide as is necessary to expose the user agent's user interface features. When an <code><a href=#the-audio-element>audio</a></code> element is not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface</a>, the user agent is expected to force its 'display' property to compute to 'none', irrespective of CSS rules.</p> <p>Whether a <code><a href=#the-video-element>video</a></code> element is <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">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><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><a href=#the-video-element>video</a></code> element itself, and is expected to be centered in the <code><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><a href=#the-video-element>video</a></code> element, as defined by the relevant rendering rules; for <a href=#webvtt>WebVTT</a>, those are the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a> defined below.</p> <p>When the user agent starts <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface</a> for a <code><a href=#the-video-element>video</a></code> element, the user agent should run the <a href=#rules-for-updating-the-text-track-rendering>rules for updating the text track rendering</a> of each of the <a href=#text-track title="text track">text tracks</a> in the <code><a href=#the-video-element>video</a></code> element's <a href=#list-of-text-tracks>list of text tracks</a> that are <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a> (e.g., for <a href=#text-track title="text track">text tracks</a> based on <a href=#webvtt>WebVTT</a>, the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>).</p> <p class=note>Resizing <code><a href=#the-video-element>video</a></code> and <code><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 class=css>@namespace url(http://www.w3.org/1999/xhtml); iframe:not([seamless]) { border: 2px inset; } <span id=video-object-fit>video { object-fit: contain; }</span></pre> </div> <div class=impl> <h4 id=timed-text-tracks-0><span class=secno>15.4.2 </span>Timed text tracks</h4> <p class=note>This section is intended to be moved to its own CSS module once an editor is found to run with it.</p> <h5 id=webvtt-cue-text-rendering-rules><span class=secno>15.4.2.1 </span><dfn>WebVTT cue text rendering rules</dfn></h5> <p>The <dfn id=rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</dfn> render the <a href=#text-track title="text track">text tracks</a> of a <a href=#media-element>media element</a> (specifically, a <code><a href=#the-video-element>video</a></code> element), or of another playback mechanism, by applying the steps below. All the <a href=#text-track title="text track">text tracks</a> that use these rules for a given <a href=#media-element>media element</a>, or other playback mechanism, are rendered together, to avoid overlapping subtitles from multiple tracks.</p> <p>The output of the steps below is a set of CSS boxes that covers the rendering area of the <a href=#media-element>media element</a> or other playback mechanism, which user agents are expected to render in a manner suiting the user.</p> <p>The rules are as follows:</p> <ol><li><p>If the <a href=#media-element>media element</a> is an <code><a href=#the-audio-element>audio</a></code> element, or is another playback mechanism with no rendering area, abort these steps. There is nothing to render.</li> <li><p>Let <var title="">video</var> be the <a href=#media-element>media element</a> or other playback mechanism.</li> <li><p>Let <var title="">output</var> be an empty list of absolutely positioned CSS block boxes.</li> <li><p>If the user agent is <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface</a> for <var title="">video</var>, add to <var title="">output</var> one or more completely transparent positioned CSS block boxes that cover the same region as the user interface.</p> <li><p>If the last time these rules were run, the user agent was not <a href=#expose-a-user-interface-to-the-user title="expose a user interface to the user">exposing a user interface</a> for <var title="">video</var>, but now it is, let <var title="">reset</var> be true. Otherwise, let <var title="">reset</var> be false.</p> <li><p>Let <var title="">tracks</var> be the subset of <var title="">video</var>'s <a href=#list-of-text-tracks>list of text tracks</a> that have as their <a href=#rules-for-updating-the-text-track-rendering>rules for updating the text track rendering</a> these <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>, and whose <a href=#text-track-mode>text track mode</a> is <a href=#text-track-showing title="text track showing">showing</a> or <a href=#text-track-showing-by-default title="text track showing by default">showing by default</a>.</li> <li><p>Let <var title="">cues</var> be an empty list of <a href=#text-track-cue title="text track cue">text track cues</a>.</li> <li><p>For each track <var title="">track</var> in <var title="">tracks</var>, append to <var title="">cues</var> all the <a href=#text-track-cue title="text track cue">cues</a> from <var title="">track</var>'s <a href=#text-track-list-of-cues title="text track list of cues">list of cues</a> that have their <a href=#text-track-cue-active-flag>text track cue active flag</a> set.</li> <li><p>If <var title="">reset</var> is false, then, for each <a href=#text-track-cue>text track cue</a> <var title="">cue</var> in <var title="">cues</var>: if <var title="">cue</var>'s <a href=#text-track-cue-display-state>text track cue display state</a> has a set of CSS boxes, then add those boxes to <var title="">output</var>, and remove <var title="">cue</var> from <var title="">cues</var>.</li> <li> <p>For each <a href=#text-track-cue>text track cue</a> <var title="">cue</var> in <var title="">cues</var> that has not yet had corresponding CSS boxes added to <var title="">output</var>, in <a href=#text-track-cue-order>text track cue order</a>, run the following substeps:</p> <ol><li><p>Let <var title="">nodes</var> be the <a href=#list-of-webvtt-node-objects>list of WebVTT Node Objects</a> obtained by applying the <a href=#webvtt-cue-text-parsing-rules>WebVTT cue text parsing rules</a> to the <var title="">cue</var>'s <a href=#text-track-cue-text>text track cue text</a>.</p> <li> <p>Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to <var title="">nodes</var> using the following constraints, to determine the <i>paragraph embedding level</i> of the cue: <a href=#refsBIDI>[BIDI]</a></p> <ul><li><var title="">nodes</var> represents a single paragraph.</li> <li>The paragraph's text consists of the concatenation of the values of each <a href=#webvtt-text-object>WebVTT Text Object</a> in <var title="">nodes</var>, in a pre-order, depth-first traversal, excluding <a href=#webvtt-ruby-text-object title="WebVTT Ruby Text Object">WebVTT Ruby Text Objects</a> and their descendants.</li> </ul></li> <li> <p>If the <i>paragraph embedding level</i> determined in the previous step is even (the <i>paragraph direction</i> is left-to-right), let <var title="">direction</var> be 'ltr', otherwise, let it be 'rtl'.</p> </li> <li><p>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, then let <var title="">block-flow</var> be 'tb'. Otherwise, if the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, then let <var title="">block-flow</var> be 'lr'. Otherwise, the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>; let <var title="">block-flow</var> be 'rl'.</li> <li> <p>Determine the value of <var title="">maximum size</var> for <var title="">cue</var> as per the appropriate rules from the following list:</p> <dl class=switch><dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a>, and <var title="">direction</var> is 'ltr'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a>, and <var title="">direction</var> is 'rtl'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a></dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a></dt> <dd> <p>Let <var title="">maximum size</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> subtracted from 100.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a>, and <var title="">direction</var> is 'ltr'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a>, and <var title="">direction</var> is 'rtl'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a></dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a></dt> <dd> <p>Let <var title="">maximum size</var> be the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a>, the <a href=#text-track-cue-text-position>text track cue text position</a> is less than or equal to 50</dt> <dd> <p>Let <var title="">maximum size</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> multiplied by two.</p> </dd> <dt>If the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a>, the <a href=#text-track-cue-text-position>text track cue text position</a> is greater than <!-- or equal to --> 50</dt> <dd> <p>Let <var title="">maximum size</var> be the result of subtracting <a href=#text-track-cue-text-position>text track cue text position</a> from 100 and then multiplying the result by two.</p> </dd> </dl></li> <li><p>If the <a href=#text-track-cue-size>text track cue size</a> is less than <var title="">maximum size</var>, then let <var title="">size</var> be <a href=#text-track-cue-size>text track cue size</a>. Otherwise, let <var title="">size</var> be <var title="">maximum size</var>.</li> <li><p>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, then let <var title="">width</var> be '<var title="">size</var> vw' and <var title="">height</var> be 'auto'. Otherwise, let <var title="">width</var> be 'auto' and <var title="">height</var> be '<var title="">size</var> vh'. (These are CSS values used by the next section to set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) <a href=#refsCSSVALUES>[CSSVALUES]</a></li> <li> <p>Determine the value of <var title="">x-position</var> or <var title="">y-position</var> for <var title="">cue</var> as per the appropriate rules from the following list:</p> <dl class=switch><dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a>, and <var title="">direction</var> is 'ltr'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a>, and <var title="">direction</var> is 'rtl'</dt> <dd> <p>Let <var title="">x-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a>, and <var title="">direction</var> is 'ltr'</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a>, and <var title="">direction</var> is 'rtl'</dt> <dd> <p>Let <var title="">x-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> subtracted from 100.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a></dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-start-alignment title="text track cue start alignment">start</a></dt> <dd> <p>Let <var title="">y-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a></dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-end-alignment title="text track cue end alignment">end</a></dt> <dd> <p>Let <var title="">y-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> subtracted from 100.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a>, and <var title="">direction</var> is 'ltr'</dt> <dd> <p>Let <var title="">x-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> minus half of <var title="">size</var>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a>, and <var title="">direction</var> is 'rtl'</dt> <dd> <p>Let <var title="">x-position-reverse</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> minus half of <var title="">size</var>.</p> <p>Let <var title="">x-position</var> be <var title="">x-position-reverse</var> subtracted from 100.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a></dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-alignment>text track cue alignment</a> is <a href=#text-track-cue-middle-alignment title="text track cue middle alignment">middle</a></dt> <dd> <p>Let <var title="">y-position</var> be the <a href=#text-track-cue-text-position>text track cue text position</a> minus half of <var title="">size</var>.</p> </dd> </dl></li> <li> <p>Determine the value of whichever of <var title="">x-position</var> or <var title="">y-position</var> is not yet calculated for <var title="">cue</var> as per the appropriate rules from the following list:</p> <dl class=switch><dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is set</dt> <dd> <p>Let <var title="">y-position</var> be zero.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is not set</dt> <dd> <p>Let <var title="">y-position</var> be the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is set</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is set</dt> <dd> <p>Let <var title="">x-position</var> be zero.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is not set</dt> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, and the <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is not set</dt> <dd> <p>Let <var title="">x-position</var> be the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>.</p> </dd> </dl></li> <li><p>Let <var title="">left</var> be '<var title="">x-position</var> vw' and <var title="">top</var> be '<var title="">y-position</var> vh'. (These again are CSS values used by the next section to set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) <a href=#refsCSSVALUES>[CSSVALUES]</a></li> <li> <p>Apply the terms of the CSS specifications to <var title="">nodes</var> within the following constraints, thus obtaining a set of CSS boxes positioned relative to an initial containing block: <a href=#refsCSS>[CSS]</a></p> <ul><li><p>The <i>document tree</i> is the tree of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> rooted at <var title="">nodes</var>.</li> <li><p>For the purposes of processing by the CSS specification, <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> are equivalent to elements with the same contents.</li> <li>For the purposes of processing by the CSS specification, <a href=#webvtt-text-object title="WebVTT Text Object">WebVTT Text Objects</a> are equivalent to text nodes.</li> <li>No style sheets are associated with <var title="">nodes</var>. (The nodes are subsequently restyled using style sheets after their boxes are generated, as described below.)</li> <li>The children of the <var title="">nodes</var> must be wrapped in an anonymous box whose 'display' property has the value 'inline'. This is the <dfn id=webvtt-cue-background-box>WebVTT cue background box</dfn>.</li> <li>Runs of children of <a href=#webvtt-ruby-object title="WebVTT Ruby Object">WebVTT Ruby Objects</a> that are not <a href=#webvtt-ruby-text-object title="WebVTT Ruby Text Object">WebVTT Ruby Text Objects</a> must be wrapped in anonymous boxes whose 'display' property has the value 'ruby-base'. <a href=#refsCSSRUBY>[CSSRUBY]</a></li> <li>Properties on <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> have their values set as defined in the next section. (That section uses some of the variables whose values were calculated earlier in this algorithm.)</li> <li>Text runs must be wrapped according to the CSS line-wrapping rules, except that additionally, regardless of the value of the 'white-space' property, lines must be wrapped at the edge of their containing blocks, even if doing so requires splitting a word where there is no line breaking opportunity. (Thus, normally text wraps as needed, but if there is a particularly long word, it does not overflow as it normally would in CSS, it is instead forcibly wrapped at the box's edge.)</li> <li>The viewport (and initial containing block) is <var title="">video</var>'s rendering area.</li> </ul><p>Let <var title="">boxes</var> be the boxes generated as descendants of the initial containing block, along with their positions.</p> </li> <li><p>If there are no line boxes in <var title="">boxes</var>, skip the remainder of these substeps for <var title="">cue</var>. The cue is ignored.</li> <li> <p>Adjust the positions of <var title="">boxes</var> according to the appropriate steps from the following list:</p> <dl class=switch><dt>If <var title="">cue</var>'s <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is set</dt> <dd> <p>Many of the steps in this algorithm vary according to the <a href=#text-track-cue-writing-direction>text track cue writing direction</a>. Steps labeled "<strong>Horizontal</strong>" must be followed only when the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, steps labeled "<strong>Vertical</strong>" must be followed when the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is either <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a> or <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>, steps labeled "<strong>Vertical Growing Left</strong>" must be followed only when the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a>, and steps labeled "<strong>Vertical Growing Right</strong>" must be followed only when the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a>.</p> <ol><li> <p><strong>Horizontal</strong>: Let <var title="">step</var> be the height of the first line box in <var title="">boxes</var>.</p> <p><strong>Vertical</strong>: Let <var title="">step</var> be the width of the first line box in <var title="">boxes</var>.</p> </li> <li><p>If <var title="">step</var> is zero, then jump to the step labeled <i>done positioning</i> below.</li> <li><p>Let <var title="">line position</var> be the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>.</li> <li><p><strong>Vertical Growing Left</strong>: Add one to <var title="">line position</var> then negate it.</li> <li><p>Let <var title="">position</var> be the result of multiplying <var title="">step</var> and <var title="">line position</var>.</li> <li><p><strong>Vertical Growing Left</strong>: Decrease <var title="">position</var> by the width of the bounding box of the boxes in <var title="">boxes</var>, then increase <var title="">position</var> by <var title="">step</var>.</li> <li> <p><strong>Horizontal</strong>: If <var title="">line position</var> is less than zero then increase <var title="">position</var> by the height of the <var title="">video</var>'s rendering area, and negate <var title="">step</var> (so its value is now minus the height of the first line box in <var title="">boxes</var>).</p> <p><strong>Vertical</strong>: If <var title="">line position</var> is less than zero then increase <var title="">position</var> by the width of the <var title="">video</var>'s rendering area, and negate <var title="">step</var>.</p> </li> <li> <p><strong>Horizontal</strong>: Move all the boxes in <var title="">boxes</var> down by the distance given by <var title="">position</var>.</p> <p><strong>Vertical</strong>: Move all the boxes in <var title="">boxes</var> right by the distance given by <var title="">position</var>.</p> </li> <li><p><i>Default</i>: Remember the position of all the boxes in <var title="">boxes</var> as their <var title="">default position</var>.</li> <li><p>Let <var title="">switched</var> be false.</li> <li><p><i>Step loop</i>: If none of the boxes in <var title="">boxes</var> would overlap any of the boxes in <var title="">output</var>, and all the boxes in <var title="">output</var> are within the <var title="">video</var>'s rendering area, then jump to the step labeled <i>done positioning</i> below.</li> <li> <p><strong>Horizontal</strong>: If <var title="">step</var> is negative and the top of the first line box in <var title="">boxes</var> is now above the top of the <var title="">video</var>'s rendering area, or if <var title="">step</var> is positive and the bottom of the first line box in <var title="">boxes</var> is now below the bottom of the <var title="">video</var>'s rendering area, jump to the step labeled <i>switch direction</i>.</p> <p><strong>Vertical</strong>: If <var title="">step</var> is negative and the left edge of the first line box in <var title="">boxes</var> is now to the left of the left edge of the <var title="">video</var>'s rendering area, or if <var title="">step</var> is positive and the right edge of the first line box in <var title="">boxes</var> is now to the right of the right edge of the <var title="">video</var>'s rendering area, jump to the step labeled <i>switch direction</i>.</p> </li> <li> <p><strong>Horizontal</strong>: Move all the boxes in <var title="">boxes</var> down by the distance given by <var title="">step</var>. (If <var title="">step</var> is negative, then this will actually result in an upwards movement of the boxes in absolute terms.)</p> <p><strong>Vertical</strong>: Move all the boxes in <var title="">boxes</var> right by the distance given by <var title="">step</var>. (If <var title="">step</var> is negative, then this will actually result in a leftwards movement of the boxes in absolute terms.)</p> </li> <li><p>Jump back to the step labeled <i>step loop</i>.</li> <li><p><i>Switch direction</i>: Move all the boxes in <var title="">boxes</var> back to their <var title="">default position</var> as determined in the step above labeled <i>default</i>.</li> <li><p>If <var title="">switched</var> is true, jump to the step labeled <i>done positioning</i> below.</li> <li><p>Negate <var title="">step</var>.</li> <li><p>Set <var title="">switched</var> to true.</li> <li><p>Jump back to the step labeled <i>step loop</i>.</li> </ol></dd> <dt>If <var title="">cue</var>'s <a href=#text-track-cue-snap-to-lines-flag>text track cue snap-to-lines flag</a> is not set</dt> <dd> <ol><li> <p>Set up <var title="">x</var> and <var title="">y</var> as follows:</p> <dl class=switch><dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, and <var title="">direction</var> is 'ltr'</dt> <dd> <p>Let <var title="">x</var> be a percentage given by the <a href=#text-track-cue-text-position>text track cue text position</a>, and let <var title="">y</var> be a percentage given by the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-horizontal-writing-direction title="text track cue horizontal writing direction">horizontal</a>, and <var title="">direction</var> is 'rtl'</dt> <dd> <p>Let <var title="">x</var> be a percentage given by the <a href=#text-track-cue-text-position>text track cue text position</a> subtracted from 100, and let <var title="">y</var> be a percentage given by the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-left-writing-direction title="text track cue vertical growing left writing direction">vertical growing left</a></dt> <dd> <p>Let <var title="">x</var> be a percentage given by the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a> subtracted from 100, and let <var title="">y</var> be a percentage given by the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> </dd> <dt>If the <a href=#text-track-cue-writing-direction>text track cue writing direction</a> is <a href=#text-track-cue-vertical-growing-right-writing-direction title="text track cue vertical growing right writing direction">vertical growing right</a></dt> <dd> <p>Let <var title="">x</var> be a percentage given by the <a href=#text-track-cue-computed-line-position>text track cue computed line position</a>, and let <var title="">y</var> be a percentage given by the <a href=#text-track-cue-text-position>text track cue text position</a>.</p> </dd> </dl></li> <li><p>Position the boxes in <var title="">boxes</var> such that the point <var title="">x</var>% along the width of the bounding box of the boxes in <var title="">boxes</var> is <var title="">x</var>% of the way across the width of the <var title="">video</var>'s rendering area, and the point <var title="">y</var>% along the height of the bounding box of the boxes in <var title="">boxes</var> is <var title="">y</var>% of the way across the height of the <var title="">video</var>'s rendering area, while maintaining the relative positions of the boxes in <var title="">boxes</var> to each other.</li> <li><p>If none of the boxes in <var title="">boxes</var> would overlap any of the boxes in <var title="">output</var>, and all the boxes in <var title="">output</var> are within the <var title="">video</var>'s rendering area, then jump to the step labeled <i>done positioning</i> below.</li> <li><p>If there is a position to which the boxes in <var title="">boxes</var> can be moved while maintaining the relative positions of the boxes in <var title="">boxes</var> to each other such that none of the boxes in <var title="">boxes</var> would overlap any of the boxes in <var title="">output</var>, and all the boxes in <var title="">output</var> would be within the <var title="">video</var>'s rendering area, then move the boxes in <var title="">boxes</var> to the closest such position to their current position, and then jump to the step labeled <i>done positioning</i> below. If there are multiple such positions that are equidistant from their current position, use the highest one amongst them; if there are several at that height, then use the leftmost one amongst them.</li> <li><p>Otherwise, jump to the step labeled <i>done positioning</i> below. (The boxes will unfortunately overlap.)</li> </ol></dd> </dl></li> <li><p><i>Done positioning</i>: If there are any line boxes in the (possibly now repositioned) <var title="">boxes</var> that do not completely fit inside <var title="">video</var>'s rendering area, remove those offending line boxes from <var title="">boxes</var>.</li> <li><p>Let <var title="">cue</var>'s <a href=#text-track-cue-display-state>text track cue display state</a> have the CSS boxes in <var title="">boxes</var>.</li> <li><p>Add the CSS boxes in <var title="">boxes</var> to <var title="">output</var>.</li> </ol></li> <li><p>Return <var title="">output</var>.</li> </ol><p>User agents may allow the user to override the above algorithm's positioning of cues, e.g. by dragging them to another location on the <code><a href=#the-video-element>video</a></code>, or even off the <code><a href=#the-video-element>video</a></code> entirely.</p> <h5 id=applying-css-properties-to-webvtt-node-objects><span class=secno>15.4.2.2 </span>Applying CSS properties to <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a></h5> <p>When following the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a>, user agents must set properties of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> as defined in this section. <a href=#refsCSS>[CSS]</a></p> <p>On the (root) <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, the 'position' property must be set to 'absolute', the 'direction' property must be set to <var title="">direction</var>, the 'block-flow' property must be set to <var title="">block-flow</var>, the 'top' property must be set to <var title="">top</var>, the 'left' property must be set to <var title="">left</var>, the 'width' property must be set to <var title="">width</var>, and the 'height' property must be set to <var title="">height</var>, where <var title="">direction</var>, <var title="">block-flow</var>, <var title="">top</var>, <var title="">left</var>, <var title="">width</var>, and <var title="">height</var> are the values with those names determined by the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text tracks</a> for the <a href=#text-track-cue>text track cue</a> from whose <a href=#text-track-cue-text title="text track cue text">text</a> the <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> was constructed.</p> <p>The 'text-align' property on the (root) <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> must be set to the value in the second cell of the row of the table below whose first cell is the value of the corresponding <a href=#text-track-cue title="text track cue">cue</a>'s <a href=#text-track-cue-alignment>text track cue alignment</a>:</p> <table><thead><tr><th><a href=#text-track-cue-alignment>Text track cue alignment</a> <th> 'text-align' value <tbody><tr><td><a href=#text-track-cue-start-alignment title="text track cue start alignment">Start alignment</a> <td> 'start' <tr><td><a href=#text-track-cue-middle-alignment title="text track cue middle alignment">Middle alignment</a> <td> 'center' <tr><td><a href=#text-track-cue-end-alignment title="text track cue end alignment">End alignment</a> <td> 'end' </table><p>The 'font' shorthand property on the (root) <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> must be set to '5vh sans-serif'. <a href=#refsCSSRUBY>[CSSRUBY]</a> <a href=#refsCSSVALUES>[CSSVALUES]</a></p> <p>The 'color' property on the (root) <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> must be set to 'rgba(255,255,255,0)'. <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p> <p>The 'background' shorthand property on the <a href=#webvtt-cue-background-box>WebVTT cue background box</a> must be set to 'rgba(0,0,0,0.8)'. <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p> <p>A text outline or stroke may also be set on the (root) <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, if supported.</p> <!-- 'text-outline' is in CSS3 Text, but Tab says that's awaiting medical attention. --> <p>The 'font-style' property on <a href=#webvtt-italic-object title="WebVTT Italic Object">WebVTT Italic Objects</a> must be set to 'italic'.</p> <p>The 'font-weight' property on <a href=#webvtt-bold-object title="WebVTT Bold Object">WebVTT Bold Objects</a> must be set to 'bold'.</p> <p>The 'text-decoration' property on <a href=#webvtt-underline-object title="WebVTT Underline Object">WebVTT Underline Objects</a> must be set to 'underline'.</p> <p>The 'display' property on <a href=#webvtt-ruby-object title="WebVTT Ruby Object">WebVTT Ruby Objects</a> must be set to 'ruby'. <a href=#refsCSSRUBY>[CSSRUBY]</a></p> <p>The 'display' property on <a href=#webvtt-ruby-text-object title="WebVTT Ruby Text Object">WebVTT Ruby Text Objects</a> must be set to 'ruby-text'. <a href=#refsCSSRUBY>[CSSRUBY]</a></p> <p>If there are style sheets that apply to the <a href=#media-element>media element</a> or other playback mechanism, then they must be interpreted as defined in the next section.</p> <p>All other non-inherited properties must be set to their initial values; inherited properties on the root <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> must inherit their values from the <a href=#media-element>media element</a> for which the <a href=#text-track-cue>text track cue</a> is being rendered, if any. If there is no <a href=#media-element>media element</a> (i.e. if the <a href=#text-track>text track</a> is being rendered for another media playback mechanism), then inherited properties on the root <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> must take their initial values.</p> <h5 id=css-extensions><span class=secno>15.4.2.3 </span>CSS extensions</h5> <p>When a user agent is rendering one or more <a href=#text-track-cue title="text track cue">text track cues</a> according to the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a>, <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> in the <a href=#list-of-webvtt-node-objects>list of WebVTT Node Objects</a> used in the rendering can be matched by certain pseudo-selectors as defined below. These selectors can begin or stop matching individual <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> while a <a href=#text-track-cue title="text track cue">cue</a> is being rendered, even in between applications of the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue text rendering rules</a> (which are only run when the set of active cues changes). User agents that support the pseudo-element described below must dynamically update renderings accordingly.</p> <p>Pseudo-elements apply to elements that are matched by selectors. For the purpose of this section, that element is the <i>matched element</i>. The pseudo-elements defined in the following sections affect the styling of parts of <a href=#text-track-cue title="text track cue">text track cues</a> that are being rendered for the <i>matched element</i>.</p> <p class=note>If the <i>matched element</i> is not a <code><a href=#the-video-element>video</a></code> element, the pseudo-elements defined below won't have any effect according to this specification.</p> <p>A CSS user agent that implements the <a href=#text-track title="text track">text tracks</a> model must implement the '::cue' and '::cue(<var title="">selector</var>)' pseudo-elements, and the <a href=#past-pseudo-class title=past-pseudo-class>':past'</a> and <a href=#future-pseudo-class title=future-pseudo-class>':future'</a> pseudo-classes.</p> <h6 id="the-'::cue'-pseudo-element"><span class=secno>15.4.2.3.1 </span>The '::cue' pseudo-element</h6> <p>The '<dfn id=pseudo-cue title=pseudo-cue>::cue</dfn>' pseudo-element (with no argument) matches any <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a> constructed for the <i>matched element</i>, with the exception that the properties corresponding to the 'background' shorthand must be applied to the <a href=#webvtt-cue-background-box>WebVTT cue background box</a> rather than the <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>.</p> <p>The following properties apply to the '::cue' pseudo-element with no argument; other properties set on the pseudo-element must be ignored:</p> <ul class=brief><li>'color'</li> <li>'text-decoration'</li> <li>'text-outline'</li> <li>'text-shadow'</li> <li>the properties corresponding to the 'background' shorthand</li> <li>the properties corresponding to the 'outline' shorthand</li> <li>the properties corresponding to the 'font' shorthand, including 'line-height'</li> <!-- add more... --> <!-- definitely not: display, float, position, top, left, right, bottom, width, height, margin-top, margin-bottom, margin-left, margin-right, clip, clear, content, cursor, direction, max-height, min-height, max-width, min-width, orphans, overflow, page-break-*, text-align, unicode-bidi, widows, z-index --> </ul><p>The '<dfn id=pseudo-cue-selector title=pseudo-cue-selector>::cue(<var title="">selector</var>)</dfn>' pseudo-element with an argument must have an argument that consists of a group of selectors. It matches any <a href=#webvtt-internal-node-object>WebVTT Internal Node Object</a> constructed for the <i>matched element</i> that also matches the given group of selectors, with the nodes being treated as follows:</p> <ul><li><p>The <i>document tree</i> against which the selectors are matched is the tree of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> rooted at the <a href=#list-of-webvtt-node-objects>list of WebVTT Node Objects</a> for the cue.</li> <li><p><a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> are elements in the tree.</li> <li><a href=#webvtt-leaf-node-object title="WebVTT Leaf Node Object">WebVTT Leaf Node Objects</a> cannot be matched.</li> <li> <p>For the purposes of element type selectors, the names of <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> are as given by the following table, where objects having the concrete class given in a cell in the first column have the name given by the second column of the same row:</p> <table><thead><tr><th>Concrete class <th>Name <tbody><tr><td><a href=#webvtt-class-object title="WebVTT Class Object">WebVTT Class Objects</a> <td><code title="">c</code> <tr><td><a href=#webvtt-italic-object title="WebVTT Italic Object">WebVTT Italic Objects</a> <td><code title="">i</code> <tr><td><a href=#webvtt-bold-object title="WebVTT Bold Object">WebVTT Bold Objects</a> <td><code title="">b</code> <tr><td><a href=#webvtt-underline-object title="WebVTT Underline Object">WebVTT Underline Objects</a> <td><code title="">u</code> <tr><td><a href=#webvtt-ruby-object title="WebVTT Ruby Object">WebVTT Ruby Objects</a> <td><code title="">ruby</code> <tr><td><a href=#webvtt-ruby-text-object title="WebVTT Ruby Text Object">WebVTT Ruby Text Objects</a> <td><code title="">rt</code> <tr><td><a href=#webvtt-voice-object title="WebVTT Voice Object">WebVTT Voice Objects</a> <td><code title="">v</code> <tr><td>Other elements (specifically, <a href=#list-of-webvtt-node-objects title="List of WebVTT Node Objects">Lists of WebVTT Node Objects</a>) <td>No explicit name. </table></li> <li><p>For the purposes of element type and universal selectors, <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> are considered as being in the namespace expressed as the empty string.</li> <li><p>For the purposes of attribute selector matching, <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> have no attributes, except for <a href=#webvtt-voice-object title="WebVTT Voice Object">WebVTT Voice Objects</a>, which have a single attribute named "<code title="">voice</code>" whose value is the value of the <a href=#webvtt-voice-object>WebVTT Voice Object</a>.</li> <li><p>For the purposes of class selector matching, <a href=#webvtt-internal-node-object title="WebVTT Internal Node Object">WebVTT Internal Node Objects</a> have the classes described as the <a href="#webvtt-node-object's-applicable-classes">WebVTT Node Object's applicable classes</a>.</li> <!-- ok, this isn't especially well-defined, but the Selectors spec doesn't really give one much to go on here. --> <li><p>For the purposes of ID selector matching, <a href=#list-of-webvtt-node-objects title="List of WebVTT Node Objects">Lists of WebVTT Node Objects</a> have the ID given by the cue's <a href=#text-track-cue-identifier>text track cue identifier</a>, if any.</li> </ul><p>The following properties apply to the '::cue()' pseudo-element with an argument:</p> <ul class=brief><li>'color'</li> <li>'text-decoration'</li> <li>'text-outline'</li> <li>'text-shadow'</li> <li>the properties corresponding to the 'background' shorthand</li> <li>the properties corresponding to the 'outline' shorthand</li> <li>properties relating to the transition and animation features</li> <!-- add more... --> <!-- but definitely not anything that affects dimensions of boxes, e.g. the 'font' shorthand's properties --> </ul><!--v2 Would be nice to support transitions that are directional, e.g. changing text fill colour or shadow size of the start of a segment when the segment becomes "past", and having the change propagate towards the end of the segment so that it reaches the end of the segment when the next segment becomes "past". --><p>In addition, the following properties apply to the '::cue()' pseudo-element with an argument when the selector does not contain the <a href=#past-pseudo-class title=past-pseudo-class>':past'</a> and <a href=#future-pseudo-class title=future-pseudo-class>':future'</a> pseudo-classes:</p> <ul class=brief><li>the properties corresponding to the 'font' shorthand, including 'line-height'</li> <!-- add more... --> <!-- definitely not: display, float, position, top, left, right, bottom, width, height, margin-top, margin-bottom, margin-left, margin-right, clip, clear, content, cursor, direction, max-height, min-height, max-width, min-width, orphans, overflow, page-break-*, text-align, unicode-bidi, widows, z-index --> </ul><p>Properties that do not apply must be ignored.</p> <p>As a special exception, the properties corresponding to the 'background' shorthand, when they would have been applied to the <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, must instead be applied to the <a href=#webvtt-cue-background-box>WebVTT cue background box</a>.</p> <h6 id="the-':past'-and-':future'-pseudo-classes"><span class=secno>15.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</h6> <p>The <a href=#past-pseudo-class title=past-pseudo-class>':past'</a> and <a href=#future-pseudo-class title=future-pseudo-class>':future'</a> pseudo-classes sometimes match <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>. <a href=#refsSELECTORS>[SELECTORS]</a></p> <p>The <dfn id=past-pseudo-class title=past-pseudo-class>':past'</dfn> pseudo-class only matches <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> that are <i><a href=#in-the-past>in the past</a></i>.</p> <p>A <a href=#webvtt-node-object>WebVTT Node Object</a> <var title="">c</var> is <dfn id=in-the-past>in the past</dfn> if, in a pre-order, depth-first traversal of the <a href=#text-track-cue>text track cue</a>'s <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, there exists a <a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a> whose value is less than the <a href=#current-playback-position>current playback position</a> of the <a href=#media-element>media element</a> that is the <i>matched element</i>, entirely after the <a href=#webvtt-node-object>WebVTT Node Object</a> <var title="">c</var>.</p> <p>The <dfn id=future-pseudo-class title=future-pseudo-class>':future'</dfn> pseudo-class only matches <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> that are <i><a href=#in-the-future>in the future</a></i>.</p> <p>A <a href=#webvtt-node-object>WebVTT Node Object</a> <var title="">c</var> is <dfn id=in-the-future>in the future</dfn> if, in a pre-order, depth-first traversal of the <a href=#text-track-cue>text track cue</a>'s <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>, there exists a <a href=#webvtt-timestamp-object>WebVTT Timestamp Object</a> whose value is greater than the <a href=#current-playback-position>current playback position</a> of the <a href=#media-element>media element</a> that is the <i>matched element</i>, entirely before the <a href=#webvtt-node-object>WebVTT Node Object</a> <var title="">c</var>.</p> </div> <!--TTVTT--> <div class=impl> <h4 id=images-0><span class=secno>15.4.3 </span>Images</h4> <p>When an <code><a href=#the-img-element>img</a></code> element or an <code><a href=#the-input-element>input</a></code> element when its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state <a href=#represents>represents</a> an image, it is expected to be treated as a replaced element.</p> <p>When an <code><a href=#the-img-element>img</a></code> element or an <code><a href=#the-input-element>input</a></code> element when its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state does not <a href=#represents title=represents>represent</a> an image, but the element already has intrinsic dimensions (e.g. from the <a href=#dimension-attributes>dimension attributes</a> or CSS rules), and either the user agent has reason to believe that the image will become <i title=img-available>available</i><!--input-img-available also--> and be rendered in due course or the <code><a href=#document>Document</a></code> is in <a href=#quirks-mode>quirks mode</a>, the element is expected to be treated as a replaced element whose content is the text that the element represents, if any, optionally alongside an icon indicating that the image is being obtained. For <code><a href=#the-input-element>input</a></code> elements, the text is expected to appear button-like to indicate that the element is a <a href=#concept-button title=concept-button>button</a>.</p> <p>When an <code><a href=#the-img-element>img</a></code> element <a href=#represents>represents</a> some text and the user agent does not expect this to change, the element is expected to be treated as a non-replaced phrasing element whose content is the text, optionally with an icon indicating that an image is missing.</p> <p>When an <code><a href=#the-img-element>img</a></code> element <a href=#represents>represents</a> nothing and the user agent does not expect this to change, the element is expected to not be rendered at all.</p> <p>When an <code><a href=#the-img-element>img</a></code> element might be a key part of the content, but neither the image nor any kind of alternative text is available, and the user agent does not expect this to change, the element is expected to be treated as a non-replaced phrasing element whose content is an icon indicating that an image is missing.</p> <!-- there's also a should requirement for this case in the <img> section itself --> <p>When an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state does not <a href=#represents title=represents>represent</a> an image and the user agent does not expect this to change, the element is expected to be treated as a replaced element consisting of a button whose content is the element's alternative text. The intrinsic dimensions of the button are expected to be about one line in height and whatever width is necessary to render the text on one line.</p> <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 href=#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 most recent addition to the group.</p> <p class=note>In other words, the animation loop of an animated image is restarted each time another image with the same <a href=#absolute-url>absolute URL</a> and image data begins to animate, e.g. after being inserted into the document.</p> <hr><p>The following CSS rules are expected to apply when the <code><a href=#document>Document</a></code> is in <a href=#quirks-mode>quirks mode</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); img[align=left i] { margin-right: 3px; } img[align=right i] { margin-left: 3px; }</pre> </div> <div class=impl> <h4 id=attributes-for-embedded-content-and-images><span class=secno>15.4.4 </span>Attributes for embedded content and images</h4> <p>The following CSS rules are expected to apply as <a href=#presentational-hints>presentational hints</a>:</p> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); iframe[frameborder=0], iframe[frameborder=no i] { border: none; } applet[align=left i], embed[align=left i], iframe[align=left i], img[align=left i], input[type=image i][align=left i], object[align=left i] { float: left; } applet[align=right i], embed[align=right i], iframe[align=right i], img[align=right i], input[type=image i][align=right i], object[align=right i] { float: right; } applet[align=top i], embed[align=top i], iframe[align=top i], img[align=top i], input[type=image i][align=top i], object[align=top i] { vertical-align: top; } applet[align=baseline i], embed[align=baseline i], iframe[align=baseline i], img[align=baseline i], input[type=image i][align=baseline i], object[align=baseline i] { vertical-align: baseline; } applet[align=texttop i], embed[align=texttop i], iframe[align=texttop i], img[align=texttop i], input[type=image i][align=texttop i], object[align=texttop i] { vertical-align: text-top; } applet[align=absmiddle i], embed[align=absmiddle i], iframe[align=absmiddle i], img[align=absmiddle i], input[type=image i][align=absmiddle i], object[align=absmiddle i], applet[align=abscenter i], embed[align=abscenter i], iframe[align=abscenter i], img[align=abscenter i], input[type=image i][align=abscenter i], object[align=abscenter i] { vertical-align: middle; } applet[align=bottom i], embed[align=bottom i], iframe[align=bottom i], img[align=bottom i], input[type=image i][align=bottom i], object[align=bottom i] { vertical-align: bottom; }</pre> <p>When an <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <code><a href=#the-object-element>object</a></code> element, or an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, has an <code title=attr-dim-align>align</code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">center</code>" or the string "<code title="">middle</code>", the user agent is expected to act as if the element's 'vertical-align' property was set to a value that aligns the vertical middle of the element with the parent element's baseline.</p> <p>The <code title=attr-dim-hspace>hspace</code> attribute of <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <code><a href=#the-object-element>object</a></code> elements, and <code><a href=#the-input-element>input</a></code> elements with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-left' and 'margin-right' on the element.</p> <p>The <code title=attr-dim-vspace>vspace</code> attribute of <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, or <code><a href=#the-object-element>object</a></code> elements, and <code><a href=#the-input-element>input</a></code> elements with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-top' and 'margin-bottom' on the element.</p> <p>When an <code><a href=#the-img-element>img</a></code> element, <code><a href=#the-object-element>object</a></code> element, or <code><a href=#the-input-element>input</a></code> element with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state is contained within a <a href=#hyperlink>hyperlink</a> and has a <code title=attr-dim-border>border</code> attribute whose value, when parsed using the <a href=#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>presentational hints</a>: four setting the parsed value as a pixel length for the element's 'border-top-width', 'border-right-width', 'border-bottom-width', and 'border-left-width' properties, and four setting the element's 'border-top-style', 'border-right-style', 'border-bottom-style', and 'border-left-style' properties to the value 'solid'.</p> <p id=dimRendering>The <code title=attr-dim-width><a href=#attr-dim-width>width</a></code> and <code title=attr-dim-height><a href=#attr-dim-height>height</a></code> attributes on <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-object-element>object</a></code> or <code><a href=#the-video-element>video</a></code> elements, and <code><a href=#the-input-element>input</a></code> elements with a <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in the <a href=#image-button-state title=attr-input-type-image>Image Button</a> state, <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension properties</a> 'width' and 'height' on the element respectively.</p> </div> <div class=impl> <h4 id=image-maps-0><span class=secno>15.4.5 </span>Image maps</h4> <p>Shapes on an <a href=#image-map>image map</a> are expected to act, for the purpose of the CSS cascade, as elements independent of the original <code><a href=#the-area-element>area</a></code> element that happen to match the same style rules but inherit from the <code><a href=#the-img-element>img</a></code> or <code><a href=#the-object-element>object</a></code> element.</p> <p>For the purposes of the rendering, only the 'cursor' property is expected to have any effect on the shape.</p> <p class=example>Thus, for example, if an <code><a href=#the-area-element>area</a></code> element has a <code title=attr-style><a href=#the-style-attribute>style</a></code> attribute that sets the 'cursor' 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><a href=#the-area-element>area</a></code> element had a CSS rule that set its 'cursor' property to 'inherit' (or if no rule setting the 'cursor' property matched the element at all), the shape's cursor would be inherited from the <code><a href=#the-img-element>img</a></code> or <code><a href=#the-object-element>object</a></code> element of the <a href=#image-map>image map</a>, not from the parent of the <code><a href=#the-area-element>area</a></code> element.</p> </div> <div class=impl> <h4 id=toolbars-0><span class=secno>15.4.6 </span>Toolbars</h4> <p>When a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is expected to be treated as a replaced element with a height about two lines high and a width derived from the contents of the element.</p> <p>The element is expected to have, by default, the appearance of a toolbar on the user agent's platform. It is expected to contain the menu that is <a href=#building-menus-and-toolbars title="building menus and toolbars">built</a> from the element.</p> </div> <div class=impl> <h3 id=bindings><span class=secno>15.5 </span>Bindings</h3> <h4 id=introduction-18><span class=secno>15.5.1 </span>Introduction</h4> <p>A number of elements have their rendering defined in terms of the 'binding' property. <a href=#refsBECSS>[BECSS]</a></p> <p>The CSS snippets below set the 'binding' property to a user-agent-defined value, represented below by keywords like <code title=""><i title="">button</i></code>. The rules then described for these bindings are only expected to apply if the element's 'binding' property has not been overridden (e.g. by the author) to have another value.</p> <p>Exactly how the bindings are implemented is not specified by this specification. User agents are encouraged to make their bindings set the 'appearance' 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. <a href=#refsCSSUI>[CSSUI]</a></p> </div> <div class=impl> <h4 id=the-button-element-0><span class=secno>15.5.2 </span>The <code><a href=#the-button-element>button</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); button { binding: <i title="">button</i>; }</pre> <p>When the <i title="">button</i> binding applies to a <code><a href=#the-button-element>button</a></code> element, the element is expected to render as an 'inline-block' box rendered as a button whose contents are the contents of the element.</p> </div> <div class=impl> <h4 id=the-details-element-0><span class=secno>15.5.3 </span>The <code><a href=#the-details-element>details</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); details { binding: <i title="">details</i>; }</pre> <p>When the <i title="">details</i> binding applies to a <code><a href=#the-details-element>details</a></code> element, the element is expected to render as a 'block' box with its 'padding-left' property set to '40px' for left-to-right elements (<a href=#ltr-specific>LTR-specific</a>) and with its 'padding-right' property set to '40px' for right-to-left elements. The element's shadow tree is expected to take the element's first child <code><a href=#the-summary-element>summary</a></code> element, if any, and place it in a first 'block' box container, and then take the element's remaining descendants, if any, and place them in a second 'block' box container.</p> <p>The first container is expected to contain at least one line box, and that line box is expected to contain a disclosure widget (typically a triangle), horizontally positioned within the left padding of the <code><a href=#the-details-element>details</a></code> element. That widget is expected to allow the user to request that the details be shown or hidden.</p> <p>The second container is expected to have its 'overflow' property set to 'hidden'. When the <code><a href=#the-details-element>details</a></code> element does not have an <code title=attr-details-open><a href=#attr-details-open>open</a></code> attribute, this second container is expected to be removed from the rendering.</p> <!-- http://mail.gnome.org/archives/usability/2006-June/msg00015.html --> </div> <div class=impl> <h4 id=the-input-element-as-a-text-entry-widget><span class=secno>15.5.4 </span>The <code><a href=#the-input-element>input</a></code> element as a text entry widget</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input { binding: <i title="">input-textfield</i>; } input[type=password i] { binding: <i title="">input-password</i>; } /* later rules override this for other values of type="" */</pre> <p>When the <i title="">input-textfield</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#text-state-and-search-state title=attr-input-type-text>Text</a>, <a href=#text-state-and-search-state title=attr-input-type-search>Search</a>, <a href=#telephone-state title=attr-input-type-tel>Telephone</a>, <a href=#url-state title=attr-input-type-url>URL</a>, or <a href=#e-mail-state title=attr-input-type-email>E-mail</a> state, the element is expected to render as an 'inline-block' box rendered as a text field.</p> <p>When the <i title="">input-password</i> binding applies, to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#password-state title=attr-input-type-password>Password</a> state, the element is expected to render as an 'inline-block' box rendered as a text field whose contents are obscured.</p> <p>If an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in one of the above states has a <code title=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>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 title="presentational hints">presentational hint</a> for the 'width' property on the element, with the value obtained from applying the <a href=#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><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in one of the above states does <em>not</em> have a <code title=attr-input-size><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 'width' property on the element to the value obtained from applying the <a href=#converting-a-character-width-to-pixels>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 title="">(<var title="">size</var>-1)×<var title="">avg</var> + <var title="">max</var></span>, where <var title="">size</var> is the character width to convert, <var title="">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 title="">max</var> is the maximum character width of that same font, also in pixels. (The element's 'letter-spacing' property does not affect the result.)</p> </div> <div class=impl> <h4 id=the-input-element-as-domain-specific-widgets><span class=secno>15.5.5 </span>The <code><a href=#the-input-element>input</a></code> element as domain-specific widgets</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=datetime i] { binding: <i title="">input-datetime</i>; } input[type=date i] { binding: <i title="">input-date</i>; } input[type=month i] { binding: <i title="">input-month</i>; } input[type=week i] { binding: <i title="">input-week</i>; } input[type=time i] { binding: <i title="">input-time</i>; } input[type=datetime-local i] { binding: <i title="">input-datetime-local</i>; } input[type=number i] { binding: <i title="">input-number</i>; }</pre> <p>When the <i title="">input-datetime</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#date-and-time-state title=attr-input-type-datetime>Date and Time</a> state, the element is expected to render as an 'inline-block' box depicting a Date and Time control.</p> <p>When the <i title="">input-date</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#date-state title=attr-input-type-date>Date</a> state, the element is expected to render as an 'inline-block' box depicting a Date control.</p> <p>When the <i title="">input-month</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#month-state title=attr-input-type-month>Month</a> state, the element is expected to render as an 'inline-block' box depicting a Month control.</p> <p>When the <i title="">input-week</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#week-state title=attr-input-type-week>Week</a> state, the element is expected to render as an 'inline-block' box depicting a Week control.</p> <p>When the <i title="">input-time</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#time-state title=attr-input-type-time>Time</a> state, the element is expected to render as an 'inline-block' box depicting a Time control.</p> <p>When the <i title="">input-datetime-local</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#local-date-and-time-state title=attr-input-type-datetime-local>Local Date and Time</a> state, the element is expected to render as an 'inline-block' box depicting a Local Date and Time control.</p> <p>When the <i title="">input-number</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#number-state title=attr-input-type-number>Number</a> state, the element is expected to render as an 'inline-block' 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> </div> <div class=impl> <h4 id=the-input-element-as-a-range-control><span class=secno>15.5.6 </span>The <code><a href=#the-input-element>input</a></code> element as a range control</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=range i] { binding: <i title="">input-range</i>; }</pre> <p>When the <i title="">input-range</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#range-state title=attr-input-type-range>Range</a> state, the element is expected to render as an 'inline-block' 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 'direction' property on this element has a computed value 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 title=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> </div> <div class=impl> <h4 id=the-input-element-as-a-color-well><span class=secno>15.5.7 </span>The <code><a href=#the-input-element>input</a></code> element as a color well</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=color i] { binding: <i title="">input-color</i>; }</pre> <p>When the <i title="">input-color</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#color-state title=attr-input-type-color>Color</a> state, the element is expected to render as an 'inline-block' 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 title=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> </div> <div class=impl> <h4 id=the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>15.5.8 </span>The <code><a href=#the-input-element>input</a></code> element as a checkbox and radio button widgets</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=checkbox i] { binding: <i title="">input-checkbox</i>; } input[type=radio i] { binding: <i title="">input-radio</i>; }</pre> <p>When the <i title="">input-checkbox</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#checkbox-state title=attr-input-type-checkbox>Checkbox</a> state, the element is expected to render as an 'inline-block' box containing a single checkbox control, with no label.</p> <p>When the <i title="">input-radio</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#radio-button-state title=attr-input-type-radio>Radio Button</a> state, the element is expected to render as an 'inline-block' box containing a single radio button control, with no label.</p> </div> <div class=impl> <h4 id=the-input-element-as-a-file-upload-control><span class=secno>15.5.9 </span>The <code><a href=#the-input-element>input</a></code> element as a file upload control</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=file i] { binding: <i title="">input-file</i>; }</pre> <p>When the <i title="">input-file</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#file-upload-state title=attr-input-type-file>File Upload</a> state, the element is expected to render as an 'inline-block' box containing a span of text giving the filename(s) of the <a href=#concept-input-type-file-selected title=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> </div> <div class=impl> <h4 id=the-input-element-as-a-button><span class=secno>15.5.10 </span>The <code><a href=#the-input-element>input</a></code> element as a button</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); input[type=submit i], input[type=reset i], input[type=button i] { binding: <i title="">input-button</i>; }</pre> <p>When the <i title="">input-button</i> binding applies to an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#submit-button-state title=attr-input-type-submit>Submit Button</a>, <a href=#reset-button-state title=attr-input-type-reset>Reset Button</a>, or <a href=#button-state title=attr-input-type-button>Button</a> state, the element is expected to render as an 'inline-block' box rendered as a button, about one line high, containing the contents of the element's <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if any, or text derived from the element's <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute in a user-agent-defined (and probably locale-specific) fashion, if not.</p> </div> <div class=impl> <h4 id=the-marquee-element-0><span class=secno>15.5.11 </span>The <code><a href=#the-marquee-element>marquee</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); marquee { binding: <i title="">marquee</i>; }</pre> <p>When the <i title="">marquee</i> binding applies to a <code><a href=#the-marquee-element>marquee</a></code> element, while the element is <a href=#concept-marquee-on title=concept-marquee-on>turned on</a>, the element is expected to render in an animated fashion according to its attributes as follows:</p> <dl><dt>If the element's <code title=attr-marquee-behavior><a href=#attr-marquee-behavior>behavior</a></code> attribute is in the <a href=#attr-marquee-behavior-scroll title=attr-marquee-behavior-scroll>scroll</a> state</dt> <dd> <p>Slide the contents of the element in the direction described by the <code title=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><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 title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute is <a href=#attr-marquee-direction-left title=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><a href=#the-marquee-element>marquee</a></code>'s content area, 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><a href=#the-marquee-element>marquee</a></code>'s content area.</p> <p>Once the animation has ended, the user agent is expected to <a href=#increment-the-marquee-current-loop-index>increment the marquee current loop index</a>. If the element is still <a href=#concept-marquee-on title=concept-marquee-on>turned on</a> after this, then the user agent is expected to restart the animation.</p> </dd> <dt>If the element's <code title=attr-marquee-behavior><a href=#attr-marquee-behavior>behavior</a></code> attribute is in the <a href=#attr-marquee-behavior-slide title=attr-marquee-behavior-slide>slide</a> state</dt> <dd> <p>Slide the contents of the element in the direction described by the <code title=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><a href=#the-marquee-element>marquee</a></code>, and ends off the end side of the <code><a href=#the-marquee-element>marquee</a></code>.</p> <p class=example>For example, if the <code title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute is <a href=#attr-marquee-direction-left title=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><a href=#the-marquee-element>marquee</a></code>'s content area, 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><a href=#the-marquee-element>marquee</a></code>'s content area.</p> <p>Once the animation has ended, the user agent is expected to <a href=#increment-the-marquee-current-loop-index>increment the marquee current loop index</a>. If the element is still <a href=#concept-marquee-on title=concept-marquee-on>turned on</a> after this, then the user agent is expected to restart the animation.</p> </dd> <dt>If the element's <code title=attr-marquee-behavior><a href=#attr-marquee-behavior>behavior</a></code> attribute is in the <a href=#attr-marquee-behavior-alternate title=attr-marquee-behavior-alternate>alternate</a> state</dt> <dd> <p>When the <a href=#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 title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute as defined below, such that it begins flush with the start side of the <code><a href=#the-marquee-element>marquee</a></code>, and ends flush with the end side of the <code><a href=#the-marquee-element>marquee</a></code>.</p> <p>When the <a href=#marquee-current-loop-index>marquee current loop index</a> is odd, slide the contents of the element in the opposite direction than that described by the <code title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute as defined below, such that it begins flush with the end side of the <code><a href=#the-marquee-element>marquee</a></code>, and ends flush with the start side of the <code><a href=#the-marquee-element>marquee</a></code>.</p> <p class=example>For example, if the <code title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute is <a href=#attr-marquee-direction-left title=attr-marquee-direction-left>left</a> (the default), then the contents would with their right edge flush with the right inner edge of the <code><a href=#the-marquee-element>marquee</a></code>'s content area, 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><a href=#the-marquee-element>marquee</a></code>'s content area.</p> <p>Once the animation has ended, the user agent is expected to <a href=#increment-the-marquee-current-loop-index>increment the marquee current loop index</a>. If the element is still <a href=#concept-marquee-on title=concept-marquee-on>turned on</a> after this, then the user agent is expected to continue the animation.</p> </dd> </dl><p>The <code title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute has the meanings described in the following table:</p> <table><thead><tr><th><code title=attr-marquee-direction><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 title=attr-marquee-direction-left>left</a> <td>← Right to left <td>Right <td>Left <td>→ Left to Right <tr><td><a href=#attr-marquee-direction-right title=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 title=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 title=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>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>marquee scroll distance</a> with each frame.</p> <p>When a <code><a href=#the-marquee-element>marquee</a></code> element has a <code title=attr-marquee-bgcolor>bgcolor</code> attribute set, the value is expected to be parsed using the <a href=#rules-for-parsing-a-legacy-color-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 title="presentational hints">presentational hint</a> setting the element's 'background-color' property to the resulting color.</p> <p>The <code title=attr-marquee-width>width</code> and <code title=attr-marquee-height>height</code> attributes on a <code><a href=#the-marquee-element>marquee</a></code> element <a href=#maps-to-the-dimension-property title="maps to the dimension property">map to the dimension properties</a> 'width' and 'height' on the element respectively.</p> <p>The intrinsic height of a <code><a href=#the-marquee-element>marquee</a></code> element with its <code title=attr-marquee-direction><a href=#attr-marquee-direction>direction</a></code> attribute in the <a href=#attr-marquee-direction-up title=attr-marquee-direction-up>up</a> or <a href=#attr-marquee-direction-down title=attr-marquee-direction-down>down</a> states is 200 CSS pixels.</p> <p>The <code title=attr-marquee-vspace>vspace</code> attribute of a <code><a href=#the-marquee-element>marquee</a></code> element <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-top' and 'margin-bottom' on the element. The <code title=attr-marquee-hspace>hspace</code> attribute of a <code><a href=#the-marquee-element>marquee</a></code> element <a href=#maps-to-the-dimension-property title="maps to the dimension property">maps to the dimension properties</a> 'margin-left' and 'margin-right' on the element.</p> <p>The 'overflow' property on the <code><a href=#the-marquee-element>marquee</a></code> element is expected to be ignored; overflow is expected to always be hidden.</p> </div> <div class=impl> <h4 id=the-meter-element-0><span class=secno>15.5.12 </span>The <code><a href=#the-meter-element>meter</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); meter { binding: <i title="">meter</i>; }</pre> <p>When the <i title="">meter</i> binding applies to a <code><a href=#the-meter-element>meter</a></code> element, the element is expected to render as an 'inline-block' box with a 'height' of '1em' and a 'width' of '5em', a 'vertical-align' 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 'direction' property on this element has a computed value 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><a href=#the-meter-element>meter</a></code> element.</p> </div> <div class=impl> <h4 id=the-progress-element-0><span class=secno>15.5.13 </span>The <code><a href=#the-progress-element>progress</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); progress { binding: <i title="">progress</i>; }</pre> <p>When the <i title="">progress</i> binding applies to a <code><a href=#the-progress-element>progress</a></code> element, the element is expected to render as an 'inline-block' box with a 'height' of '1em' and a 'width' of '10em', and a 'vertical-align' of '-0.2em'.</p> <!-- http://software.hixie.ch/utilities/js/canvas/?c.clearRect(0%2C%200%2C%20640%2C%20480)%3B%0Ac.save()%3B%0Atry%20{%0A%20%20c.fillStyle%20%3D%20'black'%3B%0A%20%20c.font%20%3D%20'8px%20sans-serif'%3B%0A%20%20c.fillText('Wide'%2C%2043%2C105)%3B%0A%20%20c.fillText('Tall'%2C%20100%2C105)%3B%0A%20%20c.fillText('Square'%2C%20128%2C105)%3B%0A%20%20c.font%20%3D%20'700%2010px%20sans-serif'%3B%0A%20%20c.fillText('Progress%20Bars'%2C%2013%2C30)%3B%0A%20%20c.font%20%3D%20'100%2010px%20sans-serif'%3B%0A%20%20c.fillText('(80%25)'%2C%2037%2C45)%3B%0A%20%20c.beginPath()%3B%0A%20%20var%20g%20%3D%20c.createLinearGradient(10%2C0%2C80%2C0)%3B%0A%20%20g.addColorStop(0%2C%20'%2300FF00')%3B%0A%20%20g.addColorStop(0.8%2C%20'%2300FF00')%3B%0A%20%20g.addColorStop(0.9%2C%20'%23FFFF00')%3B%0A%20%20c.fillStyle%20%3D%20g%3B%0A%20%20c.rect(10%2C80%2C80%2C15)%3B%0A%20%20c.fill()%3B%0A%20%20c.strokeStyle%20%3D%20'black'%3B%0A%20%20c.stroke()%3B%0A%20%20c.beginPath()%3B%0A%20%20var%20g%20%3D%20c.createLinearGradient(0%2C80%2C0%2C20)%3B%0A%20%20g.addColorStop(0%2C%20'%2300FF00')%3B%0A%20%20g.addColorStop(0.75%2C%20'%2300FF00')%3B%0A%20%20g.addColorStop(0.85%2C%20'%23FFFF00')%3B%0A%20%20c.fillStyle%20%3D%20g%3B%0A%20%20c.rect(100%2C15%2C15%2C80)%3B%0A%20%20c.fill()%3B%0A%20%20c.strokeStyle%20%3D%20'black'%3B%0A%20%20c.stroke()%3B%0A%0A%20%20c.beginPath()%3B%0A%20%20c.fillStyle%20%3D%20'yellow'%3B%0A%20%20c.arc(140%2C80%2C15%2C0%2C2*Math.PI%2C%20true)%3B%0A%20%20c.fill()%3B%0A%20%20c.beginPath()%3B%0A%20%20c.fillStyle%20%3D%20'lime'%3B%0A%20%20c.moveTo(140%2C80)%3B%0A%20%20c.arc(140%2C80%2C15%2C-Math.PI%2F2%2C1.2*Math.PI%2C%20false)%3B%0A%20%20c.fill()%3B%0A%20%20c.beginPath()%3B%0A%20%20c.arc(140%2C80%2C15%2C0%2C2*Math.PI%2C%20true)%3B%0A%20%20c.strokeStyle%20%3D%20'black'%3B%0A%20%20c.stroke()%3B%0A}%20finally%20{%0A%20%20c.restore()%3B%0A}%0A --> <p> <img alt="" class=extra src=http://images.whatwg.org/sample-progress.png> 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 'direction' property on this element has a computed value 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 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 an asynchronous 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><a href=#the-progress-element>progress</a></code> element.</p> </div> <div class=impl> <h4 id=the-select-element-0><span class=secno>15.5.14 </span>The <code><a href=#the-select-element>select</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); select { binding: <i title="">select</i>; }</pre> <p>When the <i title="">select</i> binding applies to a <code><a href=#the-select-element>select</a></code> element whose <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is present, the element is expected to render as a multi-select list box.</p> <p>When the <i title="">select</i> binding applies to a <code><a href=#the-select-element>select</a></code> element whose <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element's <a href=#concept-select-size title=concept-select-size>display size</a> is greater than 1, the element 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 'inline-block' box whose 'height' is the height necessary to contain as many rows for items as given by the element's <a href=#concept-select-size title=concept-select-size>display size</a>, or four rows if the attribute is absent, and whose 'width' is the <a href="#width-of-the-select's-labels">width of the <code>select</code>'s labels</a> plus the width of a scrollbar.</p> <p>When the <i title="">select</i> binding applies to a <code><a href=#the-select-element>select</a></code> element whose <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element's <a href=#concept-select-size title=concept-select-size>display size</a> is 1, the element is expected to render as a one-line drop down box whose width is the <a href="#width-of-the-select's-labels">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 title=concept-select-option-list>list of options</a>, with the element's <code><a href=#the-optgroup-element>optgroup</a></code> element children providing headers for groups of options where applicable.</p> <p>An <code><a href=#the-optgroup-element>optgroup</a></code> element is expected to be rendered by displaying the element's <code title=attr-optgroup-label><a href=#attr-optgroup-label>label</a></code> attribute.</p> <p>An <code><a href=#the-option-element>option</a></code> element is expected to be rendered by displaying the element's <a href=#concept-option-label title=concept-option-label>label</a>, indented under its <code><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><a href=#the-optgroup-element>optgroup</a></code>, and the width necessary to render the widest <code><a href=#the-option-element>option</a></code> element in the element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> (including its indent, if any).</p> <p>If a <code><a href=#the-select-element>select</a></code> element contains a <a href=#placeholder-label-option>placeholder label option</a>, the user agent is expected to render that <code><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>placeholder label option</a> from being explicitly selected by the user. When the <a href=#placeholder-label-option>placeholder label option</a>'s <a href=#concept-option-selectedness title=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><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> </div> <div class=impl> <h4 id=the-textarea-element-0><span class=secno>15.5.15 </span>The <code><a href=#the-textarea-element>textarea</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); textarea { binding: <i title="">textarea</i>; white-space: pre-wrap; }</pre> <p>When the <i title="">textarea</i> binding applies to a <code><a href=#the-textarea-element>textarea</a></code> element, the element is expected to render as an 'inline-block' box rendered as a multiline text field.</p> <p>If the element has a <code title=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>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 title="presentational hints">presentational hint</a> for the 'width' property on the element, with the value being the <a href=#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 'width' property on the element to the <a href=#textarea-effective-width>textarea effective width</a>.</p> <p>The <dfn id=textarea-effective-width>textarea effective width</dfn> of a <code><a href=#the-textarea-element>textarea</a></code> element is <span><var title="">size</var>×<var title="">avg</var> + <var title="">sbw</var></span>, where <var title="">size</var> is the element's <a href=#attr-textarea-cols-value title=attr-textarea-cols-value>character width</a>, <var title="">avg</var> is the average character width of the primary font of the element, in CSS pixels, and <var title="">sbw</var> is the width of a scroll bar, in CSS pixels. (The element's 'letter-spacing' property does not affect the result.)</p> <p>If the element has a <code title=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>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 title="presentational hints">presentational hint</a> for the 'height' property on the element, with the value being the <a href=#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 'height' property on the element to the <a href=#textarea-effective-height>textarea effective height</a>.</p> <p>The <dfn id=textarea-effective-height>textarea effective height</dfn> of a <code><a href=#the-textarea-element>textarea</a></code> element is the height in CSS pixels of the number of lines specified the element's <a href=#attr-textarea-rows-value title=attr-textarea-rows-value>character height</a>, plus the height of a scrollbar in CSS pixels.</p> <p>User agents are expected to apply the 'white-space' CSS property to <code><a href=#the-textarea-element>textarea</a></code> elements. For historical reasons, if the element has a <code title=attr-textarea-wrap><a href=#attr-textarea-wrap>wrap</a></code> attribute whose value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title=attr-textarea-wrap-off>off</code>", then the user agent is expected to treat the attribute as a <a href=#presentational-hints title="presentational hints">presentational hint</a> setting the element's 'white-space' property to 'pre'.</p> </div> <div class=impl> <h4 id=the-keygen-element-0><span class=secno>15.5.16 </span>The <code><a href=#the-keygen-element>keygen</a></code> element</h4> <pre class=css>@namespace url(http://www.w3.org/1999/xhtml); keygen { binding: <i title="">keygen</i>; }</pre> <p>When the <i title="">keygen</i> binding applies to a <code><a href=#the-keygen-element>keygen</a></code> element, the element is expected to render as an 'inline-block' box containing a user interface to configure the key pair to be generated.</p> </div> <div class=impl> <h3 id=frames-and-framesets><span class=secno>15.6 </span>Frames and framesets</h3> <p>When an <code><a href=#the-html-element>html</a></code> element's <a href=#the-body-element-0 title="the body element">body element</a> is actually a <code><a href=#frameset>frameset</a></code> element, the user agent is expected to render the <code><a href=#frameset>frameset</a></code> element as described below across the surface of the viewport, instead of applying the usual CSS rendering rules.</p> <p>When rendering a <code><a href=#frameset>frameset</a></code> on a surface, the user agent is expected to use the following layout algorithm:</p> <ol><li> <p>The <var title="">cols</var> and <var title="">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>rules for parsing a list of dimensions</a> to parse the value of the element's <code title=attr-frameset-cols>cols</code> attribute, if there is one. Let <var title="">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>rules for parsing a list of dimensions</a> to parse the value of the element's <code title=attr-frameset-rows>rows</code> attribute, if there is one. Let <var title="">rows</var> be the result, or an empty list if there is no such attribute.</p> </li> <li> <p>For any of the entries in <var title="">cols</var> or <var title="">rows</var> that have the number zero and the unit <i>relative</i>, change the entry's number to one.</p> </li> <li> <p>If <var title="">cols</var> has no entries, then add a single entry consisting of the value 1 and the unit <i>relative</i> to <var title="">cols</var>.</p> <p>If <var title="">rows</var> has no entries, then add a single entry consisting of the value 1 and the unit <i>relative</i> to <var title="">rows</var>.</p> </li> <li> <p>Invoke the algorithm defined below to <a href=#convert-a-list-of-dimensions-to-a-list-of-pixel-values>convert a list of dimensions to a list of pixel values</a> using <var title="">cols</var> as the input list, and the width of the surface that the <code><a href=#frameset>frameset</a></code> is being rendered into, in CSS pixels, as the input dimension. Let <var title="">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>convert a list of dimensions to a list of pixel values</a> using <var title="">rows</var> as the input list, and the height of the surface that the <code><a href=#frameset>frameset</a></code> is being rendered into, in CSS pixels, as the input dimension. Let <var title="">sized rows</var> be the resulting list.</p> </li> <li> <p>Split the surface into a grid of <span title=""><var title="">w</var>×<var title="">h</var></span> rectangles, where <var title="">w</var> is the number of entries in <var title="">sized cols</var> and <var title="">h</var> is the number of entries in <var title="">sized rows</var>.</p> <p>Size the columns so that each column in the grid is as many CSS pixels wide as the corresponding entry in the <var title="">sized cols</var> list.</p> <p>Size the rows so that each row in the grid is as many CSS pixels high as the corresponding entry in the <var title="">sized rows</var> list.</p> </li> <li> <p>Let <var title="">children</var> be the list of <code><a href=#frame>frame</a></code> and <code><a href=#frameset>frameset</a></code> elements that are children of the <code><a href=#frameset>frameset</a></code> element for which the algorithm was invoked.</p> </li> <li> <p>For each row of the grid of rectangles created in the previous step, from top to bottom, run these substeps:</p> <ol><li> <p>For each rectangle in the row, from left to right, run these substeps:</p> <ol><li> <p>If there are any elements left in <var title="">children</var>, take the first element in the list, and assign it to the rectangle.</p> <p>If this is a <code><a href=#frameset>frameset</a></code> element, then recurse the entire <code><a href=#frameset>frameset</a></code> layout algorithm for that <code><a href=#frameset>frameset</a></code> element, with the rectangle as the surface.</p> <p>Otherwise, it is a <code><a href=#frame>frame</a></code> element; create a <a href=#nested-browsing-context>nested browsing context</a> sized to fit the rectangle.</p> </li> <li> <p>If there are any elements left in <var title="">children</var>, remove the first element from <var title="">children</var>.</p> </ol></li> </ol></li> <li> <p>If the <code><a href=#frameset>frameset</a></code> element <a href=#has-a-border>has a border</a>, draw an outer set of borders around the rectangles, using the element's <a href=#frame-border-color>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>has a border</a>, draw an inner set of borders around that rectangle, using the element's <a href=#frame-border-color>frame border color</a>.</p> <p>For each (visible) border that does not abut a rectangle that is assigned a <code><a href=#frame>frame</a></code> element with a <code title=attr-frame-noresize>noresize</code> attribute (including rectangles in further nested <code><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><a href=#frameset>frameset</a></code> grids.</p> <p>A <code><a href=#frameset>frameset</a></code> or <code><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 title=attr-frames-frameborder>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> <li><p>Otherwise, if the element has a <code title=attr-frames-frameborder>frameborder</code> attribute, return false.</li> <li><p>Otherwise, if the element has a parent element that is a <code><a href=#frameset>frameset</a></code> element, then return true if <em>that</em> element <a href=#has-a-border>has a border</a>, and false if it does not.</li> <li><p>Otherwise, return true.</li> </ol><p>The <dfn id=frame-border-color>frame border color</dfn> of a <code><a href=#frameset>frameset</a></code> or <code><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 title=attr-frames-bordercolor>bordercolor</code> attribute, and applying the <a href=#rules-for-parsing-a-legacy-color-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> <li><p>Otherwise, if the element has a parent element that is a <code><a href=#frameset>frameset</a></code> element, then the <a href=#frame-border-color>frame border color</a> of that element.</p> <li><p>Otherwise, return gray.</li> </ol></li> </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 title="">input list</var> be the list of numbers and units passed to the algorithm.</p> <p>Let <var title="">output list</var> be a list of numbers the same length as <var title="">input list</var>, all zero.</p> <p>Entries in <var title="">output list</var> correspond to the entries in <var title="">input list</var> that have the same position.</p> </li> <li><p>Let <var title="">input dimension</var> be the size passed to the algorithm.</p> <li> <p>Let <var title="">count percentage</var> be the number of entries in <var title="">input list</var> whose unit is <i>percentage</i>.</p> <p>Let <var title="">total percentage</var> be the sum of all the numbers in <var title="">input list</var> whose unit is <i>percentage</i>.</p> <p>Let <var title="">count relative</var> be the number of entries in <var title="">input list</var> whose unit is <i>relative</i>.</p> <p>Let <var title="">total relative</var> be the sum of all the numbers in <var title="">input list</var> whose unit is <i>relative</i>.</p> <p>Let <var title="">count absolute</var> be the number of entries in <var title="">input list</var> whose unit is <i>absolute</i>.</p> <p>Let <var title="">total absolute</var> be the sum of all the numbers in <var title="">input list</var> whose unit is <i>absolute</i>.</p> <p>Let <var title="">remaining space</var> be the value of <var title="">input dimension</var>.</p> </li> <li> <p>If <var title="">total absolute</var> is greater than <var title="">remaining space</var>, then for each entry in <var title="">input list</var> whose unit is <i>absolute</i>, set the corresponding value in <var title="">output list</var> to the number of the entry in <var title="">input list</var> multiplied by <var title="">remaining space</var> and divided by <var title="">total absolute</var>. Then, set <var title="">remaining space</var> to zero.</p> <p>Otherwise, for each entry in <var title="">input list</var> whose unit is <i>absolute</i>, set the corresponding value in <var title="">output list</var> to the number of the entry in <var title="">input list</var>. Then, decrement <var title="">remaining space</var> by <var title="">total absolute</var>.</p> </li> <li> <p>If <var title="">total percentage</var> multiplied by the <var title="">input dimension</var> and divided by 100 is greater than <var title="">remaining space</var>, then for each entry in <var title="">input list</var> whose unit is <i>percentage</i>, set the corresponding value in <var title="">output list</var> to the number of the entry in <var title="">input list</var> multiplied by <var title="">remaining space</var> and divided by <var title="">total percentage</var>. Then, set <var title="">remaining space</var> to zero.</p> <p>Otherwise, for each entry in <var title="">input list</var> whose unit is <i>percentage</i>, set the corresponding value in <var title="">output list</var> to the number of the entry in <var title="">input list</var> multiplied by the <var title="">input dimension</var> and divided by 100. Then, decrement <var title="">remaining space</var> by <var title="">total percentage</var> multiplied by the <var title="">input dimension</var> and divided by 100.</p> </li> <li> <p>For each entry in <var title="">input list</var> whose unit is <i>relative</i>, set the corresponding value in <var title="">output list</var> to the number of the entry in <var title="">input list</var> multiplied by <var title="">remaining space</var> and divided by <var title="">total relative</var>.</p> </li> <li><p>Return <var title="">output list</var>.</li> </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> </div> <div class=impl> <h3 id=interactive-media><span class=secno>15.7 </span>Interactive media</h3> <h4 id=links,-forms,-and-navigation><span class=secno>15.7.1 </span>Links, forms, and navigation</h4> <p>User agents are expected to allow the user to control aspects of <a href=#hyperlink>hyperlink</a> activation and <a href=#form-submission>form submission</a>, such as which <a href=#browsing-context>browsing context</a> is to be used for the subsequent <a href=#navigate title=navigate>navigation</a>.</p> <p>User agents are expected to allow users to discover the destination of <a href=#hyperlink title=hyperlink>hyperlinks</a> and of <a href=#the-form-element title=form>forms</a> before triggering their <a href=#navigate title=navigate>navigation</a>.</p> <!--PING--> <p>User agents are expected to inform the user of whether a <a href=#hyperlink>hyperlink</a> includes <a href=#hyperlink-auditing>hyperlink auditing</a>, and to let them know at a minimum which domains will be contacted as part of such auditing.</p> <!--PING--> <p>User agents are expected to allow users to <a href=#navigate>navigate</a><!--DONAV cite=""--> <a href=#browsing-context title="browsing context">browsing contexts</a> to the resources <a href=#resolve-a-url title="resolve a url">indicated</a> by the <code title="">cite</code> attributes on <code><a href=#the-q-element>q</a></code>, <code><a href=#the-blockquote-element>blockquote</a></code>, <code><a href=#the-ins-element>ins</a></code>, and <code><a href=#the-del-element>del</a></code> elements.</p> <p>User agents are expected to surface <a href=#hyperlink title=hyperlink>hyperlinks</a> created by <code><a href=#the-link-element>link</a></code> elements in their user interface.</p> <p class=note>While <code><a href=#the-link-element>link</a></code> elements that create <a href=#hyperlink title=hyperlink>hyperlinks</a> will match the ':link' or ':visited' pseudo-classes, 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 title=event-click><a href=#event-click>click</a></code> events and the like.</p> <h4 id=the-title-attribute-0><span class=secno>15.7.2 </span>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute</h4> <p>Given an element (e.g. the element designated by the mouse cursor), if the element, or one of its ancestors, has a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute, and the nearest such attribute has a value that is not the empty string, it is expected that the user agent will expose the contents of that attribute as a tooltip.</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 non-zero 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> <p>User agents are encouraged to make it possible to view tooltips without the use of a pointing device, since not all users are able to use pointing devices.</p> <div class=example> <p>For example, a visual user agent could make elements with a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute focusable, and could make any focused element with a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute show its tooltip under the element while the element has focus. This would allow a user to tab around the document to find all the advisory text.</p> </div> <div class=example> <p>As another example, a screen reader could provide an audio cue when reading an element with a tooltip, with an associated key to read the last tooltip for which a cue was played.</p> </div> <h4 id=editing-hosts><span class=secno>15.7.3 </span>Editing hosts</h4> <p>The current text editing caret (i.e. the <a href=#active-range>active range</a>, if it is empty and in an <a href=#editing-host>editing host</a>), if any, is expected to act like an inline replaced element 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 margins from collapsing through the element.</p> <h4 id=text-rendered-in-native-user-interfaces><span class=secno>15.7.4 </span>Text rendered in native user interfaces</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 elements (either attribute values or the contents of elements) is expected to be rendered in a manner that honors <a href=#the-directionality>the directionality</a> of the element from which the text was obtained.</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><p dir="rtl" lang="he"> <label> <span dir=rtl lang=he title="">בחר שפת תכנות:</span> <select> <option dir="ltr">C++</option> <option dir="ltr">C#</option> <option dir="ltr">FreePascal</option> <option dir="ltr">F#</option> </select> </label> </p></pre> <p>If the <code><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 alt="" height=105 src=http://images.whatwg.org/bidiselect.png width=206></p> <!-- no need for alt text, the previous paragraph describes it completely --> </div> <p>A string provided by a script (e.g. the argument to <code title=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 behaviour 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>alert('\u05DC\u05DE\u05D3 HTML \u05D4\u05D9\u05D5\u05DD!')</pre> <p>...would always result in a message reading "<bdo dir=rtl lang="" title="">למד LMTH היום!</bdo>" (not "<bdo dir=ltr lang="" title="">דמל 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>/* Warning: this script does not handle right-to-left scripts correctly */ var s; if (s = prompt('What is your name?')) { alert(s + '! Ok, Fred, ' + s + ', and Wilma will get the car.'); }</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>var s; if (s = prompt('What is your name?')) { alert('<strong>\u200E</strong>' + s + '! Ok, Fred, ' + s + ', and Wilma will get the car.'); }</pre> </div> <h3 id=print-media><span class=secno>15.8 </span>Print media</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><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 title="obtain a physical form">obtains a physical form</a> (or a representation of a physical form) of a <code><a href=#document>Document</a></code>, the user agent is expected to create a new rendering of the <code><a href=#document>Document</a></code> for the print media.</p> </div> <h2 id=obsolete><span class=secno>16 </span>Obsolete features</h2> <h3 id=obsolete-but-conforming-features><span class=secno>16.1 </span>Obsolete but conforming features</h3> <p>Features listed in this section will trigger warnings in conformance checkers.</p> <p>Authors should not specify a <code title=attr-img-border><a href=#attr-img-border>border</a></code> attribute on an <code><a href=#the-img-element>img</a></code> element. If the attribute is present, its value must be the string "<code title="">0</code>". CSS should be used instead.</p> <p>Authors should not specify a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a <code><a href=#the-script-element>script</a></code> element. If the attribute is present, its value must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">JavaScript</code>" and either the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute must be omitted or its value must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/javascript</code>". The attribute should be entirely omitted instead (with the value "<code title="">JavaScript</code>", it has no effect), or replaced with use of the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute.</p> <p>Authors should not specify the <code title=attr-a-name><a href=#attr-a-name>name</a></code> attribute on <code><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=#concept-id title=concept-id>IDs</a> in the element's <a href=#home-subtree>home subtree</a> other than the element's own <a href=#concept-id title=concept-id>ID</a>, if any, nor be equal to the value of any of the other <code title=attr-a-name><a href=#attr-a-name>name</a></code> attributes on <code><a href=#the-a-element>a</a></code> elements in the element's <a href=#home-subtree>home subtree</a>. If this attribute is present and the element has an <a href=#concept-id title=concept-id>ID</a>, then the attribute's value must be equal to the element's <a href=#concept-id title=concept-id>ID</a>. In earlier versions of the language, this attribute was intended as a way to specify possible targets for fragment identifiers in <a href=#url title=URL>URLs</a>. The <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute should be used instead.</p> <!-- remove this once type=number is widely supported --> <p>Authors should not, but may despite requirements to the contrary elsewhere in this specification, specify the <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> and <code title=attr-input-size><a href=#attr-input-size>size</a></code> attributes on <code><a href=#the-input-element>input</a></code> elements whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attributes are in the <a href=#number-state title=attr-input-type-number>Number</a> state. One valid reason for using these attributes regardless is to help legacy user agents that do not support <code><a href=#the-input-element>input</a></code> elements with <code title="">type="number"</code> to still render the text field with a useful width.</p> <p class=note>In <a href=#syntax>the HTML syntax</a>, specifying a <a href=#syntax-doctype title=syntax-DOCTYPE>DOCTYPE</a> that is an <a href=#obsolete-permitted-doctype>obsolete permitted DOCTYPE</a> will also trigger a warning.</p> <div class=impl> <h4 id=warnings-for-obsolete-but-conforming-features><span class=secno>16.1.1 </span>Warnings for obsolete but conforming features</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 are required to 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><!-- downplayed list --><li><p>The presence of an <a href=#obsolete-permitted-doctype>obsolete permitted DOCTYPE</a> in an <a href=#html-documents title="HTML documents">HTML document</a>.</li> <li><p>The presence of a <code title=attr-img-border><a href=#attr-img-border>border</a></code> attribute on an <code><a href=#the-img-element>img</a></code> element if its value is the string "<code title="">0</code>".</li> <li><p>The presence of a <code title=attr-script-language><a href=#attr-script-language>language</a></code> attribute on a <code><a href=#the-script-element>script</a></code> element if its value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">JavaScript</code>" and if there is no <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute or there is and its value is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/javascript</code>".</li> <li><p>The presence of a <code title=attr-a-name><a href=#attr-a-name>name</a></code> attribute on an <code><a href=#the-a-element>a</a></code> element, if its value is not the empty string.</li> <li><p>The presence of a <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> attribute on an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#number-state title=attr-input-type-number>Number</a> state.</li> <li><p>The presence of a <code title=attr-input-size><a href=#attr-input-size>size</a></code> attribute on an <code><a href=#the-input-element>input</a></code> element whose <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in the <a href=#number-state title=attr-input-type-number>Number</a> state.</li> </ul><p>Conformance checkers must distinguish between pages that have no conformance errors and have none of these obsolete features, and pages that have no conformance errors but do have some of these obsolete features.</p> <p class=example>For example, a validator could report some pages as "Valid HTML" and others as "Valid HTML with warnings".</p> </div> <h3 id=non-conforming-features><span class=secno>16.2 </span>Non-conforming features</h3> <p>Elements in the following list are entirely obsolete, and must not be used by authors:</p> <dl><!-- alphabetical by first element in the group, except CSS goes last --><dt><code><a href=#the-applet-element>applet</a></code></dt> <dd><p>Use <code><a href=#the-embed-element>embed</a></code> or <code><a href=#the-object-element>object</a></code> instead.</dd> <dt><dfn id=acronym><code>acronym</code></dfn></dt> <dd><p>Use <code><a href=#the-abbr-element>abbr</a></code> instead.</dd> <dt><dfn id=bgsound><code>bgsound</code></dfn></dt> <dd><p>Use <code><a href=#the-audio-element>audio</a></code> instead.</dd> <dt><dfn id=dir><code>dir</code></dfn></dt> <dd><p>Use <code><a href=#the-ul-element>ul</a></code> instead.</dd> <dt><code><a href=#frame>frame</a></code></dt> <dt><code><a href=#frameset>frameset</a></code></dt> <dt><dfn id=noframes><code>noframes</code></dfn></dt> <dd><p>Either use <code><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.</dd> <dt><dfn id=isindex-0><code>isindex</code></dfn></dt> <dd><p>Use an explicit <code><a href=#the-form-element>form</a></code> and <a href=#text-state-and-search-state title=attr-input-type-text>text field</a> combination instead.</dd> <dt><dfn id=listing><code>listing</code></dfn></dt> <dd><p>Use <code><a href=#the-pre-element>pre</a></code> and <code><a href=#the-code-element>code</a></code> instead.</dd> <dt><dfn id=nextid><code>nextid</code></dfn></dt> <dd><p>Use GUIDs instead.</dd> <dt><dfn id=noembed><code>noembed</code></dfn></dt> <dd><p>Use <code><a href=#the-object-element>object</a></code> instead of <code><a href=#the-embed-element>embed</a></code> when fallback is necessary.</dd> <dt><dfn id=plaintext><code>plaintext</code></dfn></dt> <dd><p>Use the "<code>text/plain</code>" <a href=#mime-type>MIME type</a> instead.</dd> <dt><dfn id=rb><code>rb</code></dfn></dt> <dd><p>Providing the ruby base directly inside the <code><a href=#the-ruby-element>ruby</a></code> element is sufficient; the <code><a href=#rb>rb</a></code> element is unnecessary. Omit it altogether.</dd> <dt><dfn id=strike><code>strike</code></dfn></dt> <dd><p>Use <code><a href=#the-del-element>del</a></code> instead if the element is marking an edit, otherwise use <code><a href=#the-s-element>s</a></code> instead.</dd> <dt><dfn id=xmp><code>xmp</code></dfn></dt> <dd><p>Use <code><a href=#the-pre-element>pre</a></code> and <code><a href=#the-code-element>code</a></code> instead, and escape "<code title=""><</code>" and "<code title="">&</code>" characters as "<code title="">&lt;</code>" and "<code title="">&amp;</code>" respectively.</dd> <dt><dfn id=basefont><code>basefont</code></dfn></dt> <dt><dfn id=big><code>big</code></dfn></dt> <dt><dfn id=blink><code>blink</code></dfn></dt> <dt><dfn id=center><code>center</code></dfn></dt> <dt><dfn id=font><code>font</code></dfn></dt> <dt><code><a href=#the-marquee-element>marquee</a></code></dt> <dt><dfn id=multicol><code>multicol</code></dfn></dt> <dt><dfn id=nobr><code>nobr</code></dfn></dt> <dt><dfn id=spacer><code>spacer</code></dfn></dt> <dt><dfn id=tt><code>tt</code></dfn></dt> <dd> <p>Use appropriate elements and/or CSS instead.</p> <p>Where the <code><a href=#tt>tt</a></code> element would have been used for marking up keyboard input, consider the <code><a href=#the-kbd-element>kbd</a></code> element; for variables, consider the <code><a href=#the-var-element>var</a></code> element; for computer code, consider the <code><a href=#the-code-element>code</a></code> element; and for computer output, consider the <code><a href=#the-samp-element>samp</a></code> element.</p> <p>Similarly, if the <code><a href=#big>big</a></code> element is being used to denote a heading, consider using the <code><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><a href=#the-strong-element>strong</a></code> element; and if it is being used for highlighting text for reference purposes, consider the <code><a href=#the-mark-element>mark</a></code> element.</p> <p>See also the <a href=#usage-summary>text-level semantics usage summary</a> for more suggestions with examples.</p> </dd> </dl><hr><p>The following attributes are obsolete (though the elements are still part of the language), and must not be used by authors:</p> <dl><!-- alphabetical by element then attribute of first item in group, except CSS goes last --><dt><dfn id=attr-a-charset title=attr-a-charset><code>charset</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dt><dfn id=attr-link-charset title=attr-link-charset><code>charset</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt> <dd><p>Use an HTTP Content-Type header on the linked resource instead.</dd> <dt><dfn id=attr-a-coords title=attr-a-coords><code>coords</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dt><dfn id=attr-a-shape title=attr-a-shape><code>shape</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dd><p>Use <code><a href=#the-area-element>area</a></code> instead of <code><a href=#the-a-element>a</a></code> for image maps.</dd> <dt><dfn id=attr-a-methods title=attr-a-methods><code>methods</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dt><dfn id=attr-link-methods title=attr-link-methods><code>methods</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt> <dd><p>Use the HTTP OPTIONS feature instead.</dd> <dt><dfn id=attr-a-name title=attr-a-name><code>name</code></dfn> on <code><a href=#the-a-element>a</a></code> elements (except as noted in the previous section)</dt> <dt><dfn id=attr-embed-name title=attr-embed-name><code>name</code></dfn> on <code><a href=#the-embed-element>embed</a></code> elements</dt> <dt><dfn id=attr-img-name title=attr-img-name><code>name</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dt><dfn id=attr-option-name title=attr-option-name><code>name</code></dfn> on <code><a href=#the-option-element>option</a></code> elements</dt> <dd><p>Use the <code title=attr-id><a href=#the-id-attribute>id</a></code> attribute instead.</dd> <dt><dfn id=attr-a-rev title=attr-a-rev><code>rev</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dt><dfn id=attr-link-rev title=attr-link-rev><code>rev</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt> <dd><p>Use the <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code> attribute instead, with an opposite term. (For example, instead of <code title="">rev="made"</code>, use <code title="">rel="author"</code>.)</dd> <dt><dfn id=attr-a-urn title=attr-a-urn><code>urn</code></dfn> on <code><a href=#the-a-element>a</a></code> elements</dt> <dt><dfn id=attr-link-urn title=attr-link-urn><code>urn</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt> <dd><p>Specify the preferred persistent identifier using the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute instead.</dd> <dt><dfn id=attr-form-accept title=attr-form-accept><code>accept</code></dfn> on <code><a href=#the-form-element>form</a></code> elements</dt> <dd><p>Use the <code title=attr-input-accept><a href=#attr-input-accept>accept</a></code> attribute directly on the <code><a href=#the-input-element>input</a></code> elements instead.</dd> <dt><dfn id=attr-area-nohref title=attr-area-nohref><code>nohref</code></dfn> on <code><a href=#the-area-element>area</a></code> elements</dt> <dd><p>Omitting the <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute is sufficient; the <code title=attr-area-nohref><a href=#attr-area-nohref>nohref</a></code> attribute is unnecessary. Omit it altogether.</dd> <dt><dfn id=attr-head-profile title=attr-head-profile><code>profile</code></dfn> on <code><a href=#the-head-element>head</a></code> elements</dt> <dd><p>When used for declaring which <code><a href=#the-meta-element>meta</a></code> terms are used in the document, unnecessary; omit it altogether, and <a href=#concept-meta-extensions title=concept-meta-extensions>register the names</a>.</dd> <dd><p>When used for triggering specific user agent behaviors: use a <code><a href=#the-link-element>link</a></code> element instead.</dd> <dt><dfn id=attr-html-version title=attr-html-version><code>version</code></dfn> on <code><a href=#the-html-element>html</a></code> elements</dt> <dd><p>Unnecessary. Omit it altogether.</dd> <dt><dfn id=attr-input-usemap title=attr-input-usemap><code>usemap</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt> <dd><p>Use <code><a href=#the-img-element>img</a></code> instead of <code><a href=#the-input-element>input</a></code> for image maps.</dd> <dt><dfn id=attr-iframe-longdesc title=attr-iframe-longdesc><code>longdesc</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-img-longdesc title=attr-img-longdesc><code>longdesc</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dd><p>Use a regular <code><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>image map</a> to provide a link from the image to the image's description.</dd> <dt><dfn id=attr-img-lowsrc title=attr-img-lowsrc><code>lowsrc</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dd><p>Use a progressive JPEG image (given in the <code title=attr-img-src><a href=#attr-img-src>src</a></code> attribute), instead of using two separate images.</dd> <dt><dfn id=attr-link-target title=attr-link-target><code>target</code></dfn> on <code><a href=#the-link-element>link</a></code> elements</dt> <dd><p>Unnecessary. Omit it altogether.</dd> <dt><dfn id=attr-meta-scheme title=attr-meta-scheme><code>scheme</code></dfn> on <code><a href=#the-meta-element>meta</a></code> elements</dt> <dd><p>Use only one scheme per field, or make the scheme declaration part of the value.</dd> <dt><dfn id=attr-object-archive title=attr-object-archive><code>archive</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-classid title=attr-object-classid><code>classid</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-code title=attr-object-code><code>code</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-codebase title=attr-object-codebase><code>codebase</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-codetype title=attr-object-codetype><code>codetype</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dd><p>Use the <code title=attr-object-data><a href=#attr-object-data>data</a></code> and <code title=attr-object-type><a href=#attr-object-type>type</a></code> attributes to invoke <a href=#plugin title=plugin>plugins</a>. To set parameters with these names in particular, the <code><a href=#the-param-element>param</a></code> element can be used.</dd> <dt><dfn id=attr-object-declare title=attr-object-declare><code>declare</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dd><p>Repeat the <code><a href=#the-object-element>object</a></code> element completely each time the resource is to be reused.</dd> <dt><dfn id=attr-object-standby title=attr-object-standby><code>standby</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dd><p>Optimize the linked resource so that it loads quickly or, at least, incrementally.</dd> <dt><dfn id=attr-param-type title=attr-param-type><code>type</code></dfn> on <code><a href=#the-param-element>param</a></code> elements</dt> <dt><dfn id=attr-param-valuetype title=attr-param-valuetype><code>valuetype</code></dfn> on <code><a href=#the-param-element>param</a></code> elements</dt> <dd><p>Use the <code title=attr-param-name><a href=#attr-param-name>name</a></code> and <code title=attr-param-value><a href=#attr-param-value>value</a></code> attributes without declaring value types.</dd> <dt><dfn id=attr-script-language title=attr-script-language><code>language</code></dfn> on <code><a href=#the-script-element>script</a></code> elements (except as noted in the previous section)</dt> <dd><p>Use the <code title=attr-script-type><a href=#attr-script-type>type</a></code> attribute instead.</dd> <dt><dfn id=attr-script-event title=attr-script-event><code>event</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt> <dt><dfn id=attr-script-for title=attr-script-for><code>for</code></dfn> on <code><a href=#the-script-element>script</a></code> elements</dt> <dd><p>Use DOM Events mechanisms to register event listeners. <a href=#refsDOMCORE>[DOMCORE]</a></dd> <dt><dfn id=attr-table-datapagesize title=attr-table-datapagesize><code>datapagesize</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dd><p>Unnecessary. Omit it altogether.</dd> <dt><dfn id=attr-table-summary title=attr-table-summary><code>summary</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt><!-- 2.65% pages --> <dd><p>Use one of the <a href=#table-descriptions-techniques>techniques for describing tables</a> given in the <code><a href=#the-table-element>table</a></code> section instead.</dd> <dt><dfn id=attr-tdth-abbr title=attr-tdth-abbr><code>abbr</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dd><p>Use text that begins in an unambiguous and terse manner, and include any more elaborate text after that. The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute can also be useful in including more detailed text, so that the cell's contents can be made terse.</p> <dt><dfn id=attr-tdth-axis title=attr-tdth-axis><code>axis</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dd><p>Use the <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code> attribute on the relevant <code><a href=#the-th-element>th</a></code>.</p> <dt><dfn id=attr-td-scope title=attr-td-scope><code>scope</code></dfn> on <code><a href=#the-td-element>td</a></code> elements</dt> <dd><p>Use <code><a href=#the-th-element>th</a></code> elements for heading cells.</p> <dt><dfn id=attr-datasrc title=attr-datasrc><code>datasrc</code></dfn> on <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-button-element>button</a></code>, <code><a href=#the-div-element>div</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#the-label-element>label</a></code>, <code><a href=#the-legend-element>legend</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-option-element>option</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-span-element>span</a></code>, <code><a href=#the-table-element>table</a></code>, and <code><a href=#the-textarea-element>textarea</a></code> elements</dt> <dt><dfn id=attr-datafld title=attr-datafld><code>datafld</code></dfn> on <code><a href=#the-a-element>a</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-button-element>button</a></code>, <code><a href=#the-div-element>div</a></code>, <code><a href=#the-fieldset-element>fieldset</a></code>, <code><a href=#frame>frame</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, <code><a href=#the-img-element>img</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#the-label-element>label</a></code>, <code><a href=#the-legend-element>legend</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-span-element>span</a></code>, and <code><a href=#the-textarea-element>textarea</a></code> elements</dt> <dt><dfn id=attr-dataformatas title=attr-dataformatas><code>dataformatas</code></dfn> on <code><a href=#the-button-element>button</a></code>, <code><a href=#the-div-element>div</a></code>, <code><a href=#the-input-element>input</a></code>, <code><a href=#the-label-element>label</a></code>, <code><a href=#the-legend-element>legend</a></code>, <code><a href=#the-marquee-element>marquee</a></code>, <code><a href=#the-object-element>object</a></code>, <code><a href=#the-option-element>option</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-span-element>span</a></code>, and <code><a href=#the-table-element>table</a></code> elements</dt> <dd><p>Use script and a mechanism such as <code>XMLHttpRequest</code> to populate the page dynamically. <a href=#refsXHR>[XHR]</a></dd> <dt><dfn id=attr-body-alink title=attr-body-alink><code>alink</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-bgcolor title=attr-body-bgcolor><code>bgcolor</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-link title=attr-body-link><code>link</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-marginbottom title=attr-body-marginbottom><code>marginbottom</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-marginheight title=attr-body-marginheight><code>marginheight</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-marginleft title=attr-body-marginleft><code>marginleft</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-marginright title=attr-body-marginright><code>marginright</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-margintop title=attr-body-margintop><code>margintop</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-marginwidth title=attr-body-marginwidth><code>marginwidth</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-text title=attr-body-text><code>text</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-body-vlink title=attr-body-vlink><code>vlink</code></dfn> on <code><a href=#the-body-element>body</a></code> elements</dt> <dt><dfn id=attr-br-clear title=attr-br-clear><code>clear</code></dfn> on <code><a href=#the-br-element>br</a></code> elements</dt> <dt><dfn id=attr-caption-align title=attr-caption-align><code>align</code></dfn> on <code><a href=#the-caption-element>caption</a></code> elements</dt> <dt><dfn id=attr-col-align title=attr-col-align><code>align</code></dfn> on <code><a href=#the-col-element>col</a></code> elements</dt> <dt><dfn id=attr-col-char title=attr-col-char><code>char</code></dfn> on <code><a href=#the-col-element>col</a></code> elements</dt> <dt><dfn id=attr-col-charoff title=attr-col-charoff><code>charoff</code></dfn> on <code><a href=#the-col-element>col</a></code> elements</dt> <dt><dfn id=attr-col-valign title=attr-col-valign><code>valign</code></dfn> on <code><a href=#the-col-element>col</a></code> elements</dt> <dt><dfn id=attr-col-width title=attr-col-width><code>width</code></dfn> on <code><a href=#the-col-element>col</a></code> elements</dt> <dt><dfn id=attr-div-align title=attr-div-align><code>align</code></dfn> on <code><a href=#the-div-element>div</a></code> elements</dt> <dt><dfn id=attr-dl-compact title=attr-dl-compact><code>compact</code></dfn> on <code><a href=#the-dl-element>dl</a></code> elements</dt> <dt><dfn id=attr-embed-align title=attr-embed-align><code>align</code></dfn> on <code><a href=#the-embed-element>embed</a></code> elements</dt> <dt><dfn id=attr-embed-hspace title=attr-embed-hspace><code>hspace</code></dfn> on <code><a href=#the-embed-element>embed</a></code> elements</dt> <dt><dfn id=attr-embed-vspace title=attr-embed-vspace><code>vspace</code></dfn> on <code><a href=#the-embed-element>embed</a></code> elements</dt> <dt><dfn id=attr-hr-align title=attr-hr-align><code>align</code></dfn> on <code><a href=#the-hr-element>hr</a></code> elements</dt> <dt><dfn id=attr-hr-color title=attr-hr-color><code>color</code></dfn> on <code><a href=#the-hr-element>hr</a></code> elements</dt> <dt><dfn id=attr-hr-noshade title=attr-hr-noshade><code>noshade</code></dfn> on <code><a href=#the-hr-element>hr</a></code> elements</dt> <dt><dfn id=attr-hr-size title=attr-hr-size><code>size</code></dfn> on <code><a href=#the-hr-element>hr</a></code> elements</dt> <dt><dfn id=attr-hr-width title=attr-hr-width><code>width</code></dfn> on <code><a href=#the-hr-element>hr</a></code> elements</dt> <dt><dfn id=attr-hx-align title=attr-hx-align><code>align</code></dfn> on <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>—<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements</dt> <dt><dfn id=attr-iframe-align title=attr-iframe-align><code>align</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-allowtransparency title=attr-iframe-allowtransparency><code>allowtransparency</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-frameborder title=attr-iframe-frameborder><code>frameborder</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-hspace title=attr-iframe-hspace><code>hspace</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-marginheight title=attr-iframe-marginheight><code>marginheight</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-marginwidth title=attr-iframe-marginwidth><code>marginwidth</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-scrolling title=attr-iframe-scrolling><code>scrolling</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-iframe-vspace title=attr-iframe-vspace><code>vspace</code></dfn> on <code><a href=#the-iframe-element>iframe</a></code> elements</dt> <dt><dfn id=attr-input-align title=attr-input-align><code>align</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt> <dt><dfn id=attr-input-hspace title=attr-input-hspace><code>hspace</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt> <dt><dfn id=attr-input-vspace title=attr-input-vspace><code>vspace</code></dfn> on <code><a href=#the-input-element>input</a></code> elements</dt> <dt><dfn id=attr-img-align title=attr-img-align><code>align</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dt><dfn id=attr-img-border title=attr-img-border><code>border</code></dfn> on <code><a href=#the-img-element>img</a></code> elements (except as noted in the previous section)</dt> <dt><dfn id=attr-img-hspace title=attr-img-hspace><code>hspace</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dt><dfn id=attr-img-vspace title=attr-img-vspace><code>vspace</code></dfn> on <code><a href=#the-img-element>img</a></code> elements</dt> <dt><dfn id=attr-legend-align title=attr-legend-align><code>align</code></dfn> on <code><a href=#the-legend-element>legend</a></code> elements</dt> <dt><dfn id=attr-li-type title=attr-li-type><code>type</code></dfn> on <code><a href=#the-li-element>li</a></code> elements</dt> <dt><dfn id=attr-menu-compact title=attr-menu-compact><code>compact</code></dfn> on <code><a href=#the-menu-element>menu</a></code> elements</dt> <dt><dfn id=attr-object-align title=attr-object-align><code>align</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-border title=attr-object-border><code>border</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-hspace title=attr-object-hspace><code>hspace</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-object-vspace title=attr-object-vspace><code>vspace</code></dfn> on <code><a href=#the-object-element>object</a></code> elements</dt> <dt><dfn id=attr-ol-compact title=attr-ol-compact><code>compact</code></dfn> on <code><a href=#the-ol-element>ol</a></code> elements</dt> <dt><dfn id=attr-p-align title=attr-p-align><code>align</code></dfn> on <code><a href=#the-p-element>p</a></code> elements</dt> <dt><dfn id=attr-pre-width title=attr-pre-width><code>width</code></dfn> on <code><a href=#the-pre-element>pre</a></code> elements</dt> <dt><dfn id=attr-table-align title=attr-table-align><code>align</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-bgcolor title=attr-table-bgcolor><code>bgcolor</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-cellpadding title=attr-table-cellpadding><code>cellpadding</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-cellspacing title=attr-table-cellspacing><code>cellspacing</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-frame title=attr-table-frame><code>frame</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-rules title=attr-table-rules><code>rules</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-table-width title=attr-table-width><code>width</code></dfn> on <code><a href=#the-table-element>table</a></code> elements</dt> <dt><dfn id=attr-tbody-align title=attr-tbody-align><code>align</code></dfn> on <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements</dt> <dt><dfn id=attr-tbody-char title=attr-tbody-char><code>char</code></dfn> on <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements</dt> <dt><dfn id=attr-tbody-charoff title=attr-tbody-charoff><code>charoff</code></dfn> on <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements</dt> <dt><dfn id=attr-tbody-valign title=attr-tbody-vAlign><code>valign</code></dfn> on <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements</dt> <dt><dfn id=attr-tdth-align title=attr-tdth-align><code>align</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-bgcolor title=attr-tdth-bgcolor><code>bgcolor</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-char title=attr-tdth-char><code>char</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-charoff title=attr-tdth-charoff><code>charoff</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-height title=attr-tdth-height><code>height</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-nowrap title=attr-tdth-nowrap><code>nowrap</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-valign title=attr-tdth-valign><code>valign</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tdth-width title=attr-tdth-width><code>width</code></dfn> on <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements</dt> <dt><dfn id=attr-tr-align title=attr-tr-align><code>align</code></dfn> on <code><a href=#the-tr-element>tr</a></code> elements</dt> <dt><dfn id=attr-tr-bgcolor title=attr-tr-bgcolor><code>bgcolor</code></dfn> on <code><a href=#the-tr-element>tr</a></code> elements</dt> <dt><dfn id=attr-tr-char title=attr-tr-char><code>char</code></dfn> on <code><a href=#the-tr-element>tr</a></code> elements</dt> <dt><dfn id=attr-tr-charoff title=attr-tr-charoff><code>charoff</code></dfn> on <code><a href=#the-tr-element>tr</a></code> elements</dt> <dt><dfn id=attr-tr-valign title=attr-tr-valign><code>valign</code></dfn> on <code><a href=#the-tr-element>tr</a></code> elements</dt> <dt><dfn id=attr-ul-compact title=attr-ul-compact><code>compact</code></dfn> on <code><a href=#the-ul-element>ul</a></code> elements</dt> <dt><dfn id=attr-ul-type title=attr-ul-type><code>type</code></dfn> on <code><a href=#the-ul-element>ul</a></code> elements</dt> <dt><dfn id=attr-background title=attr-background><code>background</code></dfn> on <code><a href=#the-body-element>body</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-td-element>td</a></code>, and <code><a href=#the-th-element>th</a></code> elements</dt> <dd><p>Use CSS instead.</dd> </dl><hr><p>The <code title=attr-table-border><a href=#attr-table-border>border</a></code> attribute on the <code><a href=#the-table-element>table</a></code> element can be used to provide basic fallback styling for the purpose of making tables legible in browsing environments where CSS support is limited or absent, such as text-based browsers, WYSIWYG editors, and in situations where CSS support is disabled or the style sheet is lost. Only the empty string and the value "<code title="">1</code>" may be used as <code title=attr-table-border><a href=#attr-table-border>border</a></code> values for this purpose. Other values are considered obsolete. To regulate the thickness of such borders, authors should instead use CSS.</p> <div class=impl> <h3 id=requirements-for-implementations><span class=secno>16.3 </span>Requirements for implementations</h3> <h4 id=the-applet-element><span class=secno>16.3.1 </span>The <dfn><code>applet</code></dfn> element</h4> <p>The <code><a href=#the-applet-element>applet</a></code> element is a Java-specific variant of the <code><a href=#the-embed-element>embed</a></code> element. The <code><a href=#the-applet-element>applet</a></code> element is now obsoleted so that all extension frameworks (Java, .NET, Flash, etc) are handled in a consistent manner.</p> <p id=sandboxPluginApplet>When the element is still in the <a href=#stack-of-open-elements>stack of open elements</a> of an <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a>, and when the element is not <a href=#in-a-document>in a <code>Document</code></a>, and when the element's document is not <a href=#fully-active>fully active</a>, and when the element's <code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> had its <a href=#sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> when that <code><a href=#document>Document</a></code> was created, and when the element has an ancestor <a href=#media-element>media element</a>, and when the element has an ancestor <code><a href=#the-object-element>object</a></code> element that is <em>not</em> showing its <a href=#fallback-content>fallback content</a>, and when no Java Language runtime <a href=#plugin>plugin</a> is available, and when one <em>is</em> available but it is disabled, the element <a href=#represents>represents</a> its contents.</p> <!-- we assume here that the Java plugin can't be <span title="concept-plugin-secure">secured</span>; if anyone does end up securing one we can always change this --> <p>Otherwise, the user agent should instantiate a Java Language runtime <a href=#plugin>plugin</a>, and should pass 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, and then a parameter named "PARAM" whose value is null, and then all the names and values of <a href=#concept-param-parameter title=concept-param-parameter>parameters</a> given by <code><a href=#the-param-element>param</a></code> elements that are children of the <code><a href=#the-applet-element>applet</a></code> element, in <a href=#tree-order>tree order</a>, to the <a href=#plugin>plugin</a> used. If the <a href=#plugin>plugin</a> supports a scriptable interface, the <code><a href=#htmlappletelement>HTMLAppletElement</a></code> object representing the element should expose that interface. The <code><a href=#the-applet-element>applet</a></code> element <a href=#represents>represents</a> the <a href=#plugin>plugin</a>.</p> <!-- If we ever make this fetch anything manually, remember to delay the load event, and to include ", from the element's <span>browsing context scope origin</span> if it has one" when fetching --> <p class=note>The <code><a href=#the-applet-element>applet</a></code> element is unaffected by the CSS 'display' property. The Java Language runtime is instantiated even if the element is hidden with a 'display:none' CSS style.</p> <p>The <code><a href=#the-applet-element>applet</a></code> element must implement the <code><a href=#htmlappletelement>HTMLAppletElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlappletelement>HTMLAppletElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-applet-align title=dom-applet-align>align</a>; attribute DOMString <a href=#dom-applet-alt title=dom-applet-alt>alt</a>; attribute DOMString <a href=#dom-applet-archive title=dom-applet-archive>archive</a>; attribute DOMString <a href=#dom-applet-code title=dom-applet-code>code</a>; attribute DOMString <a href=#dom-applet-codebase title=dom-applet-codeBase>codeBase</a>; attribute DOMString <a href=#dom-applet-height title=dom-applet-height>height</a>; attribute unsigned long <a href=#dom-applet-hspace title=dom-applet-hspace>hspace</a>; attribute DOMString <a href=#dom-applet-name title=dom-applet-name>name</a>; attribute DOMString _<a href=#dom-applet-object title=dom-applet-object>object</a>; // the underscore is not part of the identifier <!-- it's a Web IDL escaping mechanism --> attribute unsigned long <a href=#dom-applet-vspace title=dom-applet-vspace>vspace</a>; attribute DOMString <a href=#dom-applet-width title=dom-applet-width>width</a>; };</pre> <p>The <dfn id=dom-applet-align title=dom-applet-align><code>align</code></dfn>, <dfn id=dom-applet-alt title=dom-applet-alt><code>alt</code></dfn>, <dfn id=dom-applet-archive title=dom-applet-archive><code>archive</code></dfn>, <dfn id=dom-applet-code title=dom-applet-code><code>code</code></dfn>, <dfn id=dom-applet-height title=dom-applet-height><code>height</code></dfn>, <dfn id=dom-applet-hspace title=dom-applet-hspace><code>hspace</code></dfn>, <dfn id=dom-applet-name title=dom-applet-name><code>name</code></dfn>, <dfn id=dom-applet-object title=dom-applet-object><code>object</code></dfn>, <dfn id=dom-applet-vspace title=dom-applet-vspace><code>vspace</code></dfn>, and <dfn id=dom-applet-width title=dom-applet-width><code>width</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name. For the purposes of reflection, the <code><a href=#the-applet-element>applet</a></code> element's <code title=attr-applet-object>object</code> content attribute is defined as containing a <a href=#url>URL</a>.</p> <p>The <dfn id=dom-applet-codebase title=dom-applet-codeBase><code>codeBase</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-applet-codebase>codebase</code> content attribute, which for the purposes of reflection is defined as containing a <a href=#url>URL</a>.</p> <h4 id=the-marquee-element><span class=secno>16.3.2 </span>The <dfn><code>marquee</code></dfn> element</h4> <p>The <code><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.</p> <p>The <a href=#task-source>task source</a> for tasks mentioned in this section is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p>The <code><a href=#the-marquee-element>marquee</a></code> element must implement the <code><a href=#htmlmarqueeelement>HTMLMarqueeElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlmarqueeelement>HTMLMarqueeElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-marquee-behavior title=dom-marquee-behavior>behavior</a>; attribute DOMString <a href=#dom-marquee-bgcolor title=dom-marquee-bgColor>bgColor</a>; attribute DOMString <a href=#dom-marquee-direction title=dom-marquee-direction>direction</a>; attribute DOMString <a href=#dom-marquee-height title=dom-marquee-height>height</a>; attribute unsigned long <a href=#dom-marquee-hspace title=dom-marquee-hspace>hspace</a>; attribute long <a href=#dom-marquee-loop title=dom-marquee-loop>loop</a>; attribute unsigned long <a href=#dom-marquee-scrollamount title=dom-marquee-scrollamount>scrollAmount</a>; attribute unsigned long <a href=#dom-marquee-scrolldelay title=dom-marquee-scrollDelay>scrollDelay</a>; attribute boolean <a href=#dom-marquee-truespeed title=dom-marquee-trueSpeed>trueSpeed</a>; attribute unsigned long <a href=#dom-marquee-vspace title=dom-marquee-vspace>vspace</a>; attribute DOMString <a href=#dom-marquee-width title=dom-marquee-width>width</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-marquee-onbounce title=handler-marquee-onbounce>onbounce</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-marquee-onfinish title=handler-marquee-onfinish>onfinish</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-marquee-onstart title=handler-marquee-onstart>onstart</a>; void <a href=#dom-marquee-start title=dom-marquee-start>start</a>(); void <a href=#dom-marquee-stop title=dom-marquee-stop>stop</a>(); };</pre> <p>A <code><a href=#the-marquee-element>marquee</a></code> element can be <dfn id=concept-marquee-on title=concept-marquee-on>turned on</dfn> or <dfn id=concept-marquee-off title=concept-marquee-off>turned off</dfn>. When it is created, it is <a href=#concept-marquee-on title=concept-marquee-on>turned on</a>.</p> <p>When the <dfn id=dom-marquee-start title=dom-marquee-start><code>start()</code></dfn> method is called, the <code><a href=#the-marquee-element>marquee</a></code> element must be <a href=#concept-marquee-on title=concept-marquee-on>turned on</a>.</p> <p>When the <dfn id=dom-marquee-stop title=dom-marquee-stop><code>stop()</code></dfn> method is called, the <code><a href=#the-marquee-element>marquee</a></code> element must be <a href=#concept-marquee-off title=concept-marquee-off>turned off</a>.</p> <p>When a <code><a href=#the-marquee-element>marquee</a></code> element is created, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-start>start</code> at the element.</p> <hr><p>The <dfn id=attr-marquee-behavior title=attr-marquee-behavior><code>behavior</code></dfn> content attribute on <code><a href=#the-marquee-element>marquee</a></code> elements is an <a href=#enumerated-attribute>enumerated attribute</a> with the following keywords (all non-conforming):</p> <table><thead><tr><th>Keyword <th>State <tbody><tr><td><code title="">scroll</code> <td><dfn id=attr-marquee-behavior-scroll title=attr-marquee-behavior-scroll>scroll</dfn> <tr><td><code title="">slide</code> <td><dfn id=attr-marquee-behavior-slide title=attr-marquee-behavior-slide>slide</dfn> <tr><td><code title="">alternate</code> <td><dfn id=attr-marquee-behavior-alternate title=attr-marquee-behavior-alternate>alternate</dfn> </table><p>The <i>missing value default</i> is the <a href=#attr-marquee-behavior-scroll title=attr-marquee-behavior-scroll>scroll</a> state.</p> <hr><p>The <dfn id=attr-marquee-direction title=attr-marquee-direction><code>direction</code></dfn> content attribute on <code><a href=#the-marquee-element>marquee</a></code> elements is an <a href=#enumerated-attribute>enumerated attribute</a> with the following keywords (all non-conforming):</p> <table><thead><tr><th>Keyword <th>State <tbody><tr><td><code title="">left</code> <td><dfn id=attr-marquee-direction-left title=attr-marquee-direction-left>left</dfn> <tr><td><code title="">right</code> <td><dfn id=attr-marquee-direction-right title=attr-marquee-direction-right>right</dfn> <tr><td><code title="">up</code> <td><dfn id=attr-marquee-direction-up title=attr-marquee-direction-up>up</dfn> <tr><td><code title="">down</code> <td><dfn id=attr-marquee-direction-down title=attr-marquee-direction-down>down</dfn> </table><p>The <i>missing value default</i> is the <a href=#attr-marquee-direction-left title=attr-marquee-direction-left>left</a> state.</p> <hr><p>The <dfn id=attr-marquee-truespeed title=attr-marquee-truespeed><code>truespeed</code></dfn> content attribute on <code><a href=#the-marquee-element>marquee</a></code> elements is a <a href=#boolean-attribute>boolean attribute</a>.</p> <hr><p>A <code><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 title=attr-marquee-scrolldelay>scrolldelay</code> attribute, and parsing its value using the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> does not return an error, then let <var title="">delay</var> be the parsed value. Otherwise, let <var title="">delay</var> be 85.</li> <li><p>If the element does not have a <code title=attr-marquee-truespeed><a href=#attr-marquee-truespeed>truespeed</a></code> attribute, and the <var title="">delay</var> value is less than 60, then let <var title="">delay</var> be 60 instead.</li> <li><p>The <a href=#marquee-scroll-interval>marquee scroll interval</a> is <var title="">delay</var>, interpreted in milliseconds.</li> </ol><hr><p>A <code><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 title=attr-marquee-scrollamount>scrollamount</code> attribute, and parsing its value using the <a href=#rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a> does not return an error, is the parsed value interpreted in CSS pixels, and otherwise is 6 CSS pixels.</p> <hr><p>A <code><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 <code title=attr-marquee-loop>loop</code> attribute, and parsing its value using the <a href=#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 title=dom-marquee-loop><code>loop</code></dfn> IDL attribute, on getting, must return the element's <a href=#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>marquee loop count</a> and either greater than zero or equal to −1, must set the element's <code title=attr-marquee-loop>loop</code> content attribute (adding it if necessary) to the <a href=#valid-integer>valid integer</a> that represents the new value. (Other values are ignored.)</p> <p>A <code><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>marquee loop count</a> is −1, then abort these steps.</p> <li><p>Increment the <a href=#marquee-current-loop-index>marquee current loop index</a> by one.</li> <li> <p>If the <a href=#marquee-current-loop-index>marquee current loop index</a> is now equal to or greater than the element's <a href=#marquee-loop-count>marquee loop count</a>, <a href=#concept-marquee-off title=concept-marquee-off>turn off</a> the <code><a href=#the-marquee-element>marquee</a></code> element and <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-finish>finish</code> at the <code><a href=#the-marquee-element>marquee</a></code> element.</p> <p>Otherwise, if the <code title=attr-marquee-behavior><a href=#attr-marquee-behavior>behavior</a></code> attribute is in the <a href=#attr-marquee-behavior-alternate title=attr-marquee-behavior-alternate>alternate</a> state, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-bounce>bounce</code> at the <code><a href=#the-marquee-element>marquee</a></code> element.</p> <p>Otherwise, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-start>start</code> at the <code><a href=#the-marquee-element>marquee</a></code> element.</p> </li> </ol><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type title="event handler event type">event handler event types</a>) that must be supported, as content and IDL attributes, by <code><a href=#the-marquee-element>marquee</a></code> elements:</p> <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a> <tbody><tr><td><dfn id=handler-marquee-onbounce title=handler-marquee-onbounce><code>onbounce</code></dfn> <td> <code title=event-bounce>bounce</code> <tr><td><dfn id=handler-marquee-onfinish title=handler-marquee-onfinish><code>onfinish</code></dfn> <td> <code title=event-finish>finish</code> <tr><td><dfn id=handler-marquee-onstart title=handler-marquee-onstart><code>onstart</code></dfn> <td> <code title=event-start>start</code> </table><hr><p>The <dfn id=dom-marquee-behavior title=dom-marquee-behavior><code>behavior</code></dfn>, <dfn id=dom-marquee-direction title=dom-marquee-direction><code>direction</code></dfn>, <dfn id=dom-marquee-height title=dom-marquee-height><code>height</code></dfn>, <dfn id=dom-marquee-hspace title=dom-marquee-hspace><code>hspace</code></dfn>, <dfn id=dom-marquee-vspace title=dom-marquee-vspace><code>vspace</code></dfn>, and <dfn id=dom-marquee-width title=dom-marquee-width><code>width</code></dfn> IDL attributes must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-marquee-bgcolor title=dom-marquee-bgColor><code>bgColor</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-marquee-bgcolor>bgcolor</code> content attribute.</p> <p>The <dfn id=dom-marquee-scrollamount title=dom-marquee-scrollAmount><code>scrollAmount</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-marquee-scrollamount>scrollamount</code> content attribute. The default value is 6.</p> <p>The <dfn id=dom-marquee-scrolldelay title=dom-marquee-scrollDelay><code>scrollDelay</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-marquee-scrolldelay>scrolldelay</code> content attribute. The default value is 85.</p> <p>The <dfn id=dom-marquee-truespeed title=dom-marquee-trueSpeed><code>trueSpeed</code></dfn> IDL attribute must <a href=#reflect>reflect</a> the <code title=attr-marquee-truespeed><a href=#attr-marquee-truespeed>truespeed</a></code> content attribute.</p> <h4 id=frames><span class=secno>16.3.3 </span>Frames</h4> <p>The <dfn id=frameset><code>frameset</code></dfn> element acts as <a href=#the-body-element-0>the body element</a> in documents that use frames.</p> <p>The <code><a href=#frameset>frameset</a></code> element must implement the <code><a href=#htmlframesetelement>HTMLFrameSetElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlframesetelement>HTMLFrameSetElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-frameset-cols title=dom-frameset-cols>cols</a>; attribute DOMString <a href=#dom-frameset-rows title=dom-frameset-rows>rows</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onafterprint title=handler-window-onafterprint>onafterprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeprint title=handler-window-onbeforeprint>onbeforeprint</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onbeforeunload title=handler-window-onbeforeunload>onbeforeunload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onblur title=handler-window-onblur>onblur</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onerror title=handler-window-onerror>onerror</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onfocus title=handler-window-onfocus>onfocus</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onhashchange title=handler-window-onhashchange>onhashchange</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onload title=handler-window-onload>onload</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onmessage title=handler-window-onmessage>onmessage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onoffline title=handler-window-onoffline>onoffline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-ononline title=handler-window-ononline>ononline</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpagehide title=handler-window-onpagehide>onpagehide</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpageshow title=handler-window-onpageshow>onpageshow</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onpopstate title=handler-window-onpopstate>onpopstate</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onresize title=handler-window-onresize>onresize</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onscroll title=handler-window-onscroll>onscroll</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onstorage title=handler-window-onstorage>onstorage</a>; [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-window-onunload title=handler-window-onunload>onunload</a>; };</pre> <p>The <dfn id=dom-frameset-cols title=dom-frameset-cols><code>cols</code></dfn> and <dfn id=dom-frameset-rows title=dom-frameset-rows><code>rows</code></dfn> IDL attributes of the <code><a href=#frameset>frameset</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <code><a href=#frameset>frameset</a></code> element must support the following <a href=#event-handler-content-attributes>event handler content attributes</a> exposing the <a href=#event-handlers>event handlers</a> of the <code><a href=#window>Window</a></code> object:</p> <ul class=brief><li><code title=handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code></li> <li><code title=handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>onbeforeprint</a></code></li> <li><code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code></li> <li><code title=handler-window-onblur><a href=#handler-window-onblur>onblur</a></code></li> <li><code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code></li> <li><code title=handler-window-onfocus><a href=#handler-window-onfocus>onfocus</a></code></li> <li><code title=handler-window-onhashchange><a href=#handler-window-onhashchange>onhashchange</a></code></li> <li><code title=handler-window-onload><a href=#handler-window-onload>onload</a></code></li> <li><code title=handler-window-onmessage><a href=#handler-window-onmessage>onmessage</a></code></li> <li><code title=handler-window-onoffline><a href=#handler-window-onoffline>onoffline</a></code></li> <li><code title=handler-window-ononline><a href=#handler-window-ononline>ononline</a></code></li> <li><code title=handler-window-onpagehide><a href=#handler-window-onpagehide>onpagehide</a></code></li> <li><code title=handler-window-onpageshow><a href=#handler-window-onpageshow>onpageshow</a></code></li> <li><code title=handler-window-onpopstate><a href=#handler-window-onpopstate>onpopstate</a></code></li> <li><code title=handler-window-onresize><a href=#handler-window-onresize>onresize</a></code></li> <li><code title=handler-window-onscroll><a href=#handler-window-onscroll>onscroll</a></code></li> <li><code title=handler-window-onstorage><a href=#handler-window-onstorage>onstorage</a></code></li> <li><code title=handler-window-onunload><a href=#handler-window-onunload>onunload</a></code></li> </ul><p>The DOM interface also exposes <a href=#event-handler-idl-attributes>event handler IDL attributes</a> that mirror those on the <code><a href=#window>Window</a></code> element.</p> <p>The <code title=handler-window-onblur><a href=#handler-window-onblur>onblur</a></code>, <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code>, <code title=handler-window-onfocus><a href=#handler-window-onfocus>onfocus</a></code>, <code title=handler-window-onload><a href=#handler-window-onload>onload</a></code>, and <code title=handler-window-onscroll><a href=#handler-window-onscroll>onscroll</a></code> <a href=#event-handler-idl-attributes>event handler IDL attributes</a> of the <code><a href=#window>Window</a></code> object, exposed on the <code><a href=#frameset>frameset</a></code> element, shadow the generic <a href=#event-handler-idl-attributes>event handler IDL attributes</a> with the same names normally supported by <a href=#html-elements>HTML elements</a>.</p> <hr><p>The <dfn id=frame><code>frame</code></dfn> element defines a <a href=#nested-browsing-context>nested browsing context</a> similar to the <code><a href=#the-iframe-element>iframe</a></code> element, but rendered within a <code><a href=#frameset>frameset</a></code> element.</p> <p>When the browsing context is created, if a <code title=attr-frame-src>src</code> attribute is present, the user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of that attribute, relative to the element, and if that is successful, must then <a href=#navigate>navigate</a><!--DONAV frame--> the element's browsing context to the resulting <a href=#absolute-url>absolute URL</a>, with <a href=#replacement-enabled>replacement enabled</a>, and with the <code><a href=#frame>frame</a></code> element's document's <a href=#browsing-context>browsing context</a> as the <a href=#source-browsing-context>source browsing context</a>.</p> <p>Whenever the <code title=attr-frame-src>src</code> attribute is set, the user agent must <a href=#resolve-a-url title="resolve a url">resolve</a> the value of that attribute, relative to the element, and if that is successful, the nested <a href=#browsing-context>browsing context</a> must be <a href=#navigate title=navigate>navigated</a><!--DONAV frame--> to the resulting <a href=#absolute-url>absolute URL</a>, with the <code><a href=#frame>frame</a></code> element's document's <a href=#browsing-context>browsing context</a> as the <a href=#source-browsing-context>source browsing context</a>.</p> <p>When the browsing context is created, if a <code title=attr-frame-name>name</code> attribute is present, the <a href=#browsing-context-name>browsing context name</a> must be set to the value of this attribute; otherwise, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</p> <p>Whenever the <code title=attr-frame-name>name</code> attribute is set, the nested <a href=#browsing-context>browsing context</a>'s <a href=#browsing-context-name title="browsing context name">name</a> must be changed to the new value. If the attribute is removed, the <a href=#browsing-context-name>browsing context name</a> must be set to the empty string.</p> <p>When content loads in a <code><a href=#frame>frame</a></code>, after any <code title=event-load>load</code> events are fired within the content itself, the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#frame>frame</a></code> element. When content fails to load (e.g. due to a network error), then the user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the element instead.</p> <p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> above is the <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p> <p>When there is an <a href=#active-parser>active parser</a> in the <code><a href=#frame>frame</a></code>, and when anything in the <code><a href=#frame>frame</a></code> is <a href=#delay-the-load-event title="delay the load event">delaying the load event</a> of the <code><a href=#frame>frame</a></code>'s <a href=#browsing-context>browsing context</a>'s <a href=#active-document>active document</a>, the <code><a href=#frame>frame</a></code> must <a href=#delay-the-load-event>delay the load event</a> of its document.</p> <p>The <code><a href=#frame>frame</a></code> element must implement the <code><a href=#htmlframeelement>HTMLFrameElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlframeelement>HTMLFrameElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-frame-name title=dom-frame-name>name</a>; attribute DOMString <a href=#dom-frame-scrolling title=dom-frame-scrolling>scrolling</a>; attribute DOMString <a href=#dom-frame-src title=dom-frame-src>src</a>; attribute DOMString <a href=#dom-frame-frameborder title=dom-frame-frameBorder>frameBorder</a>; attribute DOMString <a href=#dom-frame-longdesc title=dom-frame-longDesc>longDesc</a>; attribute boolean <a href=#dom-frame-noresize title=dom-frame-noResize>noResize</a>; readonly attribute Document? <a href=#dom-frame-contentdocument title=dom-frame-contentDocument>contentDocument</a>; readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-frame-contentwindow title=dom-frame-contentWindow>contentWindow</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-frame-marginheight title=dom-frame-marginHeight>marginHeight</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-frame-marginwidth title=dom-frame-marginWidth>marginWidth</a>; };</pre> <p>The <dfn id=dom-frame-name title=dom-frame-name><code>name</code></dfn>, <dfn id=dom-frame-scrolling title=dom-frame-scrolling><code>scrolling</code></dfn>, and <dfn id=dom-frame-src title=dom-frame-src><code>src</code></dfn> IDL attributes of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-frame-frameborder title=dom-frame-frameBorder><code>frameBorder</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-frame-frameborder>frameborder</code> content attribute.</p> <p>The <dfn id=dom-frame-longdesc title=dom-frame-longDesc><code>longDesc</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-frame-longdesc>longdesc</code> content attribute, which for the purposes of reflection is defined as containing a <a href=#url>URL</a>.</p> <p>The <dfn id=dom-frame-noresize title=dom-frame-noResize><code>noResize</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-frame-noresize>noresize</code> content attribute.</p> <p>The <dfn id=dom-frame-contentdocument title=dom-frame-contentDocument><code>contentDocument</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must return the <code><a href=#document>Document</a></code> object of the <a href=#active-document>active document</a> of the <code><a href=#frame>frame</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>The <dfn id=dom-frame-contentwindow title=dom-frame-contentWindow><code>contentWindow</code></dfn> IDL attribute must return the <code><a href=#windowproxy>WindowProxy</a></code> object of the <code><a href=#frame>frame</a></code> element's <a href=#nested-browsing-context>nested browsing context</a>.</p> <p>The <dfn id=dom-frame-marginheight title=dom-frame-marginHeight><code>marginHeight</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-frame-marginheight>marginheight</code> content attribute.</p> <p>The <dfn id=dom-frame-marginwidth title=dom-frame-marginWidth><code>marginWidth</code></dfn> IDL attribute of the <code><a href=#frame>frame</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-frame-marginwidth>marginwidth</code> content attribute.</p> <h4 id=other-elements,-attributes-and-apis><span class=secno>16.3.4 </span>Other elements, attributes and APIs</h4> <!-- alphabetical by name and attribute --> <p>User agents must treat <code><a href=#acronym>acronym</a></code> elements in a manner equivalent to <code><a href=#the-abbr-element>abbr</a></code> elements in terms of semantics and for purposes of rendering.</p> <hr><pre class=idl>partial interface <a href=#htmlanchorelement>HTMLAnchorElement</a> { attribute DOMString <a href=#dom-a-coords title=dom-a-coords>coords</a>; attribute DOMString <a href=#dom-a-charset title=dom-a-charset>charset</a>; attribute DOMString <a href=#dom-a-name title=dom-a-name>name</a>; attribute DOMString <a href=#dom-a-rev title=dom-a-rev>rev</a>; attribute DOMString <a href=#dom-a-shape title=dom-a-shape>shape</a>; };</pre> <p>The <dfn id=dom-a-coords title=dom-a-coords><code>coords</code></dfn>, <dfn id=dom-a-charset title=dom-a-charset><code>charset</code></dfn>, <dfn id=dom-a-name title=dom-a-name><code>name</code></dfn>, <dfn id=dom-a-rev title=dom-a-rev><code>rev</code></dfn>, and <dfn id=dom-a-shape title=dom-a-shape><code>shape</code></dfn> IDL attributes of the <code><a href=#the-a-element>a</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlareaelement>HTMLAreaElement</a> { attribute boolean <a href=#dom-area-nohref title=dom-area-noHref>noHref</a>; };</pre> <p>The <dfn id=dom-area-nohref title=dom-area-noHref><code>noHref</code></dfn> IDL attribute of the <code><a href=#the-area-element>area</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-area-nohref><a href=#attr-area-nohref>nohref</a></code> content attribute.</p> <hr><p>The <code><a href=#basefont>basefont</a></code> element must implement the <code><a href=#htmlbasefontelement>HTMLBaseFontElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlbasefontelement>HTMLBaseFontElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute DOMString <a href=#dom-basefont-color title=dom-basefont-color>color</a>; attribute DOMString <a href=#dom-basefont-face title=dom-basefont-face>face</a>; attribute long <a href=#dom-basefont-size title=dom-basefont-size>size</a>; <!-- yes, long, not DOMString (so says DOM2 HTML) --> };</pre> <p>The <dfn id=dom-basefont-color title=dom-basefont-color><code>color</code></dfn>, <dfn id=dom-basefont-face title=dom-basefont-face><code>face</code></dfn>, and <dfn id=dom-basefont-size title=dom-basefont-size><code>size</code></dfn> IDL attributes of the <code><a href=#basefont>basefont</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlbodyelement>HTMLBodyElement</a> { [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-body-text title=dom-body-text>text</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-body-link title=dom-body-link>link</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-body-vlink title=dom-body-vLink>vLink</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-body-alink title=dom-body-aLink>aLink</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-body-bgcolor title=dom-body-bgColor>bgColor</a>; attribute DOMString <a href=#dom-body-background title=dom-body-background>background</a>; };</pre> <p>The <dfn id=dom-body-text title=dom-body-text><code>text</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-body-text><a href=#attr-body-text>text</a></code> content attribute.</p> <p>The <dfn id=dom-body-link title=dom-body-link><code>link</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-body-link><a href=#attr-body-link>link</a></code> content attribute.</p> <p>The <dfn id=dom-body-alink title=dom-body-aLink><code>aLink</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-body-alink><a href=#attr-body-alink>alink</a></code> content attribute.</p> <p>The <dfn id=dom-body-vlink title=dom-body-vLink><code>vLink</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-body-vlink><a href=#attr-body-vlink>vlink</a></code> content attribute.</p> <p>The <dfn id=dom-body-bgcolor title=dom-body-bgColor><code>bgColor</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-body-bgcolor><a href=#attr-body-bgcolor>bgcolor</a></code> content attribute.</p> <p>The <dfn id=dom-body-background title=dom-body-background><code>background</code></dfn> IDL attribute of the <code><a href=#the-body-element>body</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-background><a href=#attr-background>background</a></code> content attribute. (The <code title=attr-background><a href=#attr-background>background</a></code> content is <em>not</em> defined to contain a <a href=#url>URL</a>, despite rules regarding its handling in the rendering section above.)</p> <hr><pre class=idl>partial interface <a href=#htmlbrelement>HTMLBRElement</a> { attribute DOMString <a href=#dom-br-clear title=dom-br-clear>clear</a>; };</pre> <p>The <dfn id=dom-br-clear title=dom-br-clear><code>clear</code></dfn> IDL attribute of the <code><a href=#the-br-element>br</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmltablecaptionelement>HTMLTableCaptionElement</a> { attribute DOMString <a href=#dom-caption-align title=dom-caption-align>align</a>; };</pre> <p>The <dfn id=dom-caption-align title=dom-caption-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-caption-element>caption</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmltablecolelement>HTMLTableColElement</a> { attribute DOMString <a href=#dom-col-align title=dom-col-align>align</a>; attribute DOMString <a href=#dom-col-ch title=dom-col-ch>ch</a>; attribute DOMString <a href=#dom-col-choff title=dom-col-chOff>chOff</a>; attribute DOMString <a href=#dom-col-valign title=dom-col-vAlign>vAlign</a>; attribute DOMString <a href=#dom-col-width title=dom-col-width>width</a>; };</pre> <p>The <dfn id=dom-col-align title=dom-col-align><code>align</code></dfn> and <dfn id=dom-col-width title=dom-col-width><code>width</code></dfn> IDL attributes of the <code><a href=#the-col-element>col</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-col-ch title=dom-col-ch><code>ch</code></dfn> IDL attribute of the <code><a href=#the-col-element>col</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-col-char><a href=#attr-col-char>char</a></code> content attribute.</p> <p>The <dfn id=dom-col-choff title=dom-col-chOff><code>chOff</code></dfn> IDL attribute of the <code><a href=#the-col-element>col</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-col-charoff><a href=#attr-col-charoff>charoff</a></code> content attribute.</p> <p>The <dfn id=dom-col-valign title=dom-col-vAlign><code>vAlign</code></dfn> IDL attribute of the <code><a href=#the-col-element>col</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-col-valign><a href=#attr-col-valign>valign</a></code> content attribute.</p> <hr><p>User agents must treat <code><a href=#dir>dir</a></code> elements in a manner equivalent to <code><a href=#the-ul-element>ul</a></code> elements in terms of semantics and for purposes of rendering.</p> <p>The <code><a href=#dir>dir</a></code> element must implement the <code><a href=#htmldirectoryelement>HTMLDirectoryElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmldirectoryelement>HTMLDirectoryElement</dfn> : <a href=#htmlelement>HTMLElement</a> { attribute boolean <a href=#dom-dir-compact title=dom-dir-compact>compact</a>; };</pre> <p>The <dfn id=dom-dir-compact title=dom-dir-compact><code>compact</code></dfn> IDL attribute of the <code><a href=#dir>dir</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmldivelement>HTMLDivElement</a> { attribute DOMString <a href=#dom-div-align title=dom-div-align>align</a>; };</pre> <p>The <dfn id=dom-div-align title=dom-div-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-div-element>div</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmldlistelement>HTMLDListElement</a> { attribute boolean <a href=#dom-dl-compact title=dom-dl-compact>compact</a>; };</pre> <p>The <dfn id=dom-dl-compact title=dom-dl-compact><code>compact</code></dfn> IDL attribute of the <code><a href=#the-dl-element>dl</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlembedelement>HTMLEmbedElement</a> { attribute DOMString <a href=#dom-embed-align title=dom-embed-align>align</a>; attribute DOMString <a href=#dom-embed-name title=dom-embed-name>name</a>; };</pre> <p>The <dfn id=dom-embed-name title=dom-embed-name><code>name</code></dfn> and <dfn id=dom-embed-align title=dom-embed-align><code>align</code></dfn> IDL attributes of the <code><a href=#the-embed-element>embed</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><p>The <code><a href=#font>font</a></code> element must implement the <code><a href=#htmlfontelement>HTMLFontElement</a></code> interface.</p> <pre class=idl>interface <dfn id=htmlfontelement>HTMLFontElement</dfn> : <a href=#htmlelement>HTMLElement</a> { [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-font-color title=dom-font-color>color</a>; attribute DOMString <a href=#dom-font-face title=dom-font-face>face</a>; attribute DOMString <a href=#dom-font-size title=dom-font-size>size</a>; <!-- yes, DOMString, not long (so says DOM2 HTML) --> };</pre> <p>The <dfn id=dom-font-color title=dom-font-color><code>color</code></dfn>, <dfn id=dom-font-face title=dom-font-face><code>face</code></dfn>, and <dfn id=dom-font-size title=dom-font-size><code>size</code></dfn> IDL attributes of the <code><a href=#font>font</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlheadingelement>HTMLHeadingElement</a> { attribute DOMString <a href=#dom-hx-align title=dom-hx-align>align</a>; };</pre> <p>The <dfn id=dom-hx-align title=dom-hx-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><p class=note>The <dfn id=dom-head-profile title=dom-head-profile><code>profile</code></dfn> IDL attribute on <code><a href=#the-head-element>head</a></code> elements (with the <code><a href=#htmlheadelement>HTMLHeadElement</a></code> interface) is intentionally omitted. Unless so required by <a href=#other-applicable-specifications title="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 class=idl>partial interface <a href=#htmlhrelement>HTMLHRElement</a> { attribute DOMString <a href=#dom-hr-align title=dom-hr-align>align</a>; attribute DOMString <a href=#dom-hr-color title=dom-hr-color>color</a>; attribute boolean <a href=#dom-hr-noshade title=dom-hr-noShade>noShade</a>; attribute DOMString <a href=#dom-hr-size title=dom-hr-size>size</a>; attribute DOMString <a href=#dom-hr-width title=dom-hr-width>width</a>; };</pre> <p>The <dfn id=dom-hr-align title=dom-hr-align><code>align</code></dfn>, <dfn id=dom-hr-color title=dom-hr-color><code>color</code></dfn>, <dfn id=dom-hr-size title=dom-hr-size><code>size</code></dfn>, and <dfn id=dom-hr-width title=dom-hr-width><code>width</code></dfn> IDL attributes of the <code><a href=#the-hr-element>hr</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-hr-noshade title=dom-hr-noShade><code>noShade</code></dfn> IDL attribute of the <code><a href=#the-hr-element>hr</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-input-noshade>noshade</code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmlhtmlelement>HTMLHtmlElement</a> { attribute DOMString <a href=#dom-html-version title=dom-html-version>version</a>; };</pre> <p>The <dfn id=dom-html-version title=dom-html-version><code>version</code></dfn> IDL attribute of the <code><a href=#the-html-element>html</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmliframeelement>HTMLIFrameElement</a> { attribute DOMString <a href=#dom-iframe-align title=dom-iframe-align>align</a>; attribute DOMString <a href=#dom-iframe-scrolling title=dom-iframe-scrolling>scrolling</a>; attribute DOMString <a href=#dom-iframe-frameborder title=dom-iframe-frameBorder>frameBorder</a>; attribute DOMString <a href=#dom-iframe-longdesc title=dom-iframe-longDesc>longDesc</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-iframe-marginheight title=dom-iframe-marginHeight>marginHeight</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-iframe-marginwidth title=dom-iframe-marginWidth>marginWidth</a>; };</pre> <p>The <dfn id=dom-iframe-align title=dom-iframe-align><code>align</code></dfn> and <dfn id=dom-iframe-scrolling title=dom-iframe-scrolling><code>scrolling</code></dfn> IDL attributes of the <code><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-iframe-frameborder title=dom-iframe-frameBorder><code>frameBorder</code></dfn> IDL attribute of the <code><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-iframe-frameborder><a href=#attr-iframe-frameborder>frameborder</a></code> content attribute.</p> <p>The <dfn id=dom-iframe-longdesc title=dom-iframe-longDesc><code>longDesc</code></dfn> IDL attribute of the <code><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect>reflect</a> the element's <code title=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 href=#url>URL</a>.</p> <p>The <dfn id=dom-iframe-marginheight title=dom-iframe-marginHeight><code>marginHeight</code></dfn> IDL attribute of the <code><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-iframe-marginheight><a href=#attr-iframe-marginheight>marginheight</a></code> content attribute.</p> <p>The <dfn id=dom-iframe-marginwidth title=dom-iframe-marginWidth><code>marginWidth</code></dfn> IDL attribute of the <code><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-iframe-marginwidth><a href=#attr-iframe-marginwidth>marginwidth</a></code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmlimageelement>HTMLImageElement</a> { attribute DOMString <a href=#dom-img-name title=dom-img-name>name</a>; attribute DOMString <a href=#dom-img-align title=dom-img-align>align</a>; attribute unsigned long <a href=#dom-img-hspace title=dom-img-hspace>hspace</a>; attribute unsigned long <a href=#dom-img-vspace title=dom-img-vspace>vspace</a>; attribute DOMString <a href=#dom-img-longdesc title=dom-img-longDesc>longDesc</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-img-border title=dom-img-border>border</a>; };</pre> <p>The <dfn id=dom-img-name title=dom-img-name><code>name</code></dfn>, <dfn id=dom-img-align title=dom-img-align><code>align</code></dfn>, <dfn id=dom-img-border title=dom-img-border><code>border</code></dfn>, <dfn id=dom-img-hspace title=dom-img-hspace><code>hspace</code></dfn>, and <dfn id=dom-img-vspace title=dom-img-vspace><code>vspace</code></dfn> IDL attributes of the <code><a href=#the-img-element>img</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-img-longdesc title=dom-img-longDesc><code>longDesc</code></dfn> IDL attribute of the <code><a href=#the-img-element>img</a></code> element must <a href=#reflect>reflect</a> the element's <code title=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 href=#url>URL</a>.</p> <!-- lowsrc is explicitly not given here, see http://www.w3.org/Bugs/Public/show_bug.cgi?id=10341 --> <hr><pre class=idl>partial interface <a href=#htmlinputelement>HTMLInputElement</a> { attribute DOMString <a href=#dom-input-align title=dom-input-align>align</a>; attribute DOMString <a href=#dom-input-usemap title=dom-input-useMap>useMap</a>; };</pre> <p>The <dfn id=dom-input-align title=dom-input-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-input-element>input</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-input-usemap title=dom-input-useMap><code>useMap</code></dfn> IDL attribute of the <code><a href=#the-input-element>input</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-input-usemap><a href=#attr-input-usemap>usemap</a></code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmllegendelement>HTMLLegendElement</a> { attribute DOMString <a href=#dom-legend-align title=dom-legend-align>align</a>; };</pre> <p>The <dfn id=dom-legend-align title=dom-legend-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-legend-element>legend</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmllielement>HTMLLIElement</a> { attribute DOMString <a href=#dom-li-type title=dom-li-type>type</a>; };</pre> <p>The <dfn id=dom-li-type title=dom-li-type><code>type</code></dfn> IDL attribute of the <code><a href=#the-li-element>li</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmllinkelement>HTMLLinkElement</a> { attribute DOMString <a href=#dom-link-charset title=dom-link-charset>charset</a>; attribute DOMString <a href=#dom-link-rev title=dom-link-rev>rev</a>; attribute DOMString <a href=#dom-link-target title=dom-link-target>target</a>; };</pre> <p>The <dfn id=dom-link-charset title=dom-link-charset><code>charset</code></dfn>, <dfn id=dom-link-rev title=dom-link-rev><code>rev</code></dfn>, and <dfn id=dom-link-target title=dom-link-target><code>target</code></dfn> IDL attributes of the <code><a href=#the-link-element>link</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><p>User agents must treat <code><a href=#listing>listing</a></code> elements in a manner equivalent to <code><a href=#the-pre-element>pre</a></code> elements in terms of semantics and for purposes of rendering.</p> <hr><pre class=idl>partial interface <a href=#htmlmenuelement>HTMLMenuElement</a> { attribute boolean <a href=#dom-menu-compact title=dom-menu-compact>compact</a>; };</pre> <p>The <dfn id=dom-menu-compact title=dom-menu-compact><code>compact</code></dfn> IDL attribute of the <code><a href=#the-menu-element>menu</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlmetaelement>HTMLMetaElement</a> { attribute DOMString <a href=#dom-meta-scheme title=dom-meta-scheme>scheme</a>; };</pre> <p>User agents may treat the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> content attribute on the <code><a href=#the-meta-element>meta</a></code> element as an extension of the element's <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> content attribute when processing a <code><a href=#the-meta-element>meta</a></code> element with a <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute whose value is one that the user agent recognizes as supporting the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute.</p> <p>User agents are encouraged to ignore the <code title=attr-meta-scheme><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 title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute.</p> <div class=example> <p>For example, if the user agent acts on <code><a href=#the-meta-element>meta</a></code> elements with <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attributes having the value "eGMS.subject.keyword", and knows that the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute is used with this metadata name, then it could take the <code title=attr-meta-scheme><a href=#attr-meta-scheme>scheme</a></code> attribute into account, acting as if it was an extension of the <code title=attr-meta-name><a href=#attr-meta-name>name</a></code> attribute. Thus the following two <code><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><!-- this markup is invalid --> <meta name="eGMS.subject.keyword" scheme="LGCL" content="Abandoned vehicles"> <meta name="eGMS.subject.keyword" scheme="ORLY" content="Mah car: kthxbye"></pre> <p>The recommended processing of this markup, however, would be equivalent to the following:</p> <pre><meta name="eGMS.subject.keyword" content="Abandoned vehicles"> <meta name="eGMS.subject.keyword" content="Mah car: kthxbye"></pre> </div> <p>The <dfn id=dom-meta-scheme title=dom-meta-scheme><code>scheme</code></dfn> IDL attribute of the <code><a href=#the-meta-element>meta</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlobjectelement>HTMLObjectElement</a> { attribute DOMString <a href=#dom-object-align title=dom-object-align>align</a>; attribute DOMString <a href=#dom-object-archive title=dom-object-archive>archive</a>; attribute DOMString <a href=#dom-object-code title=dom-object-code>code</a>; attribute boolean <a href=#dom-object-declare title=dom-object-declare>declare</a>; attribute unsigned long <a href=#dom-object-hspace title=dom-object-hspace>hspace</a>; attribute DOMString <a href=#dom-object-standby title=dom-object-standby>standby</a>; attribute unsigned long <a href=#dom-object-vspace title=dom-object-vspace>vspace</a>; attribute DOMString <a href=#dom-object-codebase title=dom-object-codeBase>codeBase</a>; attribute DOMString <a href=#dom-object-codetype title=dom-object-codeType>codeType</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-object-border title=dom-object-border>border</a>; };</pre> <p>The <dfn id=dom-object-align title=dom-object-align><code>align</code></dfn>, <dfn id=dom-object-archive title=dom-object-archive><code>archive</code></dfn>, <dfn id=dom-object-border title=dom-object-border><code>border</code></dfn>, <dfn id=dom-object-code title=dom-object-code><code>code</code></dfn>, <dfn id=dom-object-declare title=dom-object-declare><code>declare</code></dfn>, <dfn id=dom-object-hspace title=dom-object-hspace><code>hspace</code></dfn>, <dfn id=dom-object-standby title=dom-object-standby><code>standby</code></dfn>, and <dfn id=dom-object-vspace title=dom-object-vspace><code>vspace</code></dfn> IDL attributes of the <code><a href=#the-object-element>object</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-object-codebase title=dom-object-codeBase><code>codeBase</code></dfn> IDL attribute of the <code><a href=#the-object-element>object</a></code> element must <a href=#reflect>reflect</a> the element's <code title=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 href=#url>URL</a>.</p> <p>The <dfn id=dom-object-codetype title=dom-object-codeType><code>codeType</code></dfn> IDL attribute of the <code><a href=#the-object-element>object</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-object-codetype><a href=#attr-object-codetype>codetype</a></code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmlolistelement>HTMLOListElement</a> { attribute boolean <a href=#dom-ol-compact title=dom-ol-compact>compact</a>; };</pre> <p>The <dfn id=dom-ol-compact title=dom-ol-compact><code>compact</code></dfn> IDL attribute of the <code><a href=#the-ol-element>ol</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlparagraphelement>HTMLParagraphElement</a> { attribute DOMString <a href=#dom-p-align title=dom-p-align>align</a>; };</pre> <p>The <dfn id=dom-p-align title=dom-p-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-p-element>p</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlparamelement>HTMLParamElement</a> { attribute DOMString <a href=#dom-param-type title=dom-param-type>type</a>; attribute DOMString <a href=#dom-param-valuetype title=dom-param-valueType>valueType</a>; };</pre> <p>The <dfn id=dom-param-type title=dom-param-type><code>type</code></dfn> IDL attribute of the <code><a href=#the-param-element>param</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-param-valuetype title=dom-param-valueType><code>valueType</code></dfn> IDL attribute of the <code><a href=#the-param-element>param</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-param-valuetype><a href=#attr-param-valuetype>valuetype</a></code> content attribute.</p> <hr><p>User agents must treat <code><a href=#plaintext>plaintext</a></code> elements in a manner equivalent to <code><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 class=idl>partial interface <a href=#htmlpreelement>HTMLPreElement</a> { attribute long <a href=#dom-pre-width title=dom-pre-width>width</a>; };</pre> <p>The <dfn id=dom-pre-width title=dom-pre-width><code>width</code></dfn> IDL attribute of the <code><a href=#the-pre-element>pre</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <hr><pre class=idl>partial interface <a href=#htmlscriptelement>HTMLScriptElement</a> { attribute DOMString <a href=#dom-script-event title=dom-script-event>event</a>; attribute DOMString <a href=#dom-script-htmlfor title=dom-script-htmlFor>htmlFor</a>; };</pre> <p>The <dfn id=dom-script-event title=dom-script-event><code>event</code></dfn> and <dfn id=dom-script-htmlfor title=dom-script-htmlFor><code>htmlFor</code></dfn> IDL attributes of the <code><a href=#the-script-element>script</a></code> element must return the empty string on getting, and do nothing on setting.</p> <hr><pre class=idl>partial interface <a href=#htmltableelement>HTMLTableElement</a> { attribute DOMString <a href=#dom-table-align title=dom-table-align>align</a>; attribute DOMString <a href=#dom-table-frame title=dom-table-frame>frame</a>; attribute DOMString <a href=#dom-table-rules title=dom-table-rules>rules</a>; attribute DOMString <a href=#dom-table-summary title=dom-table-summary>summary</a>; attribute DOMString <a href=#dom-table-width title=dom-table-width>width</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-table-bgcolor title=dom-table-bgColor>bgColor</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-table-cellpadding title=dom-table-cellPadding>cellPadding</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-table-cellspacing title=dom-table-cellSpacing>cellSpacing</a>; };</pre> <p>The <dfn id=dom-table-align title=dom-table-align><code>align</code></dfn>, <dfn id=dom-table-frame title=dom-table-frame><code>frame</code></dfn>, <dfn id=dom-table-summary title=dom-table-summary><code>summary</code></dfn>, <dfn id=dom-table-rules title=dom-table-rules><code>rules</code></dfn>, and <dfn id=dom-table-width title=dom-table-width><code>width</code></dfn>, IDL attributes of the <code><a href=#the-table-element>table</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-table-bgcolor title=dom-table-bgColor><code>bgColor</code></dfn> IDL attribute of the <code><a href=#the-table-element>table</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-table-bgcolor><a href=#attr-table-bgcolor>bgcolor</a></code> content attribute.</p> <p>The <dfn id=dom-table-cellpadding title=dom-table-cellPadding><code>cellPadding</code></dfn> IDL attribute of the <code><a href=#the-table-element>table</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-table-cellpadding><a href=#attr-table-cellpadding>cellpadding</a></code> content attribute.</p> <p>The <dfn id=dom-table-cellspacing title=dom-table-cellSpacing><code>cellSpacing</code></dfn> IDL attribute of the <code><a href=#the-table-element>table</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-table-cellspacing><a href=#attr-table-cellspacing>cellspacing</a></code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmltablesectionelement>HTMLTableSectionElement</a> { attribute DOMString <a href=#dom-tbody-align title=dom-tbody-align>align</a>; attribute DOMString <a href=#dom-tbody-ch title=dom-tbody-ch>ch</a>; attribute DOMString <a href=#dom-tbody-choff title=dom-tbody-chOff>chOff</a>; attribute DOMString <a href=#dom-tbody-valign title=dom-tbody-vAlign>vAlign</a>; };</pre> <p>The <dfn id=dom-tbody-align title=dom-tbody-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-tbody-ch title=dom-tbody-ch><code>ch</code></dfn> IDL attribute of the <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tbody-char><a href=#attr-tbody-char>char</a></code> content attributes.</p> <p>The <dfn id=dom-tbody-choff title=dom-tbody-chOff><code>chOff</code></dfn> IDL attribute of the <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tbody-charoff><a href=#attr-tbody-charoff>charoff</a></code> content attributes.</p> <p>The <dfn id=dom-tbody-valign title=dom-tbody-vAlign><code>vAlign</code></dfn> IDL attribute of the <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-thead-element>thead</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> element must <a href=#reflect>reflect</a> the elements' <code title=attr-tbody-valign><a href=#attr-tbody-valign>valign</a></code> content attributes.</p> <hr><pre class=idl>partial interface <a href=#htmltablecellelement>HTMLTableCellElement</a> { attribute DOMString <a href=#dom-tdth-abbr title=dom-tdth-abbr>abbr</a>; attribute DOMString <a href=#dom-tdth-align title=dom-tdth-align>align</a>; attribute DOMString <a href=#dom-tdth-axis title=dom-tdth-axis>axis</a>; attribute DOMString <a href=#dom-tdth-height title=dom-tdth-height>height</a>; attribute DOMString <a href=#dom-tdth-width title=dom-tdth-width>width</a>; attribute DOMString <a href=#dom-tdth-ch title=dom-tdth-ch>ch</a>; attribute DOMString <a href=#dom-tdth-choff title=dom-tdth-chOff>chOff</a>; attribute boolean <a href=#dom-tdth-nowrap title=dom-tdth-noWrap>noWrap</a>; attribute DOMString <a href=#dom-tdth-valign title=dom-tdth-vAlign>vAlign</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-tdth-bgcolor title=dom-tdth-bgColor>bgColor</a>; };</pre> <p>The <dfn id=dom-tdth-abbr title=dom-tdth-abbr><code>abbr</code></dfn>, <dfn id=dom-tdth-align title=dom-tdth-align><code>align</code></dfn>, <dfn id=dom-tdth-axis title=dom-tdth-axis><code>axis</code></dfn>, <dfn id=dom-tdth-height title=dom-tdth-height><code>height</code></dfn>, and <dfn id=dom-tdth-width title=dom-tdth-width><code>width</code></dfn> IDL attributes of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <p>The <dfn id=dom-tdth-ch title=dom-tdth-ch><code>ch</code></dfn> IDL attribute of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tdth-char><a href=#attr-tdth-char>char</a></code> content attributes.</p> <p>The <dfn id=dom-tdth-choff title=dom-tdth-chOff><code>chOff</code></dfn> IDL attribute of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tdth-charoff><a href=#attr-tdth-charoff>charoff</a></code> content attributes.</p> <p>The <dfn id=dom-tdth-nowrap title=dom-tdth-noWrap><code>noWrap</code></dfn> IDL attribute of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tdth-nowrap><a href=#attr-tdth-nowrap>nowrap</a></code> content attributes.</p> <p>The <dfn id=dom-tdth-valign title=dom-tdth-vAlign><code>vAlign</code></dfn> IDL attribute of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> element must <a href=#reflect>reflect</a> the elements' <code title=attr-tdth-valign><a href=#attr-tdth-valign>valign</a></code> content attributes.</p> <p>The <dfn id=dom-tdth-bgcolor title=dom-tdth-bgColor><code>bgColor</code></dfn> IDL attribute of the <code><a href=#the-td-element>td</a></code> and <code><a href=#the-th-element>th</a></code> elements must <a href=#reflect>reflect</a> the elements' <code title=attr-tdth-bgcolor><a href=#attr-tdth-bgcolor>bgcolor</a></code> content attributes.</p> <hr><pre class=idl>partial interface <a href=#htmltablerowelement>HTMLTableRowElement</a> { attribute DOMString <a href=#dom-tr-align title=dom-tr-align>align</a>; attribute DOMString <a href=#dom-tr-ch title=dom-tr-ch>ch</a>; attribute DOMString <a href=#dom-tr-choff title=dom-tr-chOff>chOff</a>; attribute DOMString <a href=#dom-tr-valign title=dom-tr-vAlign>vAlign</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-tr-bgcolor title=dom-tr-bgColor>bgColor</a>; };</pre> <p>The <dfn id=dom-tr-align title=dom-tr-align><code>align</code></dfn> IDL attribute of the <code><a href=#the-tr-element>tr</a></code> element must <a href=#reflect>reflect</a> the content attribute of the same name.</p> <p>The <dfn id=dom-tr-ch title=dom-tr-ch><code>ch</code></dfn> IDL attribute of the <code><a href=#the-tr-element>tr</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-tr-char><a href=#attr-tr-char>char</a></code> content attribute.</p> <p>The <dfn id=dom-tr-choff title=dom-tr-chOff><code>chOff</code></dfn> IDL attribute of the <code><a href=#the-tr-element>tr</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-tr-charoff><a href=#attr-tr-charoff>charoff</a></code> content attribute.</p> <p>The <dfn id=dom-tr-valign title=dom-tr-vAlign><code>vAlign</code></dfn> IDL attribute of the <code><a href=#the-tr-element>tr</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-tr-valign><a href=#attr-tr-valign>valign</a></code> content attribute.</p> <p>The <dfn id=dom-tr-bgcolor title=dom-tr-bgColor><code>bgColor</code></dfn> IDL attribute of the <code><a href=#the-tr-element>tr</a></code> element must <a href=#reflect>reflect</a> the element's <code title=attr-tr-bgcolor><a href=#attr-tr-bgcolor>bgcolor</a></code> content attribute.</p> <hr><pre class=idl>partial interface <a href=#htmlulistelement>HTMLUListElement</a> { attribute boolean <a href=#dom-ul-compact title=dom-ul-compact>compact</a>; attribute DOMString <a href=#dom-ul-type title=dom-ul-type>type</a>; };</pre> <p>The <dfn id=dom-ul-compact title=dom-ul-compact><code>compact</code></dfn> and <dfn id=dom-ul-type title=dom-ul-type><code>type</code></dfn> IDL attributes of the <code><a href=#the-ul-element>ul</a></code> element must <a href=#reflect>reflect</a> the respective content attributes of the same name.</p> <hr><p>User agents must treat <code><a href=#xmp>xmp</a></code> elements in a manner equivalent to <code><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><p>The <code><a href=#bgsound>bgsound</a></code>, <code><a href=#isindex-0>isindex</a></code>, <code><a href=#multicol>multicol</a></code>, <code><a href=#nextid>nextid</a></code>, <code><a href=#rb>rb</a></code>, and <code><a href=#spacer>spacer</a></code> elements must use the <code><a href=#htmlunknownelement>HTMLUnknownElement</a></code> interface.</p> <!-- has to be explicitly listed because technically we define the elements in the spec, albeit as obsolete, and then we say that only elements not defined in this spec use HTMLUnknownElement. --> <hr><pre class=idl>partial interface <a href=#document>Document</a> { [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-fgcolor title=dom-document-fgColor>fgColor</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-linkcolor title=dom-document-linkColor>linkColor</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-vlinkcolor title=dom-document-vlinkColor>vlinkColor</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-alinkcolor title=dom-document-alinkColor>alinkColor</a>; [TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-bgcolor title=dom-document-bgColor>bgColor</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-anchors title=dom-document-anchors>anchors</a>; readonly attribute <a href=#htmlcollection>HTMLCollection</a> <a href=#dom-document-applets title=dom-document-applets>applets</a>; void <a href=#dom-document-clear title=dom-document-clear>clear</a>(); readonly attribute <a href=#htmlallcollection>HTMLAllCollection</a> <a href=#dom-document-all title=dom-document-all>all</a>; };</pre> <p>The attributes of the <code><a href=#document>Document</a></code> object listed in the first column of the following table must <a href=#reflect>reflect</a> the content attribute on <a href=#the-body-element-0>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-0>the body element</a> is a <code><a href=#the-body-element>body</a></code> element (as opposed to a <code><a href=#frameset>frameset</a></code> element). When there is no <a href=#the-body-element-0 title="the body element">body element</a> or if it is a <code><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 title=dom-document-fgColor><code>fgColor</code></dfn> <td><code title=attr-body-text><a href=#attr-body-text>text</a></code> <tr><td><dfn id=dom-document-linkcolor title=dom-document-linkColor><code>linkColor</code></dfn> <td><code title=attr-body-link><a href=#attr-body-link>link</a></code> <tr><td><dfn id=dom-document-vlinkcolor title=dom-document-vlinkColor><code>vlinkColor</code></dfn> <td><code title=attr-body-vlink><a href=#attr-body-vlink>vlink</a></code> <tr><td><dfn id=dom-document-alinkcolor title=dom-document-alinkColor><code>alinkColor</code></dfn> <td><code title=attr-body-alink><a href=#attr-body-alink>alink</a></code> <tr><td><dfn id=dom-document-bgcolor title=dom-document-bgColor><code>bgColor</code></dfn> <td><code title=attr-body-bgcolor><a href=#attr-body-bgcolor>bgcolor</a></code> </table><hr><p>The <dfn id=dom-document-anchors title=dom-document-anchors><code>anchors</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-a-element>a</a></code> elements with <code title=attr-a-name><a href=#attr-a-name>name</a></code> attributes.</p> <p>The <dfn id=dom-document-applets title=dom-document-applets><code>applets</code></dfn> attribute must return an <code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches only <code><a href=#the-applet-element>applet</a></code> elements.</p> <p>The <dfn id=dom-document-clear title=dom-document-clear><code>clear()</code></dfn> method must do nothing.</p> <hr><p>The <dfn id=dom-document-all title=dom-document-all><code>all</code></dfn> attribute must return an <code><a href=#htmlallcollection>HTMLAllCollection</a></code> rooted at the <code><a href=#document>Document</a></code> node, whose filter matches all elements.</p> <p>The object returned for <code title=dom-document-all><a href=#dom-document-all>all</a></code> has several unusual behaviors:</p> <ul><li><p>The user agent must act as if the ToBoolean() operator in JavaScript converts the object returned for <code title=dom-document-all><a href=#dom-document-all>all</a></code> to the false value.</li> <li><p>The user agent must act as if, for the purposes of the <code title="">==</code> and <code title="">!=</code> operators in JavaScript, the object returned for <code title=dom-document-all><a href=#dom-document-all>all</a></code> is equal to the <code title="">undefined</code> value.</li> <li><p>The user agent must act such that the <code title="">typeof</code> operator in JavaScript returns the string <code title="">undefined</code> when applied to the object returned for <code title=dom-document-all><a href=#dom-document-all>all</a></code>.</li> </ul><p class=note>These requirements are a <a href=#willful-violation>willful violation</a> of the JavaScript specification current at the time of writing (ECMAScript edition 5). The JavaScript specification requires that the ToBoolean() operator convert all objects to the true value, and does not have provisions for objects acting as if they were <code title="">undefined</code> for the purposes of certain operators. This violation is motivated by a desire for compatibility with two classes of legacy content: one that uses the presence of <code title=dom-document-all><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 title=dom-document-all><a href=#dom-document-all>document.all</a></code> object without testing for its presence first. <a href=#refsECMA262>[ECMA262]</a></p> </div> <h2 id=iana><span class=secno>17 </span>IANA considerations</h2> <!-- http://www.w3.org/2002/06/registering-mediatype.html --> <h3 id=text/html><span class=secno>17.1 </span><dfn><code>text/html</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type text/html --> <!-- Obsoletes: http://tools.ietf.org/html/rfc2854 Include a request to retire RFC 2854 persuant to section 6.4 of RFC 2026. --> <dl><dt>Type name:</dt> <dd>text</dd> <dt>Subtype name:</dt> <dd>html</dd> <dt>Required parameters:</dt> <dd>No required parameters</dd> <dt>Optional parameters:</dt> <dd> <dl><dt><code title="">charset</code></dt> <dd> <p>The <code title="">charset</code> parameter may be provided to definitively specify the <a href="#document's-character-encoding">document's character encoding</a>, overriding any <a href=#character-encoding-declaration title="character encoding declaration">character encoding declarations</a> in the document. The parameter's value must be the name of the character encoding used to serialize the file, must be a valid character encoding name, and must be an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the <a href=#preferred-mime-name>preferred MIME name</a> for that encoding. <a href=#refsIANACHARSET>[IANACHARSET]</a></p> </dd> </dl></dd> <dt>Encoding considerations:</dt> <dd> 8bit (see the section on <a href=#character-encoding-declaration title="character encoding declaration">character encoding declarations</a>) </dd> <dt>Security considerations:</dt> <dd> <p>Entire novels have been written about the security considerations that apply to HTML documents. Many are listed in this document, to which the reader is referred for more details. Some general concerns bear mentioning here, however:</p> <p>HTML is scripted language, and has a large number of APIs (some of which are described in this document). Script can expose the user to potential risks of information leakage, credential leakage, cross-site scripting attacks, cross-site request forgeries, and a host of other problems. While the designs in this specification are intended to be safe if implemented correctly, a full implementation is a massive undertaking and, as with any software, user agents are likely to have security bugs.</p> <p>Even without scripting, there are specific features in HTML which, for historical reasons, are required for broad compatibility with legacy content but that expose the user to unfortunate security problems. In particular, the <code><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=#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=#origin>origin</a> than any sensitive content on that site. Untrusted content can easily spoof any other page on the same origin, read data from that origin, cause scripts in that origin to execute, submit forms to and from that origin even if they are protected from cross-site request forgery attacks by unique tokens, and make use of any third-party resources exposed to or rights granted to that origin.</p> </dd> <dt>Interoperability considerations:</dt> <dd> Rules for processing both conforming and non-conforming content are defined in this specification. </dd> <dt>Published specification:</dt> <dd id=authors-using-html> This document is the relevant specification. Labeling a resource with the <code><a href=#text/html>text/html</a></code> type asserts that the resource is an <a href=#html-documents title="HTML documents">HTML document</a> using <a href=#syntax>the HTML syntax</a>. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers, tools for processing Web content, HTML authoring tools, search engines, validators. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>No sequence of bytes can uniquely identify an HTML document. More information on detecting HTML documents is available in the Media Type Sniffing specification. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></dd> <dt>File extension(s):</dt> <dd>"<code title="">html</code>" and "<code title="">htm</code>" are commonly, but certainly not exclusively, used as the extension for HTML documents.</dd> <dt>Macintosh file type code(s):</dt> <dd><code title="">TEXT</code></dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers used with <code><a href=#text/html>text/html</a></code> resources either refer to <a href=#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>17.2 </span><dfn><code>multipart/x-mixed-replace</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type multipart/x-mixed-replace --> <dl><dt>Type name:</dt> <dd>multipart</dd> <dt>Subtype name:</dt> <dd>x-mixed-replace</dd> <dt>Required parameters:</dt> <dd> <ul class=brief><li><code title="">boundary</code> (defined in RFC2046) <a href=#refsRFC2046>[RFC2046]</a> </ul></dd> <dt>Optional parameters:</dt> <dd>No optional parameters.</dd> <dt>Encoding considerations:</dt> <dd>binary</dd> <dt>Security considerations:</dt> <dd> Subresources of a <code><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><a href=#text/html>text/html</a></code>. </dd> <dt>Interoperability considerations:</dt> <dd> None. </dd> <dt>Published specification:</dt> <dd> This specification describes processing rules for Web browsers. Conformance requirements for generating resources with this type are the same as for <code>multipart/mixed</code>. <a href=#refsRFC2046>[RFC2046]</a> </dd> <dt>Applications that use this media type:</dt> <dd> This type is intended to be used in resources generated by Web servers, for consumption by Web browsers. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>No sequence of bytes can uniquely identify a <code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code> resource.</dd> <dt>File extension(s):</dt> <dd>No specific file extensions are recommended for this type.</dd> <dt>Macintosh file type code(s):</dt> <dd>No specific Macintosh file type codes are recommended for this type.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers used with <code><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code> resources apply to each body part as defined by the type used by that body part.</p> <h3 id=application/xhtml+xml><span class=secno>17.3 </span><dfn><code>application/xhtml+xml</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type application/xhtml+xml --> <!-- Obsoletes: http://tools.ietf.org/html/rfc3236 --> <dl><dt>Type name:</dt> <dd>application</dd> <dt>Subtype name:</dt> <dd>xhtml+xml</dd> <dt>Required parameters:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>Optional parameters:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>Encoding considerations:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>Security considerations:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>Interoperability considerations:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt id=authors-using-xhtml>Published specification:</dt> <dd> Labeling a resource with the <code><a href=#application/xhtml+xml>application/xhtml+xml</a></code> type asserts that the resource is an XML document that likely has a root element from the <a href=#html-namespace-0>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> </dd> <dt>Applications that use this media type:</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>Same as for <code>application/xml</code> <a href=#refsRFC3023>[RFC3023]</a></dd> <dt>File extension(s):</dt> <dd>"<code title="">xhtml</code>" and "<code title="">xht</code>" are sometimes used as extensions for XML resources that have a root element from the <a href=#html-namespace-0>HTML namespace</a>.</dd> <dt>Macintosh file type code(s):</dt> <dd><code title="">TEXT</code></dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers used with <code><a href=#application/xhtml+xml>application/xhtml+xml</a></code> resources have the same semantics as with any <a href=#xml-mime-type>XML MIME type</a>. <a href=#refsRFC3023>[RFC3023]</a></p> <h3 id=application/x-www-form-urlencoded><span class=secno>17.4 </span><dfn><code>application/x-www-form-urlencoded</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type application/x-www-form-urlencoded --> <dl><dt>Type name:</dt> <dd>application</dd> <dt>Subtype name:</dt> <dd>x-www-form-urlencoded</dd> <dt>Required parameters:</dt> <dd>No parameters</dd> <dt>Optional parameters:</dt> <dd>No parameters</dd> <dt>Encoding considerations:</dt> <dd>7bit (US-ASCII encoding of octets that themselves can be encoding text using any <a href=#ascii-compatible-character-encoding>ASCII-compatible character encoding</a>)</dd> <dt>Security considerations:</dt> <dd> <p>In isolation, an <code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code> payload poses no security risks. However, as this type is usually used as part of a form submission, all the risks that apply to HTML forms need to be considered in the context of this type.</p> </dd> <dt>Interoperability considerations:</dt> <dd> Rules for generating and processing <code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code> payloads are defined in this specification. </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. Algorithms for <a href=#application/x-www-form-urlencoded-encoding-algorithm title="application/x-www-form-urlencoded encoding algorithm">encoding</a> and <a href=#application/x-www-form-urlencoded-decoding-algorithm title="application/x-www-form-urlencoded decoding algorithm">decoding</a> are defined. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers and servers. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>There is no reliable mechanism for recognising <code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code> payloads.</dd> <dt>File extension(s):</dt> <dd>Not applicable.</dd> <dt>Macintosh file type code(s):</dt> <dd>Not applicable.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>This type is only intended to be used to describe HTML form submission payloads.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers have no meaning with the <code><a href=#application/x-www-form-urlencoded>application/x-www-form-urlencoded</a></code> type as this type is only used for uploaded payloads that do not have <a href=#url>URL</a> identifiers.</p> <h3 id=text/cache-manifest><span class=secno>17.5 </span><dfn><code>text/cache-manifest</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type text/cache-manifest --> <dl><dt>Type name:</dt> <dd>text</dd> <dt>Subtype name:</dt> <dd>cache-manifest</dd> <dt>Required parameters:</dt> <dd>No parameters</dd> <dt>Optional parameters:</dt> <dd>No parameters</dd> <dt>Encoding considerations:</dt> <dd>8bit (always UTF-8)</dd> <dt>Security considerations:</dt> <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> </dd> <dt>Interoperability considerations:</dt> <dd> Rules for processing both conforming and non-conforming content are defined in this specification. </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>Cache manifests begin with the string "<code title="">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.</dd> <dt>File extension(s):</dt> <dd>"<code title="">appcache</code>"</dd> <dt>Macintosh file type code(s):</dt> <dd>No specific Macintosh file type codes are recommended for this type.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers have no meaning with <code><a href=#text/cache-manifest>text/cache-manifest</a></code> resources.</p> <!--PING--> <h3 id=text/ping><span class=secno>17.6 </span><dfn><code>text/ping</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type text/ping --> <dl><dt>Type name:</dt> <dd>text</dd> <dt>Subtype name:</dt> <dd>ping</dd> <dt>Required parameters:</dt> <dd>No parameters</dd> <dt>Optional parameters:</dt> <dd>No parameters</dd> <dt>Encoding considerations:</dt> <dd>Not applicable.</dd> <dt>Security considerations:</dt> <dd> <p>If used exclusively in the fashion described in the context of <a href=#hyperlink-auditing>hyperlink auditing</a>, this type introduces no new security concerns.</p> </dd> <dt>Interoperability considerations:</dt> <dd> Rules applicable to this type are defined in this specification. </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd><code><a href=#text/ping>text/ping</a></code> resources always consist of the four bytes 0x50 0x49 0x4E 0x47 (ASCII 'PING').</dd> <dt>File extension(s):</dt> <dd>No specific file extension is recommended for this type.</dd> <dt>Macintosh file type code(s):</dt> <dd>No specific Macintosh file type codes are recommended for this type.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>Only intended for use with HTTP POST requests generated as part of a Web browser's processing of the <code title=attr-hyperlink-ping><a href=#ping>ping</a></code> attribute.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers have no meaning with <code><a href=#text/ping>text/ping</a></code> resources.</p> <!--PING--> <!--TTVTT--> <div data-component="other Hixie drafts (editor: Ian Hickson)"> <h3 id=text/vtt><span class=secno>17.7 </span><dfn><code>text/vtt</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type text/cues --> <dl><dt>Type name:</dt> <dd>text</dd> <dt>Subtype name:</dt> <dd>vtt</dd> <dt>Required parameters:</dt> <dd>No parameters</dd> <dt>Optional parameters:</dt> <dd>No parameters</dd> <dt>Encoding considerations:</dt> <dd>8bit (always UTF-8)</dd> <dt>Security considerations:</dt> <dd> <p>Text track files themselves pose no immediate risk unless sensitive information is included within the data. Implementations, however, are required to follow specific rules when processing text tracks, 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> </dd> <dt>Interoperability considerations:</dt> <dd> <p>Rules for processing both conforming and non-conforming content are defined in this specification.</p> <p>Some legacy files violate the requirement to use UTF-8.</p> </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. </dd> <dt>Applications that use this media type:</dt> <dd> Web browsers and other video players. </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd> <p>WebVTT files all begin with one of the following byte sequences:</p> <ul class=brief><li> EF BB BF 57 45 42 56 54 54 0A <li> EF BB BF 57 45 42 56 54 54 0D <li> EF BB BF 57 45 42 56 54 54 20 <li> EF BB BF 57 45 42 56 54 54 09 <li> 57 45 42 56 54 54 0A <li> 57 45 42 56 54 54 0D <li> 57 45 42 56 54 54 20 <li> 57 45 42 56 54 54 09 </ul><p class=note>(An optional UTF-8 BOM, the ASCII string "<code title="">WEBVTT</code>", and finally a space, tab, or line break.) </dd> <dt>File extension(s):</dt> <dd>"<code title="">vtt</code>"</dd> <dt>Macintosh file type code(s):</dt> <dd>No specific Macintosh file type codes are recommended for this type.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers have no meaning with <code><a href=#text/vtt>text/vtt</a></code> resources.</p> </div> <!--TTVTT--> <!--MD--> <h3 id=application/microdata+json><span class=secno>17.8 </span><dfn><code>application/microdata+json</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type application/microdata+json --> <dl><dt>Type name:</dt> <dd>application</dd> <dt>Subtype name:</dt> <dd>microdata+json</dd> <dt>Required parameters:</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Optional parameters:</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Encoding considerations:</dt> <dd>8bit (always UTF-8)</dd> <dt>Security considerations:</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Interoperability considerations:</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Published specification:</dt> <dd> Labeling a resource with the <code><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 title="">items</code>" consisting of an array of entries, each of which consists of an object with an entry called "<code title="">id</code>" whose value is a string, an entry called "<code title="">type</code>" whose value is another string, and an entry called "<code title="">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 title="">items</code>" entry. Thus, the relevant specifications are the JSON specification and this specification. <a href=#refsJSON>[JSON]</a> </dd> <dt>Applications that use this media type:</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>File extension(s):</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> <dt>Macintosh file type code(s):</dt> <dd>Same as for <code>application/json</code> <a href=#refsJSON>[JSON]</a></dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers used with <code><a href=#application/microdata+json>application/microdata+json</a></code> resources have the same semantics as when used with <code>application/json</code> (namely, at the time of writing, no semantics at all). <a href=#refsJSON>[JSON]</a></p> <!--MD--> <!--PEERCONNECTION--> <h3 id=application/html-peer-connection-data><span class=secno>17.9 </span><dfn><code>application/html-peer-connection-data</code></dfn></h3> <p>This registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA.</p> <!-- To: ietf-types@iana.org Subject: Registration of media type application/html-peer-connection-data --> <dl><dt>Type name:</dt> <dd>application</dd> <dt>Subtype name:</dt> <dd>html-peer-connection-data</dd> <dt>Required parameters:</dt> <dd>No required parameters</dd> <dt>Optional parameters:</dt> <dd>No optional parameters</dd> <dt>Encoding considerations:</dt> <dd>binary (this MIME type defines a binary protocol format which uses UTF-8 for text encoding)</dd> <dt>Security considerations:</dt> <dd> <p>This format is used for encoding UDP packets transmitted by potentially hostile Web page content via a trusted user agent to a destination selected by a potentially hostile remote server. To prevent this mechanism from being abused for cross-protocol attacks, all the data in these packets is masked so as to appear to be random noise. The intent of this masking is to reduce the potential attack scenarios to those already possible previously.</p> <p>However, this feature still allows random data to be sent to destinations that might not normally have been able to receive them, such as to hosts within the victim's intranet. If a service within such an intranet cannot handle receiving UDP packets containing random noise, it might be vulnerable to attack from this feature.</p> </dd> <dt>Interoperability considerations:</dt> <dd> Rules for processing both conforming and non-conforming content are defined in this specification. </dd> <dt>Published specification:</dt> <dd> This document is the relevant specification. </dd> <dt>Applications that use this media type:</dt> <dd> This type is only intended for use with SDP. <a href=#refsSDP>[SDP]</a> </dd> <dt>Additional information:</dt> <dd> <dl><dt>Magic number(s):</dt> <dd>No sequence of bytes can uniquely identify data in this format, as all data in this format is intentionally masked to avoid cross-protocol attacks.</dd> <dt>File extension(s):</dt> <dd>This format is not for use with files.</dd> <dt>Macintosh file type code(s):</dt> <dd>This format is not for use with files.</dd> </dl></dd> <dt>Person & email address to contact for further information:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Restrictions on usage:</dt> <dd>No restrictions apply.</dd> <dt>Author:</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Change controller:</dt> <dd>W3C</dd> </dl><p>Fragment identifiers cannot be used with <code><a href=#application/html-peer-connection-data>application/html-peer-connection-data</a></code> as URLs cannot be used to identify streams that use this format.</p> <!--PEERCONNECTION--> <!--PING--> <h3 id=ping-from><span class=secno>17.10 </span><dfn title=http-ping-from><code>Ping-From</code></dfn></h3> <p>This section describes a header field for registration in the Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p> <dl><dt>Header field name</dt> <dd>Ping-From</dd> <dt>Applicable protocol</dt> <dd>http</dd> <dt>Status</dt> <dd>standard</dd> <dt>Author/Change controller</dt> <dd>W3C</dd> <dt>Specification document(s)</dt> <dd> This document is the relevant specification. </dd> <dt>Related information</dt> <dd>None.</dd> </dl><h3 id=ping-to><span class=secno>17.11 </span><dfn title=http-ping-to><code>Ping-To</code></dfn></h3> <p>This section describes a header field for registration in the Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p> <dl><dt>Header field name</dt> <dd>Ping-To</dd> <dt>Applicable protocol</dt> <dd>http</dd> <dt>Status</dt> <dd>standard</dd> <dt>Author/Change controller</dt> <dd>W3C</dd> <dt>Specification document(s)</dt> <dd> This document is the relevant specification. </dd> <dt>Related information</dt> <dd>None.</dd> </dl><!--PING--><h3 id=web+-scheme-prefix><span class=secno>17.12 </span><dfn title=scheme-web><code>web+</code> scheme prefix</dfn></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=#refsRFC4395>[RFC4395]</a></p> <dl><dt>URI scheme name</dt> <dd> Schemes starting with the four characters "<code title="">web+</code>" followed by one or more letters in the range <code title="">a</code>-<code title="">z</code>. </dd> <dt>Status</dt> <dd>permanent</dd> <dt>URI scheme syntax</dt> <dd>Scheme-specific.</dd> <dt>URI scheme semantics</dt> <dd>Scheme-specific.</dd> <dt>Encoding considerations</dt> <dd>All "<code title="">web+</code>" schemes should use UTF-8 encodings were relevant.</dd> <dt>Applications/protocols that use this URI scheme name</dt> <dd>Scheme-specific.</dd> <dt>Interoperability considerations</dt> <dd>The scheme is expected to be used in the context of Web applications.</dd> <dt>Security considerations</dt> <dd> Any Web page is able to register a handler for all "<code title="">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. </dd> <dt>Contact</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>Author/Change controller</dt> <dd>Ian Hickson <ian@hixie.ch></dd> <dt>References</dt> <dd>W3C</dd> </dl><h2 class=no-num id=index>Index</h2> <div class=impl> <p>The following sections only cover conforming elements and features.</p> </div> <h3 class=no-num id=elements-1>Elements</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><a href=#the-a-element>a</a></code></th> <td>Hyperlink</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>*; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#transparent>transparent</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>; <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>; <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>; <code title=attr-hyperlink-ping><a href=#ping>ping</a></code>; <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>; <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>; <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>; <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code></td> <td><code><a href=#htmlanchorelement>HTMLAnchorElement</a></code></td> <tr><th><code><a href=#the-abbr-element>abbr</a></code></th> <td>Abbreviation</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-address-element>address</a></code></th> <td>Contact information for a page or <code><a href=#the-article-element>article</a></code> element</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-area-element>area</a></code></th> <td>Hyperlink or dead area on an image map</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-area-alt><a href=#attr-area-alt>alt</a></code>; <code title=attr-area-coords><a href=#attr-area-coords>coords</a></code>; <code title=attr-area-shape><a href=#attr-area-shape>shape</a></code>; <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>; <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code>; <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>download</a></code>; <code title=attr-hyperlink-ping><a href=#ping>ping</a></code>; <!--DOWNLOAD--><!--PING--> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>rel</a></code>; <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>media</a></code>; <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code>; <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>type</a></code></td> <td><code><a href=#htmlareaelement>HTMLAreaElement</a></code></td> <tr><th><code><a href=#the-article-element>article</a></code></th> <td>Self-contained syndicatable or reusable composition</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-content title="Sectioning content">sectioning</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-aside-element>aside</a></code></th> <td>Sidebar for tangentially related content</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-content title="Sectioning content">sectioning</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-audio-element>audio</a></code></th> <td>Audio player</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-source-element>source</a></code>*; <a href=#transparent>transparent</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-media-src><a href=#attr-media-src>src</a></code>; <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code>; <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>; <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>; <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code>; <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code>; <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code>; <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code></td> <td><code><a href=#htmlaudioelement>HTMLAudioElement</a></code></td> <tr><th><code><a href=#the-b-element>b</a></code></th> <td>Keywords</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-base-element>base</a></code></th> <td>Base URL and default target <a href=#browsing-context>browsing context</a> for <a href=#attr-hyperlink-target title=attr-hyperlink-target>hyperlinks</a> and <a href=#attr-fs-target title=attr-fs-target>forms</a></td> <td><a href=#metadata-content title="Metadata content">metadata</a></td> <td><code><a href=#the-head-element>head</a></code></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-base-href><a href=#attr-base-href>href</a></code>; <code title=attr-base-target><a href=#attr-base-target>target</a></code></td> <td><code><a href=#htmlbaseelement>HTMLBaseElement</a></code></td> <tr><th><code><a href=#the-bdi-element>bdi</a></code></th> <td>Text directionality isolation</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-bdo-element>bdo</a></code></th> <td>Text directionality formatting</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-blockquote-element>blockquote</a></code></th> <td>A section quoted from another source</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-root title="Sectioning root">sectioning root</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-blockquote-cite><a href=#attr-blockquote-cite>cite</a></code></td> <td><code><a href=#htmlquoteelement>HTMLQuoteElement</a></code></td> <tr><th><code><a href=#the-body-element>body</a></code></th> <td>Document body</td> <td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td> <td><code><a href=#the-html-element>html</a></code></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code>; <code title=handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>onbeforeprint</a></code>; <code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code>; <code title=handler-window-onblur><a href=#handler-window-onblur>onblur</a></code>; <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code>; <code title=handler-window-onfocus><a href=#handler-window-onfocus>onfocus</a></code>; <code title=handler-window-onhashchange><a href=#handler-window-onhashchange>onhashchange</a></code>; <code title=handler-window-onload><a href=#handler-window-onload>onload</a></code>; <code title=handler-window-onmessage><a href=#handler-window-onmessage>onmessage</a></code>; <code title=handler-window-onoffline><a href=#handler-window-onoffline>onoffline</a></code>; <code title=handler-window-ononline><a href=#handler-window-ononline>ononline</a></code>; <code title=handler-window-onpagehide><a href=#handler-window-onpagehide>onpagehide</a></code>; <code title=handler-window-onpageshow><a href=#handler-window-onpageshow>onpageshow</a></code>; <code title=handler-window-onpopstate><a href=#handler-window-onpopstate>onpopstate</a></code>; <code title=handler-window-onresize><a href=#handler-window-onresize>onresize</a></code>; <code title=handler-window-onscroll><a href=#handler-window-onscroll>onscroll</a></code>; <code title=handler-window-onstorage><a href=#handler-window-onstorage>onstorage</a></code>; <code title=handler-window-onunload><a href=#handler-window-onunload>onunload</a></code></td> <td><code><a href=#htmlbodyelement>HTMLBodyElement</a></code></td> <tr><th><code><a href=#the-br-element>br</a></code></th> <td>Line break, e.g. in poem or postal address</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlbrelement>HTMLBRElement</a></code></td> <tr><th><code><a href=#the-button-element>button</a></code></th> <td>Button control</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>; <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>; <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>; <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>; <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code>; <code title=attr-button-type><a href=#attr-button-type>type</a></code>; <code title=attr-button-value><a href=#attr-button-value>value</a></code></td> <td><code><a href=#htmlbuttonelement>HTMLButtonElement</a></code></td> <tr><th><code><a href=#the-canvas-element>canvas</a></code></th> <td>Scriptable bitmap canvas</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#transparent>transparent</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-canvas-width><a href=#attr-canvas-width>width</a></code>; <code title=attr-canvas-height><a href=#attr-canvas-height>height</a></code></td> <td><code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code></td> <tr><th><code><a href=#the-caption-element>caption</a></code></th> <td>Table caption</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code></td> <tr><th><code><a href=#the-cite-element>cite</a></code></th> <td>Title of a work</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-code-element>code</a></code></th> <td>Computer code</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-col-element>col</a></code></th> <td>Table column</td> <td>none</td> <td><code><a href=#the-colgroup-element>colgroup</a></code></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-col-span><a href=#attr-col-span>span</a></code></td> <td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td> <tr><th><code><a href=#the-colgroup-element>colgroup</a></code></th> <td>Group of columns in a table</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code></td> <td><code><a href=#the-col-element>col</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></td> <td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td> <tr><th><code><a href=#the-command-element>command</a></code></th> <td>Menu command</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-head-element>head</a></code>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-command-type><a href=#attr-command-type>type</a></code>; <code title=attr-command-label><a href=#attr-command-label>label</a></code>; <code title=attr-command-icon><a href=#attr-command-icon>icon</a></code>; <code title=attr-command-disabled><a href=#attr-command-disabled>disabled</a></code>; <code title=attr-command-checked><a href=#attr-command-checked>checked</a></code>; <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>radiogroup</a></code></td> <td><code><a href=#htmlcommandelement>HTMLCommandElement</a></code></td> <tr><th><code><a href=#the-data-element>data</a></code></th> <td>Machine-readable equivalent</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-data-value><a href=#attr-data-value>value</a></code></td> <td><code><a href=#htmldataelement>HTMLDataElement</a></code></td> <tr><th><code><a href=#the-datalist-element>datalist</a></code></th> <td>Container for options for <a href=#attr-input-list title=attr-input-list>combo box control</a></td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>; <code><a href=#the-option-element>option</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmldatalistelement>HTMLDataListElement</a></code></td> <tr><th><code><a href=#the-dd-element>dd</a></code></th> <td>Content for corresponding <code><a href=#the-dt-element>dt</a></code> element(s)</td> <td>none</td> <td><code><a href=#the-dl-element>dl</a></code></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-del-element>del</a></code></th> <td>A removal from the document</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#transparent>transparent</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-mod-cite><a href=#attr-mod-cite>cite</a></code>; <code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code></td> <td><code><a href=#htmlmodelement>HTMLModElement</a></code></td> <tr><th><code><a href=#the-details-element>details</a></code></th> <td>Disclosure control for hiding details</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-root title="Sectioning root">sectioning root</a>; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-summary-element>summary</a></code>*; <a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-details-open><a href=#attr-details-open>open</a></code></td> <td><code><a href=#htmldetailselement>HTMLDetailsElement</a></code></td> <tr><th><code><a href=#the-dfn-element>dfn</a></code></th> <td>Defining instance</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-div-element>div</a></code></th> <td>Generic flow container</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmldivelement>HTMLDivElement</a></code></td> <tr><th><code><a href=#the-dl-element>dl</a></code></th> <td>Association list consisting of zero or more name-value groups</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-dt-element>dt</a></code>*; <code><a href=#the-dd-element>dd</a></code>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmldlistelement>HTMLDListElement</a></code></td> <tr><th><code><a href=#the-dt-element>dt</a></code></th> <td>Legend for corresponding <code><a href=#the-dd-element>dd</a></code> element(s)</td> <td>none</td> <td><code><a href=#the-dl-element>dl</a></code></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-em-element>em</a></code></th> <td>Stress emphasis</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-embed-element>embed</a></code></th> <td><a href=#plugin>Plugin</a></td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-embed-src><a href=#attr-embed-src>src</a></code>; <code title=attr-embed-type><a href=#attr-embed-type>type</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code>; any*</td> <td><code><a href=#htmlembedelement>HTMLEmbedElement</a></code></td> <tr><th><code><a href=#the-fieldset-element>fieldset</a></code></th> <td>Group of form controls</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-root title="Sectioning root">sectioning root</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-legend-element>legend</a></code>*; <a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code></td> <td><code><a href=#htmlfieldsetelement>HTMLFieldSetElement</a></code></td> <tr><th><code><a href=#the-figcaption-element>figcaption</a></code></th> <td>Caption for <code><a href=#the-figure-element>figure</a></code></td> <td>none</td> <td><code><a href=#the-figure-element>figure</a></code></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-figure-element>figure</a></code></th> <td>Figure with optional caption</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-root title="Sectioning root">sectioning root</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-figcaption-element>figcaption</a></code>*; <a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-footer-element>footer</a></code></th> <td>Footer for a page or section</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-form-element>form</a></code></th> <td>User-submittable form</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>accept-charset</a></code>; <code title=attr-fs-action><a href=#attr-fs-action>action</a></code>; <code title=attr-form-autocomplete><a href=#attr-form-autocomplete>autocomplete</a></code>; <code title=attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code>; <code title=attr-fs-method><a href=#attr-fs-method>method</a></code>; <code title=attr-form-name><a href=#attr-form-name>name</a></code>; <code title=attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code>; <code title=attr-fs-target><a href=#attr-fs-target>target</a></code></td> <td><code><a href=#htmlformelement>HTMLFormElement</a></code></td> <tr><th><code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></th> <td>Section heading</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#heading-content title="Heading content">heading</a></td> <td><code><a href=#the-hgroup-element>hgroup</a></code>; <a href=#flow-content title="Flow content">flow</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlheadingelement>HTMLHeadingElement</a></code></td> <tr><th><code><a href=#the-head-element>head</a></code></th> <td>Container for document metadata</td> <td>none</td> <td><code><a href=#the-html-element>html</a></code></td> <td><a href=#metadata-content title="Metadata content">metadata content</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlheadelement>HTMLHeadElement</a></code></td> <tr><th><code><a href=#the-header-element>header</a></code></th> <td>Introductory or navigational aids for a page or section</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-hgroup-element>hgroup</a></code></th> <td>heading group</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#heading-content title="Heading content">heading</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and/or <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-hr-element>hr</a></code></th> <td>Thematic break</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlhrelement>HTMLHRElement</a></code></td> <tr><th><code><a href=#the-html-element>html</a></code></th> <td>Root element</td> <td>none</td> <td>none*</td> <td><code><a href=#the-head-element>head</a></code>*; <code><a href=#the-body-element>body</a></code>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code></td> <td><code><a href=#htmlhtmlelement>HTMLHtmlElement</a></code></td> <tr><th><code><a href=#the-i-element>i</a></code></th> <td>Alternate voice</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-iframe-element>iframe</a></code></th> <td><a href=#nested-browsing-context>Nested browsing context</a></td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>text*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-iframe-src><a href=#attr-iframe-src>src</a></code>; <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>srcdoc</a></code>; <code title=attr-iframe-name><a href=#attr-iframe-name>name</a></code>; <code title=attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code>; <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>seamless</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code></td> <td><code><a href=#htmliframeelement>HTMLIFrameElement</a></code></td> <tr><th><code><a href=#the-img-element>img</a></code></th> <td>Image</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a>*</td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-img-alt><a href=#attr-img-alt>alt</a></code>; <code title=attr-img-src><a href=#attr-img-src>src</a></code>; <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code>; <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code>; <code title=attr-img-ismap><a href=#attr-img-ismap>ismap</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code></td> <td><code><a href=#htmlimageelement>HTMLImageElement</a></code></td> <tr><th><code><a href=#the-input-element>input</a></code></th> <td>Form control</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>*; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#category-reset title=category-reset>resettable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-input-accept><a href=#attr-input-accept>accept</a></code>; <code title=attr-input-alt><a href=#attr-input-alt>alt</a></code>; <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>autocomplete</a></code>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code>; <code title=attr-input-checked><a href=#attr-input-checked>checked</a></code>; <code title=attr-input-dirname><a href=#attr-input-dirname>dirname</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>; <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>; <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>; <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>; <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code>; <code title=attr-input-list><a href=#attr-input-list>list</a></code>; <code title=attr-input-max><a href=#attr-input-max>max</a></code>; <code title=attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code>; <code title=attr-input-min><a href=#attr-input-min>min</a></code>; <code title=attr-input-multiple><a href=#attr-input-multiple>multiple</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code>; <code title=attr-input-pattern><a href=#attr-input-pattern>pattern</a></code>; <code title=attr-input-placeholder><a href=#attr-input-placeholder>placeholder</a></code>; <code title=attr-input-readonly><a href=#attr-input-readonly>readonly</a></code>; <code title=attr-input-required><a href=#attr-input-required>required</a></code>; <code title=attr-input-size><a href=#attr-input-size>size</a></code>; <code title=attr-input-src><a href=#attr-input-src>src</a></code>; <code title=attr-input-step><a href=#attr-input-step>step</a></code>; <code title=attr-input-type><a href=#attr-input-type>type</a></code>; <code title=attr-input-value><a href=#attr-input-value>value</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code></td> <td><code><a href=#htmlinputelement>HTMLInputElement</a></code></td> <tr><th><code><a href=#the-ins-element>ins</a></code></th> <td>An addition to the document</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#transparent>transparent</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-mod-cite><a href=#attr-mod-cite>cite</a></code>; <code title=attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code></td> <td><code><a href=#htmlmodelement>HTMLModElement</a></code></td> <tr><th><code><a href=#the-kbd-element>kbd</a></code></th> <td>User input</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-keygen-element>keygen</a></code></th> <td>Cryptographic key-pair generator form control</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#category-reset title=category-reset>resettable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code>; <code title=attr-keygen-challenge><a href=#attr-keygen-challenge>challenge</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-keygen-keytype><a href=#attr-keygen-keytype>keytype</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code></td> <td><code><a href=#htmlkeygenelement>HTMLKeygenElement</a></code></td> <tr><th><code><a href=#the-label-element>label</a></code></th> <td>Caption for a form control</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-label-for><a href=#attr-label-for>for</a></code></td> <td><code><a href=#htmllabelelement>HTMLLabelElement</a></code></td> <tr><th><code><a href=#the-legend-element>legend</a></code></th> <td>Caption for <code><a href=#the-fieldset-element>fieldset</a></code></td> <td>none</td> <td><code><a href=#the-fieldset-element>fieldset</a></code></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmllegendelement>HTMLLegendElement</a></code></td> <tr><th><code><a href=#the-li-element>li</a></code></th> <td>List item</td> <td>none</td> <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-menu-element>menu</a></code></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-li-value><a href=#attr-li-value>value</a></code>*</td> <td><code><a href=#htmllielement>HTMLLIElement</a></code></td> <tr><th><code><a href=#the-link-element>link</a></code></th> <td>Link metadata</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a>*; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><code><a href=#the-head-element>head</a></code>; <code><a href=#the-noscript-element>noscript</a></code>*; <a href=#phrasing-content title="phrasing content">phrasing</a>*</td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-link-href><a href=#attr-link-href>href</a></code>; <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code>; <code title=attr-link-media><a href=#attr-link-media>media</a></code>; <code title=attr-link-hreflang><a href=#attr-link-hreflang>hreflang</a></code>; <code title=attr-link-type><a href=#attr-link-type>type</a></code>; <code title=attr-link-sizes><a href=#attr-link-sizes>sizes</a></code></td> <td><code><a href=#htmllinkelement>HTMLLinkElement</a></code></td> <tr><th><code><a href=#the-map-element>map</a></code></th> <td><a href=#image-map>Image map</a></td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#transparent>transparent</a>; <code><a href=#the-area-element>area</a></code>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-map-name><a href=#attr-map-name>name</a></code></td> <td><code><a href=#htmlmapelement>HTMLMapElement</a></code></td> <tr><th><code><a href=#the-mark-element>mark</a></code></th> <td>Highlight</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-menu-element>menu</a></code></th> <td>Menu of commands</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#interactive-content title="Interactive content">interactive</a>*</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-li-element>li</a></code>*; <a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-menu-type><a href=#attr-menu-type>type</a></code>; <code title=attr-menu-label><a href=#attr-menu-label>label</a></code></td> <td><code><a href=#htmlmenuelement>HTMLMenuElement</a></code></td> <tr><th><code><a href=#the-meta-element>meta</a></code></th> <td>Text metadata</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a>*; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><code><a href=#the-head-element>head</a></code>; <code><a href=#the-noscript-element>noscript</a></code>*; <a href=#phrasing-content title="phrasing content">phrasing</a>*</td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-meta-name><a href=#attr-meta-name>name</a></code>; <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>http-equiv</a></code>; <code title=attr-meta-content><a href=#attr-meta-content>content</a></code>; <code title=attr-meta-charset><a href=#attr-meta-charset>charset</a></code></td> <td><code><a href=#htmlmetaelement>HTMLMetaElement</a></code></td> <tr><th><code><a href=#the-meter-element>meter</a></code></th> <td>Gauge</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#category-label title=category-label>labelable</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-meter-value><a href=#attr-meter-value>value</a></code>; <code title=attr-meter-min><a href=#attr-meter-min>min</a></code>; <code title=attr-meter-max><a href=#attr-meter-max>max</a></code>; <code title=attr-meter-low><a href=#attr-meter-low>low</a></code>; <code title=attr-meter-high><a href=#attr-meter-high>high</a></code>; <code title=attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code></td> <td><code><a href=#htmlmeterelement>HTMLMeterElement</a></code></td> <tr><th><code><a href=#the-nav-element>nav</a></code></th> <td>Section with navigational links</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-content title="Sectioning content">sectioning</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-noscript-element>noscript</a></code></th> <td>Fallback content for script</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-head-element>head</a></code>*; <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td>varies*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-object-element>object</a></code></th> <td>Image, <a href=#nested-browsing-context>nested browsing context</a>, or <a href=#plugin>plugin</a></td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a>*; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-param-element>param</a></code>*; <a href=#transparent>transparent</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-object-data><a href=#attr-object-data>data</a></code>; <code title=attr-object-type><a href=#attr-object-type>type</a></code>; <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code>; <code title=attr-object-name><a href=#attr-object-name>name</a></code>; <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code></td> <td><code><a href=#htmlobjectelement>HTMLObjectElement</a></code></td> <tr><th><code><a href=#the-ol-element>ol</a></code></th> <td>Ordered list</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-li-element>li</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code>; <code title=attr-ol-start><a href=#attr-ol-start>start</a></code></td> <td><code><a href=#htmlolistelement>HTMLOListElement</a></code></td> <tr><th><code><a href=#the-optgroup-element>optgroup</a></code></th> <td>Group of options in a list box</td> <td>none</td> <td><code><a href=#the-select-element>select</a></code></td> <td><code><a href=#the-option-element>option</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code>; <code title=attr-optgroup-label><a href=#attr-optgroup-label>label</a></code></td> <td><code><a href=#htmloptgroupelement>HTMLOptGroupElement</a></code></td> <tr><th><code><a href=#the-option-element>option</a></code></th> <td>Option in a list box or combo box control</td> <td>none</td> <td><code><a href=#the-select-element>select</a></code>; <code><a href=#the-datalist-element>datalist</a></code>; <code><a href=#the-optgroup-element>optgroup</a></code></td> <td><a href=#text-content title="text content">text</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code>; <code title=attr-option-label><a href=#attr-option-label>label</a></code>; <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code>; <code title=attr-option-value><a href=#attr-option-value>value</a></code></td> <td><code><a href=#htmloptionelement>HTMLOptionElement</a></code></td> <tr><th><code><a href=#the-output-element>output</a></code></th> <td>Calculated output value</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-reset title=category-reset>resettable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-output-for><a href=#attr-output-for>for</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code></td> <td><code><a href=#htmloutputelement>HTMLOutputElement</a></code></td> <tr><th><code><a href=#the-p-element>p</a></code></th> <td>Paragraph</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlparagraphelement>HTMLParagraphElement</a></code></td> <tr><th><code><a href=#the-param-element>param</a></code></th> <td>Parameter for <code><a href=#the-object-element>object</a></code></td> <td>none</td> <td><code><a href=#the-object-element>object</a></code></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-param-name><a href=#attr-param-name>name</a></code>; <code title=attr-param-value><a href=#attr-param-value>value</a></code></td> <td><code><a href=#htmlparamelement>HTMLParamElement</a></code></td> <tr><th><code><a href=#the-pre-element>pre</a></code></th> <td>Block of preformatted text</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlpreelement>HTMLPreElement</a></code></td> <tr><th><code><a href=#the-progress-element>progress</a></code></th> <td>Progress bar</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#category-label title=category-label>labelable</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-progress-value><a href=#attr-progress-value>value</a></code>; <code title=attr-progress-max><a href=#attr-progress-max>max</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code></td> <td><code><a href=#htmlprogresselement>HTMLProgressElement</a></code></td> <tr><th><code><a href=#the-q-element>q</a></code></th> <td>Quotation</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-q-cite><a href=#attr-q-cite>cite</a></code></td> <td><code><a href=#htmlquoteelement>HTMLQuoteElement</a></code></td> <tr><th><code><a href=#the-rp-element>rp</a></code></th> <td>Parenthesis for ruby annotation text</td> <td>none</td> <td><code><a href=#the-ruby-element>ruby</a></code></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-rt-element>rt</a></code></th> <td>Ruby annotation text</td> <td>none</td> <td><code><a href=#the-ruby-element>ruby</a></code></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-ruby-element>ruby</a></code></th> <td>Ruby annotation(s)</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a>; <code><a href=#the-rt-element>rt</a></code>; <code><a href=#the-rp-element>rp</a></code>*</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-s-element>s</a></code></th> <td>Inaccurate text</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-samp-element>samp</a></code></th> <td>Computer output</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-script-element>script</a></code></th> <td>Embedded script</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-head-element>head</a></code>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>script, data, or script documentation*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-script-src><a href=#attr-script-src>src</a></code>; <code title=attr-script-async><a href=#attr-script-async>async</a></code>; <code title=attr-script-defer><a href=#attr-script-defer>defer</a></code>; <code title=attr-script-type><a href=#attr-script-type>type</a></code>; <code title=attr-script-charset><a href=#attr-script-charset>charset</a></code></td> <td><code><a href=#htmlscriptelement>HTMLScriptElement</a></code></td> <tr><th><code><a href=#the-section-element>section</a></code></th> <td>Generic document or application section</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#sectioning-content title="Sectioning content">sectioning</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-select-element>select</a></code></th> <td>List box control</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#category-reset title=category-reset>resettable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-option-element>option</a></code>, <code><a href=#the-optgroup-element>optgroup</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code>; <code title=attr-select-required><a href=#attr-select-required>required</a></code>; <code title=attr-select-size><a href=#attr-select-size>size</a></code></td> <td><code><a href=#htmlselectelement>HTMLSelectElement</a></code></td> <tr><th><code><a href=#the-small-element>small</a></code></th> <td>Side comment</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-source-element>source</a></code></th> <td>Media source for <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code></td> <td>none</td> <td><code><a href=#the-video-element>video</a></code>; <code><a href=#the-audio-element>audio</a></code></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-source-src><a href=#attr-source-src>src</a></code>; <code title=attr-source-type><a href=#attr-source-type>type</a></code>; <code title=attr-source-media><a href=#attr-source-media>media</a></code></td> <td><code><a href=#htmlsourceelement>HTMLSourceElement</a></code></td> <tr><th><code><a href=#the-span-element>span</a></code></th> <td>Generic phrasing container</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlspanelement>HTMLSpanElement</a></code></td> <tr><th><code><a href=#the-strong-element>strong</a></code></th> <td>Importance</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-style-element>style</a></code></th> <td>Embedded styling information</td> <td><a href=#metadata-content title="Metadata content">metadata</a>; <a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-head-element>head</a></code>; <code><a href=#the-noscript-element>noscript</a></code>*; <a href=#flow-content title="flow content">flow</a>*</td> <td>varies*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-style-media><a href=#attr-style-media>media</a></code>; <code title=attr-style-type><a href=#attr-style-type>type</a></code>; <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code></td> <td><code><a href=#htmlstyleelement>HTMLStyleElement</a></code></td> <tr><th><code><a href=#the-sub-and-sup-elements>sub</a></code></th> <td>Subscript</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-summary-element>summary</a></code></th> <td>Caption for <code><a href=#the-details-element>details</a></code></td> <td>none</td> <td><code><a href=#the-details-element>details</a></code></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-sub-and-sup-elements>sup</a></code></th> <td>Superscript</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-table-element>table</a></code></th> <td>Table</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-caption-element>caption</a></code>*; <code><a href=#the-colgroup-element>colgroup</a></code>*; <code><a href=#the-thead-element>thead</a></code>*; <code><a href=#the-tbody-element>tbody</a></code>*; <code><a href=#the-tfoot-element>tfoot</a></code>*; <code><a href=#the-tr-element>tr</a></code>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-table-border><a href=#attr-table-border>border</a></code></td> <td><code><a href=#htmltableelement>HTMLTableElement</a></code></td> <tr><th><code><a href=#the-tbody-element>tbody</a></code></th> <td>Group of rows in a table</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code></td> <td><code><a href=#the-tr-element>tr</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td> <tr><th><code><a href=#the-td-element>td</a></code></th> <td>Table cell</td> <td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td> <td><code><a href=#the-tr-element>tr</a></code></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>; <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>; <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code></td> <td><code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code></td> <tr><th><code><a href=#the-textarea-element>textarea</a></code></th> <td>Multiline text field</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#interactive-content title="Interactive content">interactive</a>; <a href=#category-listed title=category-listed>listed</a>; <a href=#category-label title=category-label>labelable</a>; <a href=#category-submit title=category-submit>submittable</a>; <a href=#category-reset title=category-reset>resettable</a>; <a href=#form-associated-element title="Form-associated element">form-associated</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#text-content title="text content">text</a></td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code>; <code title=attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code>; <code title=attr-textarea-dirname><a href=#attr-textarea-dirname>dirname</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>form</a></code>; <code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>name</a></code>; <code title=attr-textarea-placeholder><a href=#attr-textarea-placeholder>placeholder</a></code>; <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code>; <code title=attr-textarea-required><a href=#attr-textarea-required>required</a></code>; <code title=attr-textarea-rows><a href=#attr-textarea-rows>rows</a></code>; <code title=attr-textarea-wrap><a href=#attr-textarea-wrap>wrap</a></code></td> <td><code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code></td> <tr><th><code><a href=#the-tfoot-element>tfoot</a></code></th> <td>Group of footer rows in a table</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code></td> <td><code><a href=#the-tr-element>tr</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td> <tr><th><code><a href=#the-th-element>th</a></code></th> <td>Table header cell</td> <td>none</td> <td><code><a href=#the-tr-element>tr</a></code></td> <td><a href=#flow-content title="Flow content">flow</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>; <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>; <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code>; <code title=attr-th-scope><a href=#attr-th-scope>scope</a></code></td> <td><code><a href=#htmltableheadercellelement>HTMLTableHeaderCellElement</a></code></td> <tr><th><code><a href=#the-thead-element>thead</a></code></th> <td>Group of heading rows in a table</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code></td> <td><code><a href=#the-tr-element>tr</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td> <tr><th><code><a href=#the-title-element>title</a></code></th> <td>Document title</td> <td><a href=#metadata-content title="Metadata content">metadata</a></td> <td><code><a href=#the-head-element>head</a></code></td> <td><a href=#text-content title="text content">text</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltitleelement>HTMLTitleElement</a></code></td> <tr><th><code><a href=#the-tr-element>tr</a></code></th> <td>Table row</td> <td>none</td> <td><code><a href=#the-table-element>table</a></code>; <code><a href=#the-thead-element>thead</a></code>; <code><a href=#the-tbody-element>tbody</a></code>; <code><a href=#the-tfoot-element>tfoot</a></code></td> <td><code><a href=#the-th-element>th</a></code>*; <code><a href=#the-td-element>td</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmltablerowelement>HTMLTableRowElement</a></code></td> <tr><th><code><a href=#the-track-element>track</a></code></th> <td>Timed text track</td> <td>none</td> <td><code><a href=#the-audio-element>audio</a></code>; <code><a href=#the-video-element>video</a></code></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-track-default><a href=#attr-track-default>default</a></code>; <code title=attr-track-kind><a href=#attr-track-kind>kind</a></code>; <code title=attr-track-label><a href=#attr-track-label>label</a></code>; <code title=attr-track-src><a href=#attr-track-src>src</a></code>; <code title=attr-track-srclang><a href=#attr-track-srclang>srclang</a></code></td> <td><code><a href=#htmltrackelement>HTMLTrackElement</a></code></td> <tr><th><code><a href=#the-u-element>u</a></code></th> <td>Keywords</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-ul-element>ul</a></code></th> <td>List</td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><a href=#flow-content title="Flow content">flow</a></td> <td><code><a href=#the-li-element>li</a></code></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlulistelement>HTMLUListElement</a></code></td> <tr><th><code><a href=#the-var-element>var</a></code></th> <td>Variable</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> <tr><th><code><a href=#the-video-element>video</a></code></th> <td>Video player</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a>; <a href=#embedded-content title="Embedded content">embedded</a>; <a href=#interactive-content title="Interactive content">interactive</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><code><a href=#the-source-element>source</a></code>*; <a href=#transparent>transparent</a>*</td> <td><a href=#global-attributes title="global attributes">globals</a>; <code title=attr-media-src><a href=#attr-media-src>src</a></code>; <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code>; <code title=attr-video-poster><a href=#attr-video-poster>poster</a></code>; <code title=attr-media-preload><a href=#attr-media-preload>preload</a></code>; <code title=attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code>; <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>mediagroup</a></code>; <code title=attr-media-loop><a href=#attr-media-loop>loop</a></code>; <code title=attr-media-muted><a href=#attr-media-muted>muted</a></code>; <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>width</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>height</a></code></td> <td><code><a href=#htmlvideoelement>HTMLVideoElement</a></code></td> <tr><th><code><a href=#the-wbr-element>wbr</a></code></th> <td>Line breaking opportunity</td> <td><a href=#flow-content title="Flow content">flow</a>; <a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td> <td>empty</td> <td><a href=#global-attributes title="global attributes">globals</a></td> <td><code><a href=#htmlelement>HTMLElement</a></code></td> </table><p>An asterisk (*) in a cell indicates that the actual rules are more complicated than indicated in the table above.</p> <p>† 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><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><a href=#the-a-element>a</a></code> element. Since the "flow" category includes all the "phrasing" elements, that means the <code><a href=#the-address-element>address</a></code> element could be a parent to an <code><a href=#the-a-element>a</a></code> element.</p> <h3 class=no-num id=element-content-categories>Element content categories</h3> <p><i>This section is non-normative.</i></p> <!-- when updating this also check the category-list <ul>s --> <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>Metadata content</a> <td> <code><a href=#the-base-element>base</a></code>; <code><a href=#the-command-element>command</a></code>; <code><a href=#the-link-element>link</a></code>; <code><a href=#the-meta-element>meta</a></code>; <code><a href=#the-noscript-element>noscript</a></code>; <code><a href=#the-script-element>script</a></code>; <code><a href=#the-style-element>style</a></code>; <code><a href=#the-title-element>title</a></code> <td> — <tr><td> <a href=#flow-content>Flow content</a> <td> <code><a href=#the-a-element>a</a></code>; <code><a href=#the-abbr-element>abbr</a></code>; <code><a href=#the-address-element>address</a></code>; <code><a href=#the-article-element>article</a></code>; <code><a href=#the-aside-element>aside</a></code>; <code><a href=#the-audio-element>audio</a></code>; <code><a href=#the-b-element>b</a></code>; <code><a href=#the-bdi-element>bdi</a></code>; <code><a href=#the-bdo-element>bdo</a></code>; <code><a href=#the-blockquote-element>blockquote</a></code>; <code><a href=#the-br-element>br</a></code>; <code><a href=#the-button-element>button</a></code>; <code><a href=#the-canvas-element>canvas</a></code>; <code><a href=#the-cite-element>cite</a></code>; <code><a href=#the-code-element>code</a></code>; <code><a href=#the-command-element>command</a></code>; <code><a href=#the-data-element>data</a></code>; <code><a href=#the-datalist-element>datalist</a></code>; <code><a href=#the-del-element>del</a></code>; <code><a href=#the-details-element>details</a></code>; <code><a href=#the-dfn-element>dfn</a></code>; <code><a href=#the-div-element>div</a></code>; <code><a href=#the-dl-element>dl</a></code>; <code><a href=#the-em-element>em</a></code>; <code><a href=#the-embed-element>embed</a></code>; <code><a href=#the-fieldset-element>fieldset</a></code>; <code><a href=#the-figure-element>figure</a></code>; <code><a href=#the-footer-element>footer</a></code>; <code><a href=#the-form-element>form</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>; <code><a href=#the-header-element>header</a></code>; <code><a href=#the-hgroup-element>hgroup</a></code>; <code><a href=#the-hr-element>hr</a></code>; <code><a href=#the-i-element>i</a></code>; <code><a href=#the-iframe-element>iframe</a></code>; <code><a href=#the-img-element>img</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-ins-element>ins</a></code>; <code><a href=#the-kbd-element>kbd</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-label-element>label</a></code>; <code><a href=#the-map-element>map</a></code>; <code><a href=#the-mark-element>mark</a></code>; <code><a href=#math>math</a></code>; <code><a href=#the-menu-element>menu</a></code>; <code><a href=#the-meter-element>meter</a></code>; <code><a href=#the-nav-element>nav</a></code>; <code><a href=#the-noscript-element>noscript</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-p-element>p</a></code>; <code><a href=#the-pre-element>pre</a></code>; <code><a href=#the-progress-element>progress</a></code>; <code><a href=#the-q-element>q</a></code>; <code><a href=#the-ruby-element>ruby</a></code>; <code><a href=#the-s-element>s</a></code>; <code><a href=#the-samp-element>samp</a></code>; <code><a href=#the-script-element>script</a></code>; <code><a href=#the-section-element>section</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-small-element>small</a></code>; <code><a href=#the-span-element>span</a></code>; <code><a href=#the-strong-element>strong</a></code>; <code><a href=#the-sub-and-sup-elements>sub</a></code>; <code><a href=#the-sub-and-sup-elements>sup</a></code>; <code><a href=#svg>svg</a></code>; <code><a href=#the-table-element>table</a></code>; <code><a href=#the-textarea-element>textarea</a></code>; <code><a href=#the-u-element>u</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-var-element>var</a></code>; <code><a href=#the-video-element>video</a></code>; <code><a href=#the-wbr-element>wbr</a></code>; <a href=#text-content title="text content">Text</a> <td> <code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element); <!--MD--> <code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present); <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present); <!--MD--> <code><a href=#the-style-element>style</a></code> (if the <code title=attr-style-scoped><a href=#attr-style-scoped>scoped</a></code> attribute is present) <tr><td> <a href=#sectioning-content>Sectioning content</a> <td> <code><a href=#the-article-element>article</a></code>; <code><a href=#the-aside-element>aside</a></code>; <code><a href=#the-nav-element>nav</a></code>; <code><a href=#the-section-element>section</a></code> <td> — <tr><td> <a href=#heading-content>Heading content</a> <td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>; <code><a href=#the-hgroup-element>hgroup</a></code> <td> — <tr><td> <a href=#phrasing-content>Phrasing content</a> <td> <code><a href=#the-abbr-element>abbr</a></code>; <code><a href=#the-audio-element>audio</a></code>; <code><a href=#the-b-element>b</a></code>; <code><a href=#the-bdi-element>bdi</a></code>; <code><a href=#the-bdo-element>bdo</a></code>; <code><a href=#the-br-element>br</a></code>; <code><a href=#the-button-element>button</a></code>; <code><a href=#the-canvas-element>canvas</a></code>; <code><a href=#the-cite-element>cite</a></code>; <code><a href=#the-code-element>code</a></code>; <code><a href=#the-command-element>command</a></code>; <code><a href=#the-data-element>data</a></code>; <code><a href=#the-datalist-element>datalist</a></code>; <code><a href=#the-dfn-element>dfn</a></code>; <code><a href=#the-em-element>em</a></code>; <code><a href=#the-embed-element>embed</a></code>; <code><a href=#the-i-element>i</a></code>; <code><a href=#the-iframe-element>iframe</a></code>; <code><a href=#the-img-element>img</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-kbd-element>kbd</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-label-element>label</a></code>; <code><a href=#the-mark-element>mark</a></code>; <code><a href=#math>math</a></code>; <code><a href=#the-meter-element>meter</a></code>; <code><a href=#the-noscript-element>noscript</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-progress-element>progress</a></code>; <code><a href=#the-q-element>q</a></code>; <code><a href=#the-ruby-element>ruby</a></code>; <code><a href=#the-s-element>s</a></code>; <code><a href=#the-samp-element>samp</a></code>; <code><a href=#the-script-element>script</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-small-element>small</a></code>; <code><a href=#the-span-element>span</a></code>; <code><a href=#the-strong-element>strong</a></code>; <code><a href=#the-sub-and-sup-elements>sub</a></code>; <code><a href=#the-sub-and-sup-elements>sup</a></code>; <code><a href=#svg>svg</a></code>; <code><a href=#the-textarea-element>textarea</a></code>; <code><a href=#the-u-element>u</a></code>; <code><a href=#the-var-element>var</a></code>; <code><a href=#the-video-element>video</a></code>; <code><a href=#the-wbr-element>wbr</a></code>; <a href=#text-content title="text content">Text</a> <td> <code><a href=#the-a-element>a</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>); <code><a href=#the-area-element>area</a></code> (if it is a descendant of a <code><a href=#the-map-element>map</a></code> element); <code><a href=#the-del-element>del</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>); <code><a href=#the-ins-element>ins</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>); <!--MD--> <code><a href=#the-link-element>link</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present); <!--MD--> <code><a href=#the-map-element>map</a></code> (if it contains only <a href=#phrasing-content>phrasing content</a>)<!-- --><!--MD--><!-- -->; <code><a href=#the-meta-element>meta</a></code> (if the <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is present)<!-- --><!--MD--><!-- --> <tr><td> <a href=#embedded-content>Embedded content</a> <td> <code><a href=#the-audio-element>audio</a></code> <code><a href=#the-canvas-element>canvas</a></code> <code><a href=#the-embed-element>embed</a></code> <code><a href=#the-iframe-element>iframe</a></code> <code><a href=#the-img-element>img</a></code> <code><a href=#math>math</a></code> <code><a href=#the-object-element>object</a></code> <code><a href=#svg>svg</a></code> <code><a href=#the-video-element>video</a></code> <td> — <tr><td> <a href=#interactive-content>Interactive content</a> <td> <code><a href=#the-a-element>a</a></code>; <code><a href=#the-button-element>button</a></code>; <code><a href=#the-details-element>details</a></code>; <code><a href=#the-embed-element>embed</a></code>; <code><a href=#the-iframe-element>iframe</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-label-element>label</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code>; <td> <code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present); <code><a href=#the-img-element>img</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present); <code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state); <code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state); <code><a href=#the-object-element>object</a></code> (if the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<!-- see also comment in <object> section -->; <code><a href=#the-video-element>video</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present) <tr><td> <a href=#sectioning-root title="sectioning root">Sectioning roots</a> <td> <code><a href=#the-blockquote-element>blockquote</a></code>; <code><a href=#the-body-element>body</a></code>; <code><a href=#the-details-element>details</a></code>; <code><a href=#the-fieldset-element>fieldset</a></code>; <code><a href=#the-figure-element>figure</a></code>; <code><a href=#the-td-element>td</a></code> <td> — <tr><td> <a href=#form-associated-element title="form-associated element">Form-associated elements</a> <td> <code><a href=#the-button-element>button</a></code>; <code><a href=#the-fieldset-element>fieldset</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-label-element>label</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code> <td> — <tr><td> <a href=#category-listed title=category-listed>Listed elements</a> <td> <code><a href=#the-button-element>button</a></code>; <code><a href=#the-fieldset-element>fieldset</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code> <td> — <tr><td> <a href=#category-submit title=category-submit>Submittable elements</a> <td> <code><a href=#the-button-element>button</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code> <td> — <tr><td> <a href=#category-reset title=category-reset>Resettable elements</a> <td> <code><a href=#the-input-element>input</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code> <td> — <tr><td> <a href=#category-label title=category-label>Labelable elements</a> <td> <code><a href=#the-button-element>button</a></code>; <code><a href=#the-input-element>input</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-meter-element>meter</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-progress-element>progress</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-textarea-element>textarea</a></code> <td> — <tr><td> <a href=#palpable-content>Palpable content</a> <td> <code><a href=#the-a-element>a</a></code>; <code><a href=#the-abbr-element>abbr</a></code>; <code><a href=#the-address-element>address</a></code>; <code><a href=#the-article-element>article</a></code>; <code><a href=#the-aside-element>aside</a></code>; <code><a href=#the-b-element>b</a></code>; <code><a href=#the-bdi-element>bdi</a></code>; <code><a href=#the-bdo-element>bdo</a></code>; <code><a href=#the-blockquote-element>blockquote</a></code>; <code><a href=#the-button-element>button</a></code>; <code><a href=#the-canvas-element>canvas</a></code>; <code><a href=#the-cite-element>cite</a></code>; <code><a href=#the-code-element>code</a></code>; <code><a href=#the-data-element>data</a></code>; <code><a href=#the-details-element>details</a></code>; <code><a href=#the-dfn-element>dfn</a></code>; <code><a href=#the-div-element>div</a></code>; <code><a href=#the-em-element>em</a></code>; <code><a href=#the-embed-element>embed</a></code>; <code><a href=#the-fieldset-element>fieldset</a></code>; <code><a href=#the-figure-element>figure</a></code>; <code><a href=#the-footer-element>footer</a></code>; <code><a href=#the-form-element>form</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>; <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>; <code><a href=#the-header-element>header</a></code>; <code><a href=#the-hgroup-element>hgroup</a></code>; <code><a href=#the-i-element>i</a></code>; <code><a href=#the-iframe-element>iframe</a></code>; <code><a href=#the-img-element>img</a></code>; <code><a href=#the-ins-element>ins</a></code>; <code><a href=#the-kbd-element>kbd</a></code>; <code><a href=#the-keygen-element>keygen</a></code>; <code><a href=#the-label-element>label</a></code>; <code><a href=#the-map-element>map</a></code>; <code><a href=#the-mark-element>mark</a></code>; <code><a href=#math>math</a></code>; <code><a href=#the-meter-element>meter</a></code>; <code><a href=#the-nav-element>nav</a></code>; <code><a href=#the-object-element>object</a></code>; <code><a href=#the-output-element>output</a></code>; <code><a href=#the-p-element>p</a></code>; <code><a href=#the-pre-element>pre</a></code>; <code><a href=#the-progress-element>progress</a></code>; <code><a href=#the-q-element>q</a></code>; <code><a href=#the-ruby-element>ruby</a></code>; <code><a href=#the-s-element>s</a></code>; <code><a href=#the-samp-element>samp</a></code>; <code><a href=#the-section-element>section</a></code>; <code><a href=#the-select-element>select</a></code>; <code><a href=#the-small-element>small</a></code>; <code><a href=#the-span-element>span</a></code>; <code><a href=#the-strong-element>strong</a></code>; <code><a href=#the-sub-and-sup-elements>sub</a></code>; <code><a href=#the-sub-and-sup-elements>sup</a></code>; <code><a href=#svg>svg</a></code>; <code><a href=#the-table-element>table</a></code>; <code><a href=#the-textarea-element>textarea</a></code>; <code><a href=#the-u-element>u</a></code>; <code><a href=#the-var-element>var</a></code>; <code><a href=#the-video-element>video</a></code> <td> <code><a href=#the-audio-element>audio</a></code> (if the <code title=attr-media-controls><a href=#attr-media-controls>controls</a></code> attribute is present); <code><a href=#the-dl-element>dl</a></code> (if the element's children include at least one name-value group); <code><a href=#the-input-element>input</a></code> (if the <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is <em>not</em> in the <a href=#hidden-state title=attr-input-type-hidden>Hidden</a> state); <code><a href=#the-menu-element>menu</a></code> (if the <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state or the <a href=#list-state title="list state">list</a> state); <code><a href=#the-ol-element>ol</a></code> (if the element's children include at least one <code><a href=#the-li-element>li</a></code> element); <code><a href=#the-ul-element>ul</a></code> (if the element's children include at least one <code><a href=#the-li-element>li</a></code> element); <a href=#text-content title="text content">Text</a> that is not <a href=#inter-element-whitespace>inter-element whitespace</a> </table><h3 class=no-num id=attributes-1>Attributes</h3> <p><i>This section is non-normative.</i></p> <table><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 title="">accept</code> <td> <code title=attr-input-accept><a href=#attr-input-accept>input</a></code> <td> Hint for expected file type in <a href=#file-upload-state title=attr-input-type-file>file upload controls</a> <td> <a href=#set-of-comma-separated-tokens>Set of comma-separated tokens</a>* consisting of <a href=#valid-mime-type title="valid MIME type">valid MIME types with no parameters</a> or <code title="">audio/*</code>, <code title="">video/*</code>, or <code title="">image/*</code> <tr><th> <code title="">accept-charset</code> <td> <code title=attr-form-accept-charset><a href=#attr-form-accept-charset>form</a></code> <td> Character encodings to use for <a href=#form-submission>form submission</a> <td> <a href=#ordered-set-of-unique-space-separated-tokens>Ordered set of unique space-separated tokens</a>, <a href=#ascii-case-insensitive>ASCII case-insensitive</a>, consisting of <a href=#preferred-mime-name title="preferred MIME name">preferred MIME names</a> of <a href=#ascii-compatible-character-encoding title="ASCII-compatible character encoding">ASCII-compatible character encodings</a>* <tr><th> <code title="">accesskey</code> <td> <a href=#the-accesskey-attribute title=attr-accesskey>HTML elements</a> <td> Keyboard shortcut to activate or focus element <td> <a href=#ordered-set-of-unique-space-separated-tokens>Ordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of one Unicode code point in length <tr><th> <code title="">action</code> <td> <code title=attr-fs-action><a href=#attr-fs-action>form</a></code> <td> <a href=#url>URL</a> to use for <a href=#form-submission>form submission</a> <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">alt</code> <td> <code title=attr-area-alt><a href=#attr-area-alt>area</a></code>; <code title=attr-img-alt><a href=#attr-img-alt>img</a></code>; <code title=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 title="">async</code> <td> <code title=attr-script-async><a href=#attr-script-async>script</a></code> <td> Execute script asynchronously <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">autocomplete</code> <td> <code title=attr-form-autocomplete><a href=#attr-form-autocomplete>form</a></code>; <code title=attr-input-autocomplete><a href=#attr-input-autocomplete>input</a></code> <td> Prevent the user agent from providing autocompletions for the form control(s) <td> "<code title="">on</code>"; "<code title="">off</code>" <tr><th> <code title="">autofocus</code> <td> <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>button</a></code>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>input</a></code>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>keygen</a></code>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>select</a></code>; <code title=attr-fe-autofocus><a href=#attr-fe-autofocus>textarea</a></code> <td> Automatically focus the form control when the page is loaded <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">autoplay</code> <td> <code title=attr-media-autoplay><a href=#attr-media-autoplay>audio</a></code>; <code title=attr-media-autoplay><a href=#attr-media-autoplay>video</a></code> <td> Hint that the <a href=#media-resource>media resource</a> can be started automatically when the page is loaded <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">border</code> <td> <code title=attr-table-border><a href=#attr-table-border>table</a></code> <td> Explicit indication that the <code><a href=#the-table-element>table</a></code> element is not being used for layout purposes <td> The empty string, or "<code title="">1</code>" <tr><th> <code title="">challenge</code> <td> <code title=attr-keygen-challenge><a href=#attr-keygen-challenge>keygen</a></code> <td> String to package with the generated and signed public key <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">charset</code> <td> <code title=attr-meta-charset><a href=#attr-meta-charset>meta</a></code> <td> <a href=#character-encoding-declaration>Character encoding declaration</a> <td> <a href=#preferred-mime-name>Preferred MIME name</a> of an encoding* <tr><th> <code title="">charset</code> <td> <code title=attr-script-charset><a href=#attr-script-charset>script</a></code> <td> Character encoding of the external script resource <td> <a href=#preferred-mime-name>Preferred MIME name</a> of an encoding* <tr><th> <code title="">checked</code> <td> <code title=attr-command-checked><a href=#attr-command-checked>command</a></code>; <code title=attr-input-checked><a href=#attr-input-checked>input</a></code> <td> Whether the command or control is checked <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">cite</code> <td> <code title=attr-blockquote-cite><a href=#attr-blockquote-cite>blockquote</a></code>; <code title=attr-mod-cite><a href=#attr-mod-cite>del</a></code>; <code title=attr-mod-cite><a href=#attr-mod-cite>ins</a></code>; <code title=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>Valid URL potentially surrounded by spaces</a> <tr><th> <code title="">class</code> <td> <a href=#classes title=attr-class>HTML elements</a> <td> Classes to which the element belongs <td> <a href=#set-of-space-separated-tokens>Set of space-separated tokens</a> <tr><th> <code title="">cols</code> <td> <code title=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>Valid non-negative integer</a> greater than zero <tr><th> <code title="">colspan</code> <td> <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>td</a></code>; <code title=attr-tdth-colspan><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>Valid non-negative integer</a> greater than zero <tr><th> <code title="">content</code> <td> <code title=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 title="">contenteditable</code> <td> <a href=#attr-contenteditable title=attr-contenteditable>HTML elements</a> <td> Whether the element is editable <td> "<code title="">true</code>"; "<code title="">false</code>" <tr><th> <code title="">contextmenu</code> <td> <a href=#attr-contextmenu title=attr-contextmenu>HTML elements</a> <td> The element's context menu <td> <a href=#concept-id title=concept-id>ID</a>* <tr><th> <code title="">controls</code> <td> <code title=attr-media-controls><a href=#attr-media-controls>audio</a></code>; <code title=attr-media-controls><a href=#attr-media-controls>video</a></code> <td> Show user agent controls <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">coords</code> <td> <code title=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>image map</a> <td> <a href=#valid-list-of-integers>Valid list of integers</a>* <tr><th> <code title="">crossorigin</code> <td> <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>audio</a></code>; <code title=attr-img-crossorigin><a href=#attr-img-crossorigin>img</a></code>; <code title=attr-media-crossorigin><a href=#attr-media-crossorigin>video</a></code> <td> How the element handles crossorigin requests. <td> "<code title=attr-crossorigin-anonymous-keyword><a href=#attr-crossorigin-anonymous-keyword>anonymous</a></code>"; "<code title=attr-crossorigin-use-credentials-keyword><a href=#attr-crossorigin-use-credentials-keyword>use-credentials</a></code>" <tr><th> <code title="">data</code> <td> <code title=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>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">datetime</code> <td> <code title=attr-mod-datetime><a href=#attr-mod-datetime>del</a></code>; <code title=attr-mod-datetime><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>Valid date string with optional time</a> <tr><th> <code title="">default</code> <td> <code title=attr-track-default><a href=#attr-track-default>track</a></code> <td> Enable the track if no other <a href=#text-track>text track</a> is more suitable. <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">defer</code> <td> <code title=attr-script-defer><a href=#attr-script-defer>script</a></code> <td> Defer script execution <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">dir</code> <td> <a href=#the-dir-attribute title=attr-dir>HTML elements</a> <td> <a href=#the-directionality title="the directionality">The text directionality</a> of the element <td> "<code title=attr-dir-ltr><a href=#attr-dir-ltr>ltr</a></code>"; "<code title=attr-dir-rtl><a href=#attr-dir-rtl>rtl</a></code>"; "<code title=attr-dir-auto><a href=#attr-dir-auto>auto</a></code>" <tr><th> <code title="">dirname</code> <td> <code title=attr-input-dirname><a href=#attr-input-dirname>input</a></code>; <code title=attr-textarea-dirname><a href=#attr-textarea-dirname>textarea</a></code> <td> Name of form field to use for sending the element's <a href=#the-directionality title="the directionality">directionality</a> in <a href=#form-submission>form submission</a> <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">disabled</code> <td> <code title=attr-fe-disabled><a href=#attr-fe-disabled>button</a></code>; <code title=attr-command-disabled><a href=#attr-command-disabled>command</a></code>; <code title=attr-fieldset-disabled><a href=#attr-fieldset-disabled>fieldset</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>input</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>keygen</a></code>; <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>optgroup</a></code>; <code title=attr-option-disabled><a href=#attr-option-disabled>option</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>select</a></code>; <code title=attr-fe-disabled><a href=#attr-fe-disabled>textarea</a></code> <td> Whether the form control is disabled <td> <a href=#boolean-attribute>Boolean attribute</a> <!--DOWNLOAD--> <tr><th> <code title="">download</code> <td> <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>a</a></code>; <code title=attr-hyperlink-download><a href=#attr-hyperlink-download>area</a></code> <td> Whether to download the resource instead of navigating to it, and its filename if so <td> Text <!--DOWNLOAD--> <tr><th> <code title="">draggable</code> <td> <a href=#the-draggable-attribute title=attr-draggable>HTML elements</a> <td> Whether the element is draggable <td> "<code title="">true</code>"; "<code title="">false</code>" <tr><th> <code title="">dropzone</code> <td> <a href=#the-dropzone-attribute title=attr-dropzone>HTML elements</a> <td> Accepted item types for drag-and-drop <td> <a href=#unordered-set-of-unique-space-separated-tokens>Unordered set of unique space-separated tokens</a>, <a href=#ascii-case-insensitive>ASCII case-insensitive</a>, consisting of accepted types and drag feedback* <tr><th> <code title="">enctype</code> <td> <code title=attr-fs-enctype><a href=#attr-fs-enctype>form</a></code> <td> Form data set encoding type to use for <a href=#form-submission>form submission</a> <td> "<code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code>"; "<code title=attr-fs-enctype-formdata><a href=#attr-fs-enctype-formdata>multipart/form-data</a></code>"; "<code title=attr-fs-enctype-text><a href=#attr-fs-enctype-text>text/plain</a></code>" <tr><th> <code title="">for</code> <td> <code title=attr-label-for><a href=#attr-label-for>label</a></code> <td> Associate the label with form control <td> <a href=#concept-id title=concept-id>ID</a>* <tr><th> <code title="">for</code> <td> <code title=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>Unordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of IDs* <tr><th> <code title="">form</code> <td> <code title=attr-fae-form><a href=#attr-fae-form>button</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>fieldset</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>input</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>keygen</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>label</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>object</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>output</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>select</a></code>; <code title=attr-fae-form><a href=#attr-fae-form>textarea</a></code> <td> Associates the control with a <code><a href=#the-form-element>form</a></code> element <td> <a href=#concept-id title=concept-id>ID</a>* <tr><th> <code title="">formaction</code> <td> <code title=attr-fs-formaction><a href=#attr-fs-formaction>button</a></code>; <code title=attr-fs-formaction><a href=#attr-fs-formaction>input</a></code> <td> <a href=#url>URL</a> to use for <a href=#form-submission>form submission</a> <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">formenctype</code> <td> <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>button</a></code>; <code title=attr-fs-formenctype><a href=#attr-fs-formenctype>input</a></code> <td> Form data set encoding type to use for <a href=#form-submission>form submission</a> <td> "<code title=attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code>"; "<code title=attr-fs-enctype-formdata><a href=#attr-fs-enctype-formdata>multipart/form-data</a></code>"; "<code title=attr-fs-enctype-text><a href=#attr-fs-enctype-text>text/plain</a></code>" <tr><th> <code title="">formmethod</code> <td> <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>button</a></code>; <code title=attr-fs-formmethod><a href=#attr-fs-formmethod>input</a></code> <td> HTTP method to use for <a href=#form-submission>form submission</a> <td> "<code title="">GET</code>"; "<code title="">POST</code>" <tr><th> <code title="">formnovalidate</code> <td> <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>button</a></code>; <code title=attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>input</a></code> <td> Bypass form control validation for <a href=#form-submission>form submission</a> <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">formtarget</code> <td> <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>button</a></code>; <code title=attr-fs-formtarget><a href=#attr-fs-formtarget>input</a></code> <td> <a href=#browsing-context>Browsing context</a> for <a href=#form-submission>form submission</a> <td> <a href=#valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a> <tr><th> <code title="">headers</code> <td> <code title=attr-tdth-headers><a href=#attr-tdth-headers>td</a></code>; <code title=attr-tdth-headers><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>Unordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of IDs* <tr><th> <code title="">height</code> <td> <code title=attr-canvas-height><a href=#attr-canvas-height>canvas</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>embed</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>iframe</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>img</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>input</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>object</a></code>; <code title=attr-dim-height><a href=#attr-dim-height>video</a></code> <td> Vertical dimension <td> <a href=#valid-non-negative-integer>Valid non-negative integer</a> <tr><th> <code title="">hidden</code> <td> <a href=#the-hidden-attribute title=attr-hidden>HTML elements</a> <td> Whether the element is relevant <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">high</code> <td> <code title=attr-meter-high><a href=#attr-meter-high>meter</a></code> <td> Low limit of high range <td> <a href=#valid-floating-point-number>Valid floating point number</a>* <tr><th> <code title="">href</code> <td> <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>a</a></code>; <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>area</a></code> <td> Address of the <a href=#hyperlink>hyperlink</a> <td> <a href=#valid-url-potentially-surrounded-by-spaces>Valid URL potentially surrounded by spaces</a> <tr><th> <code title="">href</code> <td> <code title=attr-link-href><a href=#attr-link-href>link</a></code> <td> Address of the <a href=#hyperlink>hyperlink</a> <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">href</code> <td> <code title=attr-base-href><a href=#attr-base-href>base</a></code> <td> <a href=#document-base-url>Document base URL</a> <td> <a href=#valid-url-potentially-surrounded-by-spaces>Valid URL potentially surrounded by spaces</a> <tr><th> <code title="">hreflang</code> <td> <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>a</a></code>; <code title=attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>area</a></code>; <code title=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 title="">http-equiv</code> <td> <code title=attr-meta-http-equiv><a href=#attr-meta-http-equiv>meta</a></code> <td> Pragma directive <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">icon</code> <td> <code title=attr-command-icon><a href=#attr-command-icon>command</a></code> <td> Icon for the command <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">id</code> <td> <a href=#the-id-attribute title=attr-id>HTML elements</a> <td> The element's <a href=#concept-id title=concept-id>ID</a> <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">ismap</code> <td> <code title=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>Boolean attribute</a> <!--MD--> <tr><th> <code title="">itemid</code> <td> <a href=#attr-itemid title=attr-itemid>HTML elements</a> <td> <a href=#global-identifier>Global identifier</a> for a microdata item <td> <a href=#valid-url-potentially-surrounded-by-spaces>Valid URL potentially surrounded by spaces</a> <tr><th> <code title="">itemprop</code> <td> <a href=#names:-the-itemprop-attribute title=attr-itemprop>HTML elements</a> <td> <a href=#property-names>Property names</a> of a microdata item <td> <a href=#unordered-set-of-unique-space-separated-tokens>Unordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of <a href=#absolute-url title="absolute URL">valid absolute URLs</a>, <a href=#defined-property-name title="defined property name">defined property names</a>, or text* <tr><th> <code title="">itemref</code> <td> <a href=#attr-itemref title=attr-itemref>HTML elements</a> <td> Referenced elements <td> <a href=#unordered-set-of-unique-space-separated-tokens>Unordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of IDs* <tr><th> <code title="">itemscope</code> <td> <a href=#attr-itemscope title=attr-itemscope>HTML elements</a> <td> Introduces a microdata item <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">itemtype</code> <td> <a href=#attr-itemtype title=attr-itemtype>HTML elements</a> <td> <a href=#item-types>Item types</a> of a microdata item <td> <a href=#unordered-set-of-unique-space-separated-tokens>Unordered set of unique space-separated tokens</a>, <a href=#case-sensitive>case-sensitive</a>, consisting of <a href=#absolute-url title="absolute URL">valid absolute URL</a>* <!--MD--> <tr><th> <code title="">keytype</code> <td> <code title=attr-keygen-keytype><a href=#attr-keygen-keytype>keygen</a></code> <td> The type of cryptographic key to generate <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">kind</code> <td> <code title=attr-track-kind><a href=#attr-track-kind>track</a></code> <td> The type of text track <td> "<code title=attr-track-kind-subtitles><a href=#attr-track-kind-subtitles>subtitles</a></code>"; "<code title=attr-track-kind-captions><a href=#attr-track-kind-captions>captions</a></code>"; "<code title=attr-track-kind-descriptions><a href=#attr-track-kind-descriptions>descriptions</a></code>"; "<code title=attr-track-kind-chapters><a href=#attr-track-kind-chapters>chapters</a></code>"; "<code title=attr-track-kind-metadata><a href=#attr-track-kind-metadata>metadata</a></code>" <tr><th> <code title="">label</code> <td> <code title=attr-command-label><a href=#attr-command-label>command</a></code>; <code title=attr-menu-label><a href=#attr-menu-label>menu</a></code>; <code title=attr-optgroup-label><a href=#attr-optgroup-label>optgroup</a></code>; <code title=attr-option-label><a href=#attr-option-label>option</a></code>; <code title=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 title="">lang</code> <td> <a href=#attr-lang title=attr-lang>HTML elements</a> <td> <a href=#language>Language</a> of the element <td> Valid BCP 47 language tag or the empty string <tr><th> <code title="">list</code> <td> <code title=attr-input-list><a href=#attr-input-list>input</a></code> <td> List of autocomplete options <td> <a href=#concept-id title=concept-id>ID</a>* <tr><th> <code title="">loop</code> <td> <code title=attr-media-loop><a href=#attr-media-loop>audio</a></code>; <code title=attr-media-loop><a href=#attr-media-loop>video</a></code> <td> Whether to loop the <a href=#media-resource>media resource</a> <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">low</code> <td> <code title=attr-meter-low><a href=#attr-meter-low>meter</a></code> <td> High limit of low range <td> <a href=#valid-floating-point-number>Valid floating point number</a>* <tr><th> <code title="">manifest</code> <td> <code title=attr-html-manifest><a href=#attr-html-manifest>html</a></code> <td> <a href=#concept-appcache-manifest title=concept-appcache-manifest>Application cache manifest</a> <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">max</code> <td> <code title=attr-input-max><a href=#attr-input-max>input</a></code> <td> Maximum value <td> Varies* <tr><th> <code title="">max</code> <td> <code title=attr-meter-max><a href=#attr-meter-max>meter</a></code>; <code title=attr-progress-max><a href=#attr-progress-max>progress</a></code> <td> Upper bound of range <td> <a href=#valid-floating-point-number>Valid floating point number</a>* <tr><th> <code title="">maxlength</code> <td> <code title=attr-input-maxlength><a href=#attr-input-maxlength>input</a></code>; <code title=attr-textarea-maxlength><a href=#attr-textarea-maxlength>textarea</a></code> <td> Maximum length of value <td> <a href=#valid-non-negative-integer>Valid non-negative integer</a> <tr><th> <code title="">media</code> <td> <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>a</a></code>; <code title=attr-hyperlink-media><a href=#attr-hyperlink-media>area</a></code>; <code title=attr-link-media><a href=#attr-link-media>link</a></code>; <code title=attr-source-media><a href=#attr-source-media>source</a></code>; <code title=attr-style-media><a href=#attr-style-media>style</a></code> <td> Applicable media <td> <a href=#valid-media-query>Valid media query</a> <tr><th> <code title="">mediagroup</code> <td> <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>audio</a></code>; <code title=attr-media-mediagroup><a href=#attr-media-mediagroup>video</a></code> <td> Groups <a href=#media-element title="media element">media elements</a> together with an implicit <code><a href=#mediacontroller>MediaController</a></code> <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">method</code> <td> <code title=attr-fs-method><a href=#attr-fs-method>form</a></code> <td> HTTP method to use for <a href=#form-submission>form submission</a> <td> "<code title="">GET</code>"; "<code title="">POST</code>" <tr><th> <code title="">min</code> <td> <code title=attr-input-min><a href=#attr-input-min>input</a></code> <td> Minimum value <td> Varies* <tr><th> <code title="">min</code> <td> <code title=attr-meter-min><a href=#attr-meter-min>meter</a></code> <td> Lower bound of range <td> <a href=#valid-floating-point-number>Valid floating point number</a>* <tr><th> <code title="">multiple</code> <td> <code title=attr-input-multiple><a href=#attr-input-multiple>input</a></code>; <code title=attr-select-multiple><a href=#attr-select-multiple>select</a></code> <td> Whether to allow multiple values <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">muted</code> <td> <code title=attr-media-muted><a href=#attr-media-muted>audio</a></code>; <code title=attr-media-muted><a href=#attr-media-muted>video</a></code> <td> Whether to mute the <a href=#media-resource>media resource</a> by default <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">name</code> <td> <code title=attr-fe-name><a href=#attr-fe-name>button</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>fieldset</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>input</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>keygen</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>output</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>select</a></code>; <code title=attr-fe-name><a href=#attr-fe-name>textarea</a></code> <td> Name of form control to use for <a href=#form-submission>form submission</a> and in the <code title=dom-form-elements><a href=#dom-form-elements>form.elements</a></code> API <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">name</code> <td> <code title=attr-form-name><a href=#attr-form-name>form</a></code> <td> Name of form to use in the <code title=dom-document-forms><a href=#dom-document-forms>document.forms</a></code> API <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">name</code> <td> <code title=attr-iframe-name><a href=#attr-iframe-name>iframe</a></code>; <code title=attr-object-name><a href=#attr-object-name>object</a></code> <td> Name of <a href=#nested-browsing-context>nested browsing context</a> <td> <a href=#valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a> <tr><th> <code title="">name</code> <td> <code title=attr-map-name><a href=#attr-map-name>map</a></code> <td> Name of <a href=#image-map>image map</a> to reference from the <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">name</code> <td> <code title=attr-meta-name><a href=#attr-meta-name>meta</a></code> <td> Metadata name <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">name</code> <td> <code title=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 title="">novalidate</code> <td> <code title=attr-fs-novalidate><a href=#attr-fs-novalidate>form</a></code> <td> Bypass form control validation for <a href=#form-submission>form submission</a> <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">open</code> <td> <code title=attr-details-open><a href=#attr-details-open>details</a></code> <td> Whether the details are visible <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">optimum</code> <td> <code title=attr-meter-optimum><a href=#attr-meter-optimum>meter</a></code> <td> Optimum value in gauge <td> <a href=#valid-floating-point-number>Valid floating point number</a>* <tr><th> <code title="">pattern</code> <td> <code title=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 title="">Pattern</i> production <!--PING--> <tr><th> <code title="">ping</code> <td> <code title=attr-hyperlink-ping><a href=#ping>a</a></code>; <code title=attr-hyperlink-ping><a href=#ping>area</a></code> <td> <a href=#url title=URL>URLs</a> to ping <td> <a href=#set-of-space-separated-tokens>Set of space-separated tokens</a> consisting of <a href=#valid-non-empty-url title="valid non-empty URL">valid non-empty URLs</a> <!--PING--> <tr><th> <code title="">placeholder</code> <td> <code title=attr-input-placeholder><a href=#attr-input-placeholder>input</a></code>; <code title=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 title="">poster</code> <td> <code title=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>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">preload</code> <td> <code title=attr-media-preload><a href=#attr-media-preload>audio</a></code>; <code title=attr-media-preload><a href=#attr-media-preload>video</a></code> <td> Hints how much buffering the <a href=#media-resource>media resource</a> will likely need <td> "<code title=attr-media-preload-none><a href=#attr-media-preload-none>none</a></code>"; "<code title=attr-media-preload-metadata><a href=#attr-media-preload-metadata>metadata</a></code>"; "<code title=attr-media-preload-auto><a href=#attr-media-preload-auto>auto</a></code>" <tr><th> <code title="">radiogroup</code> <td> <code title=attr-command-radiogroup><a href=#attr-command-radiogroup>command</a></code> <td> Name of group of commands to treat as a radio button group <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">readonly</code> <td> <code title=attr-input-readonly><a href=#attr-input-readonly>input</a></code>; <code title=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>Boolean attribute</a> <tr><th> <code title="">rel</code> <td> <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>a</a></code>; <code title=attr-hyperlink-rel><a href=#attr-hyperlink-rel>area</a></code>; <code title=attr-link-rel><a href=#attr-link-rel>link</a></code> <td> Relationship between the document containing the hyperlink and the destination resource <td> <a href=#set-of-space-separated-tokens>Set of space-separated tokens</a>* <tr><th> <code title="">required</code> <td> <code title=attr-input-required><a href=#attr-input-required>input</a></code>; <code title=attr-select-required><a href=#attr-select-required>select</a></code>; <code title=attr-textarea-required><a href=#attr-textarea-required>textarea</a></code> <td> Whether the control is required for <a href=#form-submission>form submission</a> <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">reversed</code> <td> <code title=attr-ol-reversed><a href=#attr-ol-reversed>ol</a></code> <td> Number the list backwards <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">rows</code> <td> <code title=attr-textarea-rows><a href=#attr-textarea-rows>textarea</a></code> <td> Number of lines to show <td> <a href=#valid-non-negative-integer>Valid non-negative integer</a> greater than zero <tr><th> <code title="">rowspan</code> <td> <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>td</a></code>; <code title=attr-tdth-rowspan><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>Valid non-negative integer</a> <tr><th> <code title="">sandbox</code> <td> <code title=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>Unordered set of unique space-separated tokens</a>, <a href=#ascii-case-insensitive>ASCII case-insensitive</a>, consisting of "<code title=attr-iframe-sandbox-allow-forms><a href=#attr-iframe-sandbox-allow-forms>allow-forms</a></code>", "<code title=attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code>", "<code title=attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code> and "<code title=attr-iframe-sandbox-allow-top-navigation><a href=#attr-iframe-sandbox-allow-top-navigation>allow-top-navigation</a></code>" <tr><th> <code title="">spellcheck</code> <td> <a href=#attr-spellcheck title=attr-spellcheck>HTML elements</a> <td> Whether the element is to have its spelling and grammar checked <td> "<code title="">true</code>"; "<code title="">false</code>" <tr><th> <code title="">scope</code> <td> <code title=attr-th-scope><a href=#attr-th-scope>th</a></code> <td> Specifies which cells the header cell applies to <td> "<code title=attr-th-scope-row><a href=#attr-th-scope-row>row</a></code>"; "<code title=attr-th-scope-col><a href=#attr-th-scope-col>col</a></code>"; "<code title=attr-th-scope-rowgroup><a href=#attr-th-scope-rowgroup>rowgroup</a></code>"; "<code title=attr-th-scope-colgroup><a href=#attr-th-scope-colgroup>colgroup</a></code>" <tr><th> <code title="">scoped</code> <td> <code title=attr-style-scoped><a href=#attr-style-scoped>style</a></code> <td> Whether the styles apply to the entire document or just the parent subtree <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">seamless</code> <td> <code title=attr-iframe-seamless><a href=#attr-iframe-seamless>iframe</a></code> <td> Whether to apply the document's styles to the nested content <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">selected</code> <td> <code title=attr-option-selected><a href=#attr-option-selected>option</a></code> <td> Whether the option is selected by default <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">shape</code> <td> <code title=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>image map</a> <td> "<code title=attr-area-shape-keyword-circle><a href=#attr-area-shape-keyword-circle>circle</a></code>"; "<code title=attr-area-shape-keyword-default><a href=#attr-area-shape-keyword-default>default</a></code>"; "<code title=attr-area-shape-keyword-poly><a href=#attr-area-shape-keyword-poly>poly</a></code>"; "<code title=attr-area-shape-keyword-rect><a href=#attr-area-shape-keyword-rect>rect</a></code>" <tr><th> <code title="">size</code> <td> <code title=attr-input-size><a href=#attr-input-size>input</a></code>; <code title=attr-select-size><a href=#attr-select-size>select</a></code> <td> Size of the control <td> <a href=#valid-non-negative-integer>Valid non-negative integer</a> greater than zero <tr><th> <code title="">sizes</code> <td> <code title=attr-link-sizes><a href=#attr-link-sizes>link</a></code> <td> Sizes of the icons (for <code title=attr-link-rel><a href=#attr-link-rel>rel</a></code>="<code title=rel-icon><a href=#rel-icon>icon</a></code>") <td> <a href=#unordered-set-of-unique-space-separated-tokens>Unordered set of unique space-separated tokens</a>, <a href=#ascii-case-insensitive>ASCII case-insensitive</a>, consisting of sizes* <tr><th> <code title="">span</code> <td> <code title=attr-col-span><a href=#attr-col-span>col</a></code>; <code title=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>Valid non-negative integer</a> greater than zero <tr><th> <code title="">src</code> <td> <code title=attr-media-src><a href=#attr-media-src>audio</a></code>; <code title=attr-embed-src><a href=#attr-embed-src>embed</a></code>; <code title=attr-iframe-src><a href=#attr-iframe-src>iframe</a></code>; <code title=attr-img-src><a href=#attr-img-src>img</a></code>; <code title=attr-input-src><a href=#attr-input-src>input</a></code>; <code title=attr-script-src><a href=#attr-script-src>script</a></code>; <code title=attr-source-src><a href=#attr-source-src>source</a></code>; <code title=attr-track-src><a href=#attr-track-src>track</a></code>; <code title=attr-media-src><a href=#attr-media-src>video</a></code> <td> Address of the resource <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces>Valid non-empty URL potentially surrounded by spaces</a> <tr><th> <code title="">srcdoc</code> <td> <code title=attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>iframe</a></code> <td> A document to render in the <code><a href=#the-iframe-element>iframe</a></code> <td> The source of <a href=#an-iframe-srcdoc-document>an <code>iframe</code> <code title=attr-iframe-srcdoc>srcdoc</code> document</a>* <tr><th> <code title="">srclang</code> <td> <code title=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 title="">start</code> <td> <code title=attr-ol-start><a href=#attr-ol-start>ol</a></code> <td> <a href=#ordinal-value>Ordinal value</a> of the first item <td> <a href=#valid-integer>Valid integer</a> <tr><th> <code title="">step</code> <td> <code title=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>Valid floating point number</a> greater than zero, or "<code title="">any</code>" <tr><th> <code title="">style</code> <td> <a href=#the-style-attribute title=attr-style>HTML elements</a> <td> Presentational and formatting instructions <td> CSS declarations* <tr><th> <code title="">tabindex</code> <td> <a href=#attr-tabindex title=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>Valid integer</a> <tr><th> <code title="">target</code> <td> <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>a</a></code>; <code title=attr-hyperlink-target><a href=#attr-hyperlink-target>area</a></code> <td> <a href=#browsing-context>Browsing context</a> for <a href=#hyperlink>hyperlink</a> <a href=#navigate title=navigate>navigation</a> <td> <a href=#valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a> <tr><th> <code title="">target</code> <td> <code title=attr-base-target><a href=#attr-base-target>base</a></code> <td> Default <a href=#browsing-context>browsing context</a> for <a href=#hyperlink>hyperlink</a> <a href=#navigate title=navigate>navigation</a> and <a href=#form-submission>form submission</a> <td> <a href=#valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a> <tr><th> <code title="">target</code> <td> <code title=attr-fs-target><a href=#attr-fs-target>form</a></code> <td> <a href=#browsing-context>Browsing context</a> for <a href=#form-submission>form submission</a> <td> <a href=#valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a> <tr><th> <code title="">title</code> <td> <a href=#the-title-attribute title=attr-title>HTML elements</a> <td> Advisory information for the element <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">title</code> <td> <code title=attr-abbr-title><a href=#attr-abbr-title>abbr</a></code>; <code title=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="">title</code> <td> <code title=attr-command-title><a href=#attr-command-title>command</a></code> <td> Hint describing the command <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">title</code> <td> <code title=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="">title</code> <td> <code title=attr-link-title><a href=#attr-link-title>link</a></code>; <code title=attr-style-title><a href=#attr-style-title>style</a></code> <td> Alternative style sheet set name <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">type</code> <td> <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>a</a></code>; <code title=attr-hyperlink-type><a href=#attr-hyperlink-type>area</a></code>; <code title=attr-link-type><a href=#attr-link-type>link</a></code> <td> Hint for the type of the referenced resource <td> <a href=#valid-mime-type>Valid MIME type</a> <tr><th> <code title="">type</code> <td> <code title=attr-button-type><a href=#attr-button-type>button</a></code> <td> Type of button <td> "<code title=attr-button-type-submit><a href=#attr-button-type-submit>submit</a></code>"; "<code title=attr-button-type-reset><a href=#attr-button-type-reset>reset</a></code>"; "<code title=attr-button-type-button><a href=#attr-button-type-button>button</a></code>" <tr><th> <code title="">type</code> <td> <code title=attr-button-type><a href=#attr-button-type>button</a></code>; <code title=attr-input-type><a href=#attr-input-type>input</a></code> <td> Type of form control <td> <a href=#attr-input-type title=attr-input-type><code>input</code> type keyword</a> <tr><th> <code title="">type</code> <td> <code title=attr-command-type><a href=#attr-command-type>command</a></code> <td> Type of command <td> "<code title=attr-command-type-keyword-command><a href=#attr-command-type-keyword-command>command</a></code>"; "<code title=attr-command-type-keyword-checkbox><a href=#attr-command-type-keyword-checkbox>checkbox</a></code>"; "<code title=attr-command-type-keyword-radio><a href=#attr-command-type-keyword-radio>radio</a></code>" <tr><th> <code title="">type</code> <td> <code title=attr-embed-type><a href=#attr-embed-type>embed</a></code>; <code title=attr-object-type><a href=#attr-object-type>object</a></code>; <code title=attr-script-type><a href=#attr-script-type>script</a></code>; <code title=attr-source-type><a href=#attr-source-type>source</a></code>; <code title=attr-style-type><a href=#attr-style-type>style</a></code> <td> Type of embedded resource <td> <a href=#valid-mime-type>Valid MIME type</a> <tr><th> <code title="">type</code> <td> <code title=attr-menu-type><a href=#attr-menu-type>menu</a></code> <td> Type of menu <td> "<code title="context menu state"><a href=#context-menu-state>context</a></code>"; "<code title="toolbar state"><a href=#toolbar-state>toolbar</a></code>" <tr><th> <code title="">typemustmatch</code> <td> <code title=attr-object-typemustmatch><a href=#attr-object-typemustmatch>object</a></code> <td> Whether the <code title=attr-object-type><a href=#attr-object-type>type</a></code> attribute and the <a href=#content-type>Content-Type</a> value need to match for the resource to be used <td> <a href=#boolean-attribute>Boolean attribute</a> <tr><th> <code title="">usemap</code> <td> <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>img</a></code>; <code title=attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>object</a></code> <td> Name of <a href=#image-map>image map</a> to use <td> <a href=#valid-hash-name-reference>Valid hash-name reference</a>* <tr><th> <code title="">value</code> <td> <code title=attr-button-value><a href=#attr-button-value>button</a></code>; <code title=attr-option-value><a href=#attr-option-value>option</a></code> <td> Value to be used for <a href=#form-submission>form submission</a> <td> <a href=#attribute-text>Text</a> <tr><th> <code title="">value</code> <td> <code title=attr-data-value><a href=#attr-data-value>input</a></code> <td> Machine-readable value <td> <a href=#attribute-text>Text</a>* <tr><th> <code title="">value</code> <td> <code title=attr-input-value><a href=#attr-input-value>input</a></code> <td> Value of the form control <td> Varies* <tr><th> <code title="">value</code> <td> <code title=attr-li-value><a href=#attr-li-value>li</a></code> <td> <a href=#ordinal-value>Ordinal value</a> of the list item <td> <a href=#valid-integer>Valid integer</a> <tr><th> <code title="">value</code> <td> <code title=attr-meter-value><a href=#attr-meter-value>meter</a></code>; <code title=attr-progress-value><a href=#attr-progress-value>progress</a></code> <td> Current value of the element <td> <a href=#valid-floating-point-number>Valid floating point number</a> <tr><th> <code title="">value</code> <td> <code title=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 title="">width</code> <td> <code title=attr-canvas-width><a href=#attr-canvas-width>canvas</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>embed</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>iframe</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>img</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>input</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>object</a></code>; <code title=attr-dim-width><a href=#attr-dim-width>video</a></code> <td> Horizontal dimension <td> <a href=#valid-non-negative-integer>Valid non-negative integer</a> <tr><th> <code title="">wrap</code> <td> <code title=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>form submission</a> <td> "<code title=attr-textarea-wrap-soft><a href=#attr-textarea-wrap-soft>soft</a></code>"; "<code title=attr-textarea-wrap-hard><a href=#attr-textarea-wrap-hard>hard</a></code>" </table><p>An asterisk (*) in a cell indicates that the actual rules are more complicated than indicated in the table above.</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 title="">onabort</code> <td> <a href=#handler-onabort title=handler-onabort>HTML elements</a> <td> <code title=event-abort>abort</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onafterprint> <code title="">onafterprint</code> <td> <code title=handler-window-onafterprint><a href=#handler-window-onafterprint>body</a></code> <td> <code title=event-afterprint>afterprint</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onbeforeprint> <code title="">onbeforeprint</code> <td> <code title=handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>body</a></code> <td> <code title=event-beforeprint>beforeprint</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onbeforeunload> <code title="">onbeforeunload</code> <td> <code title=handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>body</a></code> <td> <code title=event-beforeunload>beforeunload</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onblur> <code title="">onblur</code> <td> <code title=handler-window-onblur><a href=#handler-window-onblur>body</a></code> <td> <code title=event-blur>blur</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onblur> <code title="">onblur</code> <td> <a href=#handler-onblur title=handler-onblur>HTML elements</a> <td> <code title=event-blur>blur</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oncanplay> <code title="">oncanplay</code> <td> <a href=#handler-oncanplay title=handler-oncanplay>HTML elements</a> <td> <code title=event-media-canplay><a href=#event-media-canplay>canplay</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oncanplaythrough> <code title="">oncanplaythrough</code> <td> <a href=#handler-oncanplaythrough title=handler-oncanplaythrough>HTML elements</a> <td> <code title=event-media-canplaythrough><a href=#event-media-canplaythrough>canplaythrough</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onchange> <code title="">onchange</code> <td> <a href=#handler-onchange title=handler-onchange>HTML elements</a> <td> <code title=event-change>change</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onclick> <code title="">onclick</code> <td> <a href=#handler-onclick title=handler-onclick>HTML elements</a> <td> <code title=event-click><a href=#event-click>click</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oncontextmenu> <code title="">oncontextmenu</code> <td> <a href=#handler-oncontextmenu title=handler-oncontextmenu>HTML elements</a> <td> <code title=event-contextmenu>contextmenu</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oncuechange> <code title="">oncuechange</code> <td> <a href=#handler-oncuechange title=handler-oncuechange>HTML elements</a> <td> <code title=event-cuechange>cuechange</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondblclick> <code title="">ondblclick</code> <td> <a href=#handler-ondblclick title=handler-ondblclick>HTML elements</a> <td> <code title=event-dblclick>dblclick</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondrag> <code title="">ondrag</code> <td> <a href=#handler-ondrag title=handler-ondrag>HTML elements</a> <td> <code title=event-drag><a href=#event-drag>drag</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondragend> <code title="">ondragend</code> <td> <a href=#handler-ondragend title=handler-ondragend>HTML elements</a> <td> <code title=event-dragend><a href=#event-dragend>dragend</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondragenter> <code title="">ondragenter</code> <td> <a href=#handler-ondragenter title=handler-ondragenter>HTML elements</a> <td> <code title=event-dragenter><a href=#event-dragenter>dragenter</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondragleave> <code title="">ondragleave</code> <td> <a href=#handler-ondragleave title=handler-ondragleave>HTML elements</a> <td> <code title=event-dragleave><a href=#event-dragleave>dragleave</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondragover> <code title="">ondragover</code> <td> <a href=#handler-ondragover title=handler-ondragover>HTML elements</a> <td> <code title=event-dragover><a href=#event-dragover>dragover</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondragstart> <code title="">ondragstart</code> <td> <a href=#handler-ondragstart title=handler-ondragstart>HTML elements</a> <td> <code title=event-dragstart><a href=#event-dragstart>dragstart</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondrop> <code title="">ondrop</code> <td> <a href=#handler-ondrop title=handler-ondrop>HTML elements</a> <td> <code title=event-drop><a href=#event-drop>drop</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ondurationchange> <code title="">ondurationchange</code> <td> <a href=#handler-ondurationchange title=handler-ondurationchange>HTML elements</a> <td> <code title=event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onemptied> <code title="">onemptied</code> <td> <a href=#handler-onemptied title=handler-onemptied>HTML elements</a> <td> <code title=event-media-emptied><a href=#event-media-emptied>emptied</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onended> <code title="">onended</code> <td> <a href=#handler-onended title=handler-onended>HTML elements</a> <td> <code title=event-media-ended><a href=#event-media-ended>ended</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onerror> <code title="">onerror</code> <td> <code title=handler-window-onerror><a href=#handler-window-onerror>body</a></code> <td> <code title=event-error>error</code> event handler for <code><a href=#window>Window</a></code> object, and handler for <a href=#runtime-script-errors>script error notifications</a> <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onerror> <code title="">onerror</code> <td> <a href=#handler-onerror title=handler-onerror>HTML elements</a> <td> <code title=event-error>error</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onfocus> <code title="">onfocus</code> <td> <code title=handler-window-onfocus><a href=#handler-window-onfocus>body</a></code> <td> <code title=event-focus>focus</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onfocus> <code title="">onfocus</code> <td> <a href=#handler-onfocus title=handler-onfocus>HTML elements</a> <td> <code title=event-focus>focus</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onhashchange> <code title="">onhashchange</code> <td> <code title=handler-window-onhashchange><a href=#handler-window-onhashchange>body</a></code> <td> <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oninput> <code title="">oninput</code> <td> <a href=#handler-oninput title=handler-oninput>HTML elements</a> <td> <code title=event-input>input</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-oninvalid> <code title="">oninvalid</code> <td> <a href=#handler-oninvalid title=handler-oninvalid>HTML elements</a> <td> <code title=event-invalid>invalid</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onkeydown> <code title="">onkeydown</code> <td> <a href=#handler-onkeydown title=handler-onkeydown>HTML elements</a> <td> <code title=event-keydown>keydown</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onkeypress> <code title="">onkeypress</code> <td> <a href=#handler-onkeypress title=handler-onkeypress>HTML elements</a> <td> <code title=event-keypress>keypress</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onkeyup> <code title="">onkeyup</code> <td> <a href=#handler-onkeyup title=handler-onkeyup>HTML elements</a> <td> <code title=event-keyup>keyup</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onload> <code title="">onload</code> <td> <code title=handler-window-onload><a href=#handler-window-onload>body</a></code> <td> <code title=event-load>load</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onload> <code title="">onload</code> <td> <a href=#handler-onload title=handler-onload>HTML elements</a> <td> <code title=event-load>load</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onloadeddata> <code title="">onloadeddata</code> <td> <a href=#handler-onloadeddata title=handler-onloadeddata>HTML elements</a> <td> <code title=event-media-loadeddata><a href=#event-media-loadeddata>loadeddata</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onloadedmetadata> <code title="">onloadedmetadata</code> <td> <a href=#handler-onloadedmetadata title=handler-onloadedmetadata>HTML elements</a> <td> <code title=event-media-loadedmetadata><a href=#event-media-loadedmetadata>loadedmetadata</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onloadstart> <code title="">onloadstart</code> <td> <a href=#handler-onloadstart title=handler-onloadstart>HTML elements</a> <td> <code title=event-media-loadstart><a href=#event-media-loadstart>loadstart</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onmessage> <code title="">onmessage</code> <td> <code title=handler-window-onmessage><a href=#handler-window-onmessage>body</a></code> <td> <code title=event-message><a href=#event-message>message</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmousedown> <code title="">onmousedown</code> <td> <a href=#handler-onmousedown title=handler-onmousedown>HTML elements</a> <td> <code title=event-mousedown>mousedown</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmousemove> <code title="">onmousemove</code> <td> <a href=#handler-onmousemove title=handler-onmousemove>HTML elements</a> <td> <code title=event-mousemove>mousemove</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmouseout> <code title="">onmouseout</code> <td> <a href=#handler-onmouseout title=handler-onmouseout>HTML elements</a> <td> <code title=event-mouseout>mouseout</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmouseover> <code title="">onmouseover</code> <td> <a href=#handler-onmouseover title=handler-onmouseover>HTML elements</a> <td> <code title=event-mouseover>mouseover</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmouseup> <code title="">onmouseup</code> <td> <a href=#handler-onmouseup title=handler-onmouseup>HTML elements</a> <td> <code title=event-mouseup>mouseup</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onmousewheel> <code title="">onmousewheel</code> <td> <a href=#handler-onmousewheel title=handler-onmousewheel>HTML elements</a> <td> <code title=event-mousewheel>mousewheel</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onoffline> <code title="">onoffline</code> <td> <code title=handler-window-onoffline><a href=#handler-window-onoffline>body</a></code> <td> <code title=event-offline><a href=#event-offline>offline</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-ononline> <code title="">ononline</code> <td> <code title=handler-window-ononline><a href=#handler-window-ononline>body</a></code> <td> <code title=event-online><a href=#event-online>online</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onpagehide> <code title="">onpagehide</code> <td> <code title=handler-window-onpagehide><a href=#handler-window-onpagehide>body</a></code> <td> <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onpageshow> <code title="">onpageshow</code> <td> <code title=handler-window-onpageshow><a href=#handler-window-onpageshow>body</a></code> <td> <code title=event-pageshow><a href=#event-pageshow>pageshow</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onpause> <code title="">onpause</code> <td> <a href=#handler-onpause title=handler-onpause>HTML elements</a> <td> <code title=event-media-pause><a href=#event-media-pause>pause</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onplay> <code title="">onplay</code> <td> <a href=#handler-onplay title=handler-onplay>HTML elements</a> <td> <code title=event-media-play><a href=#event-media-play>play</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onplaying> <code title="">onplaying</code> <td> <a href=#handler-onplaying title=handler-onplaying>HTML elements</a> <td> <code title=event-media-playing><a href=#event-media-playing>playing</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onpopstate> <code title="">onpopstate</code> <td> <code title=handler-window-onpopstate><a href=#handler-window-onpopstate>body</a></code> <td> <code title=event-popstate><a href=#event-popstate>popstate</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onprogress> <code title="">onprogress</code> <td> <a href=#handler-onprogress title=handler-onprogress>HTML elements</a> <td> <code title=event-media-progress><a href=#event-media-progress>progress</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onratechange> <code title="">onratechange</code> <td> <a href=#handler-onratechange title=handler-onratechange>HTML elements</a> <td> <code title=event-media-ratechange><a href=#event-media-ratechange>ratechange</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onreset> <code title="">onreset</code> <td> <a href=#handler-onreset title=handler-onreset>HTML elements</a> <td> <code title=event-reset>reset</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onresize> <code title="">onresize</code> <td> <code title=handler-window-onresize><a href=#handler-window-onresize>body</a></code> <td> <code title=event-resize>resize</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onscroll> <code title="">onscroll</code> <td> <code title=handler-window-onscroll><a href=#handler-window-onscroll>body</a></code> <td> <code title=event-scroll>scroll</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onscroll> <code title="">onscroll</code> <td> <a href=#handler-onscroll title=handler-onscroll>HTML elements</a> <td> <code title=event-scroll>scroll</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onseeked> <code title="">onseeked</code> <td> <a href=#handler-onseeked title=handler-onseeked>HTML elements</a> <td> <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onseeking> <code title="">onseeking</code> <td> <a href=#handler-onseeking title=handler-onseeking>HTML elements</a> <td> <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onselect> <code title="">onselect</code> <td> <a href=#handler-onselect title=handler-onselect>HTML elements</a> <td> <code title=event-select>select</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onshow> <code title="">onshow</code> <td> <a href=#handler-onshow title=handler-onshow>HTML elements</a> <td> <code title=event-show>show</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onstalled> <code title="">onstalled</code> <td> <a href=#handler-onstalled title=handler-onstalled>HTML elements</a> <td> <code title=event-media-stalled><a href=#event-media-stalled>stalled</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onstorage> <code title="">onstorage</code> <td> <code title=handler-window-onstorage><a href=#handler-window-onstorage>body</a></code> <td> <code title=event-storage><a href=#event-storage>storage</a></code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onsubmit> <code title="">onsubmit</code> <td> <a href=#handler-onsubmit title=handler-onsubmit>HTML elements</a> <td> <code title=event-submit>submit</code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onsuspend> <code title="">onsuspend</code> <td> <a href=#handler-onsuspend title=handler-onsuspend>HTML elements</a> <td> <code title=event-media-suspend><a href=#event-media-suspend>suspend</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-ontimeupdate> <code title="">ontimeupdate</code> <td> <a href=#handler-ontimeupdate title=handler-ontimeupdate>HTML elements</a> <td> <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-window-onunload> <code title="">onunload</code> <td> <code title=handler-window-onunload><a href=#handler-window-onunload>body</a></code> <td> <code title=event-unload>unload</code> event handler for <code><a href=#window>Window</a></code> object <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onvolumechange> <code title="">onvolumechange</code> <td> <a href=#handler-onvolumechange title=handler-onvolumechange>HTML elements</a> <td> <code title=event-media-volumechange><a href=#event-media-volumechange>volumechange</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> <tr><th id=ix-handler-onwaiting> <code title="">onwaiting</code> <td> <a href=#handler-onwaiting title=handler-onwaiting>HTML elements</a> <td> <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> event handler <td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a> </table><!-- v2 for completeness: (also search for REFLECTIDL) <h3 class="no-num">Reflecting IDL attributes</h3> <p><i>This section is non-normative.</i></p> <table> <caption>List of <dfn>reflecting IDL attributes</dfn></caption> <thead> <tr> <th> Interface <th> Element(s) <th> IDL attribute <th> Reflects... <tbody> ... <tr> <td> <code>HTMLElement</code> <td> <span>HTML elements</span> <td> <code title="dom-contextMenu">contextMenu</code> <td> <code title="attr-contextmenu">contextmenu</code> <tr> <td> <code>HTMLOptionElement</code> <td> <code>option</code> <td> <code title="dom-option-text">text</code> <td> <code>textContent</code> </table> ( include option.text; textarea.defaultValue, and other attributes that "reflect" the element's textContent ) --><h3 class=no-num id=interfaces>Interfaces</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><a href=#the-a-element>a</a></code> <td> <code><a href=#htmlanchorelement>HTMLAnchorElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-abbr-element>abbr</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-address-element>address</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-area-element>area</a></code> <td> <code><a href=#htmlareaelement>HTMLAreaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-article-element>article</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-aside-element>aside</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-audio-element>audio</a></code> <td> <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-b-element>b</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-base-element>base</a></code> <td> <code><a href=#htmlbaseelement>HTMLBaseElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-bdi-element>bdi</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-bdo-element>bdo</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-blockquote-element>blockquote</a></code> <td> <code><a href=#htmlquoteelement>HTMLQuoteElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-body-element>body</a></code> <td> <code><a href=#htmlbodyelement>HTMLBodyElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-br-element>br</a></code> <td> <code><a href=#htmlbrelement>HTMLBRElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-button-element>button</a></code> <td> <code><a href=#htmlbuttonelement>HTMLButtonElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-canvas-element>canvas</a></code> <td> <code><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-caption-element>caption</a></code> <td> <code><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-cite-element>cite</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-code-element>code</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-col-element>col</a></code> <td> <code><a href=#htmltablecolelement>HTMLTableColElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-colgroup-element>colgroup</a></code> <td> <code><a href=#htmltablecolelement>HTMLTableColElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-command-element>command</a></code> <td> <code><a href=#htmlcommandelement>HTMLCommandElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-data-element>data</a></code> <td> <code><a href=#htmldataelement>HTMLDataElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-datalist-element>datalist</a></code> <td> <code><a href=#htmldatalistelement>HTMLDataListElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-dd-element>dd</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-del-element>del</a></code> <td> <code><a href=#htmlmodelement>HTMLModElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-details-element>details</a></code> <td> <code><a href=#htmldetailselement>HTMLDetailsElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-dfn-element>dfn</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-div-element>div</a></code> <td> <code><a href=#htmldivelement>HTMLDivElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-dl-element>dl</a></code> <td> <code><a href=#htmldlistelement>HTMLDListElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-dt-element>dt</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-em-element>em</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-embed-element>embed</a></code> <td> <code><a href=#htmlembedelement>HTMLEmbedElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-fieldset-element>fieldset</a></code> <td> <code><a href=#htmlfieldsetelement>HTMLFieldSetElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-figcaption-element>figcaption</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-figure-element>figure</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-footer-element>footer</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-form-element>form</a></code> <td> <code><a href=#htmlformelement>HTMLFormElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-head-element>head</a></code> <td> <code><a href=#htmlheadelement>HTMLHeadElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> <td> <code><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-header-element>header</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-hgroup-element>hgroup</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-hr-element>hr</a></code> <td> <code><a href=#htmlhrelement>HTMLHRElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-html-element>html</a></code> <td> <code><a href=#htmlhtmlelement>HTMLHtmlElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-i-element>i</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-iframe-element>iframe</a></code> <td> <code><a href=#htmliframeelement>HTMLIFrameElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-img-element>img</a></code> <td> <code><a href=#htmlimageelement>HTMLImageElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-input-element>input</a></code> <td> <code><a href=#htmlinputelement>HTMLInputElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-ins-element>ins</a></code> <td> <code><a href=#htmlmodelement>HTMLModElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-kbd-element>kbd</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-keygen-element>keygen</a></code> <td> <code><a href=#htmlkeygenelement>HTMLKeygenElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-label-element>label</a></code> <td> <code><a href=#htmllabelelement>HTMLLabelElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-legend-element>legend</a></code> <td> <code><a href=#htmllegendelement>HTMLLegendElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-li-element>li</a></code> <td> <code><a href=#htmllielement>HTMLLIElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-link-element>link</a></code> <td> <code><a href=#htmllinkelement>HTMLLinkElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-map-element>map</a></code> <td> <code><a href=#htmlmapelement>HTMLMapElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-mark-element>mark</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-menu-element>menu</a></code> <td> <code><a href=#htmlmenuelement>HTMLMenuElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-meta-element>meta</a></code> <td> <code><a href=#htmlmetaelement>HTMLMetaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-meter-element>meter</a></code> <td> <code><a href=#htmlmeterelement>HTMLMeterElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-nav-element>nav</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-noscript-element>noscript</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-object-element>object</a></code> <td> <code><a href=#htmlobjectelement>HTMLObjectElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-ol-element>ol</a></code> <td> <code><a href=#htmlolistelement>HTMLOListElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-optgroup-element>optgroup</a></code> <td> <code><a href=#htmloptgroupelement>HTMLOptGroupElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-option-element>option</a></code> <td> <code><a href=#htmloptionelement>HTMLOptionElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-output-element>output</a></code> <td> <code><a href=#htmloutputelement>HTMLOutputElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-p-element>p</a></code> <td> <code><a href=#htmlparagraphelement>HTMLParagraphElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-param-element>param</a></code> <td> <code><a href=#htmlparamelement>HTMLParamElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-pre-element>pre</a></code> <td> <code><a href=#htmlpreelement>HTMLPreElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-progress-element>progress</a></code> <td> <code><a href=#htmlprogresselement>HTMLProgressElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-q-element>q</a></code> <td> <code><a href=#htmlquoteelement>HTMLQuoteElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-rp-element>rp</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-rt-element>rt</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-ruby-element>ruby</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-s-element>s</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-samp-element>samp</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-script-element>script</a></code> <td> <code><a href=#htmlscriptelement>HTMLScriptElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-section-element>section</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-select-element>select</a></code> <td> <code><a href=#htmlselectelement>HTMLSelectElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-small-element>small</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-source-element>source</a></code> <td> <code><a href=#htmlsourceelement>HTMLSourceElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-span-element>span</a></code> <td> <code><a href=#htmlspanelement>HTMLSpanElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-strong-element>strong</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-style-element>style</a></code> <td> <code><a href=#htmlstyleelement>HTMLStyleElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-sub-and-sup-elements>sub</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-summary-element>summary</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-sub-and-sup-elements>sup</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-table-element>table</a></code> <td> <code><a href=#htmltableelement>HTMLTableElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-tbody-element>tbody</a></code> <td> <code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-td-element>td</a></code> <td> <code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code> : <code><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-textarea-element>textarea</a></code> <td> <code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-tfoot-element>tfoot</a></code> <td> <code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-th-element>th</a></code> <td> <code><a href=#htmltableheadercellelement>HTMLTableHeaderCellElement</a></code> : <code><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-thead-element>thead</a></code> <td> <code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-title-element>title</a></code> <td> <code><a href=#htmltitleelement>HTMLTitleElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-tr-element>tr</a></code> <td> <code><a href=#htmltablerowelement>HTMLTableRowElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-track-element>track</a></code> <td> <code><a href=#htmltrackelement>HTMLTrackElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-u-element>u</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-ul-element>ul</a></code> <td> <code><a href=#htmlulistelement>HTMLUListElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-var-element>var</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-video-element>video</a></code> <td> <code><a href=#htmlvideoelement>HTMLVideoElement</a></code> : <code><a href=#htmlmediaelement>HTMLMediaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code> <tr><td> <code><a href=#the-wbr-element>wbr</a></code> <td> <code><a href=#htmlelement>HTMLElement</a></code> </table><h2 class=no-num id=references>References</h2><!--REFS--> <p>All references are normative unless marked "Non-normative".</p> <!-- Dates are only included for standards older than the Web, because the newer ones keep changing. --> <dl><dt id=refsABNF>[ABNF]</dt> <dd><cite><a href=http://www.ietf.org/rfc/std/std68.txt>Augmented BNF for Syntax Specifications: ABNF</a></cite>, D. Crocker, P. Overell. IETF.</dd> <dt id=refsABOUT>[ABOUT]</dt> <dd><cite><a href=http://tools.ietf.org/html/draft-ietf-appsawg-about-uri-scheme>The 'about' URI scheme</a></cite>, L. Hunt, M. Yevstifeyev. IETF.</dd> <dt id=refsAES128CTR>[AES128CTR]</dt> <dd><cite><a href=http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf>Advanced Encryption Standard (AES)</a></cite>. NIST.</dd> <dt id=refsARIA>[ARIA]</dt> <dd><cite><a href=http://www.w3.org/WAI/PF/aria/>Accessible Rich Internet Applications (WAI-ARIA)</a></cite>, J. Craig, M. Cooper, L. Pappas, R. Schwerdtfeger, L. Seeman. W3C.</dd> <dt id=refsARIAIMPL>[ARIAIMPL]</dt> <dd><cite><a href=http://www.w3.org/WAI/PF/aria-implementation/>WAI-ARIA 1.0 User Agent Implementation Guide</a></cite>, A. Snow-Weaver, M. Cooper. W3C.</dd> <dt id=refsATAG>[ATAG]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/TR/ATAG20/>Authoring Tool Accessibility Guidelines (ATAG) 2.0</a></cite>, J. Richards, J. Spellman, J. Treviranus. W3C.</dd> <dt id=refsATOM>[ATOM]</dt> <dd>(Non-normative) <cite><a href=http://tools.ietf.org/html/rfc4287>The Atom Syndication Format</a></cite>, M. Nottingham, R. Sayre. IETF.</dd> <dt id=refsBCP47>[BCP47]</dt> <dd><cite><a href=http://www.ietf.org/rfc/bcp/bcp47.txt>Tags for Identifying Languages; Matching of Language Tags</a></cite>, A. Phillips, M. Davis. IETF.</dd> <dt id=refsBECSS>[BECSS]</dt> <dd><cite><a href=http://www.w3.org/TR/becss/>Behavioral Extensions to CSS</a></cite>, I. Hickson. W3C.</dd> <dt id=refsBEZIER>[BEZIER]</dt> <dd><cite>Courbes à poles</cite>, P. de Casteljau. INPI, 1959.</dd> <dt id=refsBIDI>[BIDI]</dt> <dd><cite><a href=http://www.unicode.org/reports/tr9/>UAX #9: Unicode Bidirectional Algorithm</a></cite>, M. Davis. Unicode Consortium.</dd> <dt id=refsBOCU1>[BOCU1]</dt> <dd>(Non-normative) <cite><a href=http://www.unicode.org/notes/tn6/>UTN #6: BOCU-1: MIME-Compatible Unicode Compression</a></cite>, M. Scherer, M. Davis. Unicode Consortium.</dd> <dt id=refsCESU8>[CESU8]</dt> <dd>(Non-normative) <cite><a href=http://www.unicode.org/reports/tr26/>UTR #26: Compatibility Encoding Scheme For UTF-16: 8-BIT (CESU-8)</a></cite>, T. Phipps. Unicode Consortium.</dd> <dt id=refsCHARMOD>[CHARMOD]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/TR/charmod/>Character Model for the World Wide Web 1.0: Fundamentals</a></cite>, M. Dürst, F. Yergeau, R. Ishida, M. Wolf, T. Texin. W3C.</dd> <dt id=refsCLDR>[CLDR]</dt> <dd><cite><a href=http://cldr.unicode.org/>Unicode Common Locale Data Repository</a></cite>. Unicode.</dd> <dt id=refsCOMPUTABLE>[COMPUTABLE]</dt> <dd>(Non-normative) <cite><a href=http://www.turingarchive.org/browse.php/B/12>On computable numbers, with an application to the Entscheidungsproblem</a></cite>, A. Turing. In <cite>Proceedings of the London Mathematical Society</cite>, series 2, volume 42, pages 230-265. London Mathematical Society, 1937.</dd> <dt id=refsCOOKIES>[COOKIES]</dt> <!-- <dd><cite><a href="http://tools.ietf.org/html/rfc2109">HTTP State Management Mechanism</a></cite>, D. Kristol, L. Montulli. IETF.</dd> <dd><cite><a href="http://tools.ietf.org/html/rfc2965">HTTP State Management Mechanism</a></cite>, D. Kristol, L. Montulli. IETF.</dd> --> <dd><cite><a href=http://tools.ietf.org/html/rfc6265>HTTP State Management Mechanism</a></cite>, A. Barth. IETF.</dd> <dt id=refsCORS>[CORS]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/cors/">Cross-Origin Resource Sharing</a></cite>, A. van Kesteren. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/2006/waf/access-control/>Cross-Origin Resource Sharing</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsCP50220>[CP50220]</dt> <dd><cite><a href=http://www.iana.org/assignments/charset-reg/CP50220>CP50220</a></cite>, Y. Naruse. IANA.</dd> <!-- really should be "NARUSE, Y." or some such, but there's a western bias to these references for consistency. sorry. --> <dt id=refsCP51932>[CP51932]</dt> <dd><cite><a href=http://www.iana.org/assignments/charset-reg/CP51932>CP51932</a></cite>, Y. Naruse. IANA.</dd> <!-- really should be "NARUSE, Y." or some such, but there's a western bias to these references for consistency. sorry. --> <dt id=refsCSS>[CSS]</dt> <dd><cite><a href=http://www.w3.org/TR/CSS/>Cascading Style Sheets Level 2 Revision 1</a></cite>, B. Bos, T. Çelik, I. Hickson, H. Lie. W3C.</dd> <dt id=refsCSSATTR>[CSSATTR]</dt> <dd><cite><a href=http://dev.w3.org/csswg/css-style-attr/>CSS Styling Attribute Syntax</a></cite>, T. Çelik, E. Etemad. W3C.</dd> <dt id=refsCSSCOLOR>[CSSCOLOR]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/css3-color/">CSS Color Module Level 3</a></cite>, T. Çelik, C. Lilley, L. Baron. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/csswg/css3-color/>CSS Color Module Level 3</a></cite>, T. Çelik, C. Lilley, L. Baron. W3C.</dd> <dt id=refsCSSFONTS>[CSSFONTS]</dt> <dd><cite><a href=http://www.w3.org/TR/css3-fonts/>CSS Fonts Module Level 3</a></cite>, J. Daggett. W3C.</dd> <dt id=refsCSSIMAGES>[CSSIMAGES]</dt> <dd><cite><a href=http://dev.w3.org/csswg/css3-images/>CSS Image Values and Replaced Content Module Level 3</a></cite>, E. Etemad, T. Atkins. W3C.</dd> <dt id=refsCSSOM>[CSSOM]</dt> <dd><cite><a href=http://dev.w3.org/csswg/cssom/>Cascading Style Sheets Object Model (CSSOM)</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsCSSOMVIEW>[CSSOMVIEW]</dt> <dd><cite><a href=http://dev.w3.org/csswg/cssom-view/>CSSOM View Module</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsCSSRUBY>[CSSRUBY]</dt> <dd><cite><a href=http://dev.w3.org/csswg/css3-ruby/>CSS3 Ruby Module</a></cite>, R. Ishida. W3C.</dd> <dt id=refsCSSUI>[CSSUI]</dt> <dd><cite><a href=http://dev.w3.org/csswg/css3-ui/>CSS3 Basic User Interface Module</a></cite>, T. Çelik. W3C.</dd> <dt id=refsCSSVALUES>[CSSVALUES]</dt> <dd><cite><a href=http://dev.w3.org/csswg/css3-values/>CSS3 Values and Units</a></cite>, H. Lie, C. Lilley. W3C.</dd> <dt id=refsDOMCORE>[DOMCORE]</dt> <dd><cite><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html>Web DOM Core</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsDOMEVENTS>[DOMEVENTS]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Events/">Document Object Model (DOM) Level 3 Events Specification</a></cite>, B. Höhrmann, P. Le Hegaret, T. Pixley. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html>Document Object Model (DOM) Level 3 Events Specification</a></cite>, D. Schepers. W3C.</dd> <dt id=refsDOMPARSING>[DOMPARSING]</dt> <dd><cite><a href=http://html5.org/specs/dom-parsing.html>DOM Parsing and Serialization</a></cite>, Ms2ger. html5.org.</dd> <dt id=refsDOMRANGE>[DOMRANGE]</dt> <dd><cite><a href=http://html5.org/specs/dom-range.html>DOM Range</a></cite>, A. Gregor, Ms2ger. html5.org.</dd> <dt id=refsDOT>[DOT]</dt> <dd>(Non-normative) <cite><a href=http://www.graphviz.org/content/dot-language>The DOT Language</a></cite>. Graphviz.</dd> <dt id=refsE163>[E163]</dt> <dd><cite>Recommendation E.163 — Numbering Plan for The International Telephone Service</cite>, CCITT Blue Book, Fascicle II.2, pp. 128-134, November 1988.</dd> <dt id=refsECMA262>[ECMA262]</dt> <dd><cite><a href=http://www.ecma-international.org/publications/standards/Ecma-262.htm>ECMAScript Language Specification</a></cite>. ECMA.</dd> <dt id=refsEDITING>[EDITING]</dt> <dd><cite><a href=http://aryeh.name/spec/editing/editing.html>HTML Editing APIs</a></cite>, A. Gregor.</dd> <dt id=refsECMA357>[ECMA357]</dt> <dd>(Non-normative) <cite><a href=http://www.ecma-international.org/publications/standards/Ecma-357.htm>ECMAScript for XML (E4X) Specification</a></cite>. ECMA.</dd> <dt id=refsEUCKR>[EUCKR]</dt> <dd><cite>Hangul Unix Environment</cite>. Korea Industrial Standards Association. Ref. No. KS C 5861-1992.</dd> <dt id=refsEUCJP>[EUCJP]</dt> <dd><cite>Definition and Notes of Japanese EUC</cite>. UI-OSF-USLP. In English in the abridged translation of the <a href=http://home.m05.itscom.net/numa/uocjleE.pdf>UI-OSF Application Platform Profile for Japanese Environment</a>, Appendix C.</dd> <dt id=refsFILEAPI>[FILEAPI]</dt> <dd><cite><a href=http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html>File API</a></cite>, A. Ranganathan. W3C.</dd> <dt id=refsFILESYSTEMAPI>[FILESYSTEMAPI]</dt> <dd><cite><a href=http://dev.w3.org/2009/dap/file-system/file-dir-sys.html>File API: Directories and System</a></cite>, E. Uhrhane. W3C.</dd> <dt id=refsGBK>[GBK]</dt> <dd><cite>Chinese Internal Code Specification</cite>. Chinese IT Standardization Technical Committee.</dd> <!-- http://www.iana.org/assignments/charset-reg/GBK --> <dt id=refsGRAPHICS>[GRAPHICS]</dt> <dd>(Non-normative) <cite>Computer Graphics: Principles and Practice in C</cite>, Second Edition, J. Foley, A. van Dam, S. Feiner, J. Hughes. Addison-Wesley. ISBN 0-201-84840-6.</dd> <!-- This book ("Computer Graphics: Principles and Practice in C") apparently does not make any references to literature in the bibliographic section to define the "even-odd" rule for polygon filling and hit testing. In the absence of such a reference, I guess that this book is the most authoritative reference. --> <dt id=refsGREGORIAN>[GREGORIAN]</dt> <dd>(Non-normative) <cite>Inter Gravissimas</cite>, A. Lilius, C. Clavius. Gregory XIII Papal Bulls, February 1582.</dd> <dt id=refsHMAC>[HMAC]</dt> <dd><cite><a href=http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf>The Keyed-Hash Message Authentication Code (HMAC)</a></cite>. NIST.</dd> <dt id=refsHTMLDIFF>[HTMLDIFF]</dt> <!-- <dd>(Non-normative) <cite><a href="http://www.w3.org/TR/html5-diff/">HTML5 differences from HTML4</a></cite>, A. van Kesteren. W3C.</dd> --> <dd>(Non-normative) <cite><a href=http://dev.w3.org/html5/html4-differences/>HTML5 differences from HTML4</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsHTTP>[HTTP]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2616>Hypertext Transfer Protocol — HTTP/1.1</a></cite>, R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee. IETF.</dd> <dt id=refsIANACHARSET>[IANACHARSET]</dt> <dd><cite><a href=http://www.iana.org/assignments/character-sets>Character Sets</a></cite>. IANA.</dd> <dt id=refsIANAPERMHEADERS>[IANAPERMHEADERS]</dt> <dd><cite><a href=http://www.iana.org/assignments/message-headers/perm-headers.html>Permanent Message Header Field Names</a></cite>. IANA.</dd> <dt id=refsICE>[ICE]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5245>Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols</a></cite>, J. Rosenberg. IETF.</dd> <dt id=refsISO8601>[ISO8601]</dt> <dd><cite><a href="http://isotc.iso.org/livelink/livelink/4021199/ISO_8601_2004_E.zip?func=doc.Fetch&nodeid=4021199">ISO8601: Data elements and interchange formats — Information interchange — Representation of dates and times</a></cite>. ISO.</dd> <dt id=refsISO885911>[ISO885911]</dt> <dd><cite><a href=http://std.dkuug.dk/jtc1/sc2/open/02n3333.pdf>ISO-8859-11: Information technology — 8-bit single-byte coded graphic character sets — Part 11: Latin/Thai alphabet</a></cite>. ISO.</dd> <dt id=refsJPEG>[JPEG]</dt> <dd><cite><a href=http://www.w3.org/Graphics/JPEG/jfif3.pdf>JPEG File Interchange Format</a></cite>, E. Hamilton.</dd> <dt id=refsJSON>[JSON]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4627>The application/json Media Type for JavaScript Object Notation (JSON)</a></cite>, D. Crockford. IETF.</dd> <dt id=refsJSURL>[JSURL]</dt> <dd><cite><a href=http://tools.ietf.org/html/draft-hoehrmann-javascript-scheme>The 'javascript' resource identifier scheme</a></cite>, B. Höhrmann. IETF.</dd> <dt id=refsMAILTO>[MAILTO]</dt> <dd>(Non-normative) <cite><a href=http://tools.ietf.org/html/rfc6068>The 'mailto' URI scheme</a></cite>, M. Duerst, L. Masinter, J. Zawinski. IETF.</dd> <dt id=refsMATHML>[MATHML]</dt> <dd><cite><a href=http://www.w3.org/TR/MathML/>Mathematical Markup Language (MathML)</a></cite>, D. Carlisle, P. Ion, R. Miner, N. Poppelier. W3C.</dd> <dt id=refsMEDIAFRAG>[MEDIAFRAG]</dt> <dd><cite><a href=http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/>Media Fragments URI</a></cite>, R. Troncy, E. Mannens, S. Pfeiffer, D. Van Deursen. W3C.</dd> <dt id=refsMFREL>[MFREL]</dt> <dd><cite><a href=http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions>Microformats Wiki: existing rel values</a></cite>. Microformats.</dd> <dt id=refsMIMESNIFF>[MIMESNIFF]</dt> <dd><cite><a href=http://mimesniff.spec.whatwg.org/>MIME Sniffing</a></cite>, A. Barth, I. Hickson. WHATWG.</dd> <dt id=refsMQ>[MQ]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/css3-mediaqueries/">Media Queries</a></cite>, H. Lie, T. Çelik, D. Glazman, A. van Kesteren. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/csswg/css3-mediaqueries/>Media Queries</a></cite>, H. Lie, T. Çelik, D. Glazman, A. van Kesteren. W3C.</dd> <dt id=refsNPAPI>[NPAPI]</dt> <dd>(Non-normative) <cite><a href=https://developer.mozilla.org/en/Gecko_Plugin_API_Reference>Gecko Plugin API Reference</a></cite>. Mozilla.</dd> <dt id=refsOPENSEARCH>[OPENSEARCH]</dt> <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.</dd> <dt id=refsORIGIN>[ORIGIN]</dt> <dd><cite><a href=http://tools.ietf.org/html/draft-ietf-websec-origin>The Web Origin Concept</a></cite>, A. Barth. IETF.</dd> <dt id=refsPDF>[PDF]</dt> <dd>(Non-normative) <cite><a href=http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf>Document management — Portable document format — Part 1: PDF</a></cite>. ISO.</dd> <dt id=refsPINGBACK>[PINGBACK]</dt> <dd><cite><a href=http://www.hixie.ch/specs/pingback/pingback>Pingback 1.0</a></cite>, S. Langridge, I. Hickson.</dd> <dt id=refsPNG>[PNG]</dt> <dd><cite><a href=http://www.w3.org/TR/PNG/>Portable Network Graphics (PNG) Specification</a></cite>, D. Duce. W3C.</dd> <dt id=refsPOLYGLOT>[POLYGLOT]</dt> <dd>(Non-normative) <cite><a href=http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html>Polyglot Markup: HTML-Compatible XHTML Documents</a></cite>, E. Graff. W3C.</dd> <dt id=refsPORTERDUFF>[PORTERDUFF]</dt> <dd><cite><a href=http://keithp.com/~keithp/porterduff/p253-porter.pdf>Compositing Digital Images</a></cite>, T. Porter, T. Duff. In <cite>Computer graphics</cite>, volume 18, number 3, pp. 253-259. ACM Press, July 1984.</dd> <dt id=refsPPUTF8>[PPUTF8]</dt> <dd>(Non-normative) <cite><a href=http://www.ifi.uzh.ch/mml/mduerst/papers/PDF/IUC11-UTF-8.pdf>The Properties and Promises <!-- Promizes (sic) --> of UTF-8</a></cite>, M. Dürst. University of Zürich. In <cite>Proceedings of the 11th International Unicode Conference</cite>.</dd> <dt id=refsPROGRESS>[PROGRESS]</dt> <dd><cite><a href=http://dev.w3.org/2006/webapi/progress/>Progress Events</a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsPSL>[PSL]</dt> <dd><cite><a href=http://publicsuffix.org/>Public Suffix List</a></cite>. Mozilla Foundation.</dd> <dt id=refsRFC1034>[RFC1034]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1034>Domain Names - Concepts and Facilities</a></cite>, P. Mockapetris. IETF, November 1987.</dd> <dt id=refsRFC1345>[RFC1345]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1345>Character Mnemonics and Character Sets</a></cite>, K. Simonsen. IETF.</dd> <dt id=refsRFC1468>[RFC1468]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1468>Japanese Character Encoding for Internet Messages</a></cite>, J. Murai, M. Crispin, E. van der Poel. IETF.</dd> <dt id=refsRFC1554>[RFC1554]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1554>ISO-2022-JP-2: Multilingual Extension of ISO-2022-JP</a></cite>, M. Ohta, K. Handa. IETF.</dd> <dt id=refsRFC1557>[RFC1557]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1557>Korean Character Encoding for Internet Messages</a></cite>, U. Choi, K. Chon, H. Park. IETF.</dd> <dt id=refsRFC1842>[RFC1842]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1842>ASCII Printable Characters-Based Chinese Character Encoding for Internet Messages</a></cite>, Y. Wei, Y. Zhang, J. Li, J. Ding, Y. Jiang. IETF.</dd> <dt id=refsRFC1922>[RFC1922]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc1922>Chinese Character Encoding for Internet Messages</a></cite>, HF. Zhu, DY. Hu, ZG. Wang, TC. Kao, WCH. Chang, M. Crispin. IETF.</dd> <dt id=refsRFC2046>[RFC2046]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2046>Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N. Borenstein. IETF.</dd> <!-- for text/plain and "Internet Media type"; not for definition of "valid MIME type". --> <dt id=refsRFC2119>[RFC2119]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2119>Key words for use in RFCs to Indicate Requirement Levels</a></cite>, S. Bradner. IETF.</dd> <dt id=refsRFC2237>[RFC2237]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2237>Japanese Character Encoding for Internet Messages</a></cite>, K. Tamaru. IETF.</dd> <dt id=refsRFC2313>[RFC2313]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2313>PKCS #1: RSA Encryption</a></cite>, B. Kaliski. IETF.</dd> <dt id=refsRFC2318>[RFC2318]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2318>The text/css Media Type</a></cite>, H. Lie, B. Bos, C. Lilley. IETF.</dd> <dt id=refsRFC2388>[RFC2388]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2388>Returning Values from Forms: multipart/form-data</a></cite>, L. Masinter. IETF.</dd> <dt id=refsRFC2397>[RFC2397]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2397>The "data" URL scheme</a></cite>, L. Masinter. IETF.</dd> <dt id=refsRFC2445>[RFC2445]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2445>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</a></cite>, F. Dawson, D. Stenerson. IETF.</dd> <dt id=refsRFC2483>[RFC2483]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2483>URI Resolution Services Necessary for URN Resolution</a></cite>, M. Mealling, R. Daniel. IETF.</dd> <dt id=refsRFC2781>[RFC2781]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2781>UTF-16, an encoding of ISO 10646</a></cite>, P. Hoffman, F. Yergeau. IETF.</dd> <dt id=refsRFC3676>[RFC3676]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3676>The Text/Plain Format and DelSp Parameters</a></cite>, R. Gellens. IETF.</dd> <dt id=refsRFC3023>[RFC3023]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3023>XML Media Types</a></cite>, M. Murata, S. St. Laurent, D. Kohn. IETF.</dd> <dt id=refsRFC3279>[RFC3279]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3279>Algorithms and Identifiers for the Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile</a></cite>, W. Polk, R. Housley, L. Bassham. IETF.</dd> <dt id=refsRFC3490>[RFC3490]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3490>Internationalizing Domain Names in Applications (IDNA)</a></cite>, P. Faltstrom, P. Hoffman, A. Costello. IETF.</dd> <dt id=refsRFC3629>[RFC3629]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3629>UTF-8, a transformation format of ISO 10646</a></cite>, F. Yergeau. IETF.</dd> <dt id=refsRFC3864>[RFC3864]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3864>Registration Procedures for Message Header Fields</a></cite>, G. Klyne, M. Nottingham, J. Mogul. IETF.</dd> <dt id=refsRFC3986>[RFC3986]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3986>Uniform Resource Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding, L. Masinter. IETF.</dd> <dt id=refsRFC3987>[RFC3987]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3987>Internationalized Resource Identifiers (IRIs)</a></cite>, M. Dürst, M. Suignard. IETF.</dd> <dt id=refsRFC4281>[RFC4281]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4281>The Codecs Parameter for "Bucket" Media Types</a></cite>, R. Gellens, D. Singer, P. Frojdh. IETF.</dd> <dt id=refsRFC4329>[RFC4329]</dt> <dd>(Non-normative) <cite><a href=http://tools.ietf.org/html/rfc4329>Scripting Media Types</a></cite>, B. Höhrmann. IETF.</dd> <dt id=refsRFC4395>[RFC4395]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4395>Guidelines and Registration Procedures for New URI Schemes</a></cite>, T. Hansen, T. Hardie, L. Masinter. IETF.</dd> <dt id=refsRFC4648>[RFC4648]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4648>The Base16, Base32, and Base64 Data Encodings</a></cite>, S. Josefsson. IETF.</dd> <dt id=refsRFC5280>[RFC5280]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5280>Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile</a></cite>, D. Cooper, S. Santesson, S. Farrell, S. Boeyen, R. Housley, W. Polk. IETF.</dd> <dt id=refsRFC5322>[RFC5322]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5322>Internet Message Format</a></cite>, P. Resnick. IETF.</dd> <dt id=refsRFC5724>[RFC5724]</dt> <dd><cite><a href=http://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.</dd> <dt id=refsRFC6266>[RFC6266]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc6266>Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)</a></cite>, J. Reschke. IETF.</dd> <dt id=refsRFC6350>[RFC6350]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc6350>vCard Format Specification</a></cite>, S. Perreault. IETF.</dd> <dt id=refsSCSU>[SCSU]</dt> <dd>(Non-normative) <cite><a href=http://www.unicode.org/reports/tr6/>UTR #6: A Standard Compression Scheme For Unicode</a></cite>, M. Wolf, K. Whistler, C. Wicksteed, M. Davis, A. Freytag, M. Scherer. Unicode Consortium.</dd> <dt id=refsSDP>[SDP]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4566>SDP: Session Description Protocol</a></cite>, M. Handley, V. Jacobson, C. Perkins. IETF.</dd> <dt id=refsSDPLABEL>[SDPLABEL]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc4574>The Session Description Protocol (SDP) Label Attribute</a></cite>, O. Levin, G. Camarillo. IETF.</dd> <dt id=refsSDPOFFERANSWER>[SDPOFFERANSWER]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc3264>An Offer/Answer Model with the Session Description Protocol (SDP)</a></cite>, J. Rosenberg, H. Schulzrinne. IETF.</dd> <dt id=refsSELECTORS>[SELECTORS]</dt> <dd><cite><a href=http://dev.w3.org/csswg/selectors4/>Selectors</a></cite>, E. Etemad, T. Çelik, D. Glazman, I. Hickson, P. Linss, J. Williams. W3C.</dd> <dt id=refsSHA1>[SHA1]</dt> <dd><cite><a href=http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf>Secure Hash Standard</a></cite>. NIST.</dd> <dt id=refsSHIFTJIS>[SHIFTJIS]</dt> <dd><cite>JIS X0208: 7-bit and 8-bit double byte coded KANJI sets for information interchange</cite>. Japanese Industrial Standards Committee.</dd> <dt id=refsSRGB>[SRGB]</dt> <dd><cite lang=en-GB><a href="http://webstore.iec.ch/webstore/webstore.nsf/artnum/025408!OpenDocument&Click=">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.</dd> <dt id=refsSTUN>[STUN]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5389>Session Traversal Utilities for NAT (STUN)</a></cite>, J. Rosenberg, R. Mahy, P. Matthews, D. Wing. IETF.</dd> <dt id=refsSVG>[SVG]</dt> <dd><cite><a href=http://www.w3.org/TR/SVGTiny12/>Scalable Vector Graphics (SVG) Tiny 1.2 Specification</a></cite>, O. Andersson, R. Berjon, E. Dahlström, A. Emmons, J. Ferraiolo, A. Grasso, V. Hardy, S. Hayman, D. Jackson, C. Lilley, C. McCormack, A. Neumann, C. Northway, A. Quint, N. Ramani, D. Schepers, A. Shellshear. W3C.</dd> <dt id=refsTIS620>[TIS620]</dt> <dd><cite><a href=http://www.nectec.or.th/it-standards/std620/std620.htm>UDC 681.3.04:003.62</a></cite>. Thai Industrial Standards Institute, Ministry of Industry, Royal Thai Government. ISBN 974-606-153-4.</dd> <dt id=refsTURN>[TURN]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5766>Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)</a></cite>, R. Mahy, P. Matthews, J. Rosenberg. IETF.</dd> <dt id=refsTYPEDARRAY>[TYPEDARRAY]</dt> <dd><cite><a href=http://www.khronos.org/registry/typedarray/specs/latest/>Typed Array Specification</a></cite>, D. Herman, K. Russell. Khronos.</dd> <dt id=refsUAAG>[UAAG]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/TR/UAAG20/>Web Content Accessibility Guidelines (UAAG) 2.0</a></cite>, J. Allan, K. Ford, J. Richards, J. Spellman. W3C.</dd> <dt id=refsUNDO>[UNDO]</dt> <dd><cite><a href=http://rniwa.com/editing/undomanager.html>UndoManager and DOM Transaction</a></cite>, R. Niwa.</dd> <dt id=refsUNICODE>[UNICODE]</dt> <dd><cite><a href=http://www.unicode.org/versions/>The Unicode Standard</a></cite>. Unicode Consortium.</dd> <dt id=refsUNIVCHARDET>[UNIVCHARDET]</dt> <dd>(Non-normative) <cite><a href=http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html>A composite approach to language/encoding detection</a></cite>, S. Li, K. Momoi. Netscape. In <cite>Proceedings of the 19th International Unicode Conference</cite>.</dd> <dt id=refsUTF7>[UTF7]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc2152>UTF-7: A Mail-Safe Transformation Format of Unicode</a></cite>, D. Goldsmith, M. Davis. IETF.</dd> <dt id=refsUTF8DET>[UTF8DET]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/International/questions/qa-forms-utf-8>Multilingual form encoding</a></cite>, M. Dürst. W3C.</dd> <dt id=refsUTR36>[UTR36]</dt> <dd>(Non-normative) <cite><a href=http://www.unicode.org/reports/tr36/>UTR #36: Unicode Security Considerations</a></cite>, M. Davis, M. Suignard. Unicode Consortium.</dd> <dt id=refsWCAG>[WCAG]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/TR/WCAG20/>Web Content Accessibility Guidelines (WCAG) 2.0</a></cite>, B. Caldwell, M. Cooper, L. Reid, G. Vanderheiden. W3C.</dd> <dt id=refsWEBGL>[WEBGL]</dt> <dd><cite><a href=https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html>WebGL Specification</a></cite>, C. Marrin. Khronos Group.</dd> <dt id=refsWEBIDL>[WEBIDL]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/WebIDL/">Web IDL</a></cite>, C. McCormack. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/2006/webapi/WebIDL/>Web IDL</a></cite>, C. McCormack. W3C.</dd> <dt id=refsWEBLINK>[WEBLINK]</dt> <dd><cite><a href=http://tools.ietf.org/html/rfc5988>Web Linking</a></cite>, M. Nottingham. IETF.</dd> <dt id=refsWHATWGWIKI>[WHATWGWIKI]</dt> <dd><cite><a href=http://wiki.whatwg.org/>The WHATWG Wiki</a></cite>. WHATWG.</dd> <dt id=refsWIN1252>[WIN1252]</dt> <dd><cite><a href=http://www.microsoft.com/globaldev/reference/sbcs/1252.htm>Windows 1252</a></cite>. Microsoft.</dd> <dt id=refsWIN1254>[WIN1254]</dt> <dd><cite><a href=http://www.microsoft.com/globaldev/reference/sbcs/1254.htm>Windows 1254</a></cite>. Microsoft.</dd> <dt id=refsWIN31J>[WIN31J]</dt> <dd><cite><a href=http://www.microsoft.com/globaldev/reference/dbcs/932.mspx>Windows Codepage 932</a></cite>. Microsoft.</dd> <dt id=refsWIN874>[WIN874]</dt> <dd><cite><a href=http://www.microsoft.com/globaldev/reference/sbcs/874.mspx>Windows 874</a></cite>. Microsoft.</dd> <dt id=refsWIN949>[WIN949]</dt> <dd><cite><a href=http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT>Windows Codepage 949</a></cite>. Microsoft.</dd> <dt id=refsWSP>[WSP]</dt> <dd><cite><a href=http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol>The WebSocket protocol</a></cite>, I. Fette. IETF.</dd> <dt id=refsX121>[X121]</dt> <dd><cite>Recommendation X.121 — International Numbering Plan for Public Data Networks</cite>, CCITT Blue Book, Fascicle VIII.3, pp. 317-332.</dd> <dt id=refsX690>[X690]</dt> <dd><cite><a href=http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf>Recommendation X.690 — Information Technology — ASN.1 Encoding Rules — Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER), and Distinguished Encoding Rules (DER)</a></cite>. International Telecommunication Union.</dd> <dt id=refsXFN>[XFN]</dt> <dd><cite><a href=http://gmpg.org/xfn/11>XFN 1.1 profile</a></cite>, T. Çelik, M. Mullenweg, E. Meyer. GMPG.</dd> <dt id=refsXHR>[XHR]</dt> <!-- <dd><cite><a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a></cite>, A. van Kesteren. W3C.</dd> --> <dd><cite><a href=http://dev.w3.org/2006/webapi/XMLHttpRequest-2/><code>XMLHttpRequest</code></a></cite>, A. van Kesteren. W3C.</dd> <dt id=refsXML>[XML]</dt> <dd><cite><a href=http://www.w3.org/TR/xml/>Extensible Markup Language</a></cite>, T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler, F. Yergeau. W3C.</dd> <dt id=refsXMLBASE>[XMLBASE]</dt> <dd><cite><a href=http://www.w3.org/TR/xmlbase/>XML Base</a></cite>, J. Marsh, R. Tobin. W3C.</dd> <dt id=refsXMLNS>[XMLNS]</dt> <dd><cite><a href=http://www.w3.org/TR/xml-names/>Namespaces in XML</a></cite>, T. Bray, D. Hollander, A. Layman, R. Tobin. W3C.</dd> <dt id=refsXPATH10>[XPATH10]</dt> <dd><cite><a href=http://www.w3.org/TR/1999/REC-xpath-19991116>XML Path Language (XPath) Version 1.0</a></cite>, J. Clark, S. DeRose. W3C.</dd> <dt id=refsXSLT10>[XSLT10]</dt> <dd>(Non-normative) <cite><a href=http://www.w3.org/TR/1999/REC-xslt-19991116>XSL Transformations (XSLT) Version 1.0</a></cite>, J. Clark. W3C.</dd> <!--(once XSLTProcessor is defined somewhere, update this and the place that references this) <dt id="refsXSLTP">[XSLTP]</dt> <dd>(Non-normative) <cite><a href=""></a></cite>, . .</dd> --> </dl><h2 class=no-num id=acknowledgements>Acknowledgements</h2> <!-- ACKS --> <p>Thanks to Tim Berners-Lee for inventing HTML, without which none of this would exist.</p> <p>Thanks to Aankhen, Aaron Boodman, Aaron Leventhal, Adam Barth, Adam de Boor, Adam Hepton, Adam Roben, Addison Phillips, Adele Peterson, Adrian Bateman, Adrian Sutton, Agustín Fernández, Ajai Tirumali, Akatsuki Kitamura, Alan Plum, Alastair Campbell, Alejandro G. Castro, Alex Bishop, Alex Nicolaou, Alex Rousskov, Alexander J. Vincent, Alexandre Morgaut, Alexey Feldgendler, Алексей Проскуряков (Alexey Proskuryakov), Alexis Deveria, Allan Clements, Amos Jeffries, Anders Carlsson, Andreas<!-- mqmq87 -->, Andreas Kling, Andrei Popescu, André E. Veltstra, Andrew Barfield, Andrew Clover, Andrew Gove, Andrew Grieve, Andrew Oakley, Andrew Sidwell, Andrew Simons, Andrew Smith, Andrew W. Hagen, Andrey V. Lukyanov, Andy Heydon, Andy Palay, Anne van Kesteren, Anthony Boyd, Anthony Bryan, Anthony Hickson, Anthony Ricaud, Antti Koivisto, Arne Thomassen, Aron Spohr, Arphen Lin, Arun Patole, Aryeh Gregor, Asbjørn Ulsberg, Ashley Sheridan, Atsushi Takayama, Aurelien Levy, Ave Wrigley, Ben Boyle, Ben Godfrey, Ben Lerner, Ben Leslie, Ben Meadowcroft, Ben Millard, Benjamin Carl Wiley Sittler, Benjamin Hawkes-Lewis, Bert Bos, Bijan Parsia, Bil Corry, Bill Mason, Bill McCoy, Billy Wong, Bjartur Thorlacius, Björn Höhrmann, Blake Frantz, Boris Zbarsky, Brad Fults, Brad Neuberg, Brad Spencer, Brady Eidson, Brendan Eich, Brenton Simpson, Brett Wilson, Brett Zamir, Brian Campbell, Brian Korver, Brian Kuhn, Brian Ryner, Brian Smith, Brian Wilson, Bryan Sullivan, Bruce D'Arcus, Bruce Lawson, Bruce Miller, C. Williams, Cameron McCormack, Cao Yipeng, Carlos Gabriel Cardona, Carlos Perelló Marín, Chao Cai, 윤석찬 (Channy Yun), Charl van Niekerk, Charles Iliya Krempeaux, Charles McCathieNevile, Chris Apers, Chris Cressman, Chris Evans, Chris Morris, Chris Pearce, Christian Biesinger, Christian Johansen, Christian Schmidt, Christopher Aillon, Chriswa, Clark Buehler, Cole Robison, Colin Fine, Collin Jackson, Corprew Reed, Craig Cockburn, Csaba Gabor, Csaba Marton, Cynthia Shelly, Dan Yoder, Daniel Barclay, Daniel Bratell, Daniel Brooks, Daniel Brumbaugh Keeney, Daniel Cheng, Daniel Davis, Daniel Glazman, Daniel Peng, Daniel Schattenkirchner, Daniel Spång, Daniel Steinberg, Danny Sullivan, Darin Adler, Darin Fisher, Darxus, Dave Camp, Dave Hodder, Dave Lampton, Dave Singer, Dave Townsend<!-- Mossop on moz irc -->, David Baron, David Bloom, David Bruant, David Carlisle, David E. Cleary, David Egan Evans, David Flanagan, David Gerard, David Håsäther, David Hyatt, David I. Lehn, David John Burrowes, David Matja, David Remahl, David Smith, David Woolley, DeWitt Clinton, Dean Edridge, Dean Edwards, Debi Orton, Derek Featherstone, Devdatta, Dimitri Glazkov, Dimitry Golubovsky, Dirk Pranke, Divya Manian, Dmitry Titov, dolphinling, Dominique Hazaël-Massieux, Don Brutzman, Doron Rosenberg, Doug Kramer, Doug Simpkinson, Drew Wilson, Edmund Lai, Eduard Pascual, Eduardo Vela, Edward O'Connor, Edward Welbourne, Edward Z. Yang, Ehsan Akhgari, Eira Monstad, Eitan Adler, Eliot Graff, Elizabeth Castro, Elliott Sprehn, Elliotte Harold, Eric Carlson, Eric Law, Eric Rescorla, Eric Semling, Erik Arvidsson, Erik Rose, Evan Martin, Evan Prodromou, Evert, fantasai, Felix Sasaki, Francesco Schwarz, Francis Brosnan Blazquez, Franck 'Shift' Quélain, Frank Barchard, 鵜飼文敏 (Fumitoshi Ukai), Futomi Hatano, Gavin Carothers, Gareth Rees, Garrett Smith, Geoffrey Garen, Geoffrey Sneddon, George Lund, Gianmarco Armellin, Giovanni Campagna, Glenn Adams, Glenn Maynard, Graham Klyne, Greg Botten, Greg Houston, Greg Wilkins, Gregg Tavares, Gregory J. Rosmaita, Grey, Guilherme Johansson Tramontina, Gytis Jakutonis, Håkon Wium Lie, Hallvord Reiar Michaelsen Steen, Hans S. Tømmerhalt, Hans Stimer, Harald Alvestrand, Henri Sivonen, Henrik Lied, Henry Mason, Hugh Winkler, Ian Bicking, Ian Clelland, Ian Davis, Ian Fette, Ignacio Javier, Ivan Enderlin, Ivo Emanuel Gonçalves, J. King, Jacques Distler, James Craig, James Graham, James Justin Harrell, James Kozianski, James M Snell, James Perrett, James Robinson, Jamie Lokier, Jan-Klaas Kollhof, Jason Kersey, Jason Lustig, Jason White, Jasper Bryant-Greene, Jatinder Mann, Jed Hartman, Jeff Balogh, Jeff Cutsinger, Jeff Schiller, Jeff Walden, Jeffrey Zeldman, 胡慧鋒 (Jennifer Braithwaite), Jens Bannmann, Jens Fendler, Jens Lindström, Jens Meiert, Jeremy Keith, Jeremy Orlow, Jeroen van der Meer, Jian Li, Jim Jewett, Jim Ley, Jim Meehan, Jirka Kosek, Jjgod Jiang, João Eiras, Joe Clark, Joe Gregorio, Joel Spolsky, Johan Herland, John Boyer, John Bussjaeger, John Carpenter, John Fallows, John Foliot, John Harding, John Keiser, John Snyders, John-Mark Bell, Johnny Stenback, Jon Ferraiolo, Jon Gibbins, Jon Perlow, Jonas Sicking, Jonathan Cook, Jonathan Rees, Jonathan Worent, Jonny Axelsson, Jorgen Horstink, Jorunn Danielsen Newth, Joseph Kesselman, Joseph Pecoraro, Josh Aas, Josh Levenberg, Joshua Bell, Joshua Randall, Jukka K. Korpela, Jules Clément-Ripoche, Julian Reschke, Jürgen Jeka, Justin Lebar, Justin Schuh, Justin Sinclair, Kai Hendry, Kartikaya Gupta, Kathy Walton, Kelly Ford, Kelly Norton, Kevin Benson, Kevin Cole, Kornél Pál, Kornel Lesinski, Kris Northfield, Kristof Zelechovski, Krzysztof Maczyński, 黒澤剛志 (Kurosawa Takeshi), Kyle Hofmann<!-- Ozob -->, Kyle Huey, Léonard Bouchet, Léonie Watson, Lachlan Hunt, Larry Masinter, Larry Page, Lars Gunther<!-- Keryx Web -->, Lars Solberg, Laura Carlson, Laura Granka, Laura L. Carlson, Laura Wisewell, Laurens Holst, Lee Kowalkowski, Leif Halvard Silli, Lenny Domnitser, Leonard Rosenthol, Leons Petrazickis, Lobotom Dysmon, Logan<!-- on moz irc -->, Loune, Luke Kenneth Casson Leighton, Maciej Stachowiak, Magnus Kristiansen<!-- Dashiva -->, Maik Merten, Malcolm Rowe, Mark Birbeck, Mark Davis, Mark Miller, Mark Nottingham, Mark Pilgrim, Mark Rowe<!--bdash-->, Mark Schenk, Mark Wilton-Jones, Martijn Wargers, Martin Atkins, Martin Dürst, Martin Honnen, Martin Janecke, Martin Kutschker, Martin Nilsson, Martin Thomson, Masataka Yakura, Mathieu Henri, Matias Larsson, Matt Schmidt, Matt Wright, Matthew Gregan, Matthew Mastracci, Matthew Raymond, Matthew Thomas, Mattias Waldau, Max Romantschuk, Menno van Slooten, Micah Dubinko, Michael 'Ratt' Iannarelli, Michael A. Nachbaur, Michael A. Puls II<!--Shadow2531-->, Michael Carter, Michael Daskalov, Michael Enright, Michael Gratton, Michael Nordman, Michael Powers, Michael Rakowski, Michael(tm) Smith, Michal Zalewski, Michel Fortin, Michelangelo De Simone, Michiel van der Blonk, Mihai Şucan<!-- from ROBO Design -->, Mihai Parparita, Mike Brown, Mike Dierken<!-- S. Mike Dierken -->, Mike Dixon, Mike Schinkel, Mike Shaver, Mikko Rantalainen, Mohamed Zergaoui<!-- Innovimax SARL -->, Mounir Lamouri, Ms2ger, NARUSE Yui, Neil Deakin, Neil Rashbrook, Neil Soiffer, Nicholas Shanks, Nicholas Stimpson, Nicholas Zakas, Nickolay Ponomarev, Nicolas Gallagher, Noah Mendelsohn, Noah Slater, NoozNooz42, Ojan Vafai, Olaf Hoffmann, Olav Junker Kjær, Oldřich Vetešník, Oli Studholme, Oliver Hunt, Oliver Rigby, Olivier Gendrin, Olli Pettay, oSand, <!-- from reddit --> Patrick H. Lauke, Patrik Persson, Paul Norman, Per-Erik Brodin, Perry Smith, Peter Beverloo, Peter Karlsson, Peter Kasting, Peter Stark, Peter-Paul Koch, Phil Pickering, Philip Jägenstedt, Philip Taylor, Philip TAYLOR<!-- a different one -->, Philippe De Ryck, Prateek Rungta, Pravir Gupta, Rachid Finge, Rajas Moonka, Ralf Stoltze, Ralph Giles, Raphael Champeimont, Remci Mizkur, Remco, Remy Sharp, Rene Saarsoo, Rene Stach, Ric Hardacre, Rich Doughty, Richard Ishida, Rigo Wenning, Rikkert Koppes, Rimantas Liubertas, Riona Macnamara, Rob Ennals, Rob Jellinghaus, Rob S, Robert Blaut, Robert Collins, Robert O'Callahan, Robert Sayre, Robin Berjon, Rodger Combs, Roland Steiner, Roman Ivanov, Roy Fielding, Ruud Steltenpool, Ryan King, Ryosuke Niwa, S. Mike Dierken, Salvatore Loreto, Sam Dutton, Sam Kuper, Sam Ruby, Sam Weinig, Sander van Lambalgen, Sarven Capadisli, Scott González, Scott Hess, Sean Fraser, Sean Hayes, Sean Hogan, Sean Knapp, Sebastian Markbåge, Sebastian Schnitzenbaumer, Seth Call, Shanti Rao, Shaun Inman, Shiki Okasaka, Sierk Bornemann, Sigbjørn Vik, Silvia Pfeiffer, Simon Montagu, Simon Pieters, Simon Spiegel, skeww, <!-- on reddit --> Stanton McCandlish, Stefan Håkansson, Stefan Haustein, Stefan Santesson, Stefan Weiss, Steffen Meschkat, Stephen Ma, Steve Faulkner, Steve Runyon, Steven Bennett, Steven Garrity, Steven Tate, Stewart Brodie, Stuart Ballard, Stuart Parmenter, Subramanian Peruvemba, Sunava Dutta, Susan Borgrink, Susan <!--G.--> Lesch, Sylvain Pasche, T. J. Crowder, Tab Atkins, <span lang=tr title="">Tantek Çelik</span>, 田村健人 (TAMURA Kent), Ted Mielczarek, Terrence Wood, Thomas Broyer, Thomas Koetter, Thomas O'Connor, Tim Altman, Tim Johansson, Toby Inkster, Todd Moody, Tom Baker, Tom Pike, Tommy Thorsen, Travis Leithead, Tyler Close, Vladimir Katardjiev, Vladimir Vukićević, voracity, Wakaba, Wayne Carr, Wayne Pollock, Wellington Fernando de Macedo, Weston Ruter, Wilhelm Joys Andersen, Will Levine, William Swanson, Wladimir Palant, Wojciech Mach, Wolfram Kriesing, Yang Chen, Ye-Kui Wang, Yehuda Katz, Yi-An Huang, Yngve Nysaeter Pettersen, Yuzo Fujishima, Zhenbin Xu, 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=http://www.w3.org/html/wg/lists/>various W3C HTML WG lists</a> and the <a href=http://www.whatwg.org/mailing-list>various WHATWG lists</a>. <p>Special thanks to Richard Williamson for creating the first implementation of <code><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 title=attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code>, and other features first widely deployed by the Windows Internet Explorer browser.</p> <!--MD--> <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> <!--MD--> <p>Thanks to the SubRip community, including in particular Zuggy and ai4spam, for their work on the SubRip software program whose SRT file format was used as the basis for the WebVTT text track file format.</p> <div class=impl> <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> </div> <p>Thanks to the many sources that provided inspiration for the examples used in the specification.</p> <div itemscope="" itemtype=http://n.whatwg.org/work> <p>The image in the introduction is based on <a href=http://www.flickr.com/photos/wonderlane/2986252088/ itemprop=work>a photo</a> by <a href=http://www.flickr.com/photos/wonderlane/ itemprop=http://creativecommons.org/ns#attributionURL>Wonderlane</a>. (<a href=http://creativecommons.org/licenses/by/2.0/ itemprop=license>CC BY 2.0</a>) </div> <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> <!-- Hopefully Kam won't notice he's covered by these acknowledgements three times! --> <!-- v2 * library of resources: var library = new ZipFile("data.zip"); library.onload = function() { var sound1 = library.getAudio("sound1.wav"); // returns an Audio object var image1 = library.getImage("image1.png"); // returns an HTMLImageElement var doc1 = library.getXMLDocument("doc1.xml"); // returns a Document (XML Document mode) var doc2 = library.getHTMLDocument("doc1.html"); // returns a Document (HTML Document mode) } or: var library = new ResourceLoader("data.zip"); library.add("moredata.zip"); library.onload = function() { ... } library.onloading = function() { reportLoadProgress(library.progress); // 0.0 .. 1.0 } or: var library = new AudioZip("sounds.zip"); library.onload = function() { var sound1 = library["sound1.wav"]; sound.play(); } v2 * a fairly common situation for web authors is to have two lists, where the contents of the second depends on the value of the first. Is there any way we could extend the current model to include this functionality? (e.g. bugzilla product/component ui) v2 * quick-searchable select v2 * include/exclude selectors (two multi-select columns with arrows to move selected items) and that sort of thing. http://slashdot.org/comments.pl?sid=110240&cid=9357022 v2 * Oh, and forms need a standardized Help widget/icon. I know I can turn my cursor into a question mark, but I'm looking for something simple and pervasive. Maybe you can wrap fields in a help tag, just as you do for fieldsets. And in that help tag, attributes are available that allow for a nice, formatted, clean, full help text popup/area/thing. http://slashdot.org/comments.pl?sid=110240&cid=9359006 v2 * Validating only part of a form. - Anja Lehmann v2 * Reminder to add a way to expose access keys in buttons, i.e. Sub&mit where & signifies the m is the access key to use. Possibly automatic? <input accesskey="m" value="Submit"> browser would be smart enough to underline the first instance of the access key if it exists (case insensitive)? - kerz [or deprecate the lot (->web apps)] v2 * need an attribute that says "the children of this element are in their own tabbing universe, tabindex should be relative to each other, not to the document" -> web apps? v2 * make select widgets have multiple columns or ->web apps with list view v2 * required as a group (one of the following must be available): + i propose something like the following: <input type="text" group="contact" name="voicephone"> Voice phone <input type="text" group="contact" name="fax"> Fax <input type="text" group="contact" name="mobile"> Mobile phone <input type="text" group="contact" name="email"> E-mail if the user fills out none of the form fields in the "contact" group, an error message is shown and the form is not submitted. - Peter-Paul Koch v2 * formatting of number fields, text fields, etc, so that when the field is not focused, the value is displayed differently. Seems like this would also be useful e.g. for <output> or something so you can display localised dates, etc. v2 * being able to select date range (from day x to day y) v2 * ways of visualizing a linefeed in a <textarea> so it looks different from wrapping text v2 * all login systems have 1. enter username and password 2. create new account 3. lost password some way of integrating this into one system, since it's so common v2 * way of identifying different sorts of mailadresses a) mailing-list b) person c) department in a company ("support", "marketing" and such) d) general mail (like "info", "mail", "contact" and such) e) other sorts of groupings (or ->web apps; this is talking about in mailto: links, I think) v2 * hotswapping login identities like in windows xp you are logged in on operamail.com, and you want to check the mail of another user. somehow, combined with the wand or whatever, the browser will remember the login page, and it can re-submit it without having to load the initial page (saving time) v2 * provide different measuring systems, like having the html indicate fluid in both fluid ounces and liters, and the browser can display one or the other based on regional settings in the browser or ui, display conversions in a tooltip, or let the user decide which format to display. v2 * indicate "x days ago" or "y days into the future" rather than date v2 * input control for anniversaries v2 * only submit fields that have changed, or a way to include in the submission a list of which form controls were changed from their default value v2 * type="time" value="now" v2 * add something to type="number" to support basic currency and unit formatting of input v2 * <fieldset enabled-if-checked="myCheckboxOrRadioButton"> ...to allow sections to only be enabled if a radio button makes it relevant, for instance. v2 * Yan Morin proposed a multi-column dropdown <select> or <datalist>: _________________ |_New_York______|V|_________________ <- input with a table link and a down arrow |_City__________|_State_|_Country_|_| <- header of the table | Montreal | QC | Canada |A| <- top arrow of the scroll |>New York <| NY | US | | <- selected row | Washington | DC | US |X| <- cursor scroll | San Francisco | CA | US | | |_Toronto_______|__ON___|_Canada__|V| <- bottom arrow of the scroll v2 * add for="" attribute to <input type="password"> so that you can link usernames and passwords. (Jonas Sicking) v2 * value for unchecked checkbox? v2 * A way to specify the default button - Michael Gratton v2 * <fieldset readonly>? v2 * dolphinling suggests having a way to mark certain parts of a form as being dependent on another (mutually exclusive parts of a form) v2 * expose the form data set, either as an object (on which one can invoke the JSON serialiser), or in the form of a method on HTMLFormElement that returns the form data set serialised according to a particular encoding (defaulting to the form's enctype="" one, probably). This would allow forms to be used with XHR-like systems without having to manually construct the form data set the way that is done today. v2 * expose the file upload progress when uploading files in a form (ideally using the same mechanism as XHR2?); ack Rob Evans Consistency in editorial style: v2 * need to become consistent about whether or not to quote keyword ("<code title="">foo</code>" vs <code>foo</code>) v2 * make the spec consistent about whether the word "algorithm" is part of an algorithm's name or not ("</dfn> algorithm", "</span> algorithm") v2 * make the spec more consistent about its use of "hexadecimal" and "base-sixteen", the order that 0-9 A-Z a-z is mentioned, and the detail to which the spec explains how to interpret a string as a hexadecimal number. v2 * become more consistent about what markup we use to mark up productions (nothing? <i>? <code>?) v2 * use <code>Document</code> consistently instead of 'document'. v2 * be clearer about arrays/lists/collections being zero-based despite using the term "/index/th". v2 * use the sample widgets: <li><img alt="A text field with editable sections for each value, with a button to pop up a dialog showing a calendar or clock." src="sample-datetime-ui-2"></li> <li><img alt="A calendar grid with a clock in the upper right hand corner." src="sample-datetime-ui-3"></li> -->